0

I'm trying to write a program in ST to let the user define the Bakelength time (in hours) for a TON timer.

I have this currently but when I compile the code, the program throws up an 'illegal constant' error. How would I change this syntax? Any help would be much appreciated!!!

TON_1(IN:= true,PT:= t#(BakeLength)h);
Unheilig
  • 16,196
  • 193
  • 68
  • 98
user2840240
  • 87
  • 1
  • 1
  • 5

1 Answers1

2

The annotation with T# is just to define constant values in your source code like T#100s.

If Bakelength is already a variable of type TIME you can just write

TON_1(IN:= true,PT:= BakeLength);

If Bakelength is another type e.g. LREAL you have to convert the value to a TIME variable. Numeric DataTypes are always interpreted as milliseconds if you convert to TIME. Therefore if Bakelength is in hours you have to multiplicate with 3600000.

TON_1(IN:= true,PT:= LREAL_TO_TIME(Bakelength * 3600000));

Felix Keil
  • 2,344
  • 1
  • 25
  • 27