Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   NEED HELP RUNNING MULTIPLE FUNCTIONS AT SAME TIME!! (http://www.chiefdelphi.com/forums/showthread.php?t=43809)

rushrtr3 11-02-2006 23:39

NEED HELP RUNNING MULTIPLE FUNCTIONS AT SAME TIME!!
 
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 12-02-2006 02:01

Re: NEED HELP RUNNING MULTIPLE FUNCTIONS AT SAME TIME!!
 
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:
Code:

//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:
                                {




Quote:

Originally Posted by rushrtr3
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!



All times are GMT -5. The time now is 10:02.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi