A controller designed as C(s) must become a difference equation before it can run, and the sample-and-hold around it delays the loop by about half a period. The motor lab's lead experiment shows both effects with one setting, the controller period.
Two ways to turn C(s) into code
The zero-order-hold (step-invariant) equivalent assumes the controller's input is held constant between samples and reproduces its step response exactly at the sampling instants. The lab's lead uses it: for C(s) = K(s+z)/(s+p) it computes u = K(e + (z − p)w) and then updates w ← e^(−pT)w + (1 − e^(−pT))e/p. Tustin's substitution s = (2/T)(z − 1)/(z + 1), the bilinear transform, comes from the trapezoidal rule. It maps the whole imaginary axis onto the unit circle, keeps a stable C(s) stable, and matches the frequency response closely well below the Nyquist frequency π/T.
Half a sample of delay
Whatever the controller, the held command is a staircase that trails the smooth signal it stands for by T/2 on average, so the loop loses about ωcT/2 radians of phase at crossover. The motor with the lesson's lead, C(s) = 2(s+4)/(s+8), crosses over at 16.7 rad/s with a 59.1° phase margin when everything is continuous. The table compares that estimate with the sampled loop as the lab builds it and with a Tustin version of the same lead, both on the same discrete motor model.
The estimate tracks the Tustin column within 0.4° up to 40 ms and is 2.8° pessimistic at 80 ms, where ωcT = 1.3 is no longer small. The lab's column loses more as T grows: 0.4°, 0.9°, 2.3° and 6.0° below Tustin.
| Period | Samples per crossover period | Half-sample estimate | Lab (ZOH equivalent) | Tustin | Overshoot, 5 rad/s step |
|---|---|---|---|---|---|
| 10 ms | 37.7 | 54.3° | 53.9° | 54.3° | 7.3% |
| 20 ms | 18.8 | 49.5° | 48.7° | 49.6° | 12.2% |
| 40 ms | 9.4 | 39.9° | 37.9° | 40.3° | 24.4% |
| 80 ms | 4.7 | 20.8° | 17.7° | 23.6° | 52.7% |
Why the lab's version loses more
At 16.7 rad/s the continuous lead has a gain of 1.85 and a phase of 12.1°. The step-invariant version keeps the phase within about half a degree, but its gain grows with the period, to 1.89, 1.93, 2.01 and 2.18, while Tustin's stays between 1.86 and 1.89. The extra gain moves the crossover up, from 16.0 rad/s with Tustin to 17.5 rad/s with the lab's version at 80 ms, where the half-sample lag is larger. The step-invariant mapping is exact when the input really is a staircase, as it is for the plant behind a hold; a controller's input is a sampled measurement of a smooth signal, which is why Tustin usually fits a controller better.
When does the period start to hurt? With ωc = 16.7 rad/s, 10 ms costs 4.8° and 20 ms 9.6°: about 19 samples per crossover period keeps the hold under 10°. At 40 ms the cost is 19.1° and at 80 ms 38.2°, and with fewer than five samples per period the sampled design no longer resembles its continuous parent. A practical budget is ωcT ≤ 0.3, about 9°.
Try it
Open the Lead experiment and the frequency workbench, and set Target to 5 rad/s and Load torque to 0 so that the requested voltage stays below 12 V. Step Controller period through 10, 20, 40 and 80 ms: the phase margin reads 53.9°, 48.7°, 37.9° and 17.7°, and the speed rises 7.3%, 12.2%, 24.4% and 52.7% above the target. The lab offers only the step-invariant lead; the Tustin column comes from the same discrete motor model with the controller swapped. The Controller clock experiment repeats the comparison with a PID.
Limits
These numbers assume the command goes out at the sampling instant. A controller that needs a whole period to compute loses another ωcT. An anti-aliasing filter adds its own lag, and Tustin compresses frequencies near π/T, which pre-warping corrects at one chosen frequency only. The workbench excludes saturation and load, and the overshoot figures hold for the 5 rad/s step, where the voltage stays inside its limit.
Budget about ωcT/2 of phase for the hold before you discretize, keep ωcT small, and prefer Tustin for a controller fed with samples. Then check the margin of the sampled loop, not of the continuous one.
CHECK YOUR UNDERSTANDING: Your loop crosses over at 30 rad/s and you can spend 10° of phase margin on the hold. What is the longest sampling period?
10° is 0.175 rad = ωcT/2, so T = 2 × 0.175/30 = 11.6 ms, before any computation delay.