Deriving the formula from 'scratch' for charging a capacitor

So the formula for charging a capacitor is:

$$v_c(t) = V_s(1 - exp^{(-t/\tau)})$$

Where $V_s$ is the charge voltage and $v_c(t)$ the voltage over the capacitor.

If I want to derive this formula from 'scratch', as in when I use Q = CV to find the current, how would I go about doing that?

Same with the formula for discharge:

$$V_c(t) = V_s \cdot e^{(-t/\tau)}$$

• There are pages and pages on the internet helping you solve this. Such as here: dev.physicslab.org/… Commented Oct 18, 2016 at 11:59
• What Andy says and also all books about the basics of electronics worth their salt will explain this. Commented Oct 18, 2016 at 12:06
• Current is the rate of change of charge. Taking a derivative of both sides of Q=CV then gives us I=cdV/dt. Then work the equation from there. Commented Oct 18, 2016 at 13:16

simulate this circuit – Schematic created using CircuitLab

It's a pretty straightforward process. There are three steps:

1. Write a KVL equation. Because there's a capacitor, this will be a differential equation.
2. Solve the differential equation to get a general solution.
3. Apply the initial condition of the circuit to get the particular solution. In this case, the conditions tell us whether the capacitor will charge or discharge.

Let's go through this. Instead of using an actual step function, I'm going to use a DC input and assume the capacitor starts out discharged. First, you write a KVL equation:

$$V_i = v_R + v_C$$

In circuit analysis, we like to use current instead of charge. So instead of $Q = CV$, we use $i = C \frac {dV}{dt}$. The resistor and capacitor share the same current, so:

$$i_R = i_C = C \frac {dv_C}{dt}$$

You can put this into the KVL equation:

$$v_R = Ri_R = Ri_C = RC \frac {dv_C}{dt}$$ $$V_i = RC \frac {dv_C}{dt} + v_C$$

This is a first-order linear differential equation. Using, some algebra, you can rearrange it into a solvable form:

$$RC \frac {dv_C}{dt} = V_i - v_c$$ $$\frac {dv_C} {V_i - v_C} = \frac {dt} {RC}$$

Integrating both sides gives:

$$-\ln (V_i - v_C) = \frac t {RC} + C_0$$

You can get rid of the $\ln$ by moving the negative sign and making both sides a power of $e$:

$$V_i - v_C = e^{-t/RC + C_0} = e^{-t/RC}e^{C_0}$$

$C_0$ is a constant of integration, so $e^{C_0}$ is also a constant. Let's rename it to $C_1$ for convenience:

$$V_i - v_C = C_1e^{-t/RC}$$

The differential equation is solved, but there's still an unknown ($C_1$). You can find its value if you know the initial condition of the circuit. In this case, I said that the capacitor started out discharged ($v_C = 0$ at $t = 0$), so let's use that:

$$V_i - 0 = C_1e^{-0/RC} = C_1 \cdot 1$$ $$C_1 = V_i$$

Now you can find the fully-solved equation:

$$V_i - v_C = V_ie^{-t/RC}$$ $$v_C = V_i - V_ie^{-t/RC}$$ $$v_C = V_i(1 - e^{-t/RC})$$

Is this correct? At $t=0$, you have:

$$v_C = V_i(1 - 1) = 0$$

and at $t=\infty$, you have:

$$v_C = V_i(1 - 0) = V_i$$

So the capacitor starts out discharged, ends up fully-charged, and in between there's an exponential decay. That's correct!

For the discharge, $V_i = 0$ and the initial condition is that the capacitor is charged to a nonzero value, which I'll call $V_0$. You can use these to solve for $C_1$ again:

$$0 - V_0 = C_1e^{-0/RC}$$ $$C_1 = -V_0$$ $$-v_C = -V_0e^{-t/RC}$$ $$v_C = V_0e^{-t/RC}$$

• As has been said by others: Your development is in any book about electrical circuits and in thousands of websites Commented Oct 18, 2016 at 20:51

As an alternative to the classical texts approaching, please consider the following alternative derivation (and interpretation) that I developed a few years ago in order to motivate the students. It is related to the discretization of the RC circuit when the input is a voltage step (magnitude V) for $t \geq 0$.

