Go to Post In no way is my team a powerhouse but we're striving to compete among the top competitors and in my opinion that's a start. - rcmolloy [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Events   CD-Media   CD-Spy   FRC-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 02-08-2008, 10:05 AM
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: 18
sfs is an unknown quantity at this point
Analog-to-digital conversions

Our team is attempting to utilize some of the analog ports for simple limit switches (as we are running low on digital ports) and were dismayed to find out that there is about a 1 second delay when using the standard Get_Analog_Value function provided in WPILib. We attempted to incorporate the adc.h and adc.c files from Kevin.org which reportedly is more efficient, but quickly found a conflict (Timer2). Due to there being no available source code for WPILib, it's hard to know what timers are used by WPILib and their purpose. Any suggestions?
Reply With Quote
  #2   Spotlight this post!  
Unread 02-08-2008, 11:18 PM
BrianBSL BrianBSL is offline
Registered User
FRC #0190
 
Join Date: Sep 2004
Rookie Year: 2000
Location: Worcester, MA
Posts: 251
BrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud ofBrianBSL has much to be proud of
Re: Analog-to-digital conversions

A 1 second delay does not sound normal.

If you are using these for limit switches, you will likely need a pullup resistor (something like 4.7k should work) to 5V, as I don't believe the analog ports have any pullup within the RC like the digital ports do, since a switch works in an open-drain configuration rather than driving rail to rail.
__________________
My posts represent my personal views only, and do not represent the views of either my team, Team 190, nor its primary sponsor, Worcester Polytechnic Institute.
Reply With Quote
  #3   Spotlight this post!  
Unread 02-09-2008, 07:48 PM
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: 18
sfs is an unknown quantity at this point
Re: Analog-to-digital conversions

Quote:
Originally Posted by BrianBSL View Post
A 1 second delay does not sound normal.

If you are using these for limit switches, you will likely need a pullup resistor (something like 4.7k should work) to 5V, as I don't believe the analog ports have any pullup within the RC like the digital ports do, since a switch works in an open-drain configuration rather than driving rail to rail.
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).

Thanks for the tip Brian!
Reply With Quote
  #4   Spotlight this post!  
Unread 02-13-2008, 08:35 PM
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: 18
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Digital to Analog Converters 6600gt Programming 11 02-08-2007 10:27 PM
Digital to OI Analog marcan Control System 33 02-05-2007 11:46 AM
Accelerometer: Analog or Digital? psquared Programming 2 02-10-2005 03:38 PM
Analog / Digital IO Connectors Aidan F. Browne Control System 4 02-06-2005 09:26 PM
Analog vs Digital inputs? f22flyboy Programming 8 11-08-2002 09:18 PM


All times are GMT -5. The time now is 09:48 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi