Go Down

### Topic: Extremely n00b Resistor Question (Read 1 time)previous topic - next topic

#### Ownage

##### Jun 17, 2011, 07:02 pm
Hey,

I apologize for the n00bness, but here it goes .

Let's say I want to read the value of a resistor of X ohms (more accurately, voltage drop?).  In my application I am using a 2 wire RTD, but it is essentially a variable resistor.  According to my understanding the +5v pin is a +5v voltage source, it always supplies +5volts relative to GND.  If this is the case wouldn't the voltage difference ACROSS the resistor of x ohms always be 5volts?  Sure the current would change based on the resistance, but the voltage would not.  From my understanding Analog Read gives the VOLTAGE at the pin.  See the image on the left.  Just for the heck of it, assume my resistor was 10ohms.  What would analog read output?

Now for my second n00b question.  Is the image on the right a valid circuit?  Basically can I use an external battery to send power through the resistor and read the value, or if I intend to do analog reads must power come from the +5v pin?  Assuming the battery is 12V and the resistor is 10 ohms, what would analog 0 read?

Image can be found here:

http://imageshack.us/photo/my-images/101/arduinov.jpg/

#### Jack Christensen

#1
##### Jun 17, 2011, 08:50 pmLast Edit: Jun 17, 2011, 08:57 pm by Jack Christensen Reason: 1

Let's say I want to read the value of a resistor of X ohms (more accurately, voltage drop?).  In my application I am using a 2 wire RTD, but it is essentially a variable resistor.  According to my understanding the +5v pin is a +5v voltage source, it always supplies +5volts relative to GND.  If this is the case wouldn't the voltage difference ACROSS the resistor of x ohms always be 5volts?

Yes! (Well theoretically yes.  If the resistor is so small as to tax the current-supplying ability of the power supply, then the voltage will be less, and things may get warm, including but not limited to the resistor.)

Quote
Sure the current would change based on the resistance, but the voltage would not.  From my understanding Analog Read gives the VOLTAGE at the pin.  See the image on the left.  Just for the heck of it, assume my resistor was 10ohms.  What would analog read output?

Yes, and yes.  5 volts.

Quote
Now for my second n00b question.  Is the image on the right a valid circuit?  Basically can I use an external battery to send power through the resistor and read the value, or if I intend to do analog reads must power come from the +5v pin?  Assuming the battery is 12V and the resistor is 10 ohms, what would analog 0 read?

The general answer in the spirit of your question is 12 volts, but practically, the Arduino cannot tolerate more than 5V, so some sort of voltage divider would be needed.  The input pins have very high impedance, which means very, very little current will flow, causing very, very little voltage drop across the resistor.  So in effect, the battery's voltage is seen at the input pin.

I know next to nothing about RTDs; the most basic approach would be a voltage divider where the RTD is in one leg, see attached schematic (not necessarily a practical circuit, just to illustrate the basic theory).  I understand that RTDs can be very accurate devices, which means that some care will be needed in designing a proper circuit.  This may include using very accurate resistors (not your common 5% type, but maybe 1% or even better).  I also don't know how linear the response of an RTD is.  If non-linearity needs to be taken into account, then some additional conversion work may be needed in software.  Again, I'm ignorant, but there may be such a thing as an RTD interface device that will do a lot of this legwork for you.  And they may use more esoteric approaches, like a constant-current source.

Hope this helps!

#### MarkT

#2
##### Jun 18, 2011, 12:01 am
The usual way to _measure_ resistance is to force a known current through it and measure the voltage difference across the resistor.  A circuit called a constant current source is needed to do this, and this is how multimeters do it.

The potential divider circuit as above also measures resistance, but the output voltage is not _linearly_ related to the resistance - you have to do a little arithmetic to calculate it.  This is because the current depends on both the known and the unknown resistance.

With a potentiometer the total resistance of top and bottom parts of the divider is fixed as the wiper moves along the resistance track - here the output voltage is linearly related to the resistance (and note that the current is constant).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

#### Ownage

#3
##### Jun 18, 2011, 04:17 am
Hey,

Thanks for the schematic.  Is my logic correct here:

Let's call the +5v source A
Let's call the read pin B
Let's call the top resistor R_KNOWN (assume 10 ohms)
Let's call the bottom resistor R_VAR.

The voltage across the entire circuit (top arrow to bottom arrow) is 5V.  By OHMs law and combining series resistors we have:

5V = I * (10 + x)

Since this is a series circuit I is the same throughout.  Our read pin reads the voltage Across points A and B (circuit through +5 ---> R_KNOWN--->other side of R_KNOWN).  We now have:

