Page 1 of 1

LOW BATTERY WARNING

Posted: Mon Mar 23, 2009 2:14 am
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

Re: LOW BATTERY WARNING

Posted: Mon Mar 23, 2009 10:38 am
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.

Re: LOW BATTERY WARNING

Posted: Fri Mar 27, 2009 11:02 am
by sgvideo
Thanks Ben

Worked perfectly

Re: LOW BATTERY WARNING

Posted: Wed May 12, 2010 11:47 am
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

Re: LOW BATTERY WARNING

Posted: Thu May 13, 2010 12:15 pm
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.

Re: LOW BATTERY WARNING

Posted: Thu May 13, 2010 12:32 pm
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

Re: LOW BATTERY WARNING

Posted: Thu May 13, 2010 6:34 pm
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?

Re: LOW BATTERY WARNING

Posted: Fri May 14, 2010 10:44 am
by tanlipseong
It should work, however it require external components.
how nice if do not need external components :roll:

Regards