|
How about tring this...
Your syntax is correct.
Counter = Counter +1
Does what it does in nearly every programming language (despite the fact that it makes math profs crazy!).
Perhaps a better idea for what you are trying to do is:
Time = Time + 1 + Delta_T
Where Delta_T is the variable passed to you by the master CPU that tells you how many data packets you have missed since the last time you got a good packet of data from the master CPU.
If you use this construct, you will have a more reliable method to have something stay on for 2 seconds for example.
If you just use counter as you initially proposed, your loop time figures into the time that passes before you reach a set number. Also figured into the mix is the fact that you may have a noisy radio environment or you may have some other problem communicating with the OE.
In these cases, you can have the time until counter reaches a fixed number vary by mulitples of 2 or 3.
With Delta_T added in, your program takes into account the fact that you missed packets and thus your time estimations are more robust.
Joe J.
|