Electronic – How does the microcontroller read potentiometer resistance as integer without regard to potentiometer value

microcontrollerpotentiometerresistance

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?

Best Answer

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.