Electronic – Capacitor charge in an RC circuit

capacitor

In order to study the behavior of an RC circuit, I connected a resistor and a capacitor to an Arduino's I/O as shown:

enter image description here

The Arduino digital Output feeds the circuit with a square pulse of 2 sec duration. (one second HIGH, one second LOW)

for a charge time of 1 sec:
$$V_c = E(1-e^{-\dfrac{t}{\tau}}) = E(1-e^{-\dfrac{1}{0.83}})=0.7E$$

where E is the power supply voltage

Converting E value to a 10bit range, $$V_c = 0.7 \times 1024 = 717$$

Now, this is the graph I take from the analog input:

enter image description here

whose minimum value is 237 (0.23E), and maximum value = 784 (0.76E).

Assuming that the capacitor's value may differ a little, I may accept that 0.70E = 0.76E. But in that case, shouldn't Vc start from zero?

Assuming that the capacitor is semi charged, shouldn't in any case max-min=0.7E? (Before initiating, I discharged the capacitor connecting it with a resistor for several seconds.)

Any thoughts would be appreciated.

EDIT:
Using several values of charge time, every time the graph seems to be positioned in the middle, meaning Vc(min)+Vc(max) = E/2.

Best Answer

You should view E as the difference between the current charge of the capacitor and its final value at t=∞. Since the capacitor isn't fully discharged when the pin turns on in your graph, you have some initial charge (or voltage) on the capacitor.

For most intents and purposes, you can take t=5T as the final value since you'll be within 99%; 1-e^-5=0.993. You should wait 5 time constants (Ts) between toggling the digital pin if you want to see a charge where Vc(0) ≈ 0.

You can plot this in your calculator for a sanity check. Suppose Vcc is 5V and you have 2.3V of charge on the capacitor initially (at t=0), your equation should be:

Vc(t)=(5-2.3)*(1-e^t/T)+2.3. 

You will see the same charging curve.

I'm swapping the terms "charge" and "voltage" a little recklessly here. Voltage = Charge/ Capacitance. They are somewhat interchangeable in terms of this explanation since there is a direct correlation.