Author Topic: resistive divider -> ADC - how to get low parasitic drain?  (Read 7897 times)

0 Members and 1 Guest are viewing this topic.

Offline rr100Topic starter

  • Frequent Contributor
  • **
  • Posts: 339
resistive divider -> ADC - how to get low parasitic drain?
« on: June 30, 2012, 06:47:23 am »
I have a micro (attiny13a) monitoring a battery, I know how to save power in the micro by disabling the ADC (and putting the micro to sleep, it uses only some microamps). Question is, how to get rid of the current from the voltage divider from before ADC? I can up to a point to increase the impedance on the micro side and use higher and higher resistors. Any better idea? Mosfet controlled by the micro turning on and off the divider?
 

Offline Rerouter

  • Super Contributor
  • ***
  • Posts: 4700
  • Country: au
  • Question Everything... Except This Statement
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #1 on: June 30, 2012, 06:56:49 am »
like the other thread on this topic, if your divider resistors are high enough in value, you can simple pull an output to digital low when you want to measure, for your ground,

this method will likely leave a few micro/nano-amp being drained through the protection diodes of the pin if your voltage is greater than its supply, but it shouldnt be a problem,
 

Offline digsys

  • Supporter
  • ****
  • Posts: 2209
  • Country: au
    • DIGSYS
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #2 on: June 30, 2012, 07:11:08 am »
Quote
.. this method will likely leave a few micro/nano-amp being drained through the protection diodes of the pin if your voltage is greater than its supply, but it shouldnt be a problem,
He'd need to test how much leakage there was though, it may be enough to fire up the internal voltage rail.
Increasing the resistive divider MAY end up de-linearizing the ADC curve, which is not good, also to be tested.
Otherwise, you'll have to use  a NPN (transistor) - PNP (FET) pair, as you originally surmised.
Hello <tap> <tap> .. is this thing on?
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10181
  • Country: nz
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #3 on: June 30, 2012, 07:11:23 am »
Something like
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #4 on: July 01, 2012, 05:01:31 am »
If you use a port pin to pull down the bottom of the resistor divider, as in the graphic, you should be aware that sleep mode on the attiny13 and maybe other attiny processors will tristate the port pins. That will put the full battery voltage into the input ADC pin during sleep. This needs to be considered, if it will damage the chip or not. Chances are no, because it will be clipped with the input protection diodes, but you will want to do the math to make sure you don't exceed the current rating of those protection diodes.

also the attiny13 is not open drain outputs, so pulling the bottom down to 0 is not really a 0. it's going to be a few mv above 0. This may or may not be a concern depending on your accuracy needs.

an alternate solution might be a P channel FET to switch the battery voltage onto the top of the divider when you wake up to read it.



 

Offline Bored@Work

  • Super Contributor
  • ***
  • Posts: 3932
  • Country: 00
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #5 on: July 01, 2012, 07:19:32 am »
AVRs are infamous for an annoying feature. Some are very prone being reverse-powered through IO pins. I.e. if the supply power is off, but you have power on an IO pin, that voltage, via the protection diode can power the AVR or parts of it. A half running MCU is not funny, like a drunken sailor not finding his way.

So I wouldn't go with the ground-switching version, but make sure the IO is turned off externally.
I delete PMs unread. If you have something to say, say it in public.
For all else: Profile->[Modify Profile]Buddies/Ignore List->Edit Ignore List
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #6 on: July 01, 2012, 04:30:22 pm »
Any better idea? Mosfet controlled by the micro turning on and off the divider?

To eliminate drain in the divider use a P channel MOSFET to switch the top. You may also need and N channel or NPN to drive the MOSFET gate.

If you don't like the cost of those parts you are into trading off battery drain against the highest resistance divider you can live with.

Switching the divider bottom doesn't do much, the top resistor will feed into the input clamp diodes possibly causing problems and the current drain won't be much different unless the battery voltage isn't much higher than the micro supply voltage.
 

