Sampling Unsmoothed DC

Status
Not open for further replies.

Suraj143

Active Member
Hi all

I have a lead acid battery charger. It’s a simple charger.

What I want to do is measure its battery voltage from a PIC. The problem is the output voltage is unsmoothed DC (there is no any capacitor).

Will this be a problem when sampling? What are the precautions do I have to make?
 

Attachments

  • Unsmoothed DC.PNG
    9.2 KB · Views: 179
What are the desired values of R1 and R2?

You can shunt R2 with a large capacitor to create a low source-impedance for the ADC input, and to get a modicum of anti-alias filtering...
 
Hi Mike the resister divider will generate 4V output when the battery voltage is 12V.

I don't know what is shunt and what is anti-alias filtering???

Is there any changes to do?
 
Last edited:
Hi Mike the resister divider will generate 4V output when the battery voltage is 12V.

I don't know what is shunt and what is anti-alias filtering???

Is there any changes to do?

Using high resistances so that they do not rapidly discharge your battery if you loose AC. The capacitor satisifies the PIC AD requirement for a low source impedance.
 

Attachments

  • Draft40.png
    19 KB · Views: 153
Hi Mike that's exactly what I want.

Thanks for your great help.

One thing I cannot find metal film resisters so I used normal resisters.

I know resister divider will scale the input voltage.But whats that 10uF capacitor do?
 
Using high resistances so that they do not rapidly discharge your battery if you loose AC. The capacitor satisifies the PIC AD requirement for a low source impedance.

Hi there,


The values of R1=200k and R2=100k are not compatible with most ADC inputs
due to the leakage current specification.
A better choice would be R1=20k and R2=10k, or even lower.

Another way to get this kind of result is to sample more often and
take the average in the uC program code. It requires more samples
however at a frequency that is either locked onto the line or is
random or there are very many samples.
 
Last edited:
Hi there,


The values of R1=200k and R2=100k are not compatible with most ADC inputs
due to the leakage current specification...


I disagree. The DC input leakage spec on the AD input pin is +-1uA. The error caused by a 1uA change in input leakage current using the 200k/100K resistor divider is about 1% (about the same error as using 1% resistors), besides, the leakage current will me more or less constant, so it causes an initial offset.

The requirement that the A/D input is fed from a voltage source with a source impedance of <10K is met by the 10uF capacitor. The settling time is long, but since the OP is measuring a battery, who cares.

Besides, I have done this, and it works just fine...
 
Last edited:
Yeah most PICs have a specified 2.5Kohm max input impedance. That filter is 67Kohm. Way, way over. Running the ADC with a dead slow sample time will not account for leakage. +/- 1uA on 66Kohm is +/-0.066v. Since the actual voltage is 3x the divider output, that's about +/-0.2v. That leakage may change with temp.

Unfortunately, for sensing 12v lead-acid's full charge voltage, the total voltage accuracy needs to be high- preferably within +/- 0.05v. Depends on whether it's a sealed lead acid but the numbers may be like 10.5v="totally dead", 12.6v=full, not charging, 14.4v=full, charging, 14.6v="over voltage" while charging. Not only resistor error but using the 5v reg as a reference is a HUGE error source. You need a precision voltage reference there unless you're just trying for a very basic "sorta full vs sorta empty" voltage.

With a PVR for the ADC Vref, then you have less than a 5v Vref. If it's like a 2.5v PVR (very common), the problem gets kinda serious, because you need to rescale the resistors for a max voltage on the ADC of 2.5v (because Vanalog cannot exceed Vref). However, the leakage current error does NOT decrease, and if you halve the analog voltage, you double the % of error due to leakage.
 
Last edited:
Ok guys so I'm going to put R1=200K & R2=100K with a 10uF capacitor like Mike mentioned.Is this ok? In this case how to calculate the impedance with that 10uF capacitor?

Can you tell how often do I have to sample?

Oznog where did you get that 67Kohm?
 
Last edited:
Oznog where did you get that 67Kohm?
Thévenin's_theorem, in this case it tells us that 100k in parallel with 200k is a 67k impedance as seen by the ADC pin, as well as the cap. However, it is a 300k impedance as seen by the battery.

This is essential basic electronics theory, you need to know it.
 
Last edited:
Hi Oznog sorry for troubling.

I 'm confused how it comes 67Kohms impedance

Does it need Thévenin's_theorem?

Cant it calculate like this ---> 100K is parallel with impedance of the capacitor = Total impedance seen by ADC?
 
