There
IS a technique to indirect address a timer in a SLC.
What you do is COPY the 3 timer words (status bits, .PRE and .ACC) from an indirect timer, do the TON, and then transfer them back to
Code:
COP #T14:[N7:0] #T4:0 1
TON T4:0
COP #T4:0 #T14:[N7:0] 1
Code fragment courtesy of
The Boolean Embassy.
Caveat Emptor. I've never used this one, but thought it useful.
But this brings up all sorts of questions. Like - just exactly how does a TON keep track of time?
If you use a time base of 1 second, then it will take many scans before the TON will update the ACC by one. How the PLC track how many scans/real-time have elapsed? I don't think it's in the "unused" status bits, but I'm not sure.
But if it's not there, then will this code fragment work in a For-Next loop and different addresses?
For that matter, if the same TON is called multiple times in a scan (say it's in a SUBroutine that's JSR'ed twice in a scan, will it "update" twice as fast (add "last scan time to TON internal timer)?
What if the JSR is called every other scan? Will the PLC keep track? I've never had the time to play with this code fragment, and these questions to really explore the answer.