Re: Using the ADC to measure the battery supply?
2007-06-19 by Dave VanHorn
Yahoo Groups archive
Index last updated: 2026-04-28 22:41 UTC
Thread
2007-06-19 by Dave VanHorn
Your only delay now is how long it takes to charge that > cap through the resistor network - but since this is a slowly changing > signal (one hopes!) that shouldn't matter. The source resistance still matters, because the AVR inputs have leakage currents into or out of the pins. If the source resistance is large relative to that current, then the voltage on the cap will be affercted, or dominated, by that leakage current. Check the specs, and design to survive the maximum specified leakage.
2007-06-19 by dlc@frii.com
> 1) The concept here is that the 0.1uF cap is way larger than the input cap > in the A/D and will present a low impedance source to the input. True, a very low impedance. > 2) What do you mean by "a certain RC charge rate?" AFAIK, the slope has > nothing to do with the A/D measurement, other than to say that you want a > steady input voltage during the actual measurement. I wasn't sure how you were using the cap, as a shunt around the resistor or as a resevoir cap, I see now it is the latter. > 3) How in the world could adding a cap across the A/D input cause the > input > current to exceed the capacity of the pin? We're not talking about a > voltage > doubler - just a simple low pass filter. Current = dV/dT through a resistor - if it is a sufficient dV and no resistor then you can get a very high, very short duration current flow. This is always a concern when _driving_ a MOSFET with a micro, I'm not just sure what kind of an issue it might be when taking an input for an ADC, I don't know what the internal circuit is. It could be (seems likely in hindsight) that this current would be internally limited in some fashion. Your only delay now is how long it takes to charge that cap through the resistor network - but since this is a slowly changing signal (one hopes!) that shouldn't matter. > 4) I have used such a circuit very successfully before. You have certainly convinced me to try this method on future projects! DLC -- Dennis Clark
> Phillip > ________________________________ > > From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf > Of dlc > Sent: Tuesday, June 19, 2007 1:01 AM > To: AVR-Chat@yahoogroups.com > Subject: Re: [AVR-Chat] Using the ADC to measure the battery supply? > > > > If the cap is across it then the ADC might not get the correct voltage > either. The ADC relies upon charging a cap inside the module. That > relies upon a certain target RC charge rate, that charge rate also must > not exceed the current capacity of the pin. You are playing a finicky > game by using a cap to boost the inrush current to offset the RC time > constant. It might work under some circumstances but since the ADC > modules specifically states that you should only be using slowly > changing signals on the circuit with low-pass filters that would tend to > contra indicate using a bypass cap I think. Have you used such a > circuit successfully before? > > curious, > DLC > > > > > Yahoo! Groups Links > > > >
2007-06-19 by Dave VanHorn
> I'm still curious enough to experiment with this idea compared to my > typical OpAmp solution. It may "work" on one unit, but if you can't handle the leakage allowed in the spec without significant error, then you're in trouble. Remember, you have to add this error to all the other sources of error in the ADC measurement.
2007-06-19 by dlc@frii.com
> Your only delay now is how long it takes to charge that >> cap through the resistor network - but since this is a slowly changing >> signal (one hopes!) that shouldn't matter. > > > The source resistance still matters, because the AVR inputs have > leakage currents into or out of the pins. If the source resistance is > large relative to that current, then the voltage on the cap will be > affercted, or dominated, by that leakage current. > > Check the specs, and design to survive the maximum specified leakage. Good point, I didn't consider that leakage. Its never just a simple answer is it? I'm still curious enough to experiment with this idea compared to my typical OpAmp solution. DLC -- Dennis Clark
2007-06-19 by kernels_nz
Firstly, the ADC uses 3 ADC clock cycles to perform it's sample and hold. You can calculate the sample and hold time by multiplying your ADC clock period by 3. Secondly, the ADC must be fed from a low impedance source - have a look at the input with your scope when your feeding it from a high impedance source, I had my voltage dropping 200mV on a 3V signal by feeding it from a too high impedance source. (Keep the loop impdance low!!) Generally when I want to measure the supply voltage in a AVR, I connect the high side of the voltage divider to a output pin, connect the center to the ADC and connect the low side to ground. That means you can control very easily without any external parts when the bulk of the current flows through your "low" impedance voltage divider, I usually use 2 * 10k resistors for the divider, but you should be able to up these values into the 100s of k without any problems. I personally wouldnt use MOHM resistors as they cause lots of problems with temperature and humidity. You change the value of a 3M3 resistor by blowing on it! <- caused a problem in one of my projects. This is an interesting topic, but in the end you need to decide what is the easiest method, generally for measuring the supply voltage you probably dont need to be VERY accurate anyway! You are usually just trying to find out whether the battery is good or low. Cheers Hein B Auckland, New Zealand. --- In AVR-Chat@yahoogroups.com, "Jim Wagner" <jim_d_wagner@...> wrote:
> > On Tue, 19 Jun 2007 19:35:43 -0000 > "Dave VanHorn" <microbrix@...> wrote: > > > > > I'm still curious enough to experiment with this idea > > compared to my > > > typical OpAmp solution. > > > > It may "work" on one unit, but if you can't handle the > > leakage allowed > > in the spec without significant error, then you're in > > trouble. > > > > Remember, you have to add this error to all the other > > sources of error > > in the ADC measurement. > > > > > > > And Op-Amps have their own input "leakage". > > Jim > > --------------------------------------------------------------- > The Think Different Store > http://www.thinkdifferentstore.com/ > For All Your Mac Gear > --------------------------------------------------------------- >
2007-06-19 by Jim Wagner
On Tue, 19 Jun 2007 19:35:43 -0000 "Dave VanHorn" <microbrix@gmail.com> wrote: > > > I'm still curious enough to experiment with this idea > compared to my > > typical OpAmp solution. > > It may "work" on one unit, but if you can't handle the > leakage allowed > in the spec without significant error, then you're in > trouble. > > Remember, you have to add this error to all the other > sources of error > in the ADC measurement. > > And Op-Amps have their own input "leakage". Jim --------------------------------------------------------------- The Think Different Store http://www.thinkdifferentstore.com/ For All Your Mac Gear ---------------------------------------------------------------
2007-06-19 by David VanHorn
> And Op-Amps have their own input "leakage". > Indeed, but the chip processes that do good analog are different from the ones that do good microcontrollers.
2007-06-19 by Jim Wagner
On Tue, 19 Jun 2007 18:39:45 -0400 "David VanHorn" <microbrix@gmail.com> wrote: > > And Op-Amps have their own input "leakage". > > > > Indeed, but the chip processes that do good analog are > different from > the ones that do good microcontrollers. No argument there. Point, however: suppose that an op-amp has an input current (bias or otherwise) of 1na. Suppose "designer" uses an affective DC source resistance of 1M (not equal both inputs). If said buffer is unity-gain, there will be an output offset of 1mv from just this source (plus others not yet enumerated). With a Vref of 2.048V and 10bit ADC, this represents about 1/2 LSB, right out the chute. Now, add Vos, ground loop, input offset currents, etc, the designer has to pay very close attention to that simple op-amp circuit in order to realize the available accuracy of the ADC. Of course, "everyone" knows this, right? Jim --------------------------------------------------------------- The Think Different Store http://www.thinkdifferentstore.com/ For All Your Mac Gear ---------------------------------------------------------------
2007-06-20 by David VanHorn
> Of course, "everyone" knows this, right? Sure! :)
2007-06-20 by Robert Adsett
At 05:25 PM 6/19/2007 +0000, Dave VanHorn wrote: > Your only delay now is how long it takes to charge that > > cap through the resistor network - but since this is a slowly changing > > signal (one hopes!) that shouldn't matter. > > >The source resistance still matters, because the AVR inputs have >leakage currents into or out of the pins. If the source resistance is >large relative to that current, then the voltage on the cap will be >affercted, or dominated, by that leakage current. > >Check the specs, and design to survive the maximum specified leakage. Very good point. I checked, the leakage was rather higher than I expected. Robert http://www.aeolusdevelopment.com/ From the Divided by a Common Language File (Edited to protect the guilty) ME - "I'd like to get Price and delivery for connector Part # XXXXX" Dist./Rep - "$X.XX Lead time 37 days" ME - "Anything we can do about lead time? 37 days seems a bit high." Dist./Rep - "that is the lead time given because our stock is live.... we currently have stock."