Ran into quite a baffling situation.
I am able to easily setup and run a TON timer when using the CFC style of graphic code...
However, I find in certain setups the ST version doesn't function
Is this a limitation of the software? Or a Bug? Or is there something I am missing?
(I am running the code in Simulation, as I have no machine to deploy to at this time.
Both run under the Main task in a PRG POU)
ST Attempt 1 (Simple works correctly)
VAR  TON_1:TON;    TimeOut :BOOL;  ValueIN:BOOl;END_VARTON_1(IN:=ValueIN,PT:=T#5S);TimeOut:=TON_1.Q;
ST Attempt 2 (Complex, doesn't work)
VARÂ Â TON_2:TON;Â Â ValueIN:BOOL:=TRUE;Â Â OUT:BOOL;Â Â Delay:TIME:=T#5S;Â Â END_VARTON_2.PT:=Delay;TON_2.IN:=ValueIN;OUT:=TON_2.Q;
TON_2.ET doesn't count up at all, despite TON_2.IN Being TRUE.
I decided to place the TON_2.PT in an init IF statement so it only runs once, and still nothing happened with the timer.
I am curious why this is the case?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Ah, That makes sense now.
Did some testing with your suggestion.
I now understand that the internal variables are only updated during a call of TON_1().
However, after the first call, the actual timer continues on without the need of TON_1 being called.
So correct me if I am wrong,
but I understand that you only need to call TON_1() twice for a single use of the TON?
Once to start the timer.
Once to update the variables AFTER PT has expired.
However in practice this isn't possible, which is why we check each loop of the program (or use an internal for/while loop) to continuously update the internal variables.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello Team,
Ran into quite a baffling situation.
I am able to easily setup and run a TON timer when using the CFC style of graphic code...
However, I find in certain setups the ST version doesn't function
Is this a limitation of the software? Or a Bug? Or is there something I am missing?
(I am running the code in Simulation, as I have no machine to deploy to at this time.
Both run under the Main task in a PRG POU)
ST Attempt 1 (Simple works correctly)
ST Attempt 2 (Complex, doesn't work)
TON_2.ET doesn't count up at all, despite TON_2.IN Being TRUE.
I decided to place the TON_2.PT in an init IF statement so it only runs once, and still nothing happened with the timer.
I am curious why this is the case?
Hi,
you never call the instance of the timer(you just set the Inputs of the instance)
TON_2();
Regards
plcmax
Ah, That makes sense now.
Did some testing with your suggestion.
I now understand that the internal variables are only updated during a call of TON_1().
However, after the first call, the actual timer continues on without the need of TON_1 being called.
So correct me if I am wrong,
but I understand that you only need to call TON_1() twice for a single use of the TON?
Once to start the timer.
Once to update the variables AFTER PT has expired.
However in practice this isn't possible, which is why we check each loop of the program (or use an internal for/while loop) to continuously update the internal variables.