Applying the Euler forward method to this first order differential equation, with $k = 0,1,2,..., N$ (where $N$ is the number of intervals and $\Delta t$ is very small):

$$\frac{v_c(k+1)- v_c(k)}{\Delta t} \approx \frac{dv_c(t)}{dt}\mid _{t=k\Delta t}$$ or $$v_c(k+1)= v_c(k)+(\frac{V-v_c(k)}{RC})\Delta t$$ Physical interpretation:

$\frac{V-v_c(k)}{R}$: The current taken as constant on $\Delta t$ interval.

$(\frac{V-v_c(k)}{R})\Delta t$: Change of capacitor charge at the end of interval (ie $\Delta q(k+1)$).

$(\frac{V-v_c(k)}{RC})\Delta t$: Change of capacitor voltage at the end of interval (ie $\Delta v_c(k+1)$).

Rearranging:

$$v_c(k+1)= \frac{V \Delta t}{RC} + (1-\frac{\Delta t}{RC})v_c(k)$$

Its possible to develop the terms of this difference equation for $k \ge 1$, considering, in this particular case, $v_c(0) = 0$: $$v_c(1) = \frac{V\Delta t}{RC}$$ $$v_c(2)= \frac{V \Delta t}{RC}+(1-\frac{\Delta t}{RC})\frac{V\Delta t}{RC}=\frac{V\Delta t}{RC}\left [1+(1-\frac{\Delta t}{RC}) \right]$$ $$v_c(3)=\frac{V \Delta t}{RC}\left [1+(1-\frac{\Delta t}{RC})+(1-\frac{\Delta t}{RC})^2 \right]$$ $$v_c(4)=\frac{V \Delta t}{RC}\left [1+(1-\frac{\Delta t}{RC})+(1-\frac{\Delta t}{RC})^2+(1-\frac{\Delta t}{RC})^3 \right]$$ ... $$v_c(k)=\frac{V \Delta t}{RC}\left [1+(1-\frac{\Delta t}{RC})+ ... +(1-\frac{\Delta t}{RC})^{k-1}\right]$$

The sum of first $k$ terms for a finite geometric series, leads to:

$$v_c(k)=V\left [1-(1-\frac{\Delta t}{RC})^k\right]$$

Since that $k=\frac{t}{\Delta t}$:

$$(1-\frac{\Delta t}{RC})^{\frac{t}{\Delta t}}=\left [(1-\frac{\Delta t}{RC})^{\frac{-1}{\frac{\Delta t}{RC}}} \right ]^{-\frac{t}{RC}}$$

Returning in the expression for $v_c(k)$ and taking the limit when $\Delta t \rightarrow 0$ (ie conversion from discrete time to continuous time): $$\lim_{\Delta t\rightarrow 0}v_c(k)=V \left \{1-\left [\lim_{\Delta t\rightarrow 0}(1-\frac{\Delta t}{RC})^{\frac{-1}{\frac{\Delta t}{RC}}} \right ]^{\frac{-t}{RC}} \right \}$$

Remembering an alternative definition of Euler's number ($e$):

$$\lim_{\Delta t\rightarrow 0}(1-\frac{\Delta t}{RC})^{\frac{-1}{\frac{\Delta t}{RC}}} = e$$ Finally: $$v_c(t)=V(1-e^{\frac{-t}{RC}})$$

• holy crap this is amazing!
– Duck
Commented Aug 9, 2018 at 19:50
• @SpaceDog: If my effort at helping was helpful, you could reciprocate by voting up on my answer. Commented Aug 10, 2018 at 22:55
• The standard solution involving calculus is much more elegant, I find. This is needlessly convoluted. Commented Dec 13, 2018 at 17:09
• @Noldorin: As was stated at the beginning of my answer, this is an alternative approach. The beauty is in connecting key concepts such as difference equations, progressions and limits. Not just to copy the standard solution that is in any book of Calculus or Electrical Circuits (in other words, to those who enjoy mathematics). Commented Jan 3, 2019 at 13:28
• I enjoy mathematics, but find this inelegant. Sorry. Personal opinion. Commented Jan 3, 2019 at 15:33