View Single Post
  #6   Spotlight this post!  
Unread 31-01-2002, 22:54
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
Here is the thing...

You cannot count on how long it will take you to get through a loop of your program.

If you have a program that is complex, you may make it in 24 msec one time and 26 msec in another.

If you make it in 24 msec, you MAY be ready to receive the next packet of data that comes from the OI, if you take 26msec, you will definitely MISS the data packet and have to wait around until the next one arrives (which will be a while because they only come at best at 25 msec intervals).

Now, add to that that not all data packets make it through intact you you begin to realize that you will only get to increment your counter at variable intervals. The intervals are outside of your programs control.

So....

What is a clever sheep supposed to do?

Well, FIRST gives you some help. If you ask for it (by setting c_Delta_T = 1 in the default program and by including Delta_T in your SERIN command, which gets data from the master CPU), the master CPU will tell you how many data packets you missed since the last time you got data from it.

SO...

Rather than just adding 1 to counter each time through the loop, you can add in Delta_T, the number of data packets you missed. This will help you keep your clock up to speed even when your program is running slower (perhaps because you left a Debug statement in the code -- you naughty little debugger you) or because you are at a competition and there are many other robots broadcasting on frequencies very near your own.

It is not a big deal but it is a better mouse trap if you care to build it.

Joe J.