# How does the microcontroller read potentiometer resistance as integer without regard to potentiometer value?

When I hook up a 5k rotary potentiomoeter to the analog input pin of a microcontroller it will read values from the pot as integers 0-1023.

If I switch the 5k out for a 500k the microcontroller will still read values as 0-1023.

How is the system able to abstract the reading from the potentiometer down to the same range and distribution of integers when the max value of the potentiometer changed?

Apparently you hook up the potentimeter as a proper potentiometer, that is: the wiper supplies a fraction of the toptal voltage to the A/D ipnput. That fraction does not depend on the Ohmic value of the potentiometer: when you tae a higher value, then for a given position of the knob bot 'sides' will get higher values, but the ratio will not change.

Note 1: the voltage supplied by the wiper will not change when you take another Ohmic value for the potentiometer, but the impedance (effective series resistance) does change. As long as this impedance (worst case 1/4 of the value of the potentiometer) is lower than what the A/D input specifies as maximum this is not harmfull.

Note 2: the most common potentiometers are linear, but there are also logarithmic (and anti-logarithmic) potentiometers, which will (for a given position) give a very different ratio.

• note: why do you say 'worst case'? isn't the output resistance always exactly R/2? – Vladimir Cravero Sep 7 '15 at 19:12
• No. In the extreme cases (0%, 100%) the impedance is 0. At 75% fpr instance it is 1/4 || 3/4, which is 0.1875. – Wouter van Ooijen Sep 7 '15 at 19:56
• Yep apparently I still can't tell the difference between parallel and series. The max (worst) case should be R/4 though. – Vladimir Cravero Sep 7 '15 at 21:17
• You are correct. – Wouter van Ooijen Sep 8 '15 at 5:26

ADCs measure voltage as a ratio compared to their reference. And the voltage at the wiper will always be between the two voltages at the ends. This remains true regardless of the overall resistance as well as the type of potentiometer used.

The potentiometer will be wired as a potential divider, so the voltage at the wiper will be relative to the wiper position irrespective of the value of potentiometer.

The value of 0-1023 is relative. Relative to the minimum and maximum ADC voltage. In the same respect, the wiper is relative to the minimum and maximum voltage present on the potentiometer (if all three terminals are used).

50% is 50% if read as 512 out of 1023 or 1/4 or 2.5V out of 5V.

## protected by W5VO♦Sep 8 '15 at 0:27

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).