Solving circuits with state variables
A simulator can show a circuit that oscillates and grows without limit when the real circuit settles quietly. The state form explains how a simulator simulates, and why it is sometimes wrong.
01What the state of a circuit is
To predict what a circuit will do from some instant onward you do not need to know its entire history: it is enough to know how much energy each element that can store energy holds. That minimal information is the state, and in an electric circuit it has a natural choice: the capacitor voltages and the inductor currents, which are precisely the quantities that cannot jump suddenly.
The number of state variables is the order of the circuit: an RC is first order, an RLC second order. It coincides with the number of poles that were counted in the \( s \)-plane.
02The state equations
Writing Kirchhoff’s laws so that each equation solves for the derivative of one state variable, the whole circuit becomes a system of first-order differential equations, in matrix form:
For the series RLC of the transient response unit, with \( x_1 = v_C \) and \( x_2 = i_L \):
03The phase plane
With two state variables, the state at each instant is a point of the \( (v_C, i_L) \) plane, and the evolution of the circuit is a curve: the trajectory. An overdamped circuit reaches equilibrium along a curve with no turns; an underdamped one, along a spiral. Looking at the trajectory shows at a glance how the energy is shared between the capacitor and the inductor at each moment.
04Solving step by step: this is how a simulator simulates
The state form lends itself to solving the circuit numerically, advancing in small time steps \( h \). The simplest method, Euler’s, uses the current derivative to take the step:
Series RLC of 1 mH and 100 nF connected to 5 V. On the left, the phase plane; on the right, \( v_C(t) \). In gray the exact solution, computed with residues; in color, the numerical integration with the chosen method and step.
Real simulators do not use explicit Euler but implicit methods —trapezoidal, Gear’s— that are stable with any step, and they also adjust \( h \) by themselves: they shrink it where the signal changes quickly and enlarge it where nothing is happening. When a SPICE simulation aborts with “timestep too small,” what it is saying is that it could not find a step small enough to follow the circuit.
05Where it shows up in electronics
| Case | What the state form contributes |
|---|---|
| Transient analysis in SPICE | Numerically integrates the state variables of the whole circuit |
| Control of a switching converter | The averaged state-space model is the basis of loop design |
| Nonlinear or time-varying circuits | Where Laplace does not apply, the state form keeps working |
| Firmware of a digital filter or an observer | Directly implements \( \mathbf{x}_{k+1} = \mathbf{A}_d\mathbf{x}_k + \mathbf{B}_d u_k \) on a microcontroller |
06In the lab
Calculate the eigenvalues of \( \mathbf{A} \) for R = 60 Ω and compare them with the poles given by the transient response lab for the same resistance.
Using this page’s lab, find for each value of R the step beyond which Euler becomes unstable, and verify the criterion \( h < 2\zeta/\omega_n \).
Program Euler’s method for the RLC in Python or C and plot \( v_C(t) \). Repeat with the trapezoidal method and compare the stability with the same step.
07Common mistakes
- Choosing as state quantities that can jump. The current of a capacitor or the voltage of an inductor are not good state variables.
- Counting the order wrong. Two capacitors in parallel are a single state; the order is the number of independent storage elements.
- Trusting a simulation without looking at the step. A result that oscillates and grows can be a numerical artifact and not the circuit.
- Believing that shrinking the step is always enough. It improves accuracy, but with explicit methods and widely separated poles the cost becomes prohibitive; that is why implicit methods exist.
08Self-assessment
Which state variables are chosen in an electric circuit?
The capacitor voltages and the inductor currents.
What is the relationship between the matrix A and the poles?
The eigenvalues of A are the poles of the circuit.
What shape does the trajectory of an underdamped circuit have in the phase plane?
A spiral that converges to the equilibrium point.
When is Euler’s method stable for the RLC?
When \( h < 2\zeta/\omega_n \).
Why do simulators use implicit methods?
Because they are stable with any step, which allows large steps where the signal changes little.
09Further reading
- Katsuhiko Ogata. Modern Control Engineering. 5th ed., Prentice Hall, 2010 (Spanish edition, “Ingeniería de control moderna”, Pearson). The state-space representation, its solution and the relationship with the transfer function.
- Leon O. Chua and Pen-Min Lin. Computer-Aided Analysis of Electronic Circuits. Prentice Hall, 1975. The classic book on how simulators integrate the state equations and why they choose implicit methods.
- Charles K. Alexander and Matthew N. O. Sadiku. Fundamentals of Electric Circuits. 7th ed., McGraw-Hill, 2021. The introduction to state variables in circuits, with worked examples.