1

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.

SamGibson
  • 17,231
  • 5
  • 37
  • 58
Mini Tamm
  • 13
  • 5
  • Could you read [this on accuracy, precision, repeatability, etc](https://electronics.stackexchange.com/a/310500/38098) 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

1 Answers1

1

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

ADC Analog input impedance 100MOhm.

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

schematic

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 Stewart EE75
  • 1
  • 3
  • 54
  • 182
  • 2
    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 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
  • @MiniTamm after you define your Battery sense circuit requirements for accuracy resolution and power drain, then we can talk about improvements if any needed. My Plan A,B schematics only draw 0.45 uW. Your system draws 50mA max but what average so what is your budget for the Analog signal processing of scaling, sampling. 10 bit ADC gives ~1mV resolution on 1Vref , you want 50mV accuracy so 8 bit is adequate for ~<5mV resolution. Accuracy depends on R tolerances so 0.1% parts is adequate, maybe 0.2% but not 0.5% – Tony Stewart EE75 Jul 31 '19 at 20:17
  • 0.1% seems enough. I like the plan B since it uses same values as i calculated. I just thought when can i use so high resistor values and when i can't. If adc impedance is low then it will affect a lot divider voltage as i understund? – Mini Tamm Jul 31 '19 at 20:40
  • Also i could use op amp with negative feedback instead of voltage divider to get lower voltage. Is it better than divider? – Mini Tamm Jul 31 '19 at 20:41
  • No it is no better since the Op AMp is 100Meg But you did not use a switch so Plan A is better. Where are your Specs? – Tony Stewart EE75 Jul 31 '19 at 21:48
  • It seems plan A has too huge resistors. Hard to get accurate ones as well. I could get with 0.1% accuracy 330k and 1Mohm. What specs you mean? Power should be as low as possible to save batteries. My ADC measurement accuracy should be 50mV as i told you. – Mini Tamm Aug 01 '19 at 15:19
  • Then use 1% R's with a TrimPot and calibrate it to 0.1% and where are your specs for power consumption of the voltage divider? – Tony Stewart EE75 Aug 01 '19 at 16:20
  • DO you see NOW , how it is **IMPOSSIBLE to design anything**, unless you create your own design specs/ requirements, must not exceed limits. !!! All newbies Take note. – Tony Stewart EE75 Aug 01 '19 at 16:41
  • It isn't impossible. You just try some values and calculate the current then repeat until current is acceptable enough. Acceptable enough is if my system will last at least a year with batteries. So if it takes less than 0.1 mA average all is good. Choosing resistors in megaohms and hunderds of kiloohms is fine. – Mini Tamm Aug 02 '19 at 19:40
  • @MiniTamm You had a spec all along and I didn't realize you had it. (even tho I asked for it) " if it takes less than 0.1 mA average" Yes it is impossible to design anything without specs. – Tony Stewart EE75 Aug 02 '19 at 22:18