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

Voltage change

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



Joined: 26 Jan 2005
Posts: 13

View user's profile Send private message

Voltage change
PostPosted: Tue Feb 08, 2005 4:12 am     Reply with quote

Hi

I want to connect a PIC to a 3.7V battery which is charged by a car battery (12v.) How do I go about detecting if the car battery is 0v and maybe flash an LED. Can some one please send me the code. Thanks
dyeatman



Joined: 06 Sep 2003
Posts: 1923
Location: Norman, OK

View user's profile Send private message

More info needed
PostPosted: Tue Feb 08, 2005 7:27 am     Reply with quote

A few questions in order here:

1. Do you simply want to know when the battery is pretty much dead? Or do you want to know what voltage the battery is actuially putting out? With the first case you can use a buffer circuit on a digital input pin. In the second case you will have to use an ADC input to monitor the voltage.

2. In either case, to be able to sense 12V with a 5V device, you will have to use a voltage divider on the input to the PIC.

3. What PIC chip will you be using?

4. What CCS compiler version will you be using?

5. I hate to break it to you but the folks here won't do your project for you. We will be glad to give you suggestions and help you get started, BUT the project is assigned to you, not us, and you won't learn by us doing it for you. We will be here to help you debug once you have something put together if it doesnt work the way you hoped it would.

Good Luck!
SherpaDoug



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

View user's profile Send private message

PostPosted: Tue Feb 08, 2005 8:35 am     Reply with quote

If you just want to detect the presence or absence of the 12V, and the 12V comes in through a polarity protection diode, you can just use a voltage divider. Connect the divider to the battery side of the diode. Set it so that at max voltage (16V for an automobile system???) the voltage out of the divider is safe for the PIC, in this case 3.7V. Use high resistor values and a cap so that the PIC pin is protected, like a 300K divider with .1uF. Then at 1/2 of 16V or 8V the PIC pin is also at 1/2 voltage and starts to switch from 1 to 0 indicating the 12V is missing. The exact threashold will vary with temperature etc. The PIC datasheet will tell you more.
_________________
The search for better is endless. Instead simply find very good and get the job done.
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

View user's profile Send private message Send e-mail

PostPosted: Tue Feb 08, 2005 8:53 am     Reply with quote

Beware load dump from the alternator. Protecting from just 16V won't cut it. Think 45V and higher spikes.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
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