CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

newbee - battery level

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Jun 08, 2005 1:50 pm     Reply with quote

We have one product in which I check for a low battery voltage
and display the "LOBAT" symbol on the LCD if it's low.
On the 16F628, I used the comparator to check the voltage
of a 9v battery. The circuit consists of a IRF7306 FET with
one Source pin going to the 9v battery. The two A & B drain
pins go to a voltage divider (with 3.9K on top and 2.2K on the
bottom). The gate on the FET is driven by the Collector pin of
a 2N3904 transistor with a 3.9K to the 9v battery. The emitter
goes to ground, and the base connects to a port B pin on
the PIC, with a 3.9K series resistor. The FET is turned on
for just a few microseconds to check the battery voltage.
You could check it once every second, or once every minute,
or longer. It doesn't really matter because the test is done
so quickly that hardly any power is wasted.
The code is in the post below.
http://www.ccsinfo.com/forum/viewtopic.php?t=2236
guest
Guest







PostPosted: Thu Jun 09, 2005 8:27 am     Reply with quote

What is your PIC doing when it is not checking the battery? Is it sleeping? Is it powered off? Is it polling a UART or waiting for a button press?
If all you are doing is testing a bit the resource cost is very low. You could check it every button press or incomming serial character. If you decided to use an 8 bit counter and only check the battery every 256 characters the overhead of incrementing the counter would probably be as much as that of checking the battery and there would be no savings.

Sherpadoug
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Jun 09, 2005 9:31 am     Reply with quote

It's doing the multitasking described in this thread. One of the tasks
is called check_battery().
http://www.ccsinfo.com/forum/viewtopic.php?t=17189
Guest
Guest







PostPosted: Fri Jun 10, 2005 3:23 am     Reply with quote

Quote:
You could check it every button press

Chip is sleeping and waiting for button press to read the pin value.
Each time you press button ( that's it how i want to make it ) battery level should be readed... This could be after 1 hour or after few days...

I forget to mention ( and after a saw the PCM Programmer's routine ) , im checking just one pin, so if i get this right then i can make this with setup_Vref() ? Like this: Button pressed - if value at pin B3 == 0 battery low

Could this be done simply on this way ?
Guest
Guest







PostPosted: Sun Jun 12, 2005 8:54 am     Reply with quote

Sorry for such dumb questions but im newbee in this...

TO PCM'S EXAMPLE

Realy newbee question:

BATTERY_TEST_FET_ON_PIN_B5 ---> IS THIS V P P IN YOUR CASE
BAT_LEVEL_PIN ---> IS THIS V D D IN YOUR CASE

?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 12, 2005 10:36 am     Reply with quote

Quote:

BATTERY_TEST_FET_ON_PIN_B5 ---> IS THIS V P P IN YOUR CASE
BAT_LEVEL_PIN ---> IS THIS V D D IN YOUR CASE

I'm not sure if you understand what my post was about. It seems like
you think it's a PIC programmer. It's not. It's way to measure
the battery voltage of a 9v battery, so that the user can be warned
with a "LOBAT" symbol on a LCD when the battery is getting low.
Here are the pin descriptions. These are for a 16F628:

BATTERY_TEST_FET_ON_PIN_B5 --
This is a pin on Port B of the PIC, and it turns the FET on or off.
This pin goes to a 3.9K resistor, which then goes to the base of a
2N3904 transistor, which controls the FET. The connections are
described in a previous post, above.


BAT_LEVEL_PIN_A1 --
This is the comparator input pin on the PIC. The output of the
voltage divider goes to this pin, so it can be measured.
Guest
Guest







PostPosted: Sun Jun 12, 2005 12:03 pm     Reply with quote

I need a lobat but i have some problem with understanding...

Teoreticly:
If u would have just one pin ( let's say pin 21 ) that i want to test, and
lets say i have value of 1 on this pin, so long until battery falls under 50%.
After the battery falls under 50% i have 0 on this pin.

I want so check each time, when button will be clicked, the value of that pin.
If its 0 show LOBAT.

How would you do that?
Do i need comparator and can this be this done on this way?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 12, 2005 4:38 pm     Reply with quote

The design that I posted uses the internal comparator in the 16F628.
I don't want to design a new low battery circuit. The design that I
posted uses very little of the battery power.

Here's an example of a design that wastes the battery.
http://www.circuitcellar.com/library/print/0798/May96/Fig2.htm
Scroll down to the 9v battery input on the left side of the page.
Notice how they have a voltage divider consisting of two 5.1K
resistors connected across the 9v battery. The voltage divider
is always in the circuit. There's no way to disable it. It wastes
0.9ma (or less, as the battery ages) per hour.

You are free to design your own circuit with an external comparator
or whatever you want.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group