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 support@ccsinfo.com

Battery level monitor

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



Joined: 23 Feb 2007
Posts: 55

View user's profile Send private message

Battery level monitor
PostPosted: Mon Apr 16, 2007 3:40 am     Reply with quote

Hi,

What could be the minimal configuration to monitor the level of a battery?

In detail: I'd like to know if the Vbat is above or below a defined threshold. The PIC is powered @ 5V and the battery voltage is about 12V.

In other projects I used the internal ADC and an external op-amp to reduce both the voltage to max 5V and the source impedance.

But now I want use the internal comparator. I need a resistor divider but the source impedance must be < 10 kohm... thus the battery draws always several mA.

May you suggest me a tricky way to do this using few external components (no op-amp) ?

Thanks
Marco / iw2nzm
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 8:04 am     Reply with quote

Since you are only looking for consistency, not true accuracy, you can cheat quite a bit. Also you only need an impedance below 10K for the brief duration of the A/D measurement.

The 10K figure comes from making sure the input changes less than 1 LSB when loaded by the A/D. Since we are measuring a DC voltage we can use a capacitor to stop the input from drifting when loaded at no DC current cost. Using C=T/R with t=10us and R=10K gives 0.001uF for a single time constant. For any accuracy you need at least 5 time constants, and if you use 0.1uF you will be very safe.

So if you use a divider of say 700k and 500k with a 0.1uF cap to ground you will have a battery drain of only 10uA and a reading that is consistent within 1LSB. Note you should wait at least 250ms from when you first apply battery power till you take your first reading to let the cap get its initial charge. T=5RC=5*(500k//700k)*0.1uF

Have I lost you yet?...Just try it, it will work.
_________________
The search for better is endless. Instead simply find very good and get the job done.
iw2nzm



Joined: 23 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 8:21 am     Reply with quote

It's very interesting!

Just a question: is the capacitor connected between the A/D input and ground, right?

I'll try it of course!

Ah, btw, what's the tradeoff of this method? What cannot I do?

Thanks
Marco / iw2nzm
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Apr 16, 2007 11:08 am     Reply with quote

Yes, the cap goes from the A/D input to ground.

iw2nzm wrote:

Ah, btw, what's the tradeoff of this method? What cannot I do?


What an amazing question! I wish I heard that more often.
The problem with hanging this much capacitance on the A/D is that it limits the frequency the A/D can see. With a RC time constant of 300k * 0.1uF= 30ms a signal of 33 Hz will be distorted and nothing above about 6 Hz can be read accurately. Fortunately battery drain happens much slower than 6 Hz, so it will work in this application. Also if you use a very large capacitor you may have capacitor leakage problems if the divider impedance si too high. But a generic 0.1uF ceramic cap should do fine.

SherpaDoug
_________________
The search for better is endless. Instead simply find very good and get the job done.
iw2nzm



Joined: 23 Feb 2007
Posts: 55

View user's profile Send private message

PostPosted: Tue Apr 17, 2007 1:24 am     Reply with quote

Thanks!!!
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