Capacitor Recharges

Hi everyone!

I’m currently working on a project in which I am measuring the voltage of an capacitor with the Arduino ADC. Additionally I put in the option to switch between two methods of discharging with a NPN-Transistor: Discharging over the Analog Input of the Arduino, or discharging via a 370 Ohm resistor.

Basically it works , which is shown in the chart below. Whenever I switch to the resistor, the capacitor discharges fast, while it discharges slowly over the Analog Input of the Arduino.

But what confuses me, is that the capacitor “recharges” whenever I switch from the 370 Ohm resistor to the AnalogIn. This is also seen in the chart. Am I somehow charging the capacitor with my Arduino or is this some kind of electric effect I just don’t know about?

The analog input is not a resistor-to-ground. Unconnected, it can float-up or float-down to an undefined voltage and a capacitor won’t stop it from floating

The analog input is not a resistor-to-ground.

It is also not a resistor to positive either.
If you want it to be then enable the internal pull up resistor, with a pinMode call using INPUT_PULLUP. That will give you a 30 to 40K pull up resistor.

1.5F ? If that’s a supercap, they will “revive” from a discharge like a “dead” battery, discharge it down to 0.1V, leave it sitting with no connections for 10 minutes then test it again, bet you see a higher V.

pattex31:
Am I somehow charging the capacitor with my Arduino or is this some kind of electric effect I just don't know about?

The latter, "dielectric absorption". Supercaps have huge dielectric absorption, as Mike says they behave
rather like batteries, electrolytics have some absorption, really good film capacitors (teflon, polystyrene,
polypropylene) have very little.

An analog input has a few pF of capacitance but unless you try to take it above Vcc or below ground
(when the protection diodes kick in) it has effectively infinite input resistance, being a CMOS input.

outsider:
1.5F ? If that's a supercap, they will "revive" from a discharge like a "dead" battery, discharge it down to 0.1V, leave it sitting with no connections for 10 minutes then test it again, bet you see a higher V.

MarkT:
The latter, "dielectric absorption". Supercaps have huge dielectric absorption, as Mike says they behave
rather like batteries, electrolytics have some absorption, really good film capacitors (teflon, polystyrene,
polypropylene) have very little.

Thank you! Yes it was a supercap but I never used one before. I had something like this in mind because this always happens with my phone's battery, but I have never seen that happening with a capacitor before.

Grumpy_Mike:
It is also not a resistor to positive either.
If you want it to be then enable the internal pull up resistor, with a pinMode call using INPUT_PULLUP. That will give you a 30 to 40K pull up resistor.

I don't intent to use it as a resistor, this setup was just for testing purposes. But if no other resistor is connected, the capacitor discharges via the AnalogIn of the Arduino, right?

the capacitor discharges via the AnalogIn of the Arduino, right?

No wrong.

It is a bit like putting a long wire on the end of the capacitor and expecting that to discharge it. Maybe if you did the experiment in a screened electronic anoconic chamber you might cut down enough stray fields so the the induced signals were less than the induced pickup but I doubt it.

One of my old professors ( English use of the term not American once ) tried to measure the open loop gain of an op amp in our electrically screened room but failed due to the fact that his instruments were mains powered. This was in the days before battery operated oscilloscopes.

Grumpy_Mike:
No wrong.

It is a bit like putting a long wire on the end of the capacitor and expecting that to discharge it.

Sorry, I don't really get it... Are you saying, that the voltage drops because of self-discharge?

Since I want to measure the voltage of a capacitor, I want to know how much I will discharge it with my Arduino Nano as a voltmeter. I thought I could simply charge a capacitor, connect it to GND and A0, and measure the discharge curve. Out of that I calculate the approximate resistance of my Arduino, which transfers into a current depending on the input Voltage.

I want to know how much I will discharge it with my Arduino Nano as a voltmeter.

The technical answer to that is “bugger all”. Especially of a capacitor as huge as the one you are using.

Still if you want to know the input impedance of the analogue input just look at the data sheet. it says:-

RAIN Analog Input Resistance 100 MΩ typical

So there is a quantity known as the time constant for an RC circuit.

A capacitor will never truly discharge but after about three time constants you can consider it mostly discharged.

For your situation your time constant is 1.5 * 100 MΩ = 1500,000,000 seconds or 4.82 years so three time constants show your capacitor will be discharged in about 14 1/2 years.

Usually I don't use a supercap, this was just for testing it with low resistance. But that is what I wanted to hear :slight_smile:

Thanks for your replies and sorry for getting a little off-topic!

Grumpy_Mike:
The technical answer to that is “bugger all”. Especially of a capacitor as huge as the one you are using.

Still if you want to know the input impedance of the analogue input just look at the data sheet. it says:-
So there is a quantity known as the time constant for an RC circuit.
Time constant - Wikipedia
A capacitor will never truly discharge but after about three time constants you can consider it mostly discharged.

For your situation your time constant is 1.5 * 100 MΩ = 1500,000,000 seconds or 4.82 years so three time constants show your capacitor will be discharged in about 14 1/2 years.

1/ a simple R-C discharge decays by 0.693 x per timeconstant, so in three time constants
it’ll only decay to 0.33. I normally reckon >10 timeconstants (0.025)to be nearly done.

2/ 1500,000,000 seconds is about 48 years… you mean 150,000,000 seconds.

Allan