View Single Post
  #9   Spotlight this post!  
Unread 12-02-2012, 16:50
CRLS97 CRLS97 is offline
Registered User
FRC #0097
 
Join Date: Jan 2011
Location: Cambridge
Posts: 28
CRLS97 is an unknown quantity at this point
Re: Benefits of "Periodic Tasks VI"?

Quote:
Originally Posted by Ether View Post
I can't give an example in LabVIEW because I don't have it installed here, but here's a skeletal pseudo-C code:

Code:
while (1) {

if (!run_me) {sleep(20ms); continue;}

run_me= false;

doSomething;

sleep(250ms);

doSomethingElse;
}
The global boolean "run_me" tells the task to run once.

Notice the "sleep(20ms)" which prevents the task from chewing up an undue amount of CPU time.

Ether, are you implying that if my global variable returns false, then it waits 20ms BEFORE doing whatever else is in that case statement? If so, wouldn't that cause the error since the Teleop code is taking >20ms to complete one cycle?