Physical plants and classical controllers are designed in continuous time using differential
equations and the Laplace transform. Microcontrollers, however, execute discrete update loops
at a fixed sampling period
Choosing the right discretization method is critical. A poor choice can push stable poles outside the unit disk, introduce spurious resonances, or distort the DC gain — all of which degrade closed-loop performance or cause instability on hardware.
A continuous-time LTI system obeys
where
matches the continuous solution at sample instants
Assuming the input is held constant between samples (true for a DAC or PWM), the exact solution is
Van Loan (1978) observed that both quantities emerge from a single matrix exponential of the
augmented
The upper-left
The Tustin method replaces the Laplace variable via
Setting
Tustin maps the entire open left-half plane into the open unit disk, so it is stability-preserving by construction. It is the preferred method for discretizing controllers and filters when a specific corner frequency must be matched (after frequency prewarping).
The cheapest approximation — first-order rectangle rule:
Conditionally stable: poles may leave the unit disk when
Implicit first-order rule, equivalent to the
Unconditionally stable (maps the left-half plane into the unit disk) but introduces phase lag relative to the true system.
| Method | Time | Space | Notes |
|---|---|---|---|
| ZOH |
|
One matrix exponential via scaling/squaring | |
| Tustin | One |
||
| Forward Euler | Pure matrix multiply + add | ||
| Backward Euler | One |
All working memory is allocated on the stack; no heap is used.
Consider a scalar integrator
ZOH:
So
Tustin (
Both methods agree exactly for a pure integrator, as the bilinear transform maps the pole at
-
Singular matrix — Tustin and Backward Euler require solving
$(\alpha I - A)$ and$(I - A,T_s)$ , respectively. If$A$ has an eigenvalue exactly at$\alpha$ (Tustin) or$1/T_s$ (Backward Euler), the system matrix is singular. The LU factorisation will flag degeneracy; the caller should validate the sample rate. -
Large
$T_s$ with Forward Euler — For a mode with time constant$\tau$ , Forward Euler is stable only when$T_s < 2\tau$ . Exceeding this causes poles to flip outside the unit circle and the discrete simulation diverges. -
Frequency warping (Tustin) — The Tustin transform compresses the entire imaginary
axis into the unit circle, warping frequencies above
$\pi/T_s$ . To match a specific analogue frequency$\omega_0$ , prewarp: use$\alpha = \omega_0 / \tan(\omega_0 T_s / 2)$ instead of$2/T_s$ . - Numerical conditioning — For systems with eigenvalues spanning many decades, the augmented matrix exponential (ZOH) may suffer cancellation. Scaling the system before discretisation improves accuracy.
-
Frequency prewarping — Modify
$\alpha = \omega_c / \tan(\omega_c T_s / 2)$ before Tustin to preserve the gain at a critical frequency$\omega_c$ exactly. - Generalised hold functions — Higher-order holds (first-order hold, triangular hold) modify the ZOH integral; each requires its own augmented block.
-
Sampled-data
$H_\infty$ — Discretisation under a minimax criterion rather than exact ZOH; accounts for inter-sample behaviour explicitly.
- Embedded control — Convert a continuous PID or LQR design to a discrete update law running at a fixed ISR rate.
- Digital filter design — Convert an analogue prototype (Butterworth, Chebyshev) to a discrete IIR filter using Tustin with prewarping.
- Simulation — ZOH discretisation yields exact step-response simulation for piecewise- constant inputs, enabling hardware-in-the-loop testing without numerical ODE integration.
-
MatrixExponential — The ZOH method is entirely built on
expmof the Van Loan augmented block; the exponential accuracy directly sets the ZOH accuracy. -
LinearTimeInvariant — Both input and output are
LinearTimeInvariantstructs; the discrete model drops straight into the state-update loop. -
LU decomposition / Gaussian elimination — Tustin and Backward Euler need one
$n \times n$ factorisation each; an inline partial-pivoting LU is used to keep the module self-contained.
- C. F. Van Loan, "Computing Integrals Involving the Matrix Exponential," IEEE Transactions on Automatic Control, 23(3), pp. 395–404, 1978.
- G. Franklin, J. D. Powell, M. L. Workman, Digital Control of Dynamic Systems, 3rd ed., Addison-Wesley, 1997.
- C. Moler and C. Van Loan, "Nineteen Dubious Ways to Compute the Exponential of a Matrix, Twenty-Five Years Later," SIAM Review, 45(1), pp. 3–49, 2003.