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

(Off Topic) Battery Voltage Detector

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



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

(Off Topic) Battery Voltage Detector
PostPosted: Fri Aug 26, 2005 9:08 pm     Reply with quote

I think this has been covered before, but I couldn't find the topic.


How does one control the power to a voltage divider to sense the battery voltage? This is a 4 AA powered app that runs at either 3 or 5V and needs to last as long as possible. So, the goal is to only power the voltage divider to the ADC when taking a reading.

The topology below is an obvious option. Simply set RA4 as an input to power it up. Take a reading and then turn it off.....

However, I remember there being some issues with the configuration....



Code:



       Vbat(6V)
          |
          |
          |
          \
          /
          \
          /
          \
          /
          |
          |___________ AN0
          |
          |
          \
          /
          \
          /
          \
          /
          |
          |___________ RA4




Thanks,

John
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri Aug 26, 2005 9:46 pm     Reply with quote

When you put the RA4 into the high-Z state, +6V will appear on AN0 and RA4, and +6V is higher then the max allowed voltage. You could ground the bottom of the divider and add a small MOSFET (like 2N7000) in series with the top resistor. Or you could pick the higest possible values for the resistors, and have the smallest leakage. I remeber that the maximum value for the lower resistor is 2.5k, this was mentioned in the PIC's datasheet.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Fri Aug 26, 2005 10:01 pm     Reply with quote

Thanks Kender,

I can't believe that didn't dawn on me. I'll go the FET route and everything should workout.

John
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Fri Aug 26, 2005 10:09 pm     Reply with quote

kender wrote:
... add a small MOSFET (like 2N7000) in series with the top resistor.


Come to think of it, it should be a P-channel MOSFET, because it's a high-side switch (2N7000 will not work). You could also use a high-side switch IC.
jecottrell



Joined: 16 Jan 2005
Posts: 559
Location: Tucson, AZ

View user's profile Send private message

PostPosted: Fri Aug 26, 2005 10:44 pm     Reply with quote

Wouldn't have caught that one. I've got other designs using FETs and they are always on the ground leg (low-side). Probably would have plowed right into the wall. Thanks for the correction.

I Googled and found this option:

http://www.micrel.com/product-info/products/mic2514.shtml

Printing out the data sheet now to read up on. Just another wild Friday night!
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