SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By rfordh
#51115
Hi,
I am working on a battery powered project based on the ATmega168 and planning on using one of Sparkfun's LiPo batteries to power it. How can I monitor the remaining charge in the battery? I'm not sure how I will tell the user that the battery is low, but it would be cool if an LCD could display the percentage remaining. Is monitoring the voltage from the battery with one of the ATmega's ADC pins the way to do it?
Thanks!
By Philba
#51123
use a voltage ref as the adc input and Vbat as the VRef. For example, for a 3.7V cell, use a 2.048V ref as input. When ref reading rises to a preset value, you know the battery is running out.
By henryhallam
#51160
If all you want is a low battery warning, then voltage monitoring is fine - signal the user when it drops to say 3.5V, and refuse to power on below 3.2V to prevent permanent damage to the battery from overcharging.

If you actually want a reasonably accurate indicator of capacity remaining, you really need to meter the charge flowing out of the battery, i.e. integrate the current with respect to time and subtract that from a known total capacity of a full battery. This is because the voltage-time discharge curve of LiPo or LiIon batteries is very flat for most of the cycle, it's something like this: (numbers from memory / SWAG to illustrate the principle)

100% full - 4.2V
95% full - 4.18V
90% full - 4.15V
85% full - 3.75V
70% full - 3.72V
50% full - 3.7V
30% full - 3.68V
20% full - 3.5V
minimum safe charge - 3.0V
battery damage - 2.5V

And of course the voltage you measure changes a bit depending on the load, temperature, phase of the moon, so even if you have a high precision ADC you can't be certain whether it's at 80% or 30% charge.

This is a known problem; Among others, Maxim produce ICs that do the job for you and provide a handy digital interface: http://para.maxim-ic.com/en/search.mvp? ... ersupplies
By bretth
#51360
I've been using the DS2764 for all my LiPo powered projects. It provides an I2C interface, voltage/current monitoring, reset/power button handling, current accumulator (ie: fuel gauge), and probably most importantly, all the protection features you really should have in place when using LiPo batteries.

Here's how I have it wired up:

Image
By Alterscapes
#51392
Silly question, but I've been reading the MAX1555 and DS2764 datasheets and can't work it out:

Do I need a MAX1555 charger IC if I'm using a DS2764? It looks like I do, but the DS2764 datasheet talks about overcurrent protection at least, so I'm not sure (and if I can get away with a lower parts count, I'm certainly not complaining).

Does anyone have a sample circuit with both handy?
By daemondust
#51415
Yes, you need both the MAX1555 (or other Li+ charger) and the DS2764 (or other Li+ protector). The over current and over/under voltage protection of the DS2764 are there to protect you from errors, You shouldn't normally be anywhere near where the DS2764 is going to cut you off.

A Li+ protection IC doesn't normally limit current so much as act as a resettable fuse, it's all or nothing.

The over/under voltage protection is is slightly more advanced since during an undervoltage condition current can still flow into the battery, but not out, and the other way around for an overvoltage. Think of it as a pair of resettable fuses (that blow based on voltage instead of current) in line with diodes.
By Alterscapes
#51419
Thank you for the explanation, daemondust! =]
By rfordh
#51614
Man, I wish I had checked back to this post before I submitted my pcb. I ended up connecting the battery voltage to one of the ADC pins through a voltage divider, but I didn't include any protection for the battery. Next time, I'm definitely using the DS2764. Thanks for the tip.

I just remembered, Sparkfun says these batteries should have built in protection:
Battery includes built-in protection against over voltage, over current, and minimum voltage.
Is an external protection circuit really necessary or simply a good idea?

Thanks!
By daemondust
#51617
If you can guarantee that any batteries plugged in have protection, then you don't absolutely need it in your circuit. Some Li+ batteries only have a PTC in line with the battery that only protects against over-current, but it sounds like the ones here have a circuit similar to the DS2764 except it doesn't do the fuel gauge.
By silic0re
#54012
Hi there,

