|
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)
|