Using Switches in Autonomus

How do I, using labView, program switches attached to the drivers station to decide which autonomus mode is used?:confused:
Thanks in Advance.

As soon as the robot is enabled in autonomous mode, you won’t be able to read anything from the Driver Station. So what you need to do is continuously read the switches while the robot is disabled, figure out which autonomous selection that means, and store it in a global variable. When autonomous begins, use the value from that global variable to select the proper actions.

Is that enough to start with, or do you want more detail?

Just a reminder that the DS inputs do not have pull-up resistors. So, you need to connect a pull-up from +5 to signal and a switch from signal to ground.

Fixed that for ya

Could you explain what a pull-up resistor is and why you need it in this situation?

A pull-(up/down) resistor weakly pulls an input either high or low. This prevents the input from floating around randomly and gives it a “Unless you dictate otherwise, I am high (or low if it is a pull down).” If you’ve ever had a digital input “flutter” or be otherwise unreliable, you probably needed a pull-___ resistor.

That being said vdubs you might want to let them know that a 10k resistor works perfectly (at least it did for us).

Dont want them to use a small resistor and end up shorting the DS

I like Alan’s recommendation of using a global variable, but why not put the switches on the 'bot instead of the DS?

During the setup time between matches you place your 'bot and set your switches accordingly.

We never actually implemented the full code last year, but we had some switches on the 'bot that we could set based on which starting square we were starting in. This way, the Auto code can know its starting position as soon as it starts up. Regrettably, our autonomous code never got that mature and the switches were left unused … go figure!

Having done this both ways on the pre-2009 robots, it tends to be an easier location on the driver station, and it eliminates the awkward running back out to the robot to make sure the switches are set correctly. Also last second changes :wink: after seeing how other robots are placed.

I think our programmer for 2009 even had a one-line autonomous description on the DS box, which was better than a simple number. Not that his descriptions were, well, descriptive. :stuck_out_tongue:

Agreed. We had the DS display which autonomous mode we were running all season. Having the ability to switch your autonomous mode after seeing how your opponent is set up is very nice. It’s even nicer in a game like Lunacy where a poor autonomous mode could be the difference between a win and a loss.

Having the switched on the controls allows for last minute changes to the code in case of a strategy change - dont know how many times we’ve changed the auton after a brief stroke of inspiration 5 seconds before the match starts.

As for the DS display, I find that showing the position and the begining movement of the robot allows for the operator/driver/coach to identify the auton being used pretty well.

For example, one of my codes displays: far left to far right, or center away.