View Single Post
  #5   Spotlight this post!  
Unread 25-02-2007, 12:22
Dave K.'s Avatar
Dave K. Dave K. is offline
Engineer/Mentor
FRC #0930
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: WI
Posts: 91
Dave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to behold
Re: Converting Joystick controls over to switches

Quote:
Originally Posted by Japper View Post
I plan to use some SPDT toggle switches (with off positions).

If I connect these switches to the X & Y pins on the joystick ports (port 3 & port 4 on our OI) and the switched
values are either +5v, ground, how do I simulate (set up the hardware) so that the off condition
is read by the OI as it currently is by the joystick as a neutral condition (127)?


Does this require some sort of a weak pullup (or a trimmer pot) on the switch common to obtain this
neutral condition (value 127)?
First, I will note that if you search a bit on the forums here, you will find several different threads that will provide additional insight beyond this response.


When an analog input is open circuited, no current will flow into the pin, thus when the OI samples the input, it will read zero volts. Anything below about 500-600mV will be interpreted by the OI as a disconnected potentiometer and result in an analog value of 127. This is done so that a disconnected joystick is interpreted as a 'stopped' condition as opposed to 'full speed in reverse'.

A full scale reading is obtained when the potentiometer's wiper is at the +5V end of the range, and a zero reading is obtained when the wiper is at the other end of its travel, (i.e. 100K ohms of resistance between +5V and the analog input).


So to do what you want, connect the switch common to the analog input pin. Connect one of the switch positions to the +5V Aux pin, and then use something like a 82K or 91K resistor between the other switch pin and +5V Aux to repesent the other. You could try a 100K ohm resistor, but tolerance stack up may result in a voltage close to the trip point where the OI decides nothing is connected... and since you only need to represent something distictively less than 127, any value from about 68K on up should be adequate.

Alternately, you could just wire your switches to the switch inputs and be done with it. Ports 2 and 4 have 8 switch inputs, the extra four on each are the switch inputs from ports 1 and 3. If you are already using those inputs for something else, then using the analog inputs should work fine.
__________________
--Dave