Does the DS2764 require communicating with it over I2C to set it up, or does it have default values to begin with?

I've been searching all afternoon for a LiPoly undervoltage protection IC. So far everything I've come up with is either for multi-cell packs, or just pulls a shutdown line to a regulator rather than preventing power flow from the battery.

I think the 1000mah SFE batteries have protection, but the 2000mah cells don't seem to mention this, so I'd like to error on the side of caution. blowing up a new project (or the person using it!) would be terrible...

thanks
By bretth
#54014
The DS2764 does just work out of the box - although you'll need to talk to it over I2C if you want to read the accumulator or use the power button functionality.

Also, my schematic doesn't make this clear, but I'm using the +025 version of the part which includes the current sense resistor internally. This works well for my scenario, pulling less than 2A. Just make sure you route PACK- thru the chip instead of just connecting it to GND. This the path used for the current sensing.

FWIW, after doing some further design reviews and speaking with battery experts, all of my designs are based on battery packs with integrated protection and a thermistor. The thermistor is connected to my charging IC (LTC4090). I'm still using the DS2764 for the fuel gauge and power button, but the protection is redundant. We decided this was the best approach from a liability standpoint -- shifts more responsibility to the pack manufacturer.
By silic0re
#54095
Thanks for your help, it sounds like you've successfully gone through much of the research and design process that I'm currently going through.

I have to laugh, because it seems like the circuit to power the OLED/arm board that I'm making is more complicated than the rest of the circuit. So far there is:

(1) LiPoly Battery Protector
(2) Charge Controller
(3) Several Regulators
(4) Power switch debouncer, and flip-flop

Using the power-button functionality sounds handy, but I don't think I have the communication lines available between the two boards -- not unless one of the I2C lines are shared with the DS2764's power button. That might actually work -- if SDA is connected to the DS2764's PS#, and the power switch also pulls SDA to ground. If the power button is pressed again while the device is operating, it would just pull SDA to ground, which would interfere with I2C communications, but isn't catastrophic.


It's too bad the DS2764 doesn't have a 'turn off' pin... The idea of using it's integrated power switch functionality really appeals to me, but what happens if your system freezes... you can't turn it off without removing the battery? :( Have you already dealt with this issue? If I may ask, what was your solution?

thanks!
By bretth
#54096
I feel your pain WRT to the power circuit ending up being the most complex part of the system.... it can be pretty difficult to implement what you would think would be easy to do.

I'd recommend staying away from linking the PS# line with any other circuitry besides the power switch. In an earlier rev I tried connecting this line to an input on an IO expander so I could read its value during my normal polling operations (versus going to the DS2764 all the time). However, I found that when my uP cut off the power to the system (via the DS2764), the IO expander would actually drop to ground momentarily, which effectively kept the DS2764 in AWAKE mode, which meant that the PS button would not trigger the DS2764 to reopen the power circuit. Since the DS2764 was running directly off the battery, it was awake, but the only way to regain power to the rest of the system was to add external charging source or disconnect/connect the battery pack.

Of course, you mileage may vary... but I can assure it was not a fun bug to track down ;-)

As for the system locking up - I realized awhile back that a watchdog timer was the best way to handle this in my project. Otherwise the power circuit just becomes that much more complex, handling both the soft-reset (ie: software controlled) shutdown scenarios AND a manual power switch.

Hope that helps! -Brett
By silic0re
#54100
That's a *very* good catch! I'm sure one of the I2C lines would go low on their way to powering down, likely causing a very similar problem to what you had!

I think the following would then be the complete LiPoly circuit, including charge controller and protection? (The only thing missing would be the power adapter connection on Pin 4 of the MAX1555). The only thing I'm particularly unsure about is the connection between the MAX1555 and the DS2764 -- the charge voltage goes directly into where the (protected battery output) would be, right?

Image

thanks![/img]
By bretth
#54101
Yes, exactly. The mosfets allow the DS2764 to control current flow in each direction.