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

Checking battery voltage with A/D

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







Checking battery voltage with A/D
PostPosted: Wed Oct 19, 2005 1:25 pm     Reply with quote

Hi,

Can I monitor the battery supply (VCC) with the A/D on a PIC? is it a good way to determine the voltage level?

Anyone done this before and got circuit / advice?

Thanks
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Wed Oct 19, 2005 1:38 pm     Reply with quote

Yep, and someone posted a method very recently where the Vref was set so that as the voltage dropped, the A/D reading got higher.
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Wed Oct 19, 2005 1:54 pm     Reply with quote

....and here it is.

http://www.ccsinfo.com/forum/viewtopic.php?t=24560&start=0
Newbie
Guest







First thank....now?
PostPosted: Wed Oct 19, 2005 3:30 pm     Reply with quote

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: Wed Oct 19, 2005 4:45 pm     Reply with quote

Newbie wrote:
OK, because my circuit is running at 3.6v can I use the configuration shown here to enable / disable the voltage divider?

http://www.ccsinfo.com/forum/viewtopic.php?p=49830


The circuit, which is originally shown in that conversation will not work for a battery voltage higher then the PIC's Vcc. The reason is described in the second post of that thread.

If the battery voltage is lower then the PIC's Vcc, you can mweasure it directly without a voltage divider and a loss associated with it. EDIT: This can happen only if your Vcc is generated by a step-up converter from the Vbat.
If your PIC is powered directly from the battery without a regulator (EDIT: Vbat = Vcc), you can do the voltage reference trick mentioned above.


Last edited by kender on Wed Oct 19, 2005 6:16 pm; edited 2 times in total
Newbie
Guest







Brilliant
PostPosted: Wed Oct 19, 2005 5:48 pm     Reply with quote

So as I am powering the entire circuit from a battery, the same battery I want to monitor I can simply connect VCC to the A/D input and do read to determine the battery voltage?

What sort of resolution will I get this a 10bit A/D?

Sorry if I appear a bit thick but I am new and learning.

Thx
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

Re: Brilliant
PostPosted: Wed Oct 19, 2005 5:58 pm     Reply with quote

Newbie wrote:
So as I am powering the entire circuit from a battery, the same battery I want to monitor I can simply connect VCC to the A/D input and do read to determine the battery voltage?


If you connect Vcc to the input of the 10-bit A/D, you will be reading the same valude all the time - 1023 - independent of the battery voltage (or anything else for that matter).
Newbie
Guest







OK
PostPosted: Wed Oct 19, 2005 7:20 pm     Reply with quote

Hi again, thought I found a really nice simple answer then, dam Very Happy


OK whats the best way then? I am powering the PIC from a battery (3.6v) and I want to measure the voltage to ensure it does not drop below 3.41v is there a simple way?

Could I do a voltage divider (with enable/disable like in post) and make it 1v below VCC so I would be looking for 2.41v?

Thx
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

Re: OK
PostPosted: Wed Oct 19, 2005 7:44 pm     Reply with quote

Newbie
Guest







PostPosted: Thu Oct 20, 2005 2:30 am     Reply with quote

OK, is it better to use a particular diode, say a precision one or thermally stabilized one (if there such a thing)

Thx
Ttelmah
Guest







PostPosted: Thu Oct 20, 2005 2:59 am     Reply with quote

Yes. A 'bandgap reference diode', will give a greater accuracy, but for cost/performance, it is hard to beat a TL431 regulator. You connect it's 'ref' output to the A/D input as shown, and the anode to the digital output via a resistor. You want something close to 1mA flow through this when the output is high (so for the 3.6v, something like 1000R does nicely). Switch it on, by raising the digital signal, wait about 30uSec, to allow verything to stabilise, and charge the capacitor in the ADC, read the ADC, and switch the circuit off. The reading will relate to the supply voltage as:
(Value read/1023)*2.5 =Vdd

Best Wishes
Newbie
Guest







PostPosted: Thu Oct 20, 2005 4:42 am     Reply with quote

Hi Ttelmah,

Do I still need the CAP id I use a TL431?
Newbie
Guest







PostPosted: Thu Oct 20, 2005 5:04 am     Reply with quote

Hi again Ttelmah, more questions (told you I am new)

Do I still need the CAP if I use a TL431?

You state "1000R" is that a typo or is it just a 1K in Ohms also will a standard 5% 0.125w do or is a better spec resistor going to improve things

Thx for all your help
newguy



Joined: 24 Jun 2004
Posts: 1907

View user's profile Send private message

PostPosted: Thu Oct 20, 2005 6:34 am     Reply with quote

Newbie wrote:
Do I still need the CAP if I use a TL431?

You state "1000R" is that a typo or is it just a 1K in Ohms also will a standard 5% 0.125w do or is a better spec resistor going to improve things


The cap can't hurt things if you leave it in.

"1000R" is STANDARD in the electronics field. It means 1,000 ohms. If you see "4R7" that means 4.7 ohms. As for the rating of the resistor (power & tolerance), figure it out. It's not hard.

If your voltage reference is 1.5V, and your battery voltage is 3.6V, then you're going to have a voltage drop of 2.1V across the resistor, right? So, (2.1V)^2/1000 ohms = xxx Watts. Figure it out.

And the tolerance? Will anything be "hurt" if the 1000 ohm resistor is actually 980 ohms? Or 1,040 ohms? Figure it out.
abas.ghorbani



Joined: 07 Jul 2017
Posts: 1

View user's profile Send private message

Best And Simple Result
PostPosted: Fri Jul 07, 2017 11:34 pm     Reply with quote

When I checked Kender circuit, i could not get the result.
But I reverse the Zener diode direction and it worked.
The zener voltage becomes into 0.7v and fixed.
And the resistor value was 100 Ohm.
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