# Capacitor charge in an RC circuit

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:

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$$

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.

• You will make this question easier to understand if you explain what "E" represents in your equations. For example, add "where E is the power supply voltage" or "where E is the ADC reference voltage" after the first time you use E. – The Photon Jun 2 '16 at 16:04
• The trouble you will have amongst other things is that the ADC is a 100kOhm resistor connected to a 14pF capacitor, coupled with a couple of current sources. Because your circuit is similar in impedance, the ADC input is going to load it causing the signal to be attenuated. Try adding a unity gain (source follower) op-amp before the ADC input to buffer the signal. – Tom Carpenter Jun 2 '16 at 16:18
• @Tom Carpenter It took me some time to find an LTC1050 in order to use it as a voltage follower before the analog input. Regretably, it didn't work either. – user3060854 Jun 3 '16 at 9:35

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.

If I understand the question correctly, you are asking why the output signal is centered at $\frac{E}{2}$.

We can decompose the input signal into two components: DC component $V_{\text{DC}} = \frac{E}{2}$ and the square wave from $-\frac{E}{2}$ to $\frac{E}{2}$ (with zero DC offset). The sum of these two components equals to the square wave from $0$ to $E$, that is, to the original input signal. Here I assume that $t_{\text{high}} = t_{\text{low}}$; otherwise the DC component will be different (to be precise, the DC component equals to the integral of the input signal over the whole period).

RC circuits are linear. The linearity property allows us to compute the output for each component separately and then just take the sum. The sum will be exactly equal to the output you get for the original input signal.

Let's use this powerful technique.

1. Suppose that we feed the circuit with $V_{\text{DC}}$ alone. Then the output will be equal to the input, because the capacitor blocks direct current.

2. Suppose that we feed the circuit with a square wave with zero DC component, e.g. the symmetric square wave from $-\frac{E}{2}$ to $\frac{E}{2}$. Then the output will have zero DC component, too (this may require a separate explanation, but I will skip it for brevity). In other words, the output for this component will be centered around zero.

Taking the sum of two outputs, it's easy to see that the combined signal will be centered at $V_{\text{DC}}$ level.