If I power cycle the PLC when the timer is timing (well before ET=PT), PersistTON.Q is TRUE on the first scan and PersistTON.ET is set to PersistTON.PT.
If I power cycle when ET=T#30s, as soon as the logic is scanned again ET:=T#10M and Q is True.
Last edit: ldetzler 2022-02-17
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Because the TON is stored in PERSISTENT RETAIN Memory, StartTime is retained through a power cycle.
The first time that the TON code is scanned after the PLC boots, TIME() will return a very small value, since it has just booted.
ET:=TIME()-StartTime;
Results in an overflow causing ET to be large. When we get to this line of code, ET is greater than PT and Q is set TRUE.
Can someone help me understand what is happening internally for a TON that is declared as PERSISTENT RETAIN?
If I power cycle the PLC when the timer is timing (well before ET=PT), PersistTON.Q is TRUE on the first scan and PersistTON.ET is set to PersistTON.PT.
If I power cycle when ET=T#30s, as soon as the logic is scanned again ET:=T#10M and Q is True.
Last edit: ldetzler 2022-02-17
I think I've answered my own question.
I believe that TON is using the TIME() function or something similar internally. If it does, the TON function would look something like this:
Because the TON is stored in PERSISTENT RETAIN Memory, StartTime is retained through a power cycle.
The first time that the TON code is scanned after the PLC boots, TIME() will return a very small value, since it has just booted.
Results in an overflow causing ET to be large. When we get to this line of code, ET is greater than PT and Q is set TRUE.