Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: jmracek on December 20, 2015, 06:02:41 PM
-
I just tried adding a timer (ONDTMR) to a Program code block in my Do-More processor. It seems to function but the time counts at about 1/13th the speed of real time. The same goes for other timer instructions. The timers do function properly in the $Main Task.
Is there a trick or are timers just not allowed in programs?
-
Do-More timers aren't RTC-based, they integrate scan-time, so if the rung with the timer isn't scanned every actual scan, they'll fall behind. Your timer is probably in a code block that due to its execution or time-slice is only executed about every 13th real scan.
To make them work right, you'll either need to make sure they're in code that executes every scan, at least while you're timing, or build an RTC-based one yourself (which still might expire late by up to one scan-time of the code in which it resides).
-
Timers accumulate time when the code is being executed. If they are located code that isn't executing every scan, they will drop time. There are a bunch of reasons why a timer might not be executing every scan, but I'll need more info about the program to offer an opinion.