View Full Version : Using Switches on the Operator Interface
CronosPrime1
22-01-2006, 14:06
I know it has been done many times. I know it's often very handy. But how do you install switches and buttons on the OI? I want my robot to dump balls into the corner goals when I push a button or flip a switch. The OI, unlike the RC, does not seem to have convenient digital input connections, only serial ports. How, then, would I connect something like a three-way switch (to control a spike, for instance) to the OI? Please don't tell me to use the buttons on the joysticks. I know how to do that. I'm interested in wiring an actual switch or button to the OI. I know lots of people have done it, but how do you do it?
Jared Russell
22-01-2006, 14:15
Use the pinout of the serial port to make your own connector (put a switch between ground and one of the buttons).
See pages 7-10 of http://www.ifirobotics.com/docs/oi-ref-guide-11-21-05.pdf.
MacFlightSierra
22-01-2006, 14:17
Using a custom control box in addition to the drive joysticks is a great idea, we are also building one at the moment.
The pinout diagrams for the OI ports are available from IFI in the OI reference guide (they have not changed since 2005/05 I beleive) - http://www.ifirobotics.com/oi.shtml
The pinout chart gives the pin number for the OI digital and analog inputs, as well as the LED feedback drivers, and the IFI aliases for those inputs/outputs.
You will need 15 pin solder cups [male and female] and some basic wiring skills, but its quite simple to do. For switches - wire them between the input pin and any ground pin of that port.
good luck, have fun.
Al Skierkiewicz
22-01-2006, 14:23
So as not to confuse the reader, the 15 pin connectors on the OI are gameports not serial ports. They are compatible with the oldstyle game port joysticks found on PC's from long ago. (In computer years, that is.)
CronosPrime1
22-01-2006, 14:29
So as not to confuse the reader, the 15 pin connectors on the OI are gameports not serial ports. They are compatible with the oldstyle game port joysticks found on PC's from long ago. (In computer years, that is.)
Yea, I still have one of those joysticks. I think I might use it for the robot actually. Will joysticks that did not come in the kit work for controlling the robot? It's not joystick-dependent, is it?
CronosPrime1
22-01-2006, 14:32
Can someone please give me a less technical explanation of what everyone said about the pinouts and so on? I may be an experienced computer programmer, but I am fairly close to a newbie at robot programming. I'm not sure I know anything about the pins in the gameports.
Tristan Lall
22-01-2006, 14:32
Yea, I still have one of those joysticks. I think I might use it for the robot actually. Will joysticks that did not come in the kit work for controlling the robot? It's not joystick-dependent, is it?A gameport joystick will usually work, however there exist some non-standard implementations that may not function quite as expected. In general, any simple 2-axis, 2-button gameport joystick will work.
Jared Russell
22-01-2006, 14:45
The 15 pin connector that goes to a joystick - each pin corresponds to a particular function in the program. The document linked to earlier has the pinout description of what each does. To use a digital switch, for example, connect one terminal of the switch to ground and the other to one of the pins that corresponds to, say, p1_sw_trig (assuming your switchbox is plugged into port 1).
Then, in the program, whenever you access p1_sw_trig, you are actually getting the value of your switch.
CronosPrime1
22-01-2006, 14:51
Okay, that works. Now what if I have a multi-way switch? Can I plug it into the pin corresponding to p4_x, let's say, under port 4, and get a value from 0 to 255, where 0 will be one position, 1 will be another, and 2 will be another? And how will the switch know which position should be 0 and which should be 2? Or is it going to return 1,0, and -1, thus throwing my unsigned char data type off balance?
Billfred
22-01-2006, 14:55
Well, p4_x is an analog variable, so you'd have to rig up some resistors in varying amounts to get different values for the switch positions. (I'm not entirely sure on the values of the resistors, so I won't guess.) Alternatively, you could wire it to two different digital inputs.
CronosPrime1
22-01-2006, 15:36
So, in a word, to get a binary switch working, I can simply wire it to the right pins, but to get a 0-255 thing working (analog), I'm actually going to have to build resistors or get potentiometers?
CronosPrime1
22-01-2006, 17:13
Well, I think I'll just wire several binary switches and ask the computer to compute values using binary. Like if I want to select between 4 things, I'll convert input from 2 binary switches to a number from 0-3, and attach a printed label sheet to the operator interface so my team members can know what's going on. No problem, I guess. Binary math is easy.
Billfred
22-01-2006, 17:47
Well, I think I'll just wire several binary switches and ask the computer to compute values using binary. Like if I want to select between 4 things, I'll convert input from 2 binary switches to a number from 0-3, and attach a printed label sheet to the operator interface so my team members can know what's going on. No problem, I guess. Binary math is easy.
Binary math may be easy, but I'd avoid it on the OI.
Last season, I was field coach for 1293 during their short (two-match, if I recall) reign as #1 seed at Palmetto. I wasn't even doing the driving, and my mind had a million things going (time remaining, which goals were ours, which goals needed to be ours, is anyone in the loading zones, et cetera). Trying to throw in much of any sort of math would've had dire consequences.
The general thing you'll see on most OI panels is that they're simple. A driver should be able to judge what's going on by touch or a brief glance. This, in turn, gives them more time to figure out how to do more important things, like moving around those two 120-pound hunks of machinery blocking your path to the goal. (Of course, if your two switches corresponded to something visual on the robot, such as a left and right ball sucker, then by all means go for it.)
That said, binary is perfectly fine on the robot side for things like setting an autonomous mode. Even the most tense field coach in the world can figure that sort of thing out.
Hope this helps!
artdutra04
22-01-2006, 18:14
The general thing you'll see on most OI panels is that they're simple. A driver should be able to judge what's going on by touch or a brief glance. This, in turn, gives them more time to figure out how to do more important things, like moving around those two 120-pound hunks of machinery blocking your path to the goal. (Of course, if your two switches corresponded to something visual on the robot, such as a left and right ball sucker, then by all means go for it.)Yes - simple is really good! :)
Last year, we decided that to make driver reaction faster, we would only use momentary large (coin op arcade-style) push buttons on our operator interface (besides the joysticks of course). We would then use code to make them emulate toggle switches. (Such as hit it once to start a function, and hit it again to stop it).
This may not be perfectly suited for every application, but I can tell from experience (I was the co-driver for my team last year), that not having to look down at the button when you push it really helps. As you can see, our 2005 operator interface was about as simple at you could get. http://www.simtropolis.com/idealbb/images/smilies/10.gif
http://www.chiefdelphi.com/media/img/b29/b2914f88985067c3bf2983872d3cdcfc_m.jpg (http://www.chiefdelphi.com/media/photos/8571)
CronosPrime1
23-01-2006, 06:52
Well, I plan on having a driver and a switch-pushing person. But the system is very intuitive I think
Switch 1 - Conveyor belt on/off
Switch 2 - Conveyor belt forward/backward. If Switch 1 is open, Switch 2 does nothing and conveyor belt does not move.
Switch 3 and 4 - create a 0-3 number for setting autonomous mode. Set before match.
artdutra04
23-01-2006, 11:23
Well, I plan on having a driver and a switch-pushing person. But the system is very intuitive I think
Switch 1 - Conveyor belt on/off
Switch 2 - Conveyor belt forward/backward. If Switch 1 is open, Switch 2 does nothing and conveyor belt does not move.
Switch 3 and 4 - create a 0-3 number for setting autonomous mode. Set before match.Why not incorperate Switch 1 and 2 into a single switch? You can use a SPDT (or would it be SPTP?) toggle switch with a center neutral position. That way, when you push the switch up, it goes forward. When you put it in the down position, the conveyor goes in reverse. And when you put it back to the center position, it goes off. This would simplify things for the drivers. :)
Here are some pictures of the switches I'm refering to:
http://www.switchchannel.com/products/rocker/orl/ORL31ABB_pho.JPG http://www.switchchannel.com/products/rocker/dr/DR32EBB_pho.jpg
CronosPrime1
24-01-2006, 00:35
If I use a three way switch, I even have one right now, how would I wire it?
artdutra04
24-01-2006, 01:29
If I use a three way switch, I even have one right now, how would I wire it?You should be able to do this by grounding the center pin, and then connecting each of the two sides to a different wire on the joysticks - such as p1_sw_aux1 and p1_sw_aux2. If you get leave the switch in the center, there will be no signal. If you move the toggle switch in one direction, you get signal back in either the aux1 or aux2. If you move the toggle switch in the other direction, you will get back a signal from the other aux port.
Example:
/-\
/-------------\
| Toggle |
| Switch |
+-------------+
| | |
1 2 3Wire #1 contact to p1_sw_aux1, wire #2 to ground, and wire #3 to p1_sw_aux2.
CronosPrime1
24-01-2006, 06:48
Awesome. Thanks, I'll try that.
CronosPrime1
30-01-2006, 17:57
Oh, and if I have multiple switches that I want to wire to the same port, how do I do that? I know it is theoretically possible to wire up to eight switches each to ports 3 and 4, but how would I do that? Each port only has 2 or 3 ground pins. Can I wire the ground to several switches to the same pin? If so, is this advisable?
Al Skierkiewicz
31-01-2006, 07:07
Cronos,
You can have a common groung that attaches (daisey chain) to each switch and returns to only one pin in the connector for that port. There is very little current in this circuitry.
And now for something completely different...If you have the need to select just one of a multiple of chioces, you can use a rotary switch to selectively short out resistors in a string. Wire the string as you would a pot and return it to an analog input. We have used this method in the past for a autonomous mode selector that could be set for one of eleven different auto modes.
P1h3r1e3d13
02-02-2006, 23:41
If you have the need to select just one of a multiple of chioces, you can use a rotary switch to selectively short out resistors in a string. Wire the string as you would a pot and return it to an analog input.Good idea; that sounds more user-friendly than my plan of discrete-ifying a pot in code (ie: for analog value between 0 and x, var=0; between x and y, var=1, etc.) Is a rotary switch like that available to buy with resistors pre-wired, or am I going to have to solder this up myself? If I do, what is an acceptable range of resistances for an analog input?
The general thing you'll see on most OI panels is that they're simple.
Simple--and well labeled. You don't want to be searching for the button that stops the belt and hit the one that shoots. I was helping sort out old electronics a couple nights ago and found our 1999 switch box. How did I know that's how old it was? The labels were still intact and legible on all(or almost all of) the (four) switches. Knowing what the robot did, I put a date on it. Meanwhile, our '02 box has one knob that few (except maybe some of our mentors) know what the function is. Split color switches might be good too.
Al Skierkiewicz
03-02-2006, 07:32
Good idea; that sounds more user-friendly than my plan of discrete-ifying a pot in code (ie: for analog value between 0 and x, var=0; between x and y, var=1, etc.) Is a rotary switch like that available to buy with resistors pre-wired, or am I going to have to solder this up myself? If I do, what is an acceptable range of resistances for an analog input?
You are going to have to wire this up yourself. It is best for the entire string to not exceed 100K. What you are looking to do is simulate a pot. Radio Shack has a six position switch, and some nice looking knobs. Use 18K resistors and you are all set to go. Each resistor would be wired between each of the terminals of the switch. Tie one end of the string to +5 volts from a joystick port. Then tie the wiper of the switch (the internal terminal) to an analog input. When you measure the switch (before you install it) it should read about 5 x 18K when it is all the way at one end, and step by 18k as you advance the shaft one click. Effectively, you now have a six position joystick. Write the code to search for a value and you are all set.
How would I go about wiring a light to the OI so that it turns on when a certain condition is met?
CronosPrime1
04-02-2006, 15:41
Well, that I can answer. The operator interface receives feedback from the robot controller, and this input can be used to determine which lights on the operator interface to light up. If you look on the operator interface, the entire third column of lights - the robot feedback section - can light up upon command from your operator interface. To do this, you must change some variables when whatever condition you want is met in the code. For the name of the variables, look at the default code, the IFI programming manual, or the OI reference guide. I don't remember the names right now.
To wire something like a light bulb for external display, I don't really think you can. The operator interface only accepts input through all of its ports, except for the radio output. There is one good alternative to something like a light bulb, though. You can use the dashboard port to connect the OI to your computer, and you can light up something on your computer screen.
Tureyhall
04-02-2006, 16:13
To wire something like a light bulb for external display, I don't really think you can. The operator interface only accepts input through all of its ports, except for the radio output. There is one good alternative to something like a light bulb, though. You can use the dashboard port to connect the OI to your computer, and you can light up something on your computer screen.
sorry, you're wrong. pins 5, 8, 9, and 15 on ports 1 & 3 are LED outputs. They are the same as the PWM and Relay lights on the OI. all this can be found in the oi ref guide.
CronosPrime1
04-02-2006, 19:36
Well, yes, I meant specifically an electronic part that isn't usually there, such as a lightbulb. You can wire external LEDs. I don't know whether you could use the LED outputs to wire your own lights. Tell me if you think it's possible, it would be cool to do that.
Tureyhall
04-02-2006, 19:54
nope, not possible. not enough power comes out of the joystick port for anything but an LED. we had the same idea a few days ago, and it didn't work.
Al Skierkiewicz
04-02-2006, 22:20
The LED outputs on the OI are internally current limited to 10 ma so that an LED can be directly connected without any other components needed. The OI reference guide explains it all starting on page 5. There are up to 8 LED driver outputs.
So, simple how would I wire a light to these ports that can power an LED. And how would I define it to light up?
Like
if Tracking_Initialized == 1
*TURN LED ON*
CronosPrime1
05-02-2006, 11:32
I quote from the operator interface manual:
"LED Drivers (see pinouts on pages 7-10)
PORT 1 and PORT 3 each provide four LED output drivers. These LED drivers allow the connection of
external LEDs that duplicate the function of the top eight Robot Feedback LEDs on the Operator
Interface. The LED drivers provide 5V that is current limited to 10mA. Connect the LED’s anode to
the desired LED drive pin. Connect the LED’s cathode to any ground pins."
See the Operator Interface manual for which pins to connect to what.
CronosPrime1
05-02-2006, 12:39
Now I have a question of my own: earlier in this thread, people were talking about how in order to wire a custom control box with switches and all to the OI, i'd need male-female solder cups. What is a solder cup? What is meant by that? What is it and where can I buy it? I thought I would just split the cable and solder wires together. Apparently I have to get some sort of special "solder cups?" Also, what is a backshell? The OI manual says:
"WARNING: The COMPETITION port has pins that connect directly to the Operator Interface microprocessor. Incorrect wiring may damage the unit and will void the warranty. This damage may not be apparent until connecting to the field at competition. Use caution and double check your wiring prior to making a connection. Always use a backshell to protect the connector’s pins from ESD discharge."
Can anyone decode that for me? What is ESD discharge and what is a backshell?
Al Skierkiewicz
05-02-2006, 15:03
Cronos,
A solder cup is a particular type of "D" connector that is designed for soldering wires to, as opposed to an IDC where a ribbon cable is simply pressed between two pieces of the connector. D connectors come in 9 pin and 15 pin types for your convience and the shell is the cover of the connector after you have wired, it. Check the Digikey website for picturs of both types.
You should not connect anything to the competition port except the dongle, a switch wired per IFI that would allow you to simulate a competition field. Wired as described on the IFI website, the switch can disable your robot function, enable the robot or start autonomous. It is simple to build a three position switch into the shell of the D connector for you to practice auto mode and competition start.
ESD stand for Electro Static Discharge and it is what occurs when you get shocked by equipment on a dry winter day. The release of energy built up on your body can and often does damage electronic equipment. By using a shell to cover the exposed pins in anything connected to the OI, you can prevent damage should your finger touch an OI input and discharge static electricity.
Connection for an operator switch box are best done by obtaining the right sex and pin count D connector and wiring to allow switches to be read by the joystick ports on the OI. Note that there are four joystick ports on the OI, each with several digital inputs to read switches on joysticks. Those inputs can be used with your software to initiate fuctions on the RC like pnuematic valves, arm controls or motor operation.
Mike Shaul
05-02-2006, 17:12
Just FYI:
This year I am using these parts from Newark (http://www.newark.com):
DB15, Male, Solder Cup - 92N3443
DB15 Backshell - 44N8888
You can check out their images/data sheets for more details.
P1h3r1e3d13
06-02-2006, 00:51
You are going to have to wire this up yourself. It is best for the entire string to not exceed 100K. What you are looking to do is simulate a pot. Radio Shack has a six position switch, and some nice looking knobs. Use 18K resistors and you are all set to go. Each resistor would be wired between each of the terminals of the switch. Tie one end of the string to +5 volts from a joystick port. Then tie the wiper of the switch (the internal terminal) to an analog input. When you measure the switch (before you install it) it should read about 5 x 18K when it is all the way at one end, and step by 18k as you advance the shaft one click. Effectively, you now have a six position joystick. Write the code to search for a value and you are all set.I was under the impression that joysticks were technically rheostats, rather than potentiometers. That is, the analog inputs just read resistance values. By that theory, the sweeper and one end of the chain would connect to a ground pin and analog input and the +5V pin wouldn't be used.
Did I read the OI ref manual wrong?
CronosPrime1
11-02-2006, 22:17
Yeah, the OI manual says you should connect joysticks to a +5V
Al Skierkiewicz
12-02-2006, 13:12
I was under the impression that joysticks were technically rheostats, rather than potentiometers. That is, the analog inputs just read resistance values. By that theory, the sweeper and one end of the chain would connect to a ground pin and analog input and the +5V pin wouldn't be used.
Did I read the OI ref manual wrong?
Check out the equivalent input circuit on the IFI website. Don't forget that the analog input has a resistor to ground internal to the OI. As such a variable resistor, external to the OI, will vary the voltage at the input if it is connected to 5 volts at one end. The beauty of this circuit design is that the OI can now recognize when a joystick has been unplugged and output a 127 to the PWM outputs it controls.
P1h3r1e3d13
12-02-2006, 18:43
Thanks.
The variables for the OI LEDs and how to use them are explained in the one of the ppts here (http://www.usfirst.org/robotics/C_help.htm). I think it's one of the later ones, but I'm afraid I don't know which.
the_short1
15-02-2006, 22:30
Thanks for all the information guys/girls. I am currently making a custom joystick out of a medium size Radioshack hobby box, i have 4 switches (conveyor on off, rev fwd, shooter on off, camera track on off) and a knob for pan and a stick for tilt (which i may be using a mini joystick stick for).. <definately will post a picture later.
i have an led on my knob and i knew nothing of how to light it up :) but thx to you, now it do :D
now to convince some students that a custom interface is better then those plain white joysticks :eyeroll:....
What I did was just took an old joystick (which has most wires needed for switches) and cannibalized the wire. :D
vBulletin® v3.6.4, Copyright ©2000-2017, Jelsoft Enterprises Ltd.