Sub topic 7
Charging a Capacitor: The RC Step Response
This chapter assumes you know Ohm's law, KVL and KCL, series and parallel resistors, Thevenin equivalents, basic calculus, and what a first-order linear differential equation looks like. Earlier chapters gave the capacitor relation i = C dv/dt, the rule that capacitor voltage cannot jump, and the first-order equation from KVL. Here we use them to solve the charging problem completely.
The setup
A step response is what a circuit does when a source switches from one constant level to another at t = 0 and stays there. For the RC circuit, a DC source V is connected through a resistor R to a capacitor C. The capacitor starts with initial voltage V0.
The step response is the simplest case where the output is neither zero nor constant. It also shows the pattern used by every first-order transient: start at an initial value, move toward a final value, and set the pace with a time constant.
Deriving the differential equation
Apply KVL around the loop for t > 0. The source voltage equals the resistor drop plus the capacitor voltage:
V = R i + v_C
The capacitor current is i = C dv_C/dt. Substituting gives
RC dvC/dt + vC = V
Divide by RC and write tau = RC:
dvC/dt + vC/tau = V/tau
This is a first-order linear equation with a constant forcing term. Equivalently, dvC/dt = (V − vC)/tau. The rate of change is proportional to the remaining gap between the source voltage and the capacitor voltage. A large gap means fast charging. A small gap means slow charging. That one sentence explains the whole curve shape.
Solving it
Solve by separating variables. Rearrange to
dvC / (V − vC) = dt / tau
Integrate from the initial state (t = 0, v_C = V0) to a general time t:
−ln(V − vC) evaluated from V0 to vC = t / tau
This gives ln[(V − V0)/(V − vC)] = t/tau. Solve for vC:
v_C(t) = V + (V0 − V) e^(−t/tau), for t ≥ 0
The result has two parts. The forced (steady-state) part is V, which is where the capacitor ends up. The transient part is (V0 − V) e^(−t/tau), which starts at the full initial gap and dies out.
The common case: starting from zero
If the capacitor starts uncharged (V0 = 0), the formula becomes
v_C(t) = V (1 − e^(−t/tau))
The current follows from i = C dv_C/dt:
i(t) = (V/R) e^(−t/tau)
The current jumps to V/R at t = 0+ and decays to zero. At t = 0+ the capacitor voltage is still zero, so the whole source voltage appears across the resistor and i = V/R. The capacitor voltage is continuous, but the current is not: it is zero before the switch closes and V/R just after.
The resistor voltage is vR = V e^(−t/tau), so vR + v_C = V at every instant, as KVL requires.
Reading the curve in units of tau
Because t appears only as t/tau, one curve describes every RC circuit. Only the time scale changes.
| Time | e^(−t/tau) | Fraction of final change reached |
|---|---|---|
| 0 | 1.000 | 0% |
| 1 tau | 0.368 | 63.2% |
| 2 tau | 0.135 | 86.5% |
| 3 tau | 0.050 | 95.0% |
| 4 tau | 0.018 | 98.2% |
| 5 tau | 0.0067 | 99.3% |
After one time constant the capacitor has covered 63.2% of the gap between its start and the final value. After five time constants it is within 1% of the final value. Engineers often treat the circuit as settled after 5 tau. Whether that is good enough depends on the application. A 12-bit converter needs about 8.3 tau to settle to within half a least significant bit (LSB), since ln(2^13) is about 9 for half an LSB of 12 bits, so 5 tau is not enough there.
The initial slope also has a useful property. The tangent to the curve at t = 0 reaches the final value exactly at t = tau. At t = 0 the slope is V/tau, so a line from the origin with that slope hits V at t = tau. This gives a quick way to sketch the curve: draw the tangent, mark tau, and draw an exponential that bends away from it.
Computing the curve
This program evaluates the response at whole multiples of tau for a 10 kΩ resistor, a 100 nF capacitor, and a 5 V step.
import math
R = 10e3 # ohms
C = 100e-9 # farads
V = 5.0 # volts, step source
tau = R * C # 1 ms
for k in range(6):
t = k * tau
v = V * (1 - math.exp(-t / tau))
print(f"t = {k} tau: v_C = {v:.3f} V")The output rises from 0.000 V at t = 0 to 3.161 V at one tau (63.2% of 5 V) and to 4.966 V at 5 tau.
Worked example: time to reach a threshold
A microcontroller input treats any voltage above 3.0 V as a logic high. It is driven from the 5 V step above through R = 10 kΩ and C = 100 nF. How long after the switch closes does the input read high?
Set v_C(t) = 3.0 V and solve:
3.0 = 5 (1 − e^(−t/tau))
e^(−t/tau) = 1 − 3/5 = 0.4
t = −tau ln(0.4) = tau × 0.916 = 0.916 ms
The general rule is t = tau ln[(V − V0)/(V − v_target)]. The target must lie between V0 and V. If it lies beyond V, the logarithm argument is negative or undefined, which tells you the capacitor never gets there.
Starting from a nonzero voltage
Suppose the same capacitor is charged to V0 = 1 V before the step. The general formula gives
v_C(t) = 5 + (1 − 5) e^(−t/tau) = 5 − 4 e^(−t/tau)
The time constant is unchanged, because tau depends only on R and C, not on the initial charge. The curve is the same shape but covers a smaller gap (4 V instead of 5 V). The same formula works if V0 is larger than V. Then (V0 − V) is positive and the capacitor discharges toward V from above. Charging and discharging are the same equation with different signs.
Checking numerically
You can test the analytic result by integrating dv/dt = (V − v)/tau with forward Euler and comparing it with the formula.
import math
R, C, V = 10e3, 100e-9, 5.0
tau = R * C
dt = tau / 100
steps = 500 # simulate 5 tau
v = 0.0
for _ in range(steps):
v += dt * (V - v) / tau # forward Euler on dv/dt = (V - v)/tau
t = steps * dt
exact = V * (1 - math.exp(-t / tau))
print(f"Euler: {v:.4f} V, exact: {exact:.4f} V")The two values agree to about three decimal places. Forward Euler with dt = tau/100 has a small error because it slightly underestimates the curve's growth. A step larger than 2 tau makes this method unstable, so keep dt well below tau.
Energy and power during charging
The source delivers energy at rate V i. The total energy supplied is
E_source = ∫ V i dt = V × Q = C V²
since the total charge moved is Q = C V. The energy stored in the capacitor at the end is
E_C = (1/2) C V²
The resistor dissipates the rest:
E_R = ∫ i² R dt = (V²/R)² R × (tau/2) ... which simplifies to (1/2) C V²
So half of the energy from the source is stored and half is lost as heat in the resistor. This 50% split does not depend on the value of R. A smaller R charges faster and draws more peak current, but the dissipated energy is the same. Only a different charging method, such as ramping the source slowly, can reduce the loss.
Common errors
- Using tau = R C with the wrong R. In a larger network, R is the Thevenin resistance seen by the capacitor, not the source resistor alone.
- Applying the step formula for t < 0. The expression holds only for t ≥ 0. Before the switch closes, the capacitor sits at V0.
- Assuming the current is continuous. Only v_C is. The resistor current jumps at t = 0.
- Declaring the circuit "done" at exactly one tau. At one tau the capacitor is only 63% of the way there.
- Mixing units. Use ohms, farads, and seconds. A 10 kΩ resistor with 100 nF gives 1 ms, not 1 s.
Summary of the method
- Write v_C(0+) = V0, using continuity.
- Find the final value v_C(infinity) by treating the capacitor as an open circuit.
- Find tau = Req C, with Req seen from the capacitor terminals with sources zeroed.
- Write vC(t) = vfinal + (V0 − v_final) e^(−t/tau).
Exercise
A 4.7 µF capacitor, initially at 2 V, is charged through a 2.2 kΩ resistor from a 9 V source starting at t = 0. Find tau, the capacitor voltage at t = 10 ms, and the time at which the voltage reaches 8 V.
Show answer
tau = R C = 2200 × 4.7e-6 = 10.34 ms. The formula is vC(t) = 9 + (2 − 9) e^(−t/tau) = 9 − 7 e^(−t/tau). At t = 10 ms, t/tau = 0.967, e^(−0.967) = 0.380, so vC = 9 − 7 × 0.380 = 6.34 V. For 8 V: 7 e^(−t/tau) = 1, so e^(−t/tau) = 1/7, and t = tau ln 7 = 10.34 ms × 1.946 = 20.1 ms.
Exercise
A 1 µF capacitor is charged from 0 V to a 10 V source through 1 kΩ. How much energy does the source supply, how much is stored in the capacitor, and how much is dissipated in the resistor? What changes if R is raised to 10 kΩ?
Show answer
The source supplies C V² = 1e-6 × 100 = 100 µJ. The capacitor stores (1/2) C V² = 50 µJ. The resistor dissipates the other 50 µJ. With R = 10 kΩ, charging takes ten times longer (tau = 10 ms instead of 1 ms), but the energy split is the same: 100 µJ supplied, 50 µJ stored, 50 µJ dissipated.