Offline rr100Topic starter

  • Frequent Contributor
  • **
  • Posts: 339
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #7 on: July 02, 2012, 08:45:16 am »
Thanks for the answers, no magic bullet it seems.
Battery voltage is 12-15V, 5V for the micro, common negative ground (but it can be changed if needed).
I need to understand how the sampling is done (I don't yet) and how much I can increase the resistors on the divider; also I need to test or maybe I can figure out from the datasheet if there's any mode in which I can put my ADC pin in some "high-impedance mode" (we're talking +0-1V on it). Then I can put a capacitor on the "output" of the divider, to slowly follow (divided) battery voltage, then when I (rarely) take a sample of the voltage I take it basically from the capacitor. Trading here bandwidth against drain.
 

Online mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 13917
  • Country: gb
    • Mike's Electric Stuff
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #8 on: July 02, 2012, 10:15:17 am »
Here's a nice solution - use a capacitor to do the level shifting
http://electricstuff.co.uk/picavrstuff.html#Measuring%20battery%20voltage
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #9 on: July 02, 2012, 06:21:38 pm »
I don't like that pnp solution with a capacitor for level shifting, there's an unknown Vbe drop
(granted, compared to the 15V battery it's negligible) but what's wrong with the PMOS solution?

It seems you are making this more complicated then it needs to be.



 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #10 on: July 02, 2012, 11:23:40 pm »
I don't like that pnp solution with a capacitor for level shifting, there's an unknown Vbe drop
(granted, compared to the 15V battery it's negligible) but what's wrong with the PMOS solution?

There isn't a Vbe drop, there is a much smaller Vce sat drop feeding the divider.

A P MOSFET solution has an Rds on drop which is likely even smaller. What's wrong is with your PMOS solution is clamp diodes in the processor prevent IO pins rising more than one diode drop above the processor supply, including trying to power the processor through the diode. The pin will never rise high enough to turn off the MOSFET. That is why a capacitor is needed in PNP and P MOSFET solutions (if you can live with pulsed drive to the divider).
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #11 on: July 03, 2012, 05:53:17 am »
I don't like that pnp solution with a capacitor for level shifting, there's an unknown Vbe drop
(granted, compared to the 15V battery it's negligible) but what's wrong with the PMOS solution?

There isn't a Vbe drop, there is a much smaller Vce sat drop feeding the divider.

A P MOSFET solution has an Rds on drop which is likely even smaller. What's wrong is with your PMOS solution is clamp diodes in the processor prevent IO pins rising more than one diode drop above the processor supply, including trying to power the processor through the diode. The pin will never rise high enough to turn off the MOSFET. That is why a capacitor is needed in PNP and P MOSFET solutions (if you can live with pulsed drive to the divider).

oops... my bad. I meant Vce drop. 

but still the I/O pin only has to pull down the gate of the MOSFET to turn it on.  Turning it off is done by the 10k pullup. the I/O pin can switch to tristate or become an input to turn off the gate.

finally, I see how the capacitor helps to prevent powering the device through its protection diodes.  Now I see how that's useful. OK
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 10181
  • Country: nz
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #12 on: July 03, 2012, 06:45:17 am »
I don't like that pnp solution with a capacitor for level shifting, there's an unknown Vbe drop
(granted, compared to the 15V battery it's negligible) but what's wrong with the PMOS solution?

There isn't a Vbe drop, there is a much smaller Vce sat drop feeding the divider.

A P MOSFET solution has an Rds on drop which is likely even smaller. What's wrong is with your PMOS solution is clamp diodes in the processor prevent IO pins rising more than one diode drop above the processor supply, including trying to power the processor through the diode. The pin will never rise high enough to turn off the MOSFET. That is why a capacitor is needed in PNP and P MOSFET solutions (if you can live with pulsed drive to the divider).

oops... my bad. I meant Vce drop. 

but still the I/O pin only has to pull down the gate of the MOSFET to turn it on.  Turning it off is done by the 10k pullup. the I/O pin can switch to tristate or become an input to turn off the gate.

finally, I see how the capacitor helps to prevent powering the device through its protection diodes.  Now I see how that's useful. OK

Even when the GPIO is set to input or tristate it still cannot be pulled above mcu VCC.
So you either have 5V or 0V on the gate, which is likely to have the fet on in both states.
« Last Edit: July 03, 2012, 06:46:52 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #13 on: July 03, 2012, 04:54:42 pm »
Even when the GPIO is set to input or tristate it still cannot be pulled above mcu VCC.
So you either have 5V or 0V on the gate, which is likely to have the fet on in both states.

oh dammit, yeah..  :-[ I'm sleeping at the wheel on this one.
 

Offline rr100Topic starter

  • Frequent Contributor
  • **
  • Posts: 339
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #14 on: July 03, 2012, 07:10:31 pm »
Very interesting discussion, who would've thought such a simple thing can be so complicated!
I finally managed to get some ADC readings and experiment a bit (that's really quick for me, I still have stuff before y2k filled under "new - to do") and it seems that input impedance is not even making a difference. Even a 220k resistor in series is doing nothing to the ADC reading (at least for 8-bit precision, which I programmed now).
Now spreadsheet says:
"The ADC is optimized for analog signals with an output impedance of approximately 10 k? or
less. If such a source is used, the sampling time will be negligible. If a source with higher impedance
is used, the sampling time will depend on how long time the source needs to charge the
S/H capacitor, with can vary widely."
Ok, fine, higher input impedance equals slower reading. I understand the theory, how the ADC samples, etc. But numbers, how much impedance can I get if I'm willing to "wait for it"? This theoretical step I'm missing.

In practical terms probably most of my problem is stupid, I can just use high value resistors and calibrate the input (which I plan to do anyway), if the readings are consistent for the same voltage, that's the end of it.
 

Offline Rufus

  • Super Contributor
  • ***
  • Posts: 2095
Re: resistive divider -> ADC - how to get low parasitic drain?
« Reply #15 on: July 03, 2012, 08:12:59 pm »
Ok, fine, higher input impedance equals slower reading. I understand the theory, how the ADC samples, etc. But numbers, how much impedance can I get if I'm willing to "wait for it"? This theoretical step I'm missing.

At speeds you need to monitor battery capacity you are limited by the errors from pin leakage current which is typically specced at +/- 1uA for CMOS processors.

100k output resistance from the divider will give 0.1v error. In practice you will likely observe much less error but have no guarantee the next chip will be as good and leakage increases rapidly with temperature.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf