#### Sumit Aich

Joined Dec 3, 2016
100
I connected two 100k resistors in series between GND pin and +5V pin.I connected the ADC A4 pin at the the middle. AREF = DEFAULT(+5V). But the ADC did not read 512 units. Instead it kept fluctuating between 506 to 508 units. What must be the reason for this weird behavior ?

#### be80be

Joined Jul 5, 2008
2,070
That's not weird behavior that's normal behavior you have 2 resistors that are not matched plus there 100 k range there not going to sit at a
dead on 512. You have to trim one the match the other. And the total need's to be less then 10k so two matched 5k would get yo as close as you get.

#### Sumit Aich

Joined Dec 3, 2016
100
That's not weird behavior that's normal behavior you have 2 resistors that are not matched plus there 100 k range there not going to sit at a
dead on 512. You have to trim one the match the other. And the total need's to be less then 10k so two matched 5k would get yo as close as you get.
Yeah thanks for helping

Next I tried this with capacitors..
I connected two 100uF capacitors in series(in series with 220ohm resistor) between GND pin and +5V pin.I connected the ADC A4 pin at the the middle of the 2 capacitors. AREF = DEFAULT(+5V). But the ADC did not read 512 units. Instead it read ~600 units.
What must be the reason for this weird behavior ?

#### WBahn

Joined Mar 31, 2012
28,519
This sounds like a lab assignment. Is it?

Given the explanation you received for the case with the resistors, what would be your best explanation at the cause?

#### Sumit Aich

Joined Dec 3, 2016
100
Given the explanation you received for the case with the resistors, what would be your best explanation at the cause?
But even if the 100uF capacitors are not exactly 100uF, would there be such large error of ~100 units ?

#### be80be

Joined Jul 5, 2008
2,070
Let's see cap +- 20 %
Resistor maybe 10 % some out of the same batch maybe closer to the same
Yep you'd see what your seeing

#### WBahn

Joined Mar 31, 2012
28,519
But even if the 100uF capacitors are not exactly 100uF, would there be such large error of ~100 units ?
What about that 220 Ω resistor? Why is it there? What does that say about the potential for a voltage across it?

Assume that one of your capacitors is above 100 uF by some percentage and that the other is below it by the same percentage. Ignoring the effect of the resistor, what does that percentage have to be to get the observed reading? How does that compare to the tolerance of your capacitors?

#### jayanthd

Joined Jul 4, 2015
945
I connected two 100k resistors in series between GND pin and +5V pin.I connected the ADC A4 pin at the the middle. AREF = DEFAULT(+5V). But the ADC did not read 512 units. Instead it kept fluctuating between 506 to 508 units. What must be the reason for this weird behavior ?
Maybe you have use 10% resistors. Did you measure the resistor values with a multimeter and selected matching resistors ?

Use 1% or better 0.1% resistors of 100k. You will get 511 as the reading.

#### Sumit Aich

Joined Dec 3, 2016
100
What about that 220 Ω resistor? Why is it there?
So that initially when the capacitors are uncharged , Arduino Uno doesn't get damaged due to excess current

#### DickCappels

Joined Aug 21, 2008
9,877
(some text removed for clarity) And the total need's to be less then 10k so two matched 5k would get yo as close as you get.
A very good point and one to which Sumit Aich should pay attention.

Of note: The ADC performs best when measuring a 10k to 20k source. Since the ends of the devider are both connected to low
Impedences with respect to ground the two are effectively in parallel with each other from the ADC's point of view, meaning that using two 30k resistors for the devider would be optimum. A small contributor to the error, especially given the likely tolerance if the resistors, as you have already noted.

#### Sumit Aich

