Using Custom Inputs on the Controller Board

Hey

I want to use custon imports on the controller board to choose which color the robot should look for. I plan on using 2 switches and using the four possible possitions as four possible options (Yellow, Red, Green, Off)

How do I call on these inputs in the code. I figured I would us one of the joystick inputs and use my owm cable, but how do I tell the code where to pull the info from?

–Sam
–Team 486
–Positronic Panthers

I suggest that you install switches for use during autonomous mode on the robot and wire them into the digital inputs on the RC following the directions in the RC reference manual. You will find examples of how to read digital inputs in the default code and in the RC programming guide.

Use the OI documentation to find which pins to use on the joystick connectors. Then look at the ifi_aliases.h file in the default code to find the software names of each switch input. You can treat each switch input as a “magic variable” which is set for you automatically and reads out as either 0 (not active) or 1 (active).

(By the way, the default code with camera support already uses the trigger switch on joystick #2 to switch among colors to track.)

Keep in mind that while in autonomous mode, the controller will read all switches as off. However, you can read the values before autonomous mode and save them on the robot controller itself to work around this.

That is true for switches on the OI. The state of switches on the RC are available during autonomous.

Sorry, that’s what I meant :slight_smile:

you can read the values before autonomous mode and save them on the robot controller itself to work around this.

I have a question about this. A few days ago I decided to write some dead reckoning code just for fun, and because I had never done so before. Basically I made it drive forward fast for 120 loops then turn left. I put it in the autonomous section and I expected the program would start running as soon as I turned the robot on even though I had it disabled. Basically I expected the program to run without driving the wheels until I enabled the robot. But it didnt. The program did not start running until I enabled the robot. This makes me wonder exactly how much of the code runs while the robot is disabled? Bascially I need the robot to tell the camera to track green even before the match starts. Can I do this somewhere or can we turn the robot on while it isnt on the field, and tether it so it will tell the camera this? Something?

Unless you put in a specific check, the software doesn’t care about enabled vs. disabled. The only difference is whether or not the RC pwm and relay outputs are activated.

Autonomous vs. manual is another story. If you put code in the autonomous section, it will only run if autonomous mode is commanded (by grounding the “autonomous” pin on the competition port). I’m not sure if the auton_mode flag is overriden by the “disable” pin or not.

  1. The autonomous mode is disabled if the disable pin is grouned. I made a switch which allows us to enable/disable the robot as well as activate autonomous mode. We also made a dongle which allows us to change the channels the robot was using. This came in handy when we participated in a post-season competition and those running it forgot that by default the robots run on the same frequency. I don’t know how many people have these, but if anyone wants instructions to make one, just send me a Private Message.

  2. I know how to work digital I/O on the RC, its just on the controller board that I don’t know how. In ifi_aliases.h it simply defined by a bizzare string (the trigger on the 1st joystick is defined by “rxdata.oi_swA_byte.bitselect.bit0,” which comments tell us is the 5th pin on port 4 [sic] plus what I assume is ground. There are only 4 possible digital inputs defined for each port. Is this the maximum? Also, is it possible to have outputs (ie for extra leds, etc)? I know that we are allowed to use computers connected to the dashboard program this year, but is there a more streamlined way?

–Sam
–Team 486
–Positronic Panthers
http://www.gotrobot.org/

Again, Sam, all your questions are answered in the OI documentation (on the IFI web site). Yes, there are four switch inputs on each joystick port. Yes, you can connect LEDs to the LED outputs provided for that purpose on two of the ports.

The “bizarre” string is pointing to a particular bit in the received communication buffer coming from the radio link. That’s how the RC gets its data from the OI. Just use the alias and don’t worry about the details of why it works.

Some Ports are more equal than others.
Specifically, see page 5 and 7-10 of http://www.ifirobotics.com/docs/oi-ref-guide-1-25-05.pdf.
“Each port provides four unique digital inputs. PORT 2 provides access to the same digital inputs as PORT 3, allowing access to 8 digital inputs from PORT 2. PORT 4 provides access to the same digital inputs as PORT 1, allowing access to 8 digital inputs from PORT 4.”