![]() |
Using Analog Inputs as Digital (on the OI)
Hey folks,
Is there anything we should watch for if we want to use analog inputs as digital? i.e. wire up a binary switch onto one of the analog inputs. Should we wire ground and signal, +5 and signal, or all three? Thanks, Guy Davidson Paly Robotics (FRC #8) |
Re: Using Analog Inputs as Digital (on the OI)
tie a 10K resistor from +5 to the analog input pin
connect a switch from ground to the same analog input pin when the switch is closed you will have a 0 when the switch is open you will have full scale analog value (I don't remember if it is 8 or 10 bit or what) write some code that interprets half-scale or lower as a switch closed else switch open |
Re: Using Analog Inputs as Digital (on the OI)
Ed,
Thank you very much. Sounds good. |
Re: Using Analog Inputs as Digital (on the OI)
Just as a reassurance, we are successfully using this on our OI panel this year.
-q |
Re: Using Analog Inputs as Digital (on the OI)
Quote:
FYI, RC analog inputs are 10 bits, 0-1023. OI inputs are 8 bit, 0-255. |
Re: Using Analog Inputs as Digital (on the OI)
Quote:
Remember, on the OI, you don't need to have a ground connection for an analog input pot reading - on the joysticks, it's just five volts through the joystick axis pot straight to the analog input. We duplicate this method in wiring digital switches to our analog in's. For devices such as rocker switches or 3-position toggle switches where only one state can be active at one time due to the mechanics of the device, wire two resistors of differing values (each less than 100K - say 10k and 80k - whatever - I like to pick them to have a distinct separation that can easily be tested for in the code) between the +5V and the different poles of the device. 10k on one pole, 80k on the other. Wire the common of the device to a single analog input. When you actuate the switch, you connect 5V through either 10k or 80k into the analog input, resulting in a distinct numeric value for each position. Use if statements to test for ranges centered around these values and set binary variables accordingly: Code:
//Wrist Rocker switch on button box |
Re: Using Analog Inputs as Digital (on the OI)
We actually use a simlar method with an 11 position switch and 10 9.1K resistors wired to a joystick analog input, to give us a method of choosing different auto modes.
|
Re: Using Analog Inputs as Digital (on the OI)
Quote:
So anyhow, my question for clarification: Al: You guys use a switch on your OI panel, and it gets read by your robot before it starts to run autonomous? If so... awesome! -q |
Re: Using Analog Inputs as Digital (on the OI)
Q, I imagine that the OI is transmitting data throughout autonomous/hybrid mode - it's just that we never find out because it's hands-off.
|
Re: Using Analog Inputs as Digital (on the OI)
Remember that the RC starts to run it's (your) program when you turn it on. The OI does not get a autonomous command until much after you power the robot. During autonomous, all OI analog inputs are held at 127 and all digital inputs at "0". See the IFI Programing Ref Guide for more information. I will let the software guys answer coding questions, electrical provides the switch wired to the inputs defined by the software team.
|
Re: Using Analog Inputs as Digital (on the OI)
Quote:
http://www.chiefdelphi.com/forums/sh...37&postcount=3 If you happen to read the rest of the referenced thread, ignore all the dissenting statements - we've used this method for years, and it still works fine, including this season. Next year, with a new control system - who knows. |
Re: Using Analog Inputs as Digital (on the OI)
Just like Al and Travis's teams, we've been using "AiDi"s through the various analog input ports for some years now. Like WildStang (heck we probably got the idea from you guys Al ;) ) we use a rotating 6 to 10 position switch with resistors in series. And, like Travis pointed out, we leave plenty of "room" for selecting which position we want. Here's a sample of how we do it.
Code:
const uint8 AUTONOMOUS_ANALOGS[7] = {6, 140, 160, 190, 210, 235, 255};Eric |
Re: Using Analog Inputs as Digital (on the OI)
Quote:
Basically we had a thumbwheel through one of the joystick ports. thumb,trigger, aux1, aux2. BCD 1,2,4,8. When we powered up, we captured the inputs from the joystick to a global varible that was frozen. When auto mode started, we read the global varible. I had heard of some isses (something changed) in 2007 that it wasn't the same. I think Nathan, our programmer worked through that, not sure what they came up with. So this year, I wasn't sure what to tell them so I suggested to move them since we had so many modes on the robot, we decided to move the thumb wheels back to the RC controller because we have three thumb wheels now. |
Re: Using Analog Inputs as Digital (on the OI)
Team 85 has used three 12 position switches for several years now. One sets the autonomous path. Others are used for selecting debug information to be sent out the programming port and displayed on the OI. In the pit or on the field we can easily check backup battery voltage, joystick centering, and other values. We also mount a 100K pot to that's handy when developing code or trying out parameters.
|
Re: Using Analog Inputs as Digital (on the OI)
Hmm. I'm just about to wire the switch, and I'm wondering if I really need a connection to ground. Shouldn't I just be able to wire: +5 aux -> 10k resistor -> switch -> analog input, all in series?
|
| All times are GMT -5. The time now is 08:03. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi