[EE] Low Battery Sensor

14 views
Skip to first unread message

Lucas Tanure

unread,
Jun 19, 2010, 8:39:49 PM6/19/10
to Microcontroller discussion list - Public.
How do I do a Low Battery sensor. If my battery is below a voltage I get
this on A/D.
Lucas A. Tanure Alves
Skype : lucas.tanure
+55 (19) 88176559
--
http://www.piclist.com PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist

ivp

unread,
Jun 19, 2010, 8:49:07 PM6/19/10
to Microcontroller discussion list - Public.
> How do I do a Low Battery sensor. If my battery is below a
> voltage I get this on A/D

Is the PIC running on the battery you're wanting to measure ?

RussellMc

unread,
Jun 20, 2010, 1:14:37 AM6/20/10
to Microcontroller discussion list - Public.
> How do I do a Low Battery sensor. If my battery is below a voltage I get
> this on A/D.

Lucas

You MUST provide more details of what you are trying to do and of your
system if you expect people to provide you with good quality answers.
You don't have to use many words but you MUST provide more inforation.


Russell

Olin Lathrop

unread,
Jun 20, 2010, 8:37:39 AM6/20/10
to Microcontroller discussion list - Public.
Lucas Tanure wrote:
> How do I do a Low Battery sensor. If my battery is below a voltage I
> get this on A/D.

Huh? I guess you start by forumalting a comprehensible question.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

Lucas Tanure

unread,
Jun 20, 2010, 8:02:42 PM6/20/10
to Microcontroller discussion list - Public.
Sorry.

Yes, the system will be powered by the battery. And I want to know if the
battery is on 20% of the power. It's a 5.0v battery.


Lucas A. Tanure Alves
Skype : lucas.tanure
+55 (19) 88176559

Veronica Merryfield

unread,
Jun 20, 2010, 8:24:48 PM6/20/10
to Microcontroller discussion list - Public.
Depending on the battery chemistry, coulomb counting may be the best way. Checking a voltage level is often not a good indicator of battery level.

Michael Watterson

unread,
Jun 20, 2010, 8:37:04 PM6/20/10
to Microcontroller discussion list - Public.
Lucas Tanure wrote:
> Sorry.
>
> Yes, the system will be powered by the battery. And I want to know if the
> battery is on 20% of the power. It's a 5.0v battery.
>
>
> Lucas A. Tanure Alves
> Skype : lucas.tanure
> +55 (19) 88176559
>
>
you need a stable reference

The simplest scheme is to have a comparator reference and detect 1V
or a fraction of 1V via resistor divider from the 5V
The reference volts must be stable as the battery discharges. But I
perhaps misunderstand, maybe you don't mean 20% of volts

Perhaps you want to detect 20% capacity left?

Where you you get a 5V battery?

is there any regulator / boost circuit between battery and CPU?

Michael Watterson

unread,
Jun 20, 2010, 8:39:41 PM6/20/10
to Microcontroller discussion list - Public.
Veronica Merryfield wrote:
> Depending on the battery chemistry, coulomb counting may be the best way. Checking a voltage level is often not a good indicator of battery level.
>
>
>
yes we need to know if it's Alkaline, Lithium Primary, rechargeable NiMH
or Lithium or what. Voltage isn't bad guess on Alkaline if the current
drain is low and steady.

RussellMc

unread,
Jun 20, 2010, 9:34:40 PM6/20/10
to Microcontroller discussion list - Public.
>> > How do I do a Low Battery sensor. If my battery is below a voltage I
>> > get this on A/D.

> Yes, the system will be powered by the battery. And I want to know if the


> battery is on 20% of the power. It's a 5.0v battery.

Lucas - rather than 'teasing us' with a little more information each
time until we have enough, why not give us as complete a description
as possible of what you want to do and what your system looks like.
You often find that some of the details which did not appear
significant turn out to be very significant. As we don't know which of
the details will turn out to be important, knowing as much as possible
as soon as possible helps.

Most beginners, when asked to provide information as above STILL only
provide a little bit more each time. We often go round and round and
round in circles trying to find out what the requirement REALLY is. If
you can be more helpful than the average beginner it would be really
appreciated. Once we know ALL of what you have and want you will get
several very good answers. Until than ALL the answers may be wrong.

