LOW BATTERY WARNING

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
sgvideo
Flowcode V4 User
Posts: 9
Joined: Tue Mar 17, 2009 10:14 am
Contact:

LOW BATTERY WARNING

Post by sgvideo »

Hi, I am new to this and did have a few problems with sleep and TMR0 issues on my project that Ben helped me on outside of the forum. At the end of the suggestions and test code, the solution was to not use an existing file and modify for my needs. it turned out to be best to start with a clean and empty file. (things can get corrupted)

Anyway now that it works, I want to add a feature that will flash an LED warning that its own battery is getting low. On searching this forum, there are only 3 references to this and I was hoping someone can point me in the right direction.

I am not very good at C and am learning ASM now.

A pretty clear solution or explanation (sample code would be great)would be greatly appreciated.

Many thanks in advance

Mitch

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: LOW BATTERY WARNING

Post by Benj »

Hello Mitch.

A simple potential dividor circuit using 2 resistors and an analogue pin should be enough to detect the battery voltage.

Simply connect two large resistors in series between your batter voltage and ground and then feed a trace from between the resistors to your analogue pin. If the battery voltage is 5V for example then if the two resistors share the same value then you will expect 2.5V on the analogue pin. If this voltage starts to drop then you know the battery is running our of power. Using large resistors eg 10K will help to reduce any wasted current used by the detection circuit.

--------Battery V
|
10K
|
----------------uC Analogue
|
10K
|
--------GND

Remember not to feed more then 5V into the analogue pin. If your voltage is more then the 10V that this circuit can handle then change your resistor values accordingly.

sgvideo
Flowcode V4 User
Posts: 9
Joined: Tue Mar 17, 2009 10:14 am
Contact:

Re: LOW BATTERY WARNING

Post by sgvideo »

Thanks Ben

Worked perfectly

User avatar
tanlipseong
Posts: 31
Joined: Thu Aug 27, 2009 3:11 pm
Location: Malaysia
Contact:

Re: LOW BATTERY WARNING

Post by tanlipseong »

Benj,

If the Vref is configure to VDD, the 2 resistor voltage divider will always be 1/2 of the VDD.

when we read ADC, we should read at around 127 (1/2 of 255).

don't understand why we can detect battery low with this method.

please explain a little bit.

Thanks in advanced

TanLS

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: LOW BATTERY WARNING

Post by medelec35 »

Hello tanlipseong. I would not connect the two resistors across +5V and 0 of PIC, Instead I would connected across the supply of the batteries which are 6V or greater.
The Pic is connected to battery supply via a 5V regulator(low voltage dropout are best for batteries. As the battery voltage will start to drop since it is greater than 5V, then the voltage to PIC will still be a constant 5V, so long as i/p to regulator stays above min recommended voltage.
All you do then is connect the o/p from 2-resistor divider to an analogue i/p. When V/out form divider falls below a ADC set amount, you can get an o/p on the PIC to change.
Martin

User avatar
tanlipseong
Posts: 31
Joined: Thu Aug 27, 2009 3:11 pm
Location: Malaysia
Contact:

Re: LOW BATTERY WARNING

Post by tanlipseong »

Medelec35,

I am developing an application that is battery operated, 3 pcs of AAA battery =4.5V, this applies to the PIC VDD.
in this case i guess i cannot use the method discribe earlier.

may be need to select PIC that has build in fixed reference 0.6V for detecting battery low condition.

if can detect using PIC that do not have above feature, please explain the method how.

thanks in advance

TanLS

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: LOW BATTERY WARNING

Post by medelec35 »

here is the situation as I see it.

If Vref is connected to +5V, and you got resistors connected to supply which is same as Vref, then if batt voltage drops, then vref will drop, and Voltage o/p form PD will drop by same ratio, hence lower battery voltage will not be detected. However, if you use an external pin as ref, then use a low current voltage reference (e.g 3V) on this external pin, then as batt voltage drops this Vref will stay steady. This would mean the voltage ratio will change, hence low batt voltage could now be detected.
This is only my theory, and I could be wrong?
Martin

User avatar
tanlipseong
Posts: 31
Joined: Thu Aug 27, 2009 3:11 pm
Location: Malaysia
Contact:

Re: LOW BATTERY WARNING

Post by tanlipseong »

It should work, however it require external components.
how nice if do not need external components :roll:

Regards

Post Reply