Battery powered Leonardo

Hi,

I have just completed the first rev of my project using ATMEGA32U4 along with a battery charger.
The circuit work fairly well but I am having the following issue.

I have a SPST throw switch that feeds the output of the battery (3.7V) to a charge pump that pumps the voltage to 5V. The SPST is either ON or OFF. I have a power rail called Vbat(3.7V) that I am hooking up to ADC0 through a 2K resistor. I am measuring 10mv from ADC0 to ground, so I know the ATMEGA32U4 is drawing power from the ADC0 input. When I increase the resistance I can get the draw down to .5mv but … the accuracy of the voltage measurement fluctuates by 30%. When I lower the resistance feeding ADC0 the measurement is with 1mv of an external meter.

I need to be able to measure Vbat for a low battery indicator but I also do not want any current draw when the switch is in the off position.

Attached is a schematic diagram, the only connection the ATMEGA32U4 has in the “OFF” position is the Vbat rail to ADC0(pin 41)

Thanks

When you connect a voltage to a pin, it is trying to power the MCU through the pin protection diode (phantom powering).
Increase the resistor to the point you're happy with, e.g. 100k or 1Megohm.
AND connect a 100n capacitor from pin to ground, to give the pin the needed low impedance during sampling.
You might also have to read the pin twice, and use the second reading.
Leo..

MikeSBlankenship:
I need to be able to measure Vbat for a low battery indicator but I also do not want any current draw when the switch is in the off position.

Attached is a schematic diagram, the only connection the ATMEGA32U4 has in the "OFF" position is the Vbat rail to ADC0(pin 41)

That's wrong - connect to the output side of your power switch. Do not change the resistor to anything
higher than 10k or you'll get less accurate readings.

I took out the 2K resistor and jumpered in a resistance decade box to play around, I also put in a 100nF cap as suggested from the input to ground. It went from a measured 700mv down to .5mv. I noticed the higher the resistance the lower the voltage reading. But as Mark T mentioned the reading were erratic with the higher resistance.

Another lesson learned in this was the voltage divider I was using near R1 and R2 for the thermal imager, I was not taking input current into the calculation. Here is a cool website website that picks the best resistor combination with a desired input current option with available resistors values.

http://howardtechnical.com/voltage-divider-calculator/

Thanks for all your help.

mike

9ad97c33ce9849429668533d3167e67241a55a09.jpg

MikeSBlankenship:
Attached is a schematic diagram, the only connection the ATMEGA32U4 has in the “OFF” position is the Vbat rail to ADC0(pin 41)

OK, so you had (some of) us thoroughly confused thinking this had something to do with the switch. You want zero current draw when your charging supply is off, whatever the switch position is.

Simple. Connect ADC0 directly to Vbus by a 10k resistor, and to +Vbat by a diode, cathode to +Vbat. Measure at least twice in succession on each occasion, use only the second value, calibrate for the diode voltage drop in your code (which you are obviously doing already). That’s what code is for, after all.

Hi Paul,

Thanks for your suggestions, I sent the board to OSH with the attached changes before I read your post.
I will do a few cuts on the new board and check your suggestion when I get them back on ~ Feb 25th 2016.

Thanks again.

GP-004-02 THERMAL IMAGER-SENT.pdf (84.4 KB)