I know on the stamp chip there are multiple segments where code can be stored, and that specific segments can be selected. But my team wants specific forms of autonomous code in a specific segment, and have the ability to flip a switch and then preform a specific atounomous program. I have no clue if this is possible, could someone tell me if the ability to do this exists, and if so how do you do this. Thanks
~Mr. Ivey
Well, in autonomous mode, be aware that the switches must be attached to the RC, not the OI.
But yes, you can have up to 8 different programs on the stamp (0-7). Slot 0 is always run by default first, so you will need to serin your switches, and depending on input, you can run any of the slots. You run a program in a different slot with the command “run.” You set different files into your slots by having them all open in the editor, and making your directive comment look like this:
'{Stamp BS2SX, slot1filename.bsx, slot2filename.bsx …}
This will go in your program for slot 0, and all the ones in the list will fill up 1-7.
Let’s say that you have your slot 0, with all the fancy initialization code, and you have two different autonomous programs, in slots 1 and 2. Then, you have your driver-control program in slot 3.
if auto_mode = 0 then run 3
if rc_sw1 = 1 then run 1
if rc_sw2 = 1 then run 2
In all of your slots, you should always check for auto_mode, because you want driver control to return as soon as possible. This should always be your first thought in all your programs.
Also remember that your 26 bytes of variable memory are shared between all of your slots. If you declare all of them in the same order, their values will be preserved. Otherwise, you must assume that they are chaos at the begining of each slot. I recommend that you find out which variables must be in all slots, and declare them all at the beginning of each slot. Then you can declare independent variables after those.
Also look at innovation firsts website at firstrobotics.com in the white papers, there you will see a presentation on what you are asking
http://www.innovationfirst.com/firstrobotics/pdfs/Multi_Bank_Code.zip
Remember to check auton_mode after EVERY serin, not just at the beginning of each file. Likewise, make sure each slot has a way of getting to the SERIN/SEROUTs. The easiest way to do this is to just copy and past them into each file. Ditto for the DO…LOOP that keeps everything running smoothly. There are many other ways you could do it and I’d be happy to answer any questions you may have regarding them via PM or email.
–Rob
Thanks, ya’ll have been most helpful.
Mr. Ivey