10
\$\begingroup\$

I have a small circuit using a PIC18F14F50 microcontroller chip which is logging data into an external EEPROM chip over an i2c interface (which I can then read back later over the USB interface). One sample is recorded every 15 minutes and doesn't need to be particualrly accurately timed.

It's ok if samples are missed or mis-timed while batteries are being changed, but it's not great if the batteries expire and no data is recorded for several days until someone notices.

So I'd like to warn the user when the battery is low in plenty of time for them to replace them. The average current is under 2mA and I'm running in from 3 AA alkaline batteries in series to give 4.5volts so I'd expect them to last quite a number of days.

But I'm wondering how to detect that the battery is low? I presume the voltage will drop as the batteries reache the end of life. I'm thinking that this PIC has a 1.024v reference voltage so I can divide down the supply voltage and feed it to an analogue input and when the divided voltage drops below that trigger a warning.

But I don't know enough about batteries to know how well this will work? And I don't know what voltage to choose that would indicate that perhaps 10-20% battery life is left. Will that even work at all? Is there a better approach?

This doesn't need to be at all accurate, I just want to give a good warning in plenty of time without getting people to disard batteries that still have life left in them.

As my current usage is fairly constant, would a simple timer be reasonable if I can work out how long the batteries last on average and then pick 85% of that time before I give the warning? Or does battery life vary more than that?

Any thoughts would be welcome.

\$\endgroup\$
  • 1
    \$\begingroup\$ What voltage does your PIC need to function? \$\endgroup\$ – Kortuk May 18 '10 at 14:39
  • 1
    \$\begingroup\$ What do you consider plenty of time. \$\endgroup\$ – Kortuk May 18 '10 at 15:55
  • \$\begingroup\$ How much current does it draw? \$\endgroup\$ – endolith May 18 '10 at 17:22
5
\$\begingroup\$

First, let me comment on the timer circuit. This will work, as long as your batteries are all of relatively the same age and kept in the same conditions. In 6 months when you are still using this and your batteries are all 6 months older you will need to update the timer. Functional solution, but not the best one.

You can divide down the voltage for your input with a resistor network that has a high enough voltage not to affect your lifetime(you can use a network that does load, you just replace your batteries more often). There is one catch, you need to Load a battery to see a true value of it's life left. You will find the more loaded a battery is the more the discharge curve looks like a line. It will never be a line, there will still be clear phases, but you can dependably correlate a loaded batteries voltage with your life left.

If your PIC is on during the measurement you will probably get a decent measurement. Have the pic spend time measuring your battery and look at the resulting voltage curve until your device dies. If the curve stays relatively flat, and then suddenly drops and your batteries die then you will want to use a transistor and load resistor to increase current draw during battery measurements. There is a large amount of information on batteries on battery university. Often microcontrollers fail to pull enough current to get a curve that is sloped the entire way(I have seen this problem with ultra low power uC like MSP430). You will probably be fine with just your PIC running.

Research into AA battery chemistry has fielded some results. It does look like they show pretty flat discharge curves with low currents(<500 mA). This will mean that you will likely want a resistor discharge circuit coupled with a transistor to allow the voltage measurements to be more valuable.

Please forgive me if this was not clear enough. If you comment and questions or suggestions I will update it.

\$\endgroup\$
  • \$\begingroup\$ extra information specific to AA has been added. \$\endgroup\$ – Kortuk May 18 '10 at 14:55
  • \$\begingroup\$ If you are only interested in specifically seeing failure start you can watch for that last discharge change in voltage in the end and the moment it starts use a warning. \$\endgroup\$ – Kortuk May 18 '10 at 15:01
  • \$\begingroup\$ Thanks for this and the other answers, it's given me enough to read about :) \$\endgroup\$ – John Burton May 23 '10 at 9:15
  • \$\begingroup\$ If you are willing to accept error in the time to replace batteries you should be able to use a timer and just recalibrate for new batteries every few months. \$\endgroup\$ – Kortuk May 23 '10 at 15:36
5
\$\begingroup\$

Yes, the battery voltage will drop, but the drop is small, say half a volt:

alt text

If you use a voltage divider to get this into the ADC range, you're dividing the range as well. I guess this is still measurable with the ADC directly. 5 V / (2^10) = 0.005 V, with ± 3 LSb offset and gain errors, so there are still a number of measurement levels between full and empty?

To measure battery charging and discharging accurately, people keep a log of how much current is being drawn with a current-sensing resistor, and decide that the battery is low after a certain amount of charge has passed by. If your current draw is relatively constant, then yes, you could just use a timer to do the same thing. Run it a few times, measure the amount of time until you consider the battery to be dead, and then use a timer in the future to guess when it's about to die. You are using fresh batteries each time?

