Design in the z-Plane
The speed loop of Sampled-Data Loops was designed in continuous time and then converted for the microcontroller. That emulation approach works when the sample rate is 20 or more times the bandwidth. On a slow processor, with a slow network in the loop, or when you want the fastest response the sampling allows, it is better to design directly in discrete time: put the closed-loop poles where you want them in the z-plane. This lesson maps the familiar specifications (, , settling time) into the z-plane, designs a PI controller there by pole placement, and shows the extreme case, deadbeat control. Poles, zeros and stability in the z-plane are introduced in Signals and Systems.
Mapping specifications with
A continuous pole sampled every gives a discrete mode with
| s-plane | z-plane |
|---|---|
| left half-plane (stable) | inside the unit circle |
| imaginary axis | unit circle |
| constant decay rate (settling time ) | circle of radius |
| constant damped frequency | ray at angle |
| constant | logarithmic spiral from |
| (integrator) | |
| very fast poles | near the origin; is a pure one-sample delay |
Settling within samples means poles inside the circle of radius about . The angle must stay well below (a pole near the negative real axis oscillates at the Nyquist frequency, sample to sample, which the plant between samples shows as ripple).
Pole placement for a PI loop
For a first-order plant the ZOH equivalent is
A discrete PI with forward-Euler integral, with and , gives the closed-loop characteristic polynomial
Match it to the desired with , :
Deadbeat control chooses (both poles at the origin): the error of a step reaches zero in a finite number of samples (two here). It is the fastest possible linear response and needs the largest control signal; it also ignores what the plant does between samples and how robust the loop is.
Worked example: direct design of the motor speed PI
Given: the course motor approximated by its mechanical pole, ((rad/s)/V), (a slow loop, e.g. speed commands over a fieldbus).
Find: PI gains for with and , and for deadbeat; their step responses with the PI acting on the error () and as I-P control (, setpoint weighting), on the design model and on the full motor (with the electrical pole); the first voltage of a step.
Solve:
- , .
- : , , desired poles . Then , : , .
- : poles , , .
- Deadbeat: , : , . The first voltage after a step is , almost five times the supply.
Check:
import numpy as np
import control as ct
Ts = 2e-3
K, p = 49.75124, 106.1023
a, g = np.exp(-p * Ts), K * (1 - np.exp(-p * Ts))
J, b, Ra, La, k = 2e-6, 1e-6, 2.0, 1e-3, 0.02
models = {"1st-order model": ct.tf([g], [1, -a], Ts),
"full motor": ct.c2d(ct.tf([k], np.polyadd(np.polymul([J, b], [La, Ra]), [k * k])), Ts, 'zoh')}
designs = {}
for wn in (300.0, 600.0):
r, th = np.exp(-0.7 * wn * Ts), wn * Ts * np.sqrt(1 - 0.49)
designs[f"zeta 0.7, wn {wn:.0f}"] = (-2 * r * np.cos(th), r * r)
designs["deadbeat"] = (0.0, 0.0)
n = np.arange(0, 0.08, Ts)
for name, (c1, c2) in designs.items():
q0, q1 = (c1 + 1 + a) / g, (c2 - a) / g
print(f"{name}: Kp = {-q1:.4f}, Ki = {(q0 + q1) / Ts:.2f}, PI zero at z = {-q1 / q0:.3f}")
Cy = ct.tf([q0, q1], [1, -1], Ts) # acts on the measurement
for bw, Cr in (("b=1", Cy), ("b=0", ct.tf([q0 + q1, 0], [1, -1], Ts))): # b=0: I-P, no zero for r
for mname, Gd in models.items():
T = ct.feedback(Gd, Cy) * Cr
_, y = ct.step_response(T, T=n)
_, u = ct.step_response(Cr * ct.feedback(1, Cy * Gd), T=n)
ns = int(np.nonzero(abs(y - 1) > 0.02)[0][-1]) + 1
print(f" {bw}, {mname:15s}: overshoot {100 * max(0.0, y.max() - 1):5.1f} %, "
f"settled after {ns:2d} samples, first voltage for 300 rad/s {300 * u[0]:5.1f} V")zeta 0.7, wn 300: Kp = 0.0396, Ki = 12.43, PI zero at z = 0.615
b=1, 1st-order model: overshoot 16.9 %, settled after 9 samples, first voltage for 300 rad/s 19.3 V
b=1, full motor : overshoot 26.0 %, settled after 11 samples, first voltage for 300 rad/s 19.3 V
b=0, 1st-order model: overshoot 4.8 %, settled after 10 samples, first voltage for 300 rad/s 7.5 V
b=0, full motor : overshoot 7.8 %, settled after 9 samples, first voltage for 300 rad/s 7.5 V
zeta 0.7, wn 600: Kp = 0.0654, Ki = 32.64, PI zero at z = 0.501
b=1, 1st-order model: overshoot 32.4 %, settled after 4 samples, first voltage for 300 rad/s 39.2 V
b=1, full motor : overshoot 58.3 %, settled after 12 samples, first voltage for 300 rad/s 39.2 V
b=0, 1st-order model: overshoot 5.5 %, settled after 5 samples, first voltage for 300 rad/s 19.6 V
b=0, full motor : overshoot 21.4 %, settled after 10 samples, first voltage for 300 rad/s 19.6 V
deadbeat: Kp = 0.0850, Ki = 52.56, PI zero at z = 0.447
b=1, 1st-order model: overshoot 80.9 %, settled after 2 samples, first voltage for 300 rad/s 57.0 V
b=1, full motor : overshoot 79.1 %, settled after 16 samples, first voltage for 300 rad/s 57.0 V
b=0, 1st-order model: overshoot 0.0 %, settled after 1 samples, first voltage for 300 rad/s 31.5 V
b=0, full motor : overshoot 32.8 %, settled after 14 samples, first voltage for 300 rad/s 31.5 V
Four lessons in one printout. The controller zero: the PI's zero at ( for the first design) sits right next to the placed poles, so with the response overshoots even on the design model, where poles with alone would give about 5 %. Removing the zero from the setpoint path with gives , as designed, and cuts the first voltage from to . The model: on the full motor, whose electrical pole () and ZOH zero the design ignored, the overshoot grows to : still acceptable for , but for the faster design, whose poles are closer to the neglected dynamics. The actuator: only the I-P design stays within the bridge for a step. Deadbeat: on its own model it is perfect (one sample with ), on the real motor it overshoots by a third and asks for to : deadbeat needs an accurate model and a strong actuator. It is used where both hold, e.g. small steps in the current loops of digital power converters, with a check of the ripple between samples (Anti-Windup covers what happens when the actuator saturates instead).
Lab: a PI zero far from the poles
In continuous time the same effect is easy to see. On the lab's first-order plant , a PI with , gives the characteristic polynomial : , , about 4.6 % overshoot from the poles alone. The PI zero is at , two and a half times farther out than the poles, and the lab reads an overshoot of only (rise time , settling ). Raise and lower to move the zero towards the poles and watch the overshoot grow, as it did in the discrete design.
Guided lab: a deliberately slow digital loop
Hand calculation. Run your motor's speed loop at to . Design the PI by pole placement for and an that keeps below about ; predict the settling time in samples and the first voltage for your step.
Simulation. Put your , , into the program.
What you would measure. The motor on a current-limited supply, encoder and H-bridge, the PI in a timer interrupt at the chosen . Steps of (small enough to stay out of saturation): expect the settling time in samples to match the prediction within one or two samples, and the overshoot within a few percent; then try the deadbeat gains with a step and observe the voltage spike and the encoder-noise sensitivity.
Hazards and safe setup. Current limit about , motor clamped, enable switch, firmware voltage limit; deadbeat gains are aggressive, so start with tiny steps.
Pitfalls
- Placing poles with a large angle (towards ): sample-to-sample oscillation and ripple between samples.
- Designing on a simplified plant model and not checking on the full one.
- Forgetting the actuator: the fastest discrete design is limited by saturation, not by mathematics.
- Mixing up the integrator discretisations: the formulas above assume .
Practice
- Where must the closed-loop poles lie for a 2 % settling time of 10 samples?
- For , map to the z-plane.
- A plant has . Find the deadbeat PI (, ).
Answer
- Inside the circle of radius .
- , : .
- , .
Test yourself
The imaginary axis of the s-plane maps under to
- the real axis
- the unit circle
- the origin
- the line Re z = 1
Deadbeat control places the closed-loop poles at
- on the unit circle
The main practical limit of deadbeat control is
- it is unstable
- the very large control signal it needs
- it cannot remove steady-state error
- it only works for continuous plants
A plant pole at sampled at maps to