TExcelTAD
Home › Control Systems & Automation › Design in the z-Plane

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 (ζ\zeta, ωn\omega_n, 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 z=esTsz = e^{sT_s}

A continuous pole s=−ζωn±jωn1−ζ2s = -\zeta\omega_n \pm j\omega_n\sqrt{1 - \zeta^2} sampled every TsT_s gives a discrete mode zkz^k with

z=esTs=r e±jθ,r=e−ζωnTs,θ=ωnTs1−ζ2z = e^{sT_s} = r\,e^{\pm j\theta}, \qquad r = e^{-\zeta\omega_n T_s}, \qquad \theta = \omega_n T_s\sqrt{1 - \zeta^2}
s-plane z-plane
left half-plane (stable) inside the unit circle
imaginary axis unit circle
constant decay rate σ\sigma (settling time 4/σ4/\sigma) circle of radius e−σTse^{-\sigma T_s}
constant damped frequency ωd\omega_d ray at angle ωdTs\omega_d T_s
constant ζ\zeta logarithmic spiral from z=1z = 1
s=0s = 0 (integrator) z=1z = 1
very fast poles near the origin; z=0z = 0 is a pure one-sample delay

Settling within nn samples means poles inside the circle of radius about 0.021/n0.02^{1/n}. The angle θ\theta must stay well below π\pi (a pole near the negative real axis oscillates at the Nyquist frequency, sample to sample, which the plant between samples shows as ripple).

-1 1 -1 1 Re z Im z 300 rad/s 600 rad/s deadbeat plant 0.809 zeta = 0.7

Pole placement for a PI loop

For a first-order plant G(s)=Kτs+1G(s) = \frac{K}{\tau s + 1} the ZOH equivalent is

G(z)=gz−a,a=e−Ts/τ,g=K(1−a)G(z) = \frac{g}{z - a}, \qquad a = e^{-T_s/\tau}, \quad g = K(1 - a)

A discrete PI with forward-Euler integral, C(z)=Kp+KiTszz−1=q0z+q1z−1C(z) = K_p + K_i T_s\frac{z}{z - 1} = \frac{q_0 z + q_1}{z - 1} with q0=Kp+KiTsq_0 = K_p + K_i T_s and q1=−Kpq_1 = -K_p, gives the closed-loop characteristic polynomial

(z−1)(z−a)+g(q0z+q1)=z2+(gq0−1−a) z+(a+gq1)(z - 1)(z - a) + g(q_0 z + q_1) = z^2 + (g q_0 - 1 - a)\,z + (a + g q_1)

Match it to the desired z2+c1z+c2z^2 + c_1 z + c_2 with c1=−2rcos⁡θc_1 = -2r\cos\theta, c2=r2c_2 = r^2:

q0=c1+1+ag,q1=c2−agq_0 = \frac{c_1 + 1 + a}{g}, \qquad q_1 = \frac{c_2 - a}{g}

Deadbeat control chooses c1=c2=0c_1 = c_2 = 0 (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, G(s)=49.75s/106.1+1G(s) = \frac{49.75}{s/106.1 + 1} ((rad/s)/V), Ts=2 msT_s = 2\ \text{ms} (a slow loop, e.g. speed commands over a fieldbus).

Find: PI gains for ζ=0.7\zeta = 0.7 with ωn=300\omega_n = 300 and 600 rad/s600\ \text{rad/s}, and for deadbeat; their step responses with the PI acting on the error (b=1b = 1) and as I-P control (b=0b = 0, setpoint weighting), on the design model and on the full motor (with the electrical pole); the first voltage of a 300 rad/s300\ \text{rad/s} step.

Solve:

  • a=e−106.1×0.002=0.8088a = e^{-106.1 \times 0.002} = 0.8088, g=49.75×(1−0.8088)=9.512g = 49.75 \times (1 - 0.8088) = 9.512.
  • ωn=300\omega_n = 300: r=e−0.42=0.657r = e^{-0.42} = 0.657, θ=0.6×0.714=0.428 rad\theta = 0.6 \times 0.714 = 0.428\ \text{rad}, desired poles 0.598±j0.2730.598 \pm j0.273. Then q0=0.0645q_0 = 0.0645, q1=−0.0396q_1 = -0.0396: Kp=0.0396 V/(rad/s)K_p = 0.0396\ \text{V/(rad/s)}, Ki=12.43 V/radK_i = 12.43\ \text{V/rad}.
  • ωn=600\omega_n = 600: poles 0.283±j0.3260.283 \pm j0.326, Kp=0.0654K_p = 0.0654, Ki=32.6K_i = 32.6.
  • Deadbeat: q0=(1+a)/g=0.190q_0 = (1 + a)/g = 0.190, q1=−a/g=−0.0850q_1 = -a/g = -0.0850: Kp=0.0850K_p = 0.0850, Ki=52.6K_i = 52.6. The first voltage after a 300 rad/s300\ \text{rad/s} step is q0×300=57 Vq_0 \times 300 = 57\ \text{V}, almost five times the supply.

Check:

python · try it yourself
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 z=−q1/q0z = -q_1/q_0 (0.6150.615 for the first design) sits right next to the placed poles, so with b=1b = 1 the response overshoots 16.9 %16.9\,\% even on the design model, where poles with ζ=0.7\zeta = 0.7 alone would give about 5 %. Removing the zero from the setpoint path with b=0b = 0 gives 4.8 %4.8\,\%, as designed, and cuts the first voltage from 19.319.3 to 7.5 V7.5\ \text{V}. The model: on the full motor, whose electrical pole (e−1894×0.002=0.023e^{-1894 \times 0.002} = 0.023) and ZOH zero the design ignored, the overshoot grows to 7.8 %7.8\,\%: still acceptable for ωn=300 rad/s\omega_n = 300\ \text{rad/s}, but 21.4 %21.4\,\% for the faster design, whose poles are closer to the neglected dynamics. The actuator: only the ωn=300\omega_n = 300 I-P design stays within the 12 V12\ \text{V} bridge for a 300 rad/s300\ \text{rad/s} step. Deadbeat: on its own model it is perfect (one sample with b=0b = 0), on the real motor it overshoots by a third and asks for 31.531.5 to 57 V57\ \text{V}: 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 1s+1\frac{1}{s + 1}, a PI with Kp=0.4K_p = 0.4, Ki=1K_i = 1 gives the characteristic polynomial s2+1.4s+1s^2 + 1.4 s + 1: ωn=1 rad/s\omega_n = 1\ \text{rad/s}, ζ=0.7\zeta = 0.7, about 4.6 % overshoot from the poles alone. The PI zero is at −Ki/Kp=−2.5-K_i/K_p = -2.5, two and a half times farther out than the poles, and the lab reads an overshoot of only 5.16 %5.16\,\% (rise time 1.928 s1.928\ \text{s}, settling 5.565 s5.565\ \text{s}). Raise KpK_p and lower KiK_i to move the zero towards the poles and watch the overshoot grow, as it did in the discrete design.

r = 1+C(s): Kp 0.4, Ki 1, Kd 0P(s) = 1/(1s+1)y-T(s) = (0.400 s + 1.000) / (1.000 s^2 + 1.400 s + 1.000)closed-loop poles: -0.70+j0.71, -0.70-j0.710.00.51.002 s4 s6 s8 sty(t)t_s 5.57 s+5.2 %y(t)setpoint10-90 % rise

Guided lab: a deliberately slow digital loop

Hand calculation. Run your motor's speed loop at Ts=2T_s = 2 to 5 ms5\ \text{ms}. Design the PI by pole placement for ζ=0.7\zeta = 0.7 and an ωn\omega_n that keeps θ=ωnTs1−ζ2\theta = \omega_n T_s\sqrt{1 - \zeta^2} below about 0.5 rad0.5\ \text{rad}; predict the settling time in samples and the first voltage for your step.

Simulation. Put your KK, τ\tau, TsT_s into the program.

What you would measure. The motor on a current-limited 12 V12\ \text{V} supply, encoder and H-bridge, the PI in a timer interrupt at the chosen TsT_s. Steps of 50 rad/s50\ \text{rad/s} (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 10 rad/s10\ \text{rad/s} step and observe the voltage spike and the encoder-noise sensitivity.

Hazards and safe setup. Current limit about 1 A1\ \text{A}, motor clamped, enable switch, firmware voltage limit; deadbeat gains are aggressive, so start with tiny steps.

Pitfalls

  • Placing poles with a large angle θ\theta (towards −1-1): 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 C(z)=Kp+KiTszz−1C(z) = K_p + K_i T_s\frac{z}{z - 1}.

Practice

  1. Where must the closed-loop poles lie for a 2 % settling time of 10 samples?
  2. For Ts=0.1 sT_s = 0.1\ \text{s}, map s=−2±j2s = -2 \pm j2 to the z-plane.
  3. A plant has G(z)=0.5z−0.5G(z) = \frac{0.5}{z - 0.5}. Find the deadbeat PI (q0q_0, q1q_1).
Answer
  1. Inside the circle of radius 0.021/10=0.6760.02^{1/10} = 0.676.
  2. r=e−0.2=0.819r = e^{-0.2} = 0.819, θ=0.2 rad\theta = 0.2\ \text{rad}: z=0.802±j0.163z = 0.802 \pm j0.163.
  3. q0=(1+0.5)/0.5=3q_0 = (1 + 0.5)/0.5 = 3, q1=−0.5/0.5=−1q_1 = -0.5/0.5 = -1.

Test yourself

The imaginary axis of the s-plane maps under z=esTsz = e^{sT_s} to

  1. the real axis
  2. the unit circle
  3. the origin
  4. the line Re z = 1

Deadbeat control places the closed-loop poles at

  1. z=1z = 1
  2. z=−1z = -1
  3. z=0z = 0
  4. on the unit circle

The main practical limit of deadbeat control is

  1. it is unstable
  2. the very large control signal it needs
  3. it cannot remove steady-state error
  4. it only works for continuous plants

A plant pole at s=−106.1 s−1s = -106.1\ \text{s}^{-1} sampled at Ts=2 msT_s = 2\ \text{ms} maps to

  1. z=0.212z = 0.212
  2. z=0.809z = 0.809
  3. z=−0.809z = -0.809
  4. z=1.236z = 1.236