\$\endgroup\$
  • 1
    \$\begingroup\$ using a charge monitoring IC is really only required when using systems that have recharge and discharge with very large capacities. I have used the voltage monitoring method with a 10 bit ADC and it has worked very well. The important part of the system is loading the Battery. \$\endgroup\$ – Kortuk May 18 '10 at 14:54
  • 1
    \$\begingroup\$ the timer method is not a good long term solution, the age and temperature conditions of a battery greatly affect the charge. We recently bought 2k batteries from an American supplier and they had clearly bought from the chinese supplier a year earlier, as they worked significantly worse than our 3 year old temperature controlled batters, and neither compare to new batteries. \$\endgroup\$ – Kortuk May 18 '10 at 14:59
  • \$\begingroup\$ That picture is at a 100mA Discharge, if you increase the discharge, the voltage follows a more linear curve. you also see the final drop earlier and can turn on notification and stop testing the battery to extend life. \$\endgroup\$ – Kortuk May 18 '10 at 16:05
  • \$\begingroup\$ @Endolith - What is your source on that image? Energizer's alkaline appnote: data.energizer.com/PDFs/alkaline_appman.pdf has a similar curve (Theirs is time vs. voltage, rather than charge vs. voltage, see fig 12 page 10), but the drop is much more gradual. Especially if the device is powered by a linear regulator, the drop in voltage won't affect the device too much. \$\endgroup\$ – Kevin Vermeer Jul 23 '10 at 2:31
  • \$\begingroup\$ What do you mean by "more gradual"? Their graph looks a little more steep to me. \$\endgroup\$ – endolith Jul 23 '10 at 20:54
2
\$\begingroup\$

I think the only solid way to monitor a system like that is a kind of watchdog-like arrangement: Have some other, separately powered, system check it from time to time (or wait for a signal) and if it's not responding, alert.

You could also use that separate system to check for the battery instead. It won't suffer from the main battery being dead which will kill any monitoring system running off the main battery. If you can arrange a battery monitor that will run on a small battery like a coin cell and guarantee that it will outlast the main battery, that should do the job.

If you don't want or can't have a second power source, the other comments seem to contain very good suggestions for self monitoring.

\$\endgroup\$
  • \$\begingroup\$ That is definitely the most robust way. The other system hardly has to work: Just set a pin high on the watched system, set an interrupt on the watcher, and go into deep sleep mode. Then, when it changes, start beeping (or whatever the signal is) every 5..10..30..60 minutes, etc. \$\endgroup\$ – Kevin Vermeer Jul 23 '10 at 2:40
  • \$\begingroup\$ That wouldn't really work for me, it would inform me once it was too late to change the battery in time, not before. \$\endgroup\$ – John Burton Jul 23 '10 at 10:38
  • \$\begingroup\$ So you'll probably have to monitor the battery. \$\endgroup\$ – XTL Jul 23 '10 at 10:50
2
\$\begingroup\$

You can get a much more accurate voltage reference with an op amp (use one with an enable pin, so that it can easily be shut off), and just tune your circuit to the voltage range you want to measure: 0V at 0.8V, and 3.3V at 1.1V. If it's saturated, you know that you've got plenty of charge, and you don't seem to need a monitor, just an alarm.

Also, make sure that you measure several times (or use a current sense resistor), rather than assuming that a drop in voltage is caused by a dying battery. It's not - battery voltage is dependent upon both discharge current and remaining charge. A current spike can cause a big drop in voltage, but the battery will recover when it is removed. See Figure 9 of Energizer's alkaline datasheet.

\$\endgroup\$
  • \$\begingroup\$ In the end I did a few different thing. I reprogrammed the software to properly put the microcontroller in sleep mode between samples which has hugely reduce the average power consumption. The batteries I used still have a measured voltage of more than 90% of their original after about 2 months. I've set a level of about 80% to signal low battery. I think they'll still have 50% or so left, but that will give me plenty of time to change them \$\endgroup\$ – John Burton Jul 23 '10 at 10:44
  • \$\begingroup\$ Oh! I didn't realize you weren't doing this already - and yes, sleep mode is a great thing. \$\endgroup\$ – Kevin Vermeer Jul 23 '10 at 12:34
0
\$\begingroup\$

If possible measure the voltage of an AA Alkaline battery just after it has been loaded by your normal load (device) and you stopped the load current, when it drops below 0.9V per AA battery your batteries are depleted. I do this is many products I designed and it works perfect. Normal Alkaline batteries will recover after a load has been removed but this takes time depending on the load current. Sometimes this can be minutes or even hours depending on temperature and load current. Measuring it during steady use with a small current you will have to take a higher voltage depending on your current but normally 1.2V is OK for a device using only 5mA.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.