04-12-2010 12:53 AM - edited 04-12-2010 12:56 AM
Hi everyone,
I am building a simple program for turning on and off a single Bit. The task is to turn ON the Bit for a period length T1, and OFF the Bit for a period length T2. T1 is normally different from T2, and can be controlled by users.
Since T1 and T2 can be variable, they sometimes can be very long.
If I use a Wait function inside a While loop, it needs long delay to be able to Stop the Main program.
The same situation happens when I use Timed loop.
Can anyone suggest me how to do this task?
Thanks a lot.
04-12-2010 02:35 AM
It's a well known problem that long delays causes sluggish response.
One easy solution is to split the delays into smaller parts, e.g. X*100ms + rest. Then either check time elapsed each loop, or calculate/make a "wait time array" and feed the wait loop.
The array is easily done through a Quotient/Remainder calculation with 100(ms) as divider -> Initialize array with 100 ms * Quotient -> Build array with Remainder.
/Y
04-12-2010 07:25 AM
04-12-2010 07:27 AM
04-12-2010 09:18 AM
Here's another possibility using OpenG Wait ms:
Ton
04-12-2010 08:02 PM