C9 · Lesson 46 · Discretizing continuous systems
Turning a differential equation into a difference equation
Controllers are designed with Laplace transforms, but they run on microcontrollers that see the world one sample at a time. Simulators face the same problem in reverse: a circuit is a differential equation, and a computer can only step it. Every conversion from continuous to discrete time is an approximation of how the system behaves between samples, and the wrong one can make a perfectly stable system blow up.
- The smooth curve is a first-order system's step response, , plotted against the sample index n, with t = nT.
- The stems are two discrete versions. ZOH (zero-order hold) gives the exact values at every sample. Forward Euler, which steps along the slope, wanders off as aT grows.
- Push aT past 1: Euler overshoots and rings. Past 2 it diverges, although the real system is perfectly stable.
Predict
A first-order plant with a = 50 s⁻¹ is simulated by forward Euler with a 50 ms step. What happens?
It diverges. aT = 2.5, so Euler's pole is 1 − 2.5 = −1.5, outside the unit circle: each step flips the sign and grows by 1.5. Forward Euler is stable only for aT < 2, here a step under 40 ms, and accurate only for aT well under 1.
Name it
Pole mapping
Sampling a continuous mode every T seconds gives , so a continuous pole at s becomes a discrete pole at
The left half-plane maps inside the unit circle. A pole at lands at radius and angle .
Methods
| Method | Replace s with | Keeps |
|---|---|---|
| zero-order hold | exact solution with the input held constant between samples | the step response at the samples |
| forward Euler | nothing exactly; unstable for large T | |
| backward Euler | stability, always (it over-damps) | |
| Tustin (bilinear) | stability and the frequency response's shape (lesson 42) |
For , the ZOH equivalent is
For a state-space model , the ZOH equivalent is and .
The hold costs phase
A controller that outputs a held value updates T seconds apart; on average its output is T/2 late. That half-sample delay adds a phase lag of , which eats into the loop's phase margin. The usual rule is to sample at least 10 to 30 times faster than the closed loop's bandwidth.
Worked example
Discretize with a zero-order hold at T = 0.1 s.
Show the solution
- Discrete pole.
- Transfer function.
- Recursion.
- Check. Its DC gain is 0.0952/(1 − 0.9048) = 1, as the original's is, and its step response matches exactly at every sample.
Answer , or .
Worked example
A plant with a = 50 s⁻¹ is simulated with forward Euler. What step size keeps it stable, and what keeps it accurate to a few percent?
Show the solution
- Stability. Stability needs aT < 2, so T < 40 ms.
- Accuracy. The Euler pole should be close to the true one. At aT = 0.1:
- Step for accuracy. That difference compounds to a few percent in the time constant, so T ≈ 2 ms.
- Stable or right. Stable is a much weaker requirement than right.
Answer T < 40 ms keeps it stable, but it takes T ≈ 2 ms to be accurate to a few percent.
Worked example
A digital control loop crosses over at 100 Hz and samples at 2 kHz. How much phase does the hold cost at crossover?
Show the solution
- Hold delay. The hold's average delay is
- Phase lag at crossover.
- Effect on margin. A loop designed in continuous time with 45° of margin keeps only about 36°.
- Faster sampling. Sampling at 10 kHz would cut the loss to 1.8°.
Answer the hold costs 9° of phase at crossover.
Check
is discretized with a zero-order hold at T = 0.001 s.
(a)
Where is the discrete pole?
(b)
What is the coefficient on u[n − 1]?
Check
A plant pole is at s = −20, simulated by forward Euler.
(a)
What is the largest step that keeps it stable?
Write units the way you normally would: 1.5 ms, 1500 µs and 0.0015 s are the same answer.
(b)
What is the Euler pole with a 1 ms step?
Check
A continuous pole pair at is sampled every 0.01 s.
(a)
What radius do the discrete poles have?
(b)
At what angle?
Write units the way you normally would: 1.5 rad and 1500 mrad are the same answer.
Check
A loop crosses over at 100 Hz and samples at 1 kHz.
(a)
How much phase does the hold's half-sample delay cost at crossover?
(b)
How many samples per period of the crossover frequency is that?
Check
Apply forward Euler to with step T, starting from y[n] = y.
Step 1
What is y[n + 1]?
Type it the way you would write it, like 3sin(2πft) or 3*sin(2*pi*f*t). Angles can be in radians or carry a degree sign, like 45°.
Step 2
What factor multiplies y each step?
Step 3
Below what T does the factor stay between −1 and 1?
Check
Which discretization reproduces a system's step response exactly at the sample instants?
Explain why
Why can forward Euler turn a stable system unstable, when zero-order hold never does?
Zero-order hold solves the differential equation exactly over each step, assuming only that the input stays constant, so each continuous pole s becomes , which is inside the unit circle whenever s is in the left half-plane, for any step size. Forward Euler instead assumes the slope at the start of a step holds for the whole step. For a fast mode and a long step that overshoots: becomes , and once aT passes 2 the factor is below −1, so each step overshoots the equilibrium by more than the last. The real system decays; the approximation diverges, purely because the step was too long for the dynamics.
Practice
Keep practicing
7 kinds of problem on this topic, dealt one at a time with new numbers every time, for as long as you like.