View Single Post
  #2   Spotlight this post!  
Unread 13-02-2008, 21:35
sfs sfs is offline
Registered User
AKA: Steve Siirila
FRC #2220 (Blue Twilight)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2006
Location: Eagan, MN
Posts: 20
sfs is an unknown quantity at this point
Re: Analog-to-digital conversions

Quote:
Originally Posted by sfs View Post
That did it. You guessed correctly that we were simply grounding the signal line and did not include a pullup to +5V. The RC guide on IFI Robotics indicates that a 10K resistor is appropriate, so we used that. In PWM wire terms, we wired black(Gnd) to the switch NO (normally open contact), red(+5V) to the switch NC (normally closed), and white(signal) to the switch COM(common). This worked out fine for us, no delays. We now get values near 0 for a closed switch, and values near 1023 for an open switch (we map 0-511 to CLOSED, 512-1023 to OPEN just to be safe).
I should note that while the above works, it is likely overkill. It was inspired based on the wiring of a potentiometer. However, the resistor (as wired above) doesn't serve any purpose. It also requires the limit switch to be wired with 3 wires. The pull-up resistor SHOULD be wired from +5V to signal, to keep the signal line from floating when not pulled to ground. Then you wire the signal line and ground line to the limit switches, not the +5V. This should give you a zero (or very low at least) value when the limit switch is closed, and a non-zero (depending on the pullup resistor) value when the limit switch is open. I haven't verified this yet, but it seems like the more logical approach.