Joined Dec 3, 2016
100
Assume that one of your capacitors is above 100 uF by some percentage and that the other is below it by the same percentage. Ignoring the effect of the resistor, what does that percentage have to be to get the observed reading? How does that compare to the tolerance of your capacitors?
Yeah, you were correct. The percentage error in capacitance should be +-17% which is within the tolerance of 20%.
But I was wondering how do I know the exact value of the capacitance of the 100uF capacitors.
Do I have to use Arduino Uno to measure the time constant or is there any other way. Maybe I should buy capacitors of very less tolerance and then compare my 100uF capacitors, by reading the voltage in-between, when both are is series from GND to +5V.

#### WBahn

Joined Mar 31, 2012
28,519
Yeah, you were correct. The percentage error in capacitance should be +-17% which is within the tolerance of 20%.
But I was wondering how do I know the exact value of the capacitance of the 100uF capacitors.
Do I have to use Arduino Uno to measure the time constant or is there any other way. Maybe I should buy capacitors of very less tolerance and then compare my 100uF capacitors, by reading the voltage in-between, when both are is series from GND to +5V.
Even many cheap digital multimeters have halfway decent capacitance measurement capability.

If you measure the time constant, be sure you know the actual resistance of the timing resistor you use.

Getting tighter tolerance capacitors of that size is easier said than done. It is uncommon to need tight tolerances given the purposes they are used for and the manufacturing process used results in inexpensive, large-value capacitors that have poor tolerances -- usually the set of tradeoffs you want in this case.

I think you have a potentially bigger issue with the leakage current of your capacitors, which I assume are aluminum electrolytics. Let's say that the capacitance values were exactly the same, and also that the leakage current of both capacitors was identical. How much leakage current would be needed to result in a 100 count difference in the ADC reading?

Is the resistor in series with the capacitor across which the reading of 600 was taken?

Try putting the resistor in series with the other capacitor and see if your reading ends up being low?

After than, swap the two capacitors and see if the reading is consistent with that.

Next, power the system up and record readings every, say, five to ten seconds for several minutes (or until the readings stop changing). What is the final reading? Next, reverse the capacitors and repeat the experiment.

Joined Feb 20, 2016
4,290
Yeah thanks for helping

Next I tried this with capacitors..
I connected two 100uF capacitors in series(in series with 220ohm resistor) between GND pin and +5V pin.I connected the ADC A4 pin at the the middle of the 2 capacitors. AREF = DEFAULT(+5V). But the ADC did not read 512 units. Instead it read ~600 units.
What must be the reason for this weird behavior ?
Why did you use a capacitive divider across DC? That is like using 2 very high value unknown resistors as you are relying on the leakage current. And the leakage resistance would not be identical I'd expect.
Most ADCs have a recommend source resistance and 100K would be too high, as has been mentioned before. Adding a tantulum cap from the mid point of the resistors to ground would help as it can supply the ADC instantaneous input current, but the response time will be long. It does depend what you are trying to measure. The cap to ground will be ok for slow changing values.

#### BobTPH

Joined Jun 5, 2013
6,554
Your measurement is off by 6 units out of 1023, or 0.6% off, and you are complaining? It is your expectation that is wrong, not the measurement.

Bob

Joined Jan 15, 2015
7,193
Read post #10 and more important understand what Dick is covering. Read the A/D input specifications for the Arduino Uno or more on base the actual chip used. Additionally as others have covered you are not exactly working with a precision divider.

Ron

#### WBahn

Joined Mar 31, 2012
28,519
So that initially when the capacitors are uncharged , Arduino Uno doesn't get damaged due to excess current
Not unreasonable.

You might put in two equal resistors, one attached to the power rail and one to the ground rail. That way whatever current is flowing will produce similar voltage drops in both halves of your divider. This would include the net residual leakage current.

Although I've alluded to it previously, capacitors make poor low frequency (e.g., DC) voltage dividers. All capacitors exhibit some degree of leakage and self-discharge currents and these are almost never well matched (not to mention highly dependent on all kinds of things). As a result, the initial DC charge won't be quite the same on them and the charge sharing will drift with time. Aluminum electrolytics are among the worst in this regard (though today's capacitors are a whole lot better than those from a few decades ago).