Using a POT for ADC

potentiometer

I am using a potentiometer with 5% tolerance as a voltage divider in order to send voltage signals to a microcontroller. The mcu reads the voltage and converts it to digital numbers which is then converted to time. The problem that I am having is that when the system resets, the clock changes its reading, I don't really know why this is happening but it happens often.

Best Answer

I'd say you have a precision error. The microcontroller reads the voltage from the potentiometer with a reference to something, usually Vcc but it can also be referencing ground, or some other internal voltage.

If your voltage changes, the value converted by the ADC will change as well. Voltage changes can come about from many things, including but not limited to ambient temperature changes, power supply load, component temperatures, etc.

If everything is fairly consistent, you may just have a rounding error. For example prior to reset you might get an arbitrary value of 10.4 (for example), but after reset or a second ADC read you get 10.5. The latter would be rounded up to 11 if using integer math.

You might want to modify your code to have fewer or broader "steps" to convert to time, so that input values do not necessarily have to be as precise.