LOW BATTERY WARNING

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

Moderators: Benj, Mods

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

LOW BATTERY WARNING

Postby sgvideo » Mon Mar 23, 2009 2:14 am

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: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times
Contact:

Re: LOW BATTERY WARNING

Postby Benj » Mon Mar 23, 2009 10:38 am

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

Postby sgvideo » Fri Mar 27, 2009 11:02 am

Thanks Ben

Worked perfectly

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

Re: LOW BATTERY WARNING

Postby tanlipseong » Wed May 12, 2010 11:47 am

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8324
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: LOW BATTERY WARNING

Postby medelec35 » Thu May 13, 2010 12:15 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: LOW BATTERY WARNING

Postby tanlipseong » Thu May 13, 2010 12:32 pm

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

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 8324
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2380 times
Been thanked: 3391 times
Contact:

Re: LOW BATTERY WARNING

Postby medelec35 » Thu May 13, 2010 6:34 pm

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

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.

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

Re: LOW BATTERY WARNING

Postby tanlipseong » Fri May 14, 2010 10:44 am

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

Regards