Followers 0

# Event Timing

## 3 posts in this topic

There is a question to all audience. There is a SLC 5/05 proccessor. I need to store time how long event, let say some fault, last. It would never last more then 8 hours = 8*60*60=28800 sec (if it more it will reset at end of the shift and start over). I can make timer TON with base time 1sec. to start timing when event starts, and use value in the ACC register. I need convert this value to Hours, minutes and seconds and store them in the words N7:0, N7:1, N7:2. Is anybody knows how to do this? There are probably some COMPUTE instructions involved. Other idea is to use register S:4 – free running clock. Let say use S:4/2 (every 40ms) and start counter CTU and count 25 pulses of S:4/2. It will be equal to one sec. Then build cascade counters logic to count minutes and hours and move values of the ACC registers to the N7:0, N7:1, and N7:2. I am wondering what would be fewer load on PLC. Right now I have average scan time 20ms and max scan time 30ms. Thank you.

##### Share on other sites
It's all integer math so... read the elapsed time into an integer(n7:10)gross seconds divide n7:10 by 60 results to n7:11 (gross minutes) divide n7:11 by 60 results to n7:12 (gross hours) N7:12=N7:0 (hours) N7:11 -(N7:12 *60) = N7:1 (remainder minutes) N7:10 -(N7:11*60) = N7:2 (remainder seconds)

##### Share on other sites
System do it for you: starttime = S:4, ellapsed time = S:4 - starttime ? Use as many varible as needed for S:4 regisry contents, I don't know it.