# Multiple Programs

hey, My mentor thought that instead of using switches to decide between autonomous programs, that we should load all of oue programs into different slots (i beleive there are eight) and then choose which program we want to run. My questions are, how dod you load them into different slots, and, how do you choose which slot to run. Thanks.

you still have to use switches to choose which program to run.

please read Innovations First’s Multi-bank programming guide: http://www.innovationfirst.com/firstrobotics/pdfs/Multi_Bank_Code.zip , then ask again if you have questions

Well, as was said, you’ll still have to have something resembling a “switch” to choose between the different code slots (at least 3 since 2^3 = 8). To choose between this many programs in essentially binary logic, however, could be considered confusing to an operator (if he is not familar with it). If what you are looking for is a quick alternative, you might consider what we (team 122) did, which worked great for us at VCU.

Have some sort of pre-existing switch that will be set to 1 when it is time to choose the program (BEFORE the match starts), and then goes to 0, “locking” the program. What you use to select between the 8 (we added a mode that did nothing to make it 9), programs is use the joystick: full right and full reverse is 0, middle and full reverse is 1, full left and full reverse is 2 … etc.

Now all you have to do is make some labels or give the operator a sheet of paper with the configuration and which program it represents, and everything should flow smoothly.

Here’s some code that we used that worked for us. It takes advantage of the integer math of PBASIC:

``````
auton_choice var nib

...

if (sw_override = 0) OR (comp_mode = 0) then skip_auton_set
auton_choice = p1_x/90
auton_choice = p1_y/90 * 3 + auton_choice
skip_auton_set

``````

comp_mode is zero before the match and after the match (the last of which doesn’t matter here). In the above code, we used the override switch to “lock” the selection – any switch would work, however.

Or, get an 8 position rotary switch…it is hard to mess up with one of those.