PDA

View Full Version : ADC'ing higher DC voltage dilemna



HankMcSpank
- 26th September 2011, 09:50
Here's my problem...I need to monitor/track the "health" of a 9V battery (in order to make PWM adjustments as its voltage fades).

The battery is 9V ...not good wrt a PIC IO pin

ok, no problem let's do potential divider...and configure it so the junction voltage equals approximately the PIC's supply voltage - this means when a fresh battery is installed, I'll get the maximum ADC reading, which will get less and less as the battery fades - all is good thus far.

Hmm...but this potential divider is going to eat current all the time ...ok, maybe not a lot, but remember this is a 9V battery...which isn't bestowed with a lot of power delicvery in the first place, so tens of microamps count! Therefore what I need is a potential divider where I can 'lift' up one of the connections at either end of the potential divider (are you following this at the back?!).. but the problem if I lift the ground end of the chain, then the pic ADC pin will float up to 9V - which might not be to good for the PIC IO Pin! (has anyone tested when a PIC faces certain death by pushing the IO pin DC levels?

So to my question...

What's the slickest way of ADC'ing a DC voltage some two to three times higher than the PIC supply itself *but* without incurring constant current draw?

Can any one particular PIC pin withstand much higher voltage (I keep reading about open drain/open collectors wrt PICS...with some implication-rightly or wrongly - that such pins might be able to take higher voltage on the chin?!)

Many thanks,
Hank

HenrikOlsson
- 26th September 2011, 09:59
Hi Hank,
As far as I know all I/O pins have internal clamp diodes, Vss->Pin->Vdd. As long as the top end resistor of the divider is large enough to limit the current going into the pin and up thru the diode to a safe level you should be fine. Use a logic level MOSFET and "disconnect" the bottom of the divider from GND/Vss.

If you look at the SERIN command in the PBP manual they are actually using this scheme, a 22k resistor in series with the TX-line from the PC makes it work just fine even though the TX-line toggles between something like +/-12V or there abouts.

Give it a try.

/Henrik.

tumbleweed
- 26th September 2011, 11:26
I see a lot of references to using the internal clamp diodes of chips for a number of purposes.

Those interested may want to read the following Microchip documents:
TB3009 (http://ww1.microchip.com/downloads/en/AppNotes/93009A.pdf)
TB3013 (http://ww1.microchip.com/downloads/en/AppNotes/93013a.pdf)

And then see if they still want to recommend doing this.

HenrikOlsson
- 26th September 2011, 11:44
Hi,
That's an excellent read, thank you for the links!
As with most things the way you choose to do something may differ from time to time and recommendations changes. There are limitations to using the internal diodes, as described in those docs but, depending on the application it may still work fine.

However, passing current thru the internal diode kind of defeats the purpose (I didn't think it thru properly). The idea was to disconnect the voltage divider from ground to lower the current consumption but if we're passing current thru the pin diode (or external diode) into Vcc we haven't gained much....ooops.

Perhaps a second MOSFET or analog switch in series with the pin....

/Henrik.

ardhuru
- 26th September 2011, 13:24
Hank, take a look at http://www.electricstuff.co.uk/picavrstuff.html#Measuring%20battery%20voltage

Its precisely what you are looking for. And while there, do check out the other neat things on the home page!

Regards,

Anand

HankMcSpank
- 26th September 2011, 14:03
Hank, take a look at http://www.electricstuff.co.uk/picavrstuff.html#Measuring battery voltage

Its precisely what you are looking for. And while there, do check out the other neat things on the home page!

Regards,

Anand

Thanks Anand mate ....a clever low parts count solution - job done! (curious as to how long that tranny is switched on to allow an ADC sample of the potenetial divider junction voltage to take place though!)

(thanks Henrik & tumbleweed for the input too)

ardhuru
- 26th September 2011, 15:21
I'm glad it worked for you. Did you actually try it out yet?

Anand

HankMcSpank
- 26th September 2011, 15:51
No not yet....another 2-3 days before I get around to knocking up the associated circuit on breadboard - I'll report back.