Go to Post There can never be enough help, unless there's too much help. - Joshua May [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 05-06-2008, 21:26
QRohlf's Avatar
QRohlf QRohlf is offline
Registered User
FRC #1823 (PING)
Team Role: Engineer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Portland, OR
Posts: 7
QRohlf is an unknown quantity at this point
Get Resistance from Analog In?

Hi! I am new to the competition, but I am fairly competent in C. I need to read a resistance value using the analog input. I know ohm's law, etc. but I am uncertain of how to apply it, or even how to read rc_ana_in01 correctly.

Help greatly appreciated.
  #2   Spotlight this post!  
Unread 05-06-2008, 22:23
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,998
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Get Resistance from Analog In?

The analog input measures voltage; your task is to create a voltage proportional to the unknown resistance.

This assumes you really want to measure resistance, as opposed to some physical phenomenon that the resistance represents (such as the position of something). If the latter, calibrate manually (One end reads "47" on the analog input, the other end reads "984", so midpoint would be around 468 or so).

One way is to create a voltage divider and feed it with a known fixed voltage. If your unknown resistance can be narrowed down to a range, the reference resistance can be about equal to half the maximum value. So, from the +5v source, you go through the unknown resistance, then the known (reference) resistance, and end at Ground. Sense the analog voltage between the two resistances...5 volts (1023 counts) means zero resistance, and 2.5 volts (511 counts) means equal to reference, and 5/3 volts (about 341 counts) means twice the reference.

Another way (if the range of unknown resistance is very high, or completely unknown) is to create a constant current source and measure the voltage across the resistor - R=V/I, and if I is known and V is measured (make sure it doesn't exceed the analog input range, 5 volts on a 2008 RC) you can calculate R.

Hope that gets you started...

Don
__________________

I am N2IRZ - What's your callsign?

Last edited by DonRotolo : 06-06-2008 at 20:23. Reason: I got Ohm's Law wrong... (Ouch)
  #3   Spotlight this post!  
Unread 05-06-2008, 22:25
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,998
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Get Resistance from Analog In?

Ah, basics: I can't say exactly how to read in the value, but it is a simple command like "Get Analog Input 1", returning a value from 0 to 1023 which corresponds to 0 volts and 5 volts respectively. Search "Potentiometer" on this forum for code examples.
__________________

I am N2IRZ - What's your callsign?
  #4   Spotlight this post!  
Unread 05-06-2008, 22:43
usbcd36's Avatar
usbcd36 usbcd36 is offline
Registered User
AKA: "DOS"
FRC #2399 (The Fighting Unicorns)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2006
Location: Solon, OH
Posts: 151
usbcd36 is a jewel in the roughusbcd36 is a jewel in the roughusbcd36 is a jewel in the rough
Re: Get Resistance from Analog In?

Quote:
Originally Posted by Don Rotolo View Post
Another way (if the range of unknown resistance is very high, or completely unknown) is to create a constant current source and measure the voltage across the resistor - V=R/I, and if I is known and V is measured (make sure it doesn't exceed the analog input range, 5 volts on a 2008 RC) you can calculate R.

Hope that gets you started...

Don
V = IR

Doesn't work the other way around, unfortunately.

With my limited knowledge of physics, I can say that one way to do this might be to connect the two outer terminals of a potentiometer to +5v and G, then connect the wiper to the sense pin of the RC. At one end of the pot, the sense pin would be at a 5v potential difference from ground, and at the other, a 0v potential difference. Definitely use a pot of significant resistance, though, or you'll draw too much current and break something. Find the max current draw from the RC, take a small fraction of that, plug it and 5v into Ohm's law and solve for R.

Last edited by usbcd36 : 05-06-2008 at 22:52.
  #5   Spotlight this post!  
Unread 06-06-2008, 09:47
simpsonboy77 simpsonboy77 is offline
Registered User
AKA: Garrett Dicken
FRC #0041 (RoboWarriors)
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: New Jersey
Posts: 88
simpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond reputesimpsonboy77 has a reputation beyond repute
Re: Get Resistance from Analog In?

That is exactly how you wire it. If you are using Kevin's code you type in Get_ADC_Result(CHANNEL) =. Channel must be from 1-16 depending on which port you plug it into. It returns in 10 bit resolution so if you are saving it to a byte, do Get_ADC_Result(CHANNEL)/4. If you want to make it slightly faster you can use >>2 instead of /4.
__________________
2017 Shenzhen, China Regional CSA
2013 - Present MAR Control System Adviser and FTAA
2009 - Present Programming an Electrical Mentor Team 41
2007 - 2008 Team 41 Lead Programmer, Electrical
2005 - 2008 Team 41 Member
2008 NYC Regional Winner
  #6   Spotlight this post!  
Unread 06-06-2008, 20:22
DonRotolo's Avatar
DonRotolo DonRotolo is offline
Back to humble
FRC #0832
Team Role: Mentor
 
Join Date: Jan 2005
Rookie Year: 2005
Location: Atlanta GA
Posts: 6,998
DonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond reputeDonRotolo has a reputation beyond repute
Re: Get Resistance from Analog In?

Quote:
Originally Posted by usbcd36 View Post
V = IR

Doesn't work the other way around, unfortunately.
D'oh - no, of course it doesn't. Thanks, my brain was asleep but my fingers were still typing.

He never mentioned a potentiometer...
__________________

I am N2IRZ - What's your callsign?
Closed Thread


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
get distance from cmucam ModMan24 Programming 14 29-10-2010 17:51
Selecting bits from an analog input Spencer E. Programming 2 13-01-2008 09:06
C code to get information from CMUcam2 lrantisi Programming 5 20-03-2007 18:16
Programming Analog Input from 2004 Controller Danny Diaz Programming 8 30-01-2007 22:44
Resistance to Analog Input Value. Josh Hambright Electrical 12 15-04-2003 16:12


All times are GMT -5. The time now is 00:08.

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


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