SOLUTION: Make sure your power input is 200mV over the reference power source (that's a typical bandgap reference voltage required). So, 3.2V is required for a 3V reference.

I'm finishing up a embedded design with an 8051 MCU, and coding up the ADC to function as a battery voltage detector.

I noticed a strange anomaly, I'm sure there is a very easy explanation.

I power the MCU & circuit with a 3.7v Lipo battery (so it fully charges up to 4.2v and discharges to say 3.5v with the protection IC on it... something like that).

I have a voltage divider from the circuit power, that turns the input voltage going into the ADC input from a max of 2.483v max to 1.848v min.

I set the ADC to use 4v as the internal reference voltage. I assumed this would be fine since since the inputs from the voltage divider are below 4v.

I got all kinds of funky readings that are not consistent from a adjustable power supply. It's not a software issue combining the 12 bit results. The hardware is just putting out flucating values.

I thought maybe my adjustable power supply has a really noisy output, but looking at it with a scope the output isn't flucating around like crazy.

On a lark, I changed the internal reference to 3v and all of a sudden the readings are totally stable and respond as you'd think.

Is there some reason that the 3v reference voltage works so much better? Is the 4v reference voltage just too far off?

Maybe this is obvious -- could it be that the 4v reference isn't possible if the Lipo is at 3.7v? This is some really cheap Asian 8051, they don't really spell out how the AD reference voltages work.

I'm not 100% on the arithmetic of an AD, I could sit and noodle the step values of the 12bit AD, but I really just am curious if there is something obvious here why the AD readings didn't work well with the 4v voltage reference?

  • \$\begingroup\$ a smoothing cap might help to reduce fluctuations, if you can live with the latency. \$\endgroup\$
    – dandavis
    Sep 16, 2017 at 20:41

1 Answer 1


"could it be that the 4v reference isn't possible if the Lipo is at 3.7v?"

Yes, it's not magic, it's just a very small voltage regulator. It will be built around a "bandgap" reference which puts out a fixed 1.25V, combined with an op-amp like structure to buffer the reference.

  • \$\begingroup\$ This was like 6 months ago when I made this code and didn't know so much of things. I guess I thought if it could provide a 4V reference source, the MCU had some kind of step-up converter of sorts in the IC... looks like, not so much... The anomally is probably the reference value changing with different input levels since it couldn't always hit the 4v internal value. \$\endgroup\$
    – Leroy105
    Sep 16, 2017 at 19:48
  • \$\begingroup\$ Also, if you can switch to a lower ADC reference voltage like 2 Volts then it will work. Adjust your input divider so it does not exceed whatever reference voltage you use. \$\endgroup\$ Sep 16, 2017 at 20:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.