# Measuring battery voltage and impedance

I have been trying to figure out how to properly measure battery voltage for a few days. The more I read, the less I understand. I know there are many questions like this out in the internet and I have read most of them, but I haven't properly understood many of them. Also, many of them have no examples. Perhaps you can help me to understand some of the aspects.

What I'm trying to do:

I want to measure battery voltage which is 4.5V (3 x AA batteries) when full. I'm using an ATmega328P ADC to do that. My system runs on 3.3V. I have low power step down regulator to convert 4.5V to 3.3V.

My system takes max 50mA. I'm definitely concerned about battery life and accuracy. I would like to see about 50mV accuracy.

What I have read / what are my options (ideas):

1. Obviously the simplest solution is to use just voltage divider to feed the ATmega ADC. As I understand the ATmega, AREF is around 1.1V so I need to calibrate it 1/4 down. I was thinking about using 1 Mohm and 330 kohm resistors.

2. Then I read using P-MOSFET to switch it on and off when measuring, would be way to save power. Definitely it is. Problem is that I need additional N-channel to control P-MOSFET, and additional resistor/resistors. Not sure how good it is in terms of battery saving. Also many additional components.

3. I read about using an additional buffer between the ADC and divider. Now I started reading about impedances. In my case it probably won't matter, but just out of curiosity can anyone explain me simply enough when and how impedances matter when using ADC and how op-amps help?

I know a bit of theory behind them and understand that an op-amp input has high impedance and an op-amp output has low impedance. It would be really nice if I would get some examples. All links are welcome as well. I already tried to understand it, but I'm still confused. Examples would be great.

Also how accuracy/resolution depends on resistor values? Higher resistors seem to have the worst accuracy.

4. I ended up reading about differential amplifiers. Obviously it is overkill in my case.

5. I thought to use a specific μC for that.

• Could you read this on accuracy, precision, repeatability, etc and verify that you understand the terms and are correctly describing what you want when you write, "$50\:\text{mV}$"? There is initial accuracy (which you buy) but then there is time and temperature effects (and other effects, too) that affect this. So you'd need to specify a lot more about your goals to have confidence in the appropriateness of the answers you'll get here towards your actual goals. What battery life? What environment? Etc. – jonk Jul 28 '19 at 18:35

update Since @Marla raised a good point. Let me simplify this for you.

EDIT AUG 1: Only basic EE101 math skills are needed to compute resolution which must be << accuracy of system based on layout, noise, coding errors etc.

Since Vref ~ 1.1V and 50mV accuracy is desired this = 0.05/1.1*100%= 4.5%

## Design Spec

Choose 1% accuracy parts and hope to achieve 2% accuracy or use a trimpot with 5% parts and trim to 0.5% error or better which is 10% of your spec. 5% parts are < \$0.50 (1 pc)

So use 5% parts with a trimpot to reduce 10% tolerance max stackup error and trim to <0.5% error. ( or use an analog switch with 0.5% parts and lower value... your choice )

• Power Dissipation Specs for Divider ( incl. optional VBat selector switch) = TBD

simulate this circuit – Schematic created using CircuitLab

## Plan C

A clever choice of Pch FET Vgs(th)~2V you can get it to act as a <<1 Kohm switch ON and >100K OFF, using uC logic levels to replace the Analog switch since the circuit impedance is so high using uC logic levels for a 2~4=Vgs threshold and 5V with Vol=0V for ON and 5V-3.3V for OFF. I'll let you optimize this.

## extraneous into

You can measure the 4.5V battery voltage with any analog current meter rated for 50uA by choosing the appropriate series R for full scale and some diodes in series to indicate low voltage as 0% State of Charge near 2.5V . If you have a DMM or an old analog meter with a 50uA scale, try a 3V white LED in series which may drop somewhere around 2.5V or less at 50uA in series to drop 4.5 down to 2V then 2V/50uA= 40KOhm for a series R for a crude example. ( I could improve the accuracy, but this is just to demonstrate a 50uA 0 to 100% SOC monitor for a battery.)

However, you are using the ATMega chip which draws anywhere up to 7mA on 5V at the high clock frequency of 16MHz. Do you see any problems here?

Of course, sleep mode and low duty cycle helps bring that down. Your regulator may not have a low idle current as well. Do you know what it is?

This may help understand the ATMega power consumption. The trick to reducing power is reduce the clock rate and increase the interval between measurements

However, keep in mind all batteries have memory, in spite of what you may have heard. It was just that NiCd cells had a permanent memory that required activation to restore.

So after a heavy load they may resume to almost the same previous voltage due to two equivalent RC circuits in parallel inside every battery cell. C*ESR=T for each.

So if you draw 100 mA and the voltage drops momentarily that is due to the short term capacitance I*ESR and bigger C inside also has a bigger ESR so it has a longer time constant to recover the previous voltage after a burst of current to a load.

• Tony, I think the OP is asking about how to switch his voltage divider on and off, and using the A/D converter to measure volts. – Marla Jul 28 '19 at 17:34
• yes I realized that @Marla but I was just pointing out that the Voltage measurement can be easily done < 50uA per reading so the 50mA load makes this meaningless without other specs. like desired average current, rep rate and sleep duty cycle. – Tony Stewart Sunnyskyguy EE75 Jul 28 '19 at 20:03
• Your comment makes a good addition to your answer. Clarifies your intent. I would upvote if you add it to your answer. ;) – Marla Jul 28 '19 at 20:30
• Sorry for being 2 days away, had long work shifts. I didn't understund much what you said. Seems off topic to me. I wanted to know what is best option for voltage measurement. Also how op amps help with impedance. Im running my system on 3.3v already and atmega runs only at 8 Mhz on 3.3v(according to datasheet). I have 8 Mhz external crystal as well. Im gonna take measurement very rarely. The fact that how often i take measurements is gonna save my battery is pretty obvious. However without switching on and off voltage divider there will be current running 24/7 and wasting power. – Mini Tamm Jul 31 '19 at 17:53
• Can op amps improve my accuracy somehow? Or why they are used everywhere in voltage/current sense circuits? – Mini Tamm Jul 31 '19 at 17:54