Sub topic 3
From KVL to a first-order differential equation
This chapter assumes you can write Kirchhoff's laws for a resistive circuit, reduce a resistor network to a Thevenin equivalent, and take a derivative of an exponential. You should also know what a first-order linear differential equation looks like. The goal is to turn a circuit with one capacitor or one inductor into a single equation of the form dx/dt + x/tau = f(t). Later chapters solve that equation. Here we only build it, and we check that it is correct.
Why one storage element gives a first-order equation
A resistor relates voltage and current with no memory: v = R i. A capacitor and an inductor relate them through a derivative:
- Capacitor:
i = C dv/dt - Inductor:
v = L di/dt
Write Kirchhoff's voltage law (KVL) or current law (KCL) around a circuit with one such element. You get one equation that holds the unknown and its first derivative. No second derivative appears, so the equation is first order. The number of independent energy-storage elements sets the order of the circuit. Capacitors that can be merged by series or parallel rules count as one. So do inductors that can be merged.
Choosing the unknown
Pick the quantity that stores the energy. For a capacitor that is the voltage v_C, and for an inductor it is the current i_L. There are two reasons:
- Energy is
(1/2) C v_C^2or(1/2) L i_L^2, so these quantities describe the stored state of the circuit. - They cannot jump when a switch operates, so the initial condition at the switching instant is known from the circuit before the switch.
You can solve for another variable, such as the loop current in an RC circuit. That route needs the derivative of the source and an initial condition that you must compute separately. It is rarely worth it.
Series RC circuit driven by a source
Take a source v_s(t), a resistor R, and a capacitor C in one series loop. Let i flow around the loop, and let v_C be the capacitor voltage with the passive sign convention. The current enters the positive terminal.
KVL around the loop gives:
v_s = R i + v_C
The capacitor relation gives i = C dv_C/dt. Substitute it:
R C dv_C/dt + v_C = v_s(t)
Divide by RC and define tau = RC:
dv_C/dt + v_C/tau = v_s(t)/tau
The unknown is v_C(t). The source appears only as the right-hand side, called the forcing term.
Series RL circuit driven by a source
Use the same loop, with an inductor L in place of the capacitor. The inductor relation is v_L = L di/dt. KVL gives:
v_s = R i + L di/dt
Divide by R and define tau = L/R:
di/dt + i/tau = v_s(t)/(L) is the form you get if you divide by L. Dividing by R instead gives a form with the same shape as the RC case:
tau di/dt + i = v_s(t)/R
The two forms are the same equation. The second makes the steady-state current v_s/R visible directly.
Source-free circuits
If the source is zero, or has been disconnected by a switch, the forcing term vanishes. The circuit holds only energy stored earlier.
For a capacitor connected across a resistor, KCL at the top node says the capacitor current plus the resistor current is zero:
C dv/dt + v/R = 0, which is dv/dt + v/tau = 0 with tau = RC.
For an inductor in a loop with a resistor, KVL says L di/dt + R i = 0, which is di/dt + i/tau = 0 with tau = L/R.
These homogeneous equations lead to the natural responses in the next two chapters. Notice that they are the driven equations with f(t) = 0. You do not need a separate derivation for them.
The common standard form
Both circuits have the same structure, so one template covers them:
dx/dt + x/tau = f(t)
| Circuit | State variable `x` | `tau` | Forcing `f(t)` for a series source |
|---|---|---|---|
| Series RC | `v_C` | `R C` | `v_s(t)/tau` |
| Series RL | `i_L` | `L/R` | `v_s(t)/L` |
| Source-free RC or RL | `v_C` or `i_L` | `R C` or `L/R` | `0` |
Constant forcing is the most common case, which is a step from a DC source. Then f is a constant and the equation has a constant right-hand side. The steady-state value of x is the value where dx/dt = 0, which gives x_final = tau f. For the RC case that is v_s, and for the RL case it is v_s/R.
Larger circuits: reduce first
A circuit with many resistors but one storage element still gives a first-order equation. Remove the storage element and find the Thevenin equivalent V_th, R_th of everything it connects to. The reduced circuit is a series loop of V_th, R_th, and the element. For a capacitor:
R_th C dv_C/dt + v_C = V_th
For an inductor:
(L/R_th) di_L/dt + i_L = V_th/R_th
So tau = R_th C or tau = L/R_th, where R_th is the resistance seen by the storage element with independent sources turned off. A later chapter treats this resistance in detail. For now, remember that the derivation does not change. Only the resistor value does.
Worked example
A 5 V step is applied to R = 10 kohm in series with C = 100 nF. Then tau = R C = 10e3 * 100e-9 = 1 ms, and the equation is:
(1 ms) dv_C/dt + v_C = 5
Test the candidate v_C(t) = 5 (1 - e^(-t/tau)) for t >= 0:
dv_C/dt = (5/tau) e^(-t/tau), sotau dv_C/dt = 5 e^(-t/tau).- Adding
v_C = 5 - 5 e^(-t/tau)gives5. The equation is satisfied. - At
t = 0,v_C = 0, which matches an initially uncharged capacitor.
The next code block repeats this check numerically. It evaluates tau dv/dt + v using a central difference and compares it with the source voltage.
import math
R = 10e3 # ohms
C = 100e-9 # farads
V = 5.0 # volts, step source
tau = R * C # 1 ms
def v(t):
return V * (1 - math.exp(-t / tau))
h = tau * 1e-4 # small step for the central difference
for k in range(5):
t = (k + 0.5) * tau
dv = (v(t + h) - v(t - h)) / (2 * h)
lhs = tau * dv + v(t)
print(f"t = {t * 1e3:.2f} ms: tau*dv/dt + v = {lhs:.6f} V (source = {V} V)")Every line prints 5.000000 V for the left side. If you change the candidate to V * (1 - math.exp(-t / (2 * tau))), the left side no longer equals the source, and the check fails. That is the point of the check: a wrong tau is caught immediately.
Common errors
Other mistakes that appear often:
- Using the wrong resistance. In a multi-resistor circuit,
Rintauis the Thevenin resistance at the storage element's terminals, not the nearest resistor and not the sum of all resistors. - Mixing units.
Rin kohm andCin microfarads givestauin milliseconds. Convert to base units before you compute, or track the prefixes explicitly. - Forgetting that the equation applies per interval. The equation holds while the switch position is fixed. After a switch operates, the circuit has a new
R_th, a new forcing term, and possibly a differenttau. You write a new equation and use the old solution's value at the switching instant as the initial condition. - Dividing by the wrong constant. For the RL loop,
L di/dt + R i = v_sbecomestau di/dt + i = v_s/Ronly after dividing byR. Dividing byLgivesdi/dt + (R/L) i = v_s/L. Both are valid, but do not combine pieces of the two.
Checking an equation before solving it
Three quick checks catch most derivation mistakes:
- Units. In
tau dx/dt + x = x_final, every term has the units ofx.taumust be in seconds. - Steady state. Set
dx/dt = 0. A capacitor should act as an open circuit and an inductor as a short circuit, so you must recover the DC answer you would get by inspection. - Sign of the decay. In the source-free equation, the coefficient of
xmust be positive when written asdx/dt + x/tau = 0. A passive circuit cannot generate energy, so its natural response must decay.
Exercise
A 10 V source is in series with R = 50 ohm and an inductor L = 20 mH. Write the KVL equation for the current i(t), put it in the form tau di/dt + i = (forcing), and give tau and the steady-state current.
Show answer
KVL gives 10 = 50 i + 0.02 di/dt. Divide by 50: (0.02/50) di/dt + i = 10/50, so 0.4 ms di/dt + i = 0.2 A. Therefore tau = L/R = 0.4 ms and the steady-state current is 0.2 A (found by setting di/dt = 0).
Exercise
A capacitor C = 2 uF is connected across a resistor R = 5 kohm, with no source. Write the differential equation for v(t) using KCL, and state tau. What goes wrong if you write i_C = -C dv/dt together with the resistor current v/R flowing out of the same node?
Show answer
KCL at the top node, with both currents leaving the node, gives C dv/dt + v/R = 0, so dv/dt + v/tau = 0 with tau = RC = 5e3 * 2e-6 = 10 ms. If you write i_C = -C dv/dt for a current leaving the node, you count a sign flip twice. The equation becomes -C dv/dt + v/R = 0, which gives dv/dt = +v/tau and a growing exponential. A passive circuit cannot do that, so the sign is wrong.