Also, when people ask questions MOST beginners only answer some. When
people suggest things to check MOST beginners ignore much of what they
are told. So far you haven't had the opportunity to do this so I'm not
talking about you :-). But, see if you can bypass the behaviour of
most beginners and help us help you asap.

____________

There are NO 5V batteries :-)
There are many battery chemistries.
Current drain affects results.
Rechargeable / not rechargeable.
Environment.
Cosyt of system.
One off or many.
Hobby or commercial.
Much much more ...

Russell

Lucas Tanure

unread,
Jun 20, 2010, 10:33:45 PM6/20/10
to Microcontroller discussion list - Public.
Thank you very much Russel. Yes, I'm just a beginner.

It's Hobby. Its a 4 Series battery , each one is 1.2v, NiCd , AA Type,
2100MAh. Rechargeable

I'm using a pic18f4550, with Ccs C Compiler. The cost of the system its
about a 30U$. If the battery get lower than 20% of the power the pic will
send a mensage to host. For now it's just a simple board that detects the
voltage of the battery. It's just one and it's just to learning. And future
adding to Br-Gogo. The Brazil version of Gogo Board.
<http://www.gogoboard.org/cocoon/gogosite/home.xsp?lang=en>

About the Current drain, I think that sensor don't will consume too much.
Like a led (0.02 - 0.03A) or something like that.
For now it's a simple board that detects the voltage of the battery.


Lucas A. Tanure Alves
Skype : lucas.tanure
+55 (19) 88176559

RussellMc

unread,
Jun 21, 2010, 12:09:21 AM6/21/10
to Microcontroller discussion list - Public.
Much better, thanks.

> It's Hobby. Its a 4 Series battery , each one is 1.2v, NiCd ,  AA Type,
> 2100MAh. Rechargeable
> I'm using a pic18f4550, with Ccs C Compiler. The cost of the system its
> about a 30U$. If the battery get lower than 20% of the power the pic will
> send a mensage to host. For now it's just a simple board that detects the
> voltage of the battery.  It's just one and it's just to learning. And future
> adding to Br-Gogo. The Brazil version of Gogo Board.
> <http://www.gogoboard.org/cocoon/gogosite/home.xsp?lang=en>
> About the Current drain, I think that sensor don't will consume too much.
> Like a led (0.02 - 0.03A) or something like that.
> For now it's a simple board that detects the voltage of the battery.

Very quickly at this stage.
Datasheet here (always useful to provide a reference)

http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf

18f4550 ADC has reference of either Vdd or external pins with user reference on.

If you regulate Vdd you could use it aqs the ADC reference.
If you use battery as Vdd then you cannot measure battery voltage with
ADC directly as it will always have the same value as Vref.

If you use an external reference (eg TL431) you can use ADC to measure battery.

4 x NimH or NiCd have Vmax of about 5.2V and Vmin is a bit uncertain
but say 3.2V for very flat (= discharged) , 3.6 V for as low as you'd
sensibly go, 4V for more sensible.

