Table of Contents
Over on the RoboRio Digital IO page, we showed how a single switch can be used with a single DIO to select between two alternatives in software.
What if there are more two choices? More digital inputs!
Selecting from among more than two alternatives
One DIO input can tell the software to do one out of two possible alternatives. What if we want to select from between more than two? Use more DIO inputs!
We could use two DIOs for two different limit switches: one for UP, one for DOWN, and if neither switch is closed, we interpret that to mean the mechanism is somewhere in between.
Autonomous Selection
Suppose we want to select from four different autonomous routines. we could use two switches, and tell the drive team to set them according to a table like this:
- 0: Closed, Closed - do nothing
- 1: Closed, Open - drive forward
- 2: Open, Closed - drive forward and place power cube
- 3: Open, Open - drive forward, turn left, drive, turn right, drive, and then place cube
Given three switches and 3 digital I/Os, we could chose from 8 alternatives. The eastbots actually did this on our 2018 Season practice robot:
But requiring the drive team to read a chart and set several switches, even if the chart is written on the robot, could be confusing in the heat of the match and error prone.
A better user interface would be a rotary switch, which we used on our 2018 competition robot.
A typical rotary switch contains one or more “levels” each with a moving contact that can connect to one fixed contact at a time. We typically draw the schematic for such a switch like this:
We can connect a two-level rotary switch like this to encode those four positions into the four possible values for two DIO inputs:
More switch ideas
Suppose there were only three autonomous choices. One three-position toggle switch could control two DIOs. Such a switch is called a “single pole, double-throw, center off” switch. The switch, and its schematic symbol look like:
[picture]
Notice how the body of the switch is labled “on-off-on.” This how to tell that it has a center-off position without even moving the lever. We wired it up like this:
[picture]



