PDA

View Full Version : NEED HELP RUNNING MULTIPLE FUNCTIONS AT SAME TIME!!


rushrtr3
02-11-2006, 11:39 PM
Ok I was wondering if there is a way in "easyC" to run multiple functions, while loops, or for loops at the same time? I have 6 or more that I need continuosly running. Any help would be greatly appreciated!

Chris_Elston
02-12-2006, 02:01 AM
Last I knew, the FRC was a "sequential" execution controller. Or "single-task" controller. I believe what you are asking is if you can do a "multi-task" or "multi-threaded" applications. The answer I think you'll find is “no” you can not do that.

However if you post a little more information about your application, maybe some of us can suggest other ways of how to execute your function you require in a "sequential " process of the CPU.

State programming is a wonderful way to start a process, and let the cpu pointer keep going into your loop to service other functions such as sensor updates, PID loop, etc…then come back to the state, and check to see if your process is done, if it is done, increment the state to the next step, then test against it with a while loop.

Here is a short clip from last years code. State Programming:

//ok crap, we drove out and can't see anything so let's look around.
//first pan to the left, if we see something lock on then continue and finish this command
//if we don't see anything left after a another timeout, then pan to the right
//if we don't see anything right, well I guess we are just stuck....

switch(update_pan_flag)
{
case 0:
{
if (thumbwheel == 31)
{
update_pan_flag = 4; //thumbwheel is 31, we are on the right side skip looking left
}
else
{
set_pan = 100; //set default left camera pan (about 45 degrees is = 85)
printf("Set Camera Pan Default to Left Scan...STATE=%d\r",update_pan_flag);
update_pan_flag = 1; //next state;
}
break;
}
case 1:
{
camera_set_servos(set_pan,128); //set camera pan and tilt
printf("Write the Pan Servo (%d) to Vision...STATE=%d\r",set_pan,update_pan_flag);
update_pan_flag = 2; //next state
break;
}
case 2:
{
camera_find_color( GREEN ); //make camera look for green again, because when you write a pan varible it turns off camera
printf("Look for GREEN Color Again...STATE=%d\r",update_pan_flag);
update_pan_flag = 3; //next state
break;
}
case 3:
{







Ok I was wondering if there is a way in "easyC" to run multiple functions, while loops, or for loops at the same time? I have 6 or more that I need continuosly running. Any help would be greatly appreciated!