Getting 20% left point is troublesome using voltage alone. For light
loads they are around 1.2V/cell for most of life. For heavier loads
(approaching 1C (say 0.3C up?) miore like 1.1V for most of life.
Temperature and state of cell (cycles used, brand,etc) influence this
somewhat.

At a first guess I'd select say 1.05V/cell as low point or 4.2V for 4 cells.

This is a 4.2 - 5V OR 2 - 5.5 V part depending on which version clock
speed you choose.
If you use a 3V3 Vdd then you can regulate the supply and use that as
reference if desired.
For maximum flexibility (with some disadvantages) you can use battery
as Vdd and a reference on reference pins.

Note that Vdd max operating is 5.5 V or = 5.5/4 = 1.375 V/cell.

This is below what you will see on a NimH or NiCd cell BUT well below
the maximum you get from eg Alkaline batteries.
If you use Vdd = battery and somebody inserts Alkaline batteries you
will get up to about 6.5 V on Vdd.
This is a higher specd IC than some with Vdd abs max = 7.5V so it
would probably survive BUT would probably misoperate - with the
prospect of being destroyed dfepending on other factors. Use of an LDO
for Vdd would remove this risk.

Note that when measuring battery with an ADC you will need to scale
down the voltage to meet the ADC Vin requirement.


Russell

Michael Watterson

unread,
Jun 21, 2010, 3:55:43 AM6/21/10
to Microcontroller discussion list - Public.
Lucas Tanure wrote:
> Thank you very much Russel. Yes, I'm just a beginner.
>
> It's Hobby. Its a 4 Series battery , each one is 1.2v, NiCd , AA Type,
> 2100MAh. Rechargeable
>
2100mAH AA sound more like NiMH. Which is slightly higher volts. The
discharge curve of NiCd and NiMH are similar but not the same.

1st two hits on Bing (Google has decided it's clever to simulate
Bookmarks and show me places I have been before, or my own sites).
http://shdesigns.org/batts/battcyc.html
http://www.thomasdistributing.com/techfacts3.htm

Detecting 20% capacity left by voltage could be hard as you are likely
on flat part of curve. Detecting nearly charged or nearly flat by
voltage is fairly reliable.

The Curve moves up and down somewhat according to current draw, so you
need to know current.
http://www.thomasdistributing.com/images/discharge.gif

So as Veronica Merryfield said you need to count. That is detect the
first sharp drop from fully charged and count Time x Current (= charge
or coulombs). The system can be self training by detecting the end point
where you leave the flat part. Also each cycle the capacity is slightly
less. If you charge before it's flat you have to detect that too.

You can measure current on bench once if you think it doesn't change and
use a constant, or use 1/4 of an LM3900 and very small series resistor
on supply from battery terminal with LM3900 as differential amp that
gives 1V at max charge, 2V at no current and 3V at discharge current
etc.. or if charge current can be high and discharge is much lower you
can offset to higher volts.

The battery pack will vary from nearly 6V on charge to nearly 4V when
almost empty. So you may want a LDO regulator or some other PSU circuit
to drive the PIC. It certainly needs a more stable voltage for the A/D
reference. You might want to divide battery volts by 2 using resistors
to get a 2V to 3V range for ADC.

I'd not run a PIC directly connected to 4 x NiMH. I'd have at least a
series diode (not Schottky) or some kind of regulator. 3 x NiMH is fine
for direct connection. You may "get away" with 4 x NiMH direct to VDD &
VSS of PIC, but fully charged, on 1/100C trickle or near charged on
1/10C or just after charge the battery pack does exceed max ratings of
many 5V chips (4.75 to 5.25). I just checked a probably 1/2 charged
pack here, the Battery pack volts rises to 5.8 on charge within 2
minutes, on disconnecting it typically drops instantly to 5.3V and then
5.2V within a minute (a 1/2 charged pack). Sticking 4 x AA fresh
Alkaline in the holder gives 6.4V,. Can the user swap the cells? (End
point on Alkaline is lower than NiMH, maybe 0.9V vs 1V)

Michael Watterson

unread,
Jun 21, 2010, 4:14:02 AM6/21/10
to Microcontroller discussion list - Public.
RussellMc wrote:
>
> At a first guess I'd select say 1.05V/cell as low point or 4.2V for 4 cells.
>
>
>
Yes about that. At 1V or lower you increase risk of suddenly reverse
charging one cell (sudden drop to under 3V).

> Note that when measuring battery with an ADC you will need to scale
> down the voltage to meet the ADC Vin requirement.
>
>
I seem to have duplicated a lot of what you said... I should check all
my email when I get up before opening my mouth for other than coffee.

Ruben Jönsson

unread,
Jun 21, 2010, 4:25:29 AM6/21/10
to Microcontroller discussion list - Public.

If you don't mind using a Maxim circuit with a 1-wire interface, the DS2438 -
smart battery monitor, can do the current monitoring for you. It is an 8 pin
chip that also contains a temperature sensor that can be used to monitor
battery temperature during charging. And it has an AD converter that can
measure voltage directly on the battery and on one other source on a separate
pin.

/Ruben

==============================
Ruben Jönsson
AB Liros Electronic
Box 9124, 200 39 Malmö, Sweden
TEL INT +46 40142078
FAX INT +46 40947388
ru...@pp.sbbs.se
==============================

RussellMc

unread,
Jun 21, 2010, 5:02:18 AM6/21/10
to Microcontroller discussion list - Public.
> Yes about that. At 1V or lower you increase risk of suddenly reverse
> charging one cell (sudden drop to under 3V).

Yes. That's something I didn't mention.
As long as cells are not run close to discharge this is not an issue
but if the "battery" is allowed to run flat (fully discharged) then,
as Michael notes, one cell will run out of capacity first and be
driven into reverse polarity by the discharge current from the other
3. With NiCds this can result in the cell having a "whisker" hard
electro-plated across the cell, leaving it permanently short circuit.
While this whisker can be "burnt down" the cell will usually be
permanently damaged. NimH tend not to grow whiskers but discharging
any cell fully will shorten lifetime and is "not recommended".

> I seem to have duplicated a lot of what you said... I should check all
> my email when I get up before opening my mouth for other than coffee.

That's certainly true for some people here :-) - but you managed to
cover a number of things that I didn't. (And good points often bear
reinforcing :-) ).


