Society of Robots - Robot Forum

Software => Software => Topic started by: lcab on March 23, 2010, 10:58:07 PM

Title: Re: need help programing adc to measure resistance
Post by: lcab on March 23, 2010, 10:58:07 PM
i am trying to write a program in c to measure the resistance across two terminals using my analog to digital converter on my microprocessor. We are using the a axon atmega640  microprocessor and i had received some help in the which was
waltr
Supreme Robot

Which microprocessor?

An ADC measures voltage and converts the voltage to a digital value that is dependent on the input voltage, the internal reference voltage and the number of bits of ADC resolution.
To measure a resistance you need to use Ohm's Law (E = I*R or R = E/I). So, apply a constant current (I) through the resistor and use the ADC to measure the voltage across the resistor then calculate the resistance.
Google will find tons of information on this.

Admin
Administrator
You'll need to make a voltage divider - two resistors in series.

Attach ground to one end, 5 volts to the other, and your ADC output in the center. The voltage measured, using Ohms law, will get you resistance.

Make sure you keep total current under 20mA, lower the better.

Use 10 bit ADC to get the best accuracy.

now i am asking

if i was using a 3-pin header cable to connect to the microprocessor and i connected the 5v to the left side of the terminal and the ground to the right side of the terminal and my output cable will start on the positive terminal then run over to the ground terminal then run into the middle pin on of the microprocessor pin. Theoreactcialy Will i get the right output resistance of the resistor being measured , because i am writing the code for it now but just though i would post what i was going to do to see if a more experience person could tell me if i was heading in the right direction. thanks.

Title: Re: need help programing adc to measure resistance
Post by: benjammin105 on March 28, 2010, 04:56:08 PM
I'm interested in doing this myself but I'm using the Webbot library and I wanna measure the voltage off of the voltage divider and use it in ranges in an if statement. kinda like


if(adc measures 3.33-3.70 volts){
(execute a subroutine)

etc.

I can't quite figure out the webbot commands to do something like this. does anyone have any ideas??
Title: Re: need help programing adc to measure resistance
Post by: Soeren on March 28, 2010, 06:59:41 PM
Hi,

[...] measure the resistance across two terminals using my analog to digital converter on my microprocessor.
[...]

if i was using a 3-pin header cable to connect to the microprocessor and i connected the 5v to the left side of the terminal and the ground to the right side of the terminal and my output cable will start on the positive terminal then run over to the ground terminal then run into the middle pin on of the microprocessor pin. Theoreactcialy Will i get the right output resistance of the resistor being measured
What you have been told, is to use a voltage divider, but its precision will rely on that of your voltage regulator (which isn't something to brag about).

A much better approach is, to use a Constant Current Generator (CCG) to send a current through the resistor that you want to measure and then measure the voltage developed over it.

The current from the CCG must be matched to the range of resistance that you want to measure of course and since you didn't mentioned that, I cannot give you the values of R1 and R2, but here is a very precise way of measuring a resistance:
(http://That.Homepage.dk/Img/ResMeasure.png)