blc
Posts: 465
Joined: Mon Sep 05, 2011 9:28 am

Monitoring battery levels

Fri Aug 10, 2012 1:19 pm

EDIT: Please feel free to move this to a more appropriate section; I wasn't really sure where it should go.

I have (more than) a few project ideas for the Pi, and one of them involves being used in a portable form factor. Power would come from a set of rechargeable batteries that would run a small LCD screen and the Pi itself (as well as some interface peripherals). I haven't decided on battery chemistry yet - there are factors such as overall power draw of the system and ease of charging to consider - but I'm trying to get an idea of how I would go about measuring the current remaining battery power and displaying that information.

I've found a circuit that uses an LM3914 to drive an LED bargraph display that shows the remaining battery life. This looks like a great solution, but it has a couple of flaws that I can see:
  • It is based on the voltage reducing over time as the charge level drops. I have read that some lithium-based battery technologies (lithium ion, lithium polymer, etc) do not do this - they may drop by a small amount, but typically the voltage curve is more or less flat until the point where the charge just "dies".
  • This is a "hardware" based solution, in that it would be an LED mounted on a case. I'd prefer to report the remaining battery level in software; this circuit would work, but it's not my ideal solution. I have a fair idea how you could achieve this with an Arduino - resistor divider connected to an analogue input pin - which could be applied to the Pi GPIO pins. The real hard work would be calibrating it to a specific battery capacity. However, this is again based on the voltage level reducing over time as the charge level decreases.
As mentioned I haven't yet settled on the battery chemistry that I plan to use, as it really depends on current draw, cost, ease of charging, lifespan, etc. I will dig into this a little more once I have a clear idea of my power requirements, but I'm still planning at the moment.

Assuming that I have only the positive and ground connections of a battery, and no additional magical wizardry to monitor battery level, what is going to be the "best" way to report/monitor the battery level in software? Are there any more efficient or accurate solutions which I should consider? I ain't afraid of no soldering iron or schematic, but I'm afraid I'm at a bit of a loss when it comes to designing my own circuits.

User avatar
Mortimer
Posts: 924
Joined: Sun Jun 10, 2012 3:57 pm

Re: Monitoring battery levels

Fri Aug 10, 2012 1:22 pm

It might be worth looking into something like Sony Infolithium batteries or laptop batteries, because the Sony batteries and most laptop batteries contain a small microcontroller that does all the cell monitoring and reporting for you via I2C. So you would simply program your RPi to receive the serial stream from the battery and act accordingly.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

blc
Posts: 465
Joined: Mon Sep 05, 2011 9:28 am

Re: Monitoring battery levels

Fri Aug 10, 2012 1:47 pm

Mortimer wrote:It might be worth looking into something like Sony Infolithium batteries or laptop batteries, because the Sony batteries and most laptop batteries contain a small microcontroller that does all the cell monitoring and reporting for you via I2C. So you would simply program your RPi to receive the serial stream from the battery and act accordingly.
I had actually thought about something like that, but I don't know the cost; though a LiPO battery that could run the Pi and a screen for a few hours likely wouldn't be cheap either. I'll take a proper look when I get home... I have very rubbish and heavily restricted internet access in work... On a slight tangent, I had always assumed that laptop batteries had such technology as you never see a laptop battery with just two connectors; those extra pins have to have some use... I just always assumed that they would link to ACPI hardware in some way; I'd never considered that they might do so via I2C.

This would be a hand-held device, so I guess weight comes into the equation too. I'll take a look into Infolithium and similar technologies - cheers for the tip.

User avatar
Mortimer
Posts: 924
Joined: Sun Jun 10, 2012 3:57 pm

Re: Monitoring battery levels

Fri Aug 10, 2012 2:42 pm

I used some batteries from Ultralife a couple of years back, but I wouldn't recommend them because they were hideously expensive. Two batteries, a charger and cable came to over £1000. But did have on board controllers and SMBus connections. It is probably SMBus you'd need to look for, as this is a low speed version of I2C, which is commonly used for this type of thing. It is compatible with I2C though.
--------------
The purpose of a little toe is to ensure you keep your furniture in the right place.

azerty
Posts: 10
Joined: Thu Jun 07, 2012 4:06 am

Re: Monitoring battery levels

Sat Aug 11, 2012 1:49 am

If you end up going with a Li or LiPO battery this could be what you're looking for:
https://www.sparkfun.com/products/10617

User avatar
Burngate
Posts: 6100
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: Monitoring battery levels

Sat Aug 11, 2012 8:31 am

Not sure you'll find this relevant but ...
Many years ago, in the days of NiCad batteries and tube cameras, I had a long chat with a professional camera-battery manufacturer. Here's a quick resume.

He could get cells that (after the initial drop) would have a flat-line profile down to about 1% charge left, after which the voltage dropped like the side of a house.
The problem was that you got no indication the battery was going to die until 20 secs before it did so.

So he chose cells with a far less stable voltage. That way it drooped gently, and you had 5 mins of warning, and could choose when to swap batteries.

Most cameras had a cut-off of ~10.8v, below which they refused to work. That was to protect the battery, which had 10 1.2v cells. If the voltage dropped below 10.8v then it was likely that one cell would be reverse-biassed, and would fail.

But cameramen thought this was bad - they weren't getting all the power out of the battery! So some manufacturers put an extra cell in the pack, which meant it would discharge further before failing. Which disabled the protection system, and drastically reduced the life of the pack.

Only 50 recharges on a pack instead of 1000, for a pack costing >$100, was considered ok when the camera cost >$15k and the shoot could have a budget of $100k.

Back to real life.

Choose your battery. Hook up a ADC to read its voltage throughout its life, and make a table of volts every five minutes, till it dies. Then you can just use that table as a look-up for life left.

User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Monitoring battery levels

Sat Aug 11, 2012 2:39 pm

Typical lipo usage in something like RC planes/heli's/cars is a lot flatter that your application would be because they are caning the batteries at 5C-20C. Your application requires hours of use so will be a much more linear slope at a lot less than 1C. So voltage will be an excellent indicator if you choose lipos.
LiFePO4 drops off very quickly though - and they're heavier - although less fussy about handling. An idea of the discharge curves for lipo higher C ratings is in the graph below...

Image

Taking that discharge curve as an example, I'd be looking to terminate at around 3.5-3.6V/cell (under load) to maintain a good cycle life. You never want to take them right down to empty or you kill the cells.
Ideally you'd get hold of discharge curves for your chosen cells at 1C or less to decide your cutoff voltage.
Alex Eames RasPi.TV, RasP.iO

blc
Posts: 465
Joined: Mon Sep 05, 2011 9:28 am

Re: Monitoring battery levels

Sun Aug 12, 2012 12:58 am

Thanks for all the advice and recommendations, chaps; I've a fair idea of where to go from here. To start with, I can do some initial testing with some spare RC nicad batteries I have here; they're all 7.2v, so hopefully that'll be enough to power a 5V regulator...

Long before I even get that far though is more planning and software testing!

In case anyone is interested, the idea I have in mind is a portable hand-held gaming device - something like the GP2X (http://en.wikipedia.org/wiki/GP2X) but with better ergonomics! (Such as this http://www.slightlywarped.com/crapfacto ... ndo_64.htm). Although I'm very very far away from even thinking about a case or deciding whether this is feasible yet! :)
azerty wrote:If you end up going with a Li or LiPO battery this could be what you're looking for:
https://www.sparkfun.com/products/10617
LiPO does look like the best candidate, to be honest, and SparkFun seems to have a ton of LiPO stuff.

Return to “General discussion”