Last edited:
I agree with Mike that the source impedance doesn't need to comply with the less than 10k requirement due to the capacitor. The low source impedance is required so the internal sample and hold capacitor will charge quickly. With the 10uF cap (I think 1uF is more than enough) then the internal cap will charge almost instantly. However, I would suggest dropping the values to 50k and 22k and making sure you have a low leakage capacitor.

Mike.
Suraj, 67K comes from 1/(1/200+1/100). I.E. series resistors.
 
Yeah most PICs have a specified 2.5Kohm max input impedance. That filter is 67Kohm. Way, way over.

You labor under a common misinterpretation of the meaning of the 10K source impedance spec. Pommie has the correct explanation of why only the AC impedance needs to be low; the DC source impedance can be 67K without becoming the dominant source of error in reading the battery voltage. The error due to using 1% resistors is significant.

As you have correctly pointed out, because the PIC's AD reading is ratiometric with respect to the actual voltage on the Vcc pin, that is likely to be the largest source of error.
 








Hello again,

Thinking that the capacitor makes up a high source impedance because
it has low impedance is a common misconception with ADC inputs.
The reason it does not really work is because the leakage current is
a DC spec, and the capacitor can only reduce the AC impedance.
So in short, one is a DC spec and the other is an AC spec.

For example, with a 100k resistor and a 1uf cap, the ADC leakage
current affects the reading due to the 100k resistor times the max
leakage current. With 100k resistor and a 1000uf cap (1000 times
bigger cap) the leakage current still affects the reading in exactly
the same way. On the other hand, if the resistor is dropped to
10k the voltage generated by the leakage current is 10 times lower
than it was with the 100k resistor. That *may* make a big
difference when the device has to operate over the full temperature
range. If you are running at room temperature all the time it
may be ok of course if the system is calibrated, which often it is.

Yes, it can work for a small temperature range, but over a wider
temperature range the ADC reading may change and cause
unacceptable inaccuracies. This is something to be aware of.

Thus, one of the "precautions" would be to make sure the ADC has
the right source impedance, or a better way of putting it, the right
source resistance. If we are going to do it, might as well do it right.
In the ADC world the target is usually plus or minus one half bit.
 
Last edited:
Mr Al, you just repeated the misconception AGAIN without answering any of the points that Pommie and I posted in response to Oznog's post. If the source impedance is 10KΩ or less, then the external source tied the AD input pin is low enough to prevent the capacitive coupling backwards from internal switches from perturbing the voltage at the input pin. This is a dynamic process (AC) which happens only during the conversion sequence.

The external shunt capacitor will present a source impedance much less than 10KΩ and will hold the voltage constant during the conversion. Think about how much current it would take to "move" the capacitor voltage.
This is independent and separate from the DC leakage spec, which slightly changes the DC level at the input pin.
 
Last edited:
Hi Oznog sorry for troubling.

I 'm confused how it comes 67Kohms impedance

Does it need Thévenin's_theorem?

Cant it calculate like this ---> 100K is parallel with impedance of the capacitor = Total impedance seen by ADC?
You need Thévenin's theorem to calculate the output resistance of the filter. Look up my link, it shows how you calculate the output impedance seen by any two nodes even when there's a voltage source in there somewhere (the battery). A multimeter will not read this impedance correctly due to the DC voltage on the filter output.

There are TWO different numbers here- the AC resistance and the DC resistance. Assuming the capacitor is "large" relative to the current pulse drawn, the AC resistance is just the ESR impedance of the capacitor, which is quite low, under 100 ohms even in the worst case. For an MLCC ceramic cap, it's milliohms. So a capacitor is really considered a short circuit and you take the Thévenin equivalent which shows it's only going to see the capacitor's short circuit and the rest of the circuit is insignificant.

But for DC evaluation, the capacitor is considered an "open" and left out of the evaluation. Either way, Thévenin's theorem applies, but in this case the Thévenin evaluation is not simply a "capacitor is zero impedance, stop here".
 
Keep in mind that the capacitor we are trying to charge is only 25pF. A 1uF external cap will charge it almost instantly and it's voltage will not be effected (that you can measure).

Mike.
 
Keep in mind that the capacitor we are trying to charge is only 25pF. A 1uF external cap will charge it almost instantly and it's voltage will not be effected (that you can measure).

Mike.


sure, then you just have to wait "Bla" Seconds until you can take another accurate sample, Why not just do the right thing to start with and put an Op-Amp in there as a buffer? then you can use very high value resistors and still have the right impedance at your AtoD Pin.
 
You don't have to wait at all and there is no need for an opamp. What you are suggesting is just complete overkill.

Mike.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…