Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: davidbgtx on November 19, 2014, 09:45:29 AM

Title: Fixed Scan Rate?
Post by: davidbgtx on November 19, 2014, 09:45:29 AM
Maybe I'm missing it, is it not possible to have a fixed scan rate as you can in the WinPLC?
Title: Re: Fixed Scan Rate?
Post by: franji1 on November 19, 2014, 11:10:19 AM
In Do-more, no.

But you could easily implement it via logic by sticking some code in $tBottomOfScan task (assuming its time slice was 65535, or "do NOT yield".  I will utilize MATH's TICKus() function (micro second resolution), but you could just as easily use TICKms() for just millisecond resolution

D99 contains the last scan's "count"
D98 contains the current scan's duration (calculated on the fly)
D100 will contain the desired "scan time" in micro seconds (e.g. 2000 would be 2ms)
C99 will be ON once the scan time reaches D100
REPEAT
MATH D98 "TICKus() - D99"
STRGE D98 D100
OUT C99
UNTIL C99
MATH D99 "D99 + D98"  // this will be slightly more accurate than calling TICKus() again

You will want to stick this rung in $tFirstScan to initialize D99
MATH D99 "TICKus()"

Basically, the ladder scan will "hang" while the REPEAT/UNTIL executes.  If the scan time exceeds the desired max, it will fall out immediately.
Title: Re: Fixed Scan Rate?
Post by: davidbgtx on November 19, 2014, 12:45:47 PM
Thanks, I'll give it a try.
Title: Re: Fixed Scan Rate?
Post by: BobO on November 19, 2014, 03:35:54 PM
Thanks, I'll give it a try.

Just curious, but what problem does the fixed scan time resolve?
Title: Re: Fixed Scan Rate?
Post by: Mike Nash on November 19, 2014, 04:51:01 PM
Not my problem anymore, but I once did a pretty nice MOP (Ramp) using the fixed scan time. For later projects I decided to use the last scan actual time to calculate the amount to add or subtract.
Title: Re: Fixed Scan Rate?
Post by: DLTimmons on November 19, 2014, 05:29:10 PM
Look at the Ramp command I us it for thing like jogging motors