View Single Post
  #4   Spotlight this post!  
Unread 31-01-2002, 22:40
Joe Johnson's Avatar Unsung FIRST Hero
Joe Johnson Joe Johnson is offline
Engineer at Medrobotics
AKA: Dr. Joe
FRC #0088 (TJ2)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1996
Location: Raynham, MA
Posts: 2,648
Joe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond reputeJoe Johnson has a reputation beyond repute
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.