Russell

Olin Lathrop

unread,
Jun 21, 2010, 7:08:24 AM6/21/10
to Microcontroller discussion list - Public.
Michael Watterson wrote:

> Lucas Tanure wrote:
>> Yes, the system will be powered by the battery. And I want to know
>> if the battery is on 20% of the power. It's a 5.0v battery.
>
> you need a stable reference
>
> The simplest scheme is to have a comparator reference and detect 1V
> or a fraction of 1V via resistor divider from the 5V
> The reference volts must be stable as the battery discharges. But I
> perhaps misunderstand, maybe you don't mean 20% of volts

He clearly said 20% of "power", which makes little sense either, but is
certainly not volts. Power is the instataneous energy transferred per time.
Sortof like the concept of "cold cranking amps", but of course not exactly
since the units are different.

This guy sounds like he's not a native english speaker, so I think he
probably meant "energy" or "capacity", not power.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

Olin Lathrop

unread,
Jun 21, 2010, 7:42:35 AM6/21/10
to Microcontroller discussion list - Public.
Lucas Tanure wrote:
> It's Hobby. Its a 4 Series battery , each one is 1.2v, NiCd , AA
> Type, 2100MAh. Rechargeable
>
> I'm using a pic18f4550, with Ccs C Compiler. The cost of the system
> its about a 30U$. If the battery get lower than 20% of the power the
> pic will send a mensage to host.

It sounds like you mean 20% of capacity, or energy left, not power. Please
use the correct terms. If you really mean power, then point that out as
it's quite unusual.

NiCd batteries have useful end of charge voltages around 1.0V or even as low
as 900mV depending on temperature, current drain, general health of the
battery, and how much you're willing to abuse it. If you don't know any of
these and just want a "mostly discharged" detection, use 1.0V. That's low
enough so that not too much energy is left, but high enough that it
shouldn't damage the battery and there is enough left to still run for
little while and shut down the system cleanly.

The 18F4550 is quite happy running from 3.3V. One possibility is to use a
3.3V LDO (like Microchip MCP1700 for example) to run the PIC, then a voltage
divider to measure the battery.

Since this is apparently just meant as a rough measure of "almost empty",
you could try a PNP transistor around the LDO so that it is on when the
battery is the B-E drop above the LDO. That will be around 600mV, to the
battery pack threshold voltage will be 3.9V, which is around 970mV per cell.
Good enough for a one off hobby "battery is low" detector. The advantage of
the extra transistor is very low current drain for the battery detector,
certainly a lot less than a straight voltage divider, keeping in mind the
18F wants to see a 10Kohm or less source driving its A/D input.

There are lots of other ways too.


********************************************************************
Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014. Gold level PIC consultants since 2000.

cdb

unread,
Jun 21, 2010, 3:33:42 PM6/21/10
to Microcontroller discussion list - Public.
:: He clearly said 20% of "power", which makes little sense either,

:: but is certainly not volts.

True, but he might be thinking of voltage, after all we talk about 'the
power supply is 230/120 volts' , ' it is powered by a 12v battery' etc.

Confusing sometimes for a native English speaker let alone one where
English is a secondary one.

Colin

--
cdb, co...@btech-online.co.uk on 22/06/2010

Web presence: www.btech-online.co.uk

Hosted by: www.1and1.co.uk/?k_id=7988359

Reply all
Reply to author
Forward
0 new messages