Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Evilbeard on February 24, 2017, 06:06:26 PM
-
I'm making a machine runtime counter for a project, and I know the preset will go to 99hr 59m 59.99s, but what is the maximum range on the counter? What I'm wanting to do is use the timer's .acc to calculate the runtime minutes of the machine, but I wasn't sure if I'd have to "roll" the timer over so that it doesn't max out and cause issues.
-
I just increment a D word using a built in second, minute, or hour timer or use a timer to do the same thing.
-
I would think an accumulating up timer TMRA would work pretty well. From the help:
The maximum Time value in this form is 569 hours, 31 minutes, 23 seconds, and 647 milliseconds. If needed, the value entered for the Timer Preset will be normalized to its standard value. For example, if you entered a value of 97 Seconds, that value will be converted and displayed as 1 Minute and 37 Seconds.
-
I think I'd use a timer that can go over an hour. Then each scan, check if the timer Acc is over an hour. If it is, add one to your hour counter (really just a N, V or D register), and subtract an hour worth of ms from the Acc. That way you avoid building up error because of scan latency delaying the check.