Programming toggle switches to DS for different autonomous routines?

We would like to use toggle switches on the DS to trigger different autonomous routines. Of course, we don’t have the robot to test our code. We are attaching our best guess. Could someone look over our code to see if it would work. (We only have one routine programmed at this time.)

Autonomous VI.doc (79 KB)

Autonomous VI.doc (79 KB)

A couple of problems…

First, the Driver Station switches cannot be read during Autonomous. For your purpose they must be read BEFORE autonomous begins and remembered for use here. How you do that depends on the Framework you started with (Basic or Advanced). There are CD threads on this topic you can checkout along with sample code.

Second, as written, all your drive commands will actually occur all at once. To sequence them you must tie the error output of each Delay & Feed to the next Tank Drive command you want to have happen.

for the switches

You could just place this in the “other”, “default” case in the robotmain vi for basic framework
and for advanced framework in disable vi “execute” case

my code uses less switches, and converts them into a number, you can just modify it as you need.

as for the drive commands, i would say do as Mark said, but i dont think it should make a difference except for the crab drive sections, and that is because the device refrences force a chain, but to be safe you should chain the errors like mark said. (9.4 KB) (9.4 KB)

We have the Get SwitchVI in place now in “other”“default”, thanks Shivang1923. How did I get the selected autonomous mode to be read in the autonomous VI. We have found a few CD threads on this topic, but they are written for the advanced mode. We are using Basic mode. Is this possible in Basic or are we not finding the right threads?


ok try something along these lines

i am assuming you guys changed the vi to match your button inputs
the output of the GetSwitchVI is a number
the number is counted in binary depending on the switch: so if the first switch is true, then the number is 1, if the second then it is 2 if first AND second then 3 if none then 0.

there is a global variable called robot data. If you have watched the tipjar videos from, you would know how to place more ‘data(for lack of the proper term =P)’ into the global variable Robot Data. place just a number indicator into there.

in autonomous independent vi, unbundle the global, take the number (again, the videos from lvmastery tipjar will teach you this.) and wire it into a case structure. Then inside each of the cases, put what autonomous code you want running into it.

You could possibly get by with a cheap switch read when the cRIO first boots, but I think a better solution takes just a few edits of the Basic template.

On your Basic diagram, open the Basic Get Mode VI. On its panel is an output called Robot Mode which wasn’t connected as an output. When the template was made, I never checked to see what the DS behavior was, and assumed that Other would work fine. Since it doesn’t, here is how to fix it.

On the subVI, right click on the icon in the upper right of the Basic Get Mode panel and Show the Connector. Click on one of the connector outputs, then click on the Robot Mode. Save the VI, Close, and on the Basic Robot Main, you now have access to the Robot Mode output. Wire this to the edge of the case so that in Other you can switch on it and you can read the switches only in Auto Disabled and set a global with the state of the switches.

Greg McKaskle

I added the connection to the other(Thanks Greg). We are using three separate switches to change between three different autonomous routines so from Shivang GetSwitch VI I changed the GetSwitch inputs to indicators. I then added the DriverStationDigInputs to the global. We unbundled the new switch global in autonmous. Make sense?

We won’t get to test the code for a few weeks.

THANKS ALL! Without ChiefDelphi and LVMastery we could not have gotten our robot running.

I’m not sure I followed where you are reading the DS inputs. The place I’ve shown others is inside the Other case, but then use the new input to further limit it to autoDisabled. Read and store in the global to read other places such as your Autonomous routine.

If that is what you have, then I think you have what you need.
Good Luck.
Greg McKaskle

Another way to do this is to use the driver joystick buttons to set the auto mode, and display it on the DS LCD

I wrote a white paper on how to do this, and included a VI with the code.

I’m on an I- touch so I can’t paste the URL, but if you go to CD media, and search for my white paper it’s easy to find. Search for posts by Philbot with a keyword of Auto.

It doesn’t need any wiring changes, and it remembers the mode through reset. The mode can be changed at any time during Auto Disabled

If this helps, there is a dipswitch on the cRIO that is readily available for user use (a light too). If you only have two types of autonomous modes, you can use that switch to change modes before each match starts. In LabVIEW, the VIs for getting the switch state and controlling the light are in the driverstation palette, I think. Someplace like that, look around.

Here’s a very helpful manual about the cRIO that mentions these things: