View previous topic :: View next topic |
Author |
Message |
Newbie Guest
|
Checking battery voltage with A/D |
Posted: Wed Oct 19, 2005 1:25 pm |
|
|
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
|
|
Posted: Wed Oct 19, 2005 1:38 pm |
|
|
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: 1908
|
|
|
Newbie Guest
|
First thank....now? |
Posted: Wed Oct 19, 2005 3:30 pm |
|
|
|
|
|
kender
Joined: 09 Aug 2004 Posts: 768 Location: Silicon Valley
|
|
Posted: Wed Oct 19, 2005 4:45 pm |
|
|
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 |
Posted: Wed Oct 19, 2005 5:48 pm |
|
|
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
|
Re: Brilliant |
Posted: Wed Oct 19, 2005 5:58 pm |
|
|
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 |
Posted: Wed Oct 19, 2005 7:20 pm |
|
|
Hi again, thought I found a really nice simple answer then, dam
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
|
Re: OK |
Posted: Wed Oct 19, 2005 7:44 pm |
|
|
|
|
|
Newbie Guest
|
|
Posted: Thu Oct 20, 2005 2:30 am |
|
|
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
|
|
Posted: Thu Oct 20, 2005 2:59 am |
|
|
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
|
|
Posted: Thu Oct 20, 2005 4:42 am |
|
|
Hi Ttelmah,
Do I still need the CAP id I use a TL431? |
|
|
Newbie Guest
|
|
Posted: Thu Oct 20, 2005 5:04 am |
|
|
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: 1908
|
|
Posted: Thu Oct 20, 2005 6:34 am |
|
|
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
|
Best And Simple Result |
Posted: Fri Jul 07, 2017 11:34 pm |
|
|
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. |
|
|
|