LiPo Battery Monitoring - Page 1
Forum section: electronics / projects

author: XenonFlash54
author_rank: Contributor
timestamp: January 31, 2015, 11:27:00 pm
content: Hello Everyone!I am currently working on a project that uses two lipo 3.7V batteries in series to get 7.4V (the batterys have a low voltage cutoff circuit on board so each one stops working at 3V) I would like to be able to output the voltage remaining on a 20x4 LCD that is the main interface with the project.I have looked for a chip that could do this, but I couldn't find one that looked like it would work. So I did some googling and found a design someone made for doing something similar - my modified version is attached. So the way it would be thought to work is: the resistor voltage divider cuts the 7.4V in half (3.7V), then the PIC measures it as it drops in voltage. Now my question is,wouldthis actually work? It just seams to simple for being able to work right...Thanks for your time!DanEDIT: Oh, yeah - U1 would be a low drop out voltage regulator.

author: Siwastaja
author_rank: Super Contributor
timestamp: February 01, 2015, 03:08:39 am
content: Yes, that works well. The problem is that current is drawn all the time, but your voltage regulator draws a lot more current anyway.If you want to reduce the current consumption to zero, just replace the resistor divider ground connection with an IO pin and drive it to ground just before measuring the voltage. You may need to calibrate the result a bit due to voltage drop in the IO pin.Anyway, you need to add a capacitor directly between the ADC input and ground. This is because the output impedance of your 10K-10K divider is too high for ADC to work well, but a capacitor can supply the current the ADC needs for the very short time it samples the input. 100nF (ceramic) is enough but doesn't hurt to go higher. Helps smooth out any noise Note that if you use the IO pin trick to stop quiescent current consumption, then you need to add a delay between enabling the divider and converting voltage, as the capacitor needs to charge up through the resistors. Go for 10*R*C seconds.

author: XenonFlash54
author_rank: Contributor
timestamp: February 02, 2015, 12:46:10 pm
content: Awesome! Thanks for clearing that up Siwastaja!I think that I will go down the extra I/O pin route, so I can cut back on current consumption. The plan is to use a PIC18F67K22, and on datasheet page 498 it says that the max output voltage when a pin is low is 0.6V. So....7.4Vs cut in half with the resistor devider is 3.7VBut the I/O pin has a 0.6V output so (7.4V-0.6V)/2=3.4V - is that right?Then with the capacitor (let's say it's about.... 220nF) 10*10,000*0.00000022=0.022s=22ms - is that right too?Thanks for your time!!!Dan

author: Siwastaja
author_rank: Super Contributor
timestamp: February 02, 2015, 02:30:13 pm
content: You need to calibrate for the IO pin drop. I thought it would be purely resistive, resulting in only gain error, but it wasn't so. But in any case, the response seems linear; you can correct very well with simple offset&gain. I use this approach to measure between 2.5 and 4.2 volts, use simple two-point calibration (measured at 3.0 and 4.0 volts, then calculate offset and gain), and get +/- 10 mV accuracy from a 10-bit ADR (AVR). So, while you certainly could model this mathematically, empirical calibration is easiest and gives best results. Yeah, 22 ms sounds about right. My application uses 470R-120R divider, 100nF cap and a 2 ms delay. I can use such a low-value divider because of the IO pin trick.My application goes a bit further because I measure the chip temperature (internal sensor) and use that information to correct for internal voltage reference temperature drift, so in the end, I have more complex calibration involving Peltier-based calibration oven to get good accuracy over all voltages AND temperatures. In most cases, you won't need that. Just showing the battery level and protecting the cell is well possible with +/- 50 mV spec.

author: mij59
author_rank: Frequent Contributor
timestamp: February 02, 2015, 02:46:53 pm
content: Maybe you could use a lipo fuel gauge e.g. like this

author: PeterFW
author_rank: Frequent Contributor
timestamp: February 02, 2015, 04:11:25 pm
content: If you want a challenge you could add something like this to your project, that is a "battery fuel gauge".http://www.maximintegrated.com/en/products/power/battery-management/DS2782.htmlIt masures the current flowing in and out of the battery, that way you get a reliable estimation of the remaining battery life.But i have not used the chip mentioned above, currently i got this one on my bench, but not hooked up yet:http://www.maximintegrated.com/en/products/power/battery-management/DS2784.htmlProtection, battery capacity monitor and shunt all in one neat package.

author: XenonFlash54
author_rank: Contributor
timestamp: February 02, 2015, 08:26:52 pm
content: QuoteOkay, it does sound best to measure it on the spot. I'll play around with the values for every thing and see what works the best for me.I don't think I'll need anyreallygood accuracy, all I want to do is display a rough estimate of what's left in the battery.Quote from: mij59Yeah, when I was googling I came upon that. Maybe I'm just weird, but I prefer to build the stuff rather than use a breakout board thing.QuoteYeah, I'll have to look into this chip! The I2C interface kind of scares me away though, along with the $7.46 digikey price tag!Thanks for the advice!Dan

author: suicidaleggroll
author_rank: Super Contributor
timestamp: February 02, 2015, 08:40:45 pm
content: Quote from: Siwastaja on February 01, 2015, 03:08:39 amThat won't drop it to zero, it'll drop it to (7.4-Vcc-0.7)/10k, since whenever the pin is not set to 0 you'll be dumping current through the microcontroller's protection diode. It may actually leak MORE current than just leaving the resistor divider as he has it drawn. You need a P/N mosfet combo or similar to truly isolate the mcu from the 7.4v and prevent leaking current through the protection diodes (which could cause unpredictable results, latch up, etc. as well).

