 # reading pot resistor value without regulated voltage reference

Hello,
I’m trying to determine the resistance value of a variable resistor (pot) on a battery powered microcontroller. If I don’t have a constant voltage reference, and the battery voltage varies from 4.6V to 3.3V, how can I do this with the analog input. I have a voltage divider with a constant resistor of 10K-ohm, and the variable resistor is…say 1K-ohm to 20K-ohm.

It seems like if I read the analog voltage and say the scale is 0 to 60,000 counts…and ADC reading is 30,000 counts (half of full scale), then I can say that the variable resistor the same value as the known resistor, so it’s 10K-ohm. Half of the battery voltage dropped across the first resistor, so he second resistor must be the other half.

Similarly, if the ADC reading is 20,000 counts, that’s 1/3rd of 60,000, so (depending on if the variable resistor is on the high side or on the ground side), the variable resistor is 1/3 of the total resistance, so (x)/(x+10k)=1/3, x=3330 ohms.

I’ve been reading this online, and a couple of articles touched on it, but they didn’t explain it in a way that I understood. Is the way I understand it correct?

If you're comparing the voltage across R1 and R2 and you know R1, then it shouldn't matter what the battery voltage is because, as you alluded to, it's just a ratio. The only problem is that you will lose a lot of resolution. However, if you know the battery will always be in the range you specified, you could hook it to the AREF pin and use external analogue reference.

saximus: If you're comparing the voltage across R1 and R2 and you know R1, then it shouldn't matter what the battery voltage is because, as you alluded to, it's just a ratio. The only problem is that you will lose a lot of resolution.

If I use the ratio idea, why would I lose resolution? I didn't understand that part. The resolution is the counts values...which is the same number of counts for ratio method as it is if you have analog reference?

1. Situation where I have 3.3V reference voltage: 0-60,000 represents 0-3.3V, when gets translated via voltage divider into a resistance. (60,000-ADC)/3.3 = (R)/(R+10,000).

2. Situation where I use ratio: (ADC/60,000) = (R)/(R + 10,000)

I'm unsure about my equation right now...maybe if I know for sure, I'd see why you mentioned the resolution lost.

I'm not sure if that's right.

starsson: If I use the ratio idea, why would I lose resolution? I didn't understand that part.

Because, without using an external reference, analogRead() essentially maps 0-5V to 0-1023. If your battery is only 3.3V, the analogRead() return values can only ever be 0-675. Thus, you've lost about 33-34% of your potential resolution.

Oh, I didn’t think that was true. I thought AnalogRead() maps 0-1023 to GND to Battery Voltage? So that way, I can assume the entire battery voltage (could be 3.3V, could be 4.6 volts, or anywhere in between) is dropped by the two resistors, and I’m reading the mid-point to get the counts ratio of the first voltage drop.

saximus:
Because, without using an external reference, analogRead() essentially maps 0-5V to 0-1023. If your battery is only 3.3V, the analogRead() return values can only ever be 0-675. Thus, you’ve lost about 33-34% of your potential resolution.

If you want to measure absolute resistance you need an accurate voltage source and an accurate reference resistor. If yoou want ppm accuracy this will be expensive.

If you only need the ratio the couple the high end of the potentiometer to the Aref pin - then the samr voltage is applied to the pot and the a/d.

If you want resolution to 1 part in 60,000 you need a 16-bit adc. The arduino only has 10.

regards

Allan

saximus: Because, without using an external reference, analogRead() essentially maps 0-5V to 0-1023. If your battery is only 3.3V, the analogRead() return values can only ever be 0-675. Thus, you've lost about 33-34% of your potential resolution.

That, it total bullshit ;)

It's indeed as starsson says, the default reference is Vcc so if Vcc is the battery voltage 1023 (of a 10-bit ADC like the Uno) will always be the battery voltage (or actually Vcc - LSB) no matter the voltage. So no resolution loss.

And it's that fact that the voltage is NO part of the equation so for measuring the resistance you don't have a problem. It's indeed all about the ratio so you can determined the resistor value no matter the voltage. Measuring the voltage isn't possible that way. Then you would need a fixed reference (like the internal 1,1V).

The math:

For a voltage divider you have Vmeasure = Vcc * R2 / (R1 + R2)

And looking from the ADC point of view we have Vmeasure = Vcc * ADCreading / 1024 (assuming 10-bit)

We can equate those equations: Vcc x R2 / (R1 + R2) = Vcc x ADCreading / 1024 Hey, Vcc on both sides! We can just take it out: R2 / (R1 + R2) = ADCreading / 1024