V_ab = I * 10

Since I is the same we can substitute:

5V = (V_ab/10) * (10+x)

Rearanging once again we have:

5V/(V_ab/10) - 10 = X

V_ab is known as that is the value the arduino reads.  We now have X, the resistance.  Apply it to the linear RTD function and get the temperature.

Physics 2 FTW!!!

#### Jack Christensen

#4
##### Jun 18, 2011, 05:03 am
I think the math is OK, but the usual convention is to measure voltage relative to ground, and indeed this is what the Arduino does.  So it would measure the voltage across the RTD, that is, the voltage between the top of RTD in the schematic and ground.  So if the fixed resistor is R1 and the RTD is R2, then

R2 = R1 / ( Vin/Vout - 1)

#### Ownage

#5
##### Jun 18, 2011, 05:31 am
Ohh I thought voltage was measured in the order of the circut.

So now we have

5V = I * (10 + x) - circut

V_bGND = I * x - point b to ground
I = V_bGND/x - rearanged

5V = V_bGND/x * 10 + x
5V = V_bGND*10/x    +     vbGDN*x/x  - distribution

5V = V_bGND*10/x   +    v_bGND - cancellation

5V / V_BGND = 10/X + 1  - factoring

5V / V_BGND - 1 = 10/X

X = 10 / (5V/V_BGND -1)

R2 = R1 / (Vin / Vout -1) - more generally

Got it.  Thanks.  Now I understand how voltages are measured by an arduino!!

#### Ownage

#6
##### Jun 18, 2011, 05:37 am
Hey,

Now that I understand the voltage divider will the following work?  Basically I am using an external Battery (5v) to drive both resistors as opposed to the arduino pins.

Would I have to connect arduino's GND pin to the common ground that this battery uses, or is it fine as drawn?

http://img62.imageshack.us/i/arduino.jpg/

#### retrolefty

#7
##### Jun 18, 2011, 05:40 am
Quote
Would I have to connect arduino's GND pin to the common ground that this battery uses

Yes it is required that the battery negative be also wired to an arduino ground pin for this to work.

Lefty

#### Jack Christensen

#8
##### Jun 18, 2011, 06:57 am
A battery seems like an extra component that is unneeded.  Why not use the Arduino 5V supply?  For one thing, it won't change over time or need to be replaced.  Secondly, the A/D converter compares the voltage being measured to a reference voltage, which by default is the 5V supply, see the doc for the analogReference() function.  Finally, I don't remember the last time I saw a 5V battery

#### Ownage

#9
##### Jun 18, 2011, 03:23 pmLast Edit: Jun 18, 2011, 03:30 pm by Ownage Reason: 1
From the equation it appears that R1 could be anything !=0.  Is there any sort of convention and\or limitations to sizing R1 appropriately?  As far as the battery goes, assume that it is the same battery that is powering the arduino (voltage for the pins dropped to 5V if necessary).  Would this work and would a connection to ground pin needed, or is this implicitly achieved from the power supply?

EDIT: R2 will be on the order of 1k - 2k OHM

#### Jack Christensen

#10
##### Jun 18, 2011, 04:30 pm
Ah, OK on the battery then.  Yes, connect all grounds together, so ground on the voltage divider connects to the Arduino ground, and to the negative side of the battery.  (Ground is also sometimes called "common".  It's understood that everything connected to a ground symbol is connected together.)  Still, what I would do is power the Arduino from the battery, then connect the top end of the voltage divider to the +5 pin on the Arduino.  Might as well take advantage of the Arduino's onboard voltage regulator.  9V batteries work well, although the little rectangular guys don't have much capacity.  Six AAs can work, or even five, but four (6V) is not enough, the regulator needs at least a 2V differential, note the recommended input voltage for the Arduino is 7V-12V.

Select R1 to be near the midpoint of the expected range of R2, this will give the largest voltage swing at the output, and will allow better resolution.  So if the RTD varies between 1K and 2K, use 1500? for R1.

Like I said before, this is a very basic approach, and will probably not yield the most accurate results.  But it should work to some extent, and may be acceptable depending on your requirements.  And nothing is ever a failure, it can always be chalked up as a learning experience!   XD

#### Grumpy_Mike

#11
##### Jun 18, 2011, 11:31 pm
Quote
Would I have to connect arduino's GND pin to the common ground that this battery uses

This is why:-
http://www.thebox.myzen.co.uk/Tutorial/Power_Supplies.html

Go Up