author: Mr.B
author_rank: Unknown
timestamp: February 02, 2015, 09:31:39 pm
content: If you increase your resistor values dramatically you will reduce your current consumption.I have done this plenty of times using an AtMega328p.I use one 10m on the high side and one 2m on the low side with the AtMegas internal ADC reference programmed to 1.1v.0.1u cap across the 2m resistor.I only use a single LiPo, but the principle will work fine with 7.4v. (As long as your ADC reference can be programmed.)

author: PeterFW
author_rank: Frequent Contributor
timestamp: February 03, 2015, 12:39:25 am
content: Quote from: XenonFlash54 on February 02, 2015, 08:26:52 pmFor the longest time i too thought I2C and SPI were the devils work.But today, for the most part, i will be disapointed if something has a interface that is not I2C. Very simple to use, no mess of wires or code.You just have to ask the sensor and you will get what you want, ready to use, no extra code, calculations or the like.Greetings,Peter

author: Siwastaja
author_rank: Super Contributor
timestamp: February 03, 2015, 09:22:37 am
content: Quote from: suicidaleggroll on February 02, 2015, 08:40:45 pmTrue!! I missed that; my application (single cell) measures its own supply voltage (where this isn't a problem) so I didn't think about this. Sorry.

author: ManCave
author_rank: Regular Contributor
timestamp: February 03, 2015, 10:51:07 am
content: Hi Dan,You have some good answers there. However, I would recommend that you measure the voltage of the bottom cell too to get truly accurate voltage estimate (depending on how accurate you want to go). Read the 7.4V via resistor divider and the 3.7V (between the cells) directly with protection resistor. Then deduct the bottom from the top to get the top cell's voltage and then average the two.However, there are hundreds of fuel gauges with I2C interface available and that will really be the most accurate way to measure remaining capacity. If you can write to an LCD, you will be able to pick up I2C fairly easily. Just don't forget the pull-up resistorsBest of luck!Filip

author: XenonFlash54
author_rank: Contributor
timestamp: February 03, 2015, 10:05:37 pm
content: Quote from: suicidaleggroll on February 02, 2015, 08:40:45 pmI can see why most people just use a chip now! I guess I will to...Thanks for your help guys!!!Daniel

author: Siwastaja
author_rank: Super Contributor
timestamp: February 04, 2015, 04:15:38 am
content: The idea of that kind of a chip is to provide coulomb counting (current integration), which is almost absolutely necessary with flat discharge curve chemistries (such as NiCd, NiMH, lead acid, and LiFePO4 li-ion), but not necessarily so with the chemistries that give large range of voltages in an almost linear fashion (like traditional high energy density LCO or newer NCA/NCM cells; so practically all li-ion saying 3.6 or 3.7 volts nominal). As an example, while LiFePO4 cell runs from 3.4 to 3.1 volts with 0.3V difference between full and empty, a modern NCA cell may run from 4.2 to 3.3 volts, a 0.9V difference or three times more resolution for a simple voltage-based battery gauge to work with.Coulomb counting has its problems too, and integrated battery management or fuel gauge chips have a horrible reputation for a reason, from destroying batteries to just showing utterly false values to end users. The broken-by-design battery management IC's still haunt consumers today, even though things have got a lot better. (Anyone ever heard anyone having problems with their battery life or battery gauge in any of their iDevices? Yup, daily complaining (if the weather is ok). And you guessed it, in most cases, the cells are just fine, the gauge/management is just broken.) So, you should at least know what you are buying.So, for a simple device, needing just an approximate battery gauge, I would definitely go for just measuring the voltage. It has the following plus sides over a battery gauge chip:- Hugely more simple. Fewer components, less PCB real estate, fewer things to go wrong.- So much easier on the software side in many cases. No need to build a digital communication just for the chip; just read the voltage on ADC. (It's different, however, if you already got your I2C running and don't have a spare ADC. So it really depends!)- Adjusts automatically to any capacity loss or cell change. You can just change batteries, and it always shows the actual level. Coulomb counting needs memory and fine tuning over the age. If it's done in the chip, the chances are they messed it up. If you need to do it, you may mess it up.Plus for the coulomb counting battery gauge chip- If done right, can give very accurate (1%) readings- Can accommodate load changes better, doesn't temporarily drop the value because of high load. (important at high loads (>0.2C))- If the chip is OK (not broken by design), it will have very low quiescent current consumption- As has been pointed out, my IO pin trick won't work with two-cell design.As a summary: if your cheap chinese iDevice has a steady indication of battery level always going from 100% to 0%, but maybe with a changing speed, and sometimes recovering, it uses voltage sensing. If the battery level goes steadily and then drops suddenly from 30% to 0%, it uses a coulomb counter (done wrong, as usual).Other considerations:Why are you using two cells in series? That's asking for trouble and adding a lot of extra complexity (in most cases! there are exceptions for this, too). You know, youshoulduse a real BMS chip then, with even more quirks. You can do without if you know how. But all major (and most minor) low-power (<10W) battery-powered designs have used single cells for about 10 years almost exclusively. If you have some component requiring 5 volts (LCD?), it may be better to use a small boost converter.With one cell, you can probably eliminate the voltage regulator completely and just drive most if not all of your digital stuff directly from the cell. Then you can measure the voltage easily, too; some MCU's even allow that with zero external components (by connecting their AD mux to the internal reference, still using GND-Vcc as the measurement range, and then doing some basic math).If you have 3V3 devices that cannot run at 4.2 volts, you can use a 3V3 LDO which is specified to work with 200 mV drop (3.5 volts is about 10-15% battery left), and at the time your battery is completely exhausted, your output has just fallen a bit and everything still works in practice...But yes, I might miss something and you may have a corner case where you really need that 7-8 volts without losses and extra components from a boost converter.