TExcelTAD
Home › Control Systems & Automation › Bode Plots of the Loop and Loop Shaping

Bode Plots of the Loop and Loop Shaping

A speed controller for the course's small DC motor has to do three things at once: follow speed commands that change a few times per second, hold the speed when a load torque appears, and ignore the encoder's quantisation noise at kilohertz frequencies. Those are three statements about frequencies, and one plot answers all three: the Bode plot of the loop transfer function L(jω)=C(jω)G(jω)L(j\omega) = C(j\omega)G(j\omega). This lesson reads that plot the control engineer's way and uses it to shape a PI controller. How to draw Bode plots is in Circuit Theory; here the plot is a design tool.

Why the loop gain says everything

With L=CGL = CG, the output and the error of the loop in the intro's figure are

y=T r+S G d−T n,e=r−y=S r−S G d+T n,S=11+L,T=L1+L,S+T=1y = T\,r + S\,G\,d - T\,n, \qquad e = r - y = S\,r - S\,G\,d + T\,n, \qquad S = \frac{1}{1 + L}, \quad T = \frac{L}{1 + L}, \quad S + T = 1

Two approximations turn this into a design rule:

Where Approximation Consequence
∣L∣≫1\lvert L \rvert \gg 1 (low frequency) S≈1/LS \approx 1/L, T≈1T \approx 1 tracking error and disturbance effect are divided by ∣L∣\lvert L \rvert
∣L∣≪1\lvert L \rvert \ll 1 (high frequency) S≈1S \approx 1, T≈LT \approx L sensor noise reaches the output attenuated by ∣L∣\lvert L \rvert; feedback does nothing there
∣L∣≈1\lvert L \rvert \approx 1 (crossover ωc\omega_c) neither here 1+L1 + L can get small: margins decide overshoot and peaking

So make ∣L∣\lvert L \rvert large where commands and disturbances live, small where noise lives, and cross 0 dB0\ \text{dB} cleanly in between. The gain-crossover frequency ωc\omega_c is roughly the closed-loop bandwidth, and the rise time follows from it: tr≈1.8/ωct_r \approx 1.8/\omega_c for a well-damped loop.

Crossing cleanly. For a minimum-phase loop, Bode's gain–phase relation ties the phase to the slope of ∣L∣\lvert L \rvert: a slope of −20 dB/decade-20\ \text{dB/decade} held for a decade or so around crossover gives about −90∘-90^\circ of phase, i.e. a phase margin near 90∘90^\circ; a slope of −40 dB/decade-40\ \text{dB/decade} gives about −180∘-180^\circ, i.e. almost no margin. Loop shaping therefore aims for −20 dB/decade-20\ \text{dB/decade} through crossover, steeper slopes only well away from it. Margins are made precise in Gain and Phase Margins.

Worked example: shaping a PI speed loop

Given: the reference motor (armature voltage to speed), G(s)=k(Js+b)(Las+Ra)+k2G(s) = \frac{k}{(Js + b)(L_a s + R_a) + k^2} with Ra=2 ΩR_a = 2\ \Omega, La=1 mHL_a = 1\ \text{mH}, k=0.02 V⋅s/radk = 0.02\ \text{V} \cdot \text{s/rad}, J=2×10−6 kg⋅m2J = 2 \times 10^{-6}\ \text{kg} \cdot \text{m}^2, b=1×10−6 N⋅m⋅sb = 1 \times 10^{-6}\ \text{N} \cdot \text{m} \cdot \text{s}. PI controller C(s)=Kp+Kis=Kps+Ki/KpsC(s) = K_p + \frac{K_i}{s} = K_p\frac{s + K_i/K_p}{s}.

Find: a PI controller with crossover at ωc=300 rad/s\omega_c = 300\ \text{rad/s}; its phase margin; how well it rejects a disturbance at 11 and 10 rad/s10\ \text{rad/s} and how much encoder noise at 5000 rad/s5000\ \text{rad/s} reaches the speed.

Solve:

  • Plant: denominator 2×10−9s2+4.001×10−6s+4.02×10−42 \times 10^{-9} s^2 + 4.001 \times 10^{-6} s + 4.02 \times 10^{-4}, poles at −106.1-106.1 and −1894 rad/s-1894\ \text{rad/s}, DC gain 0.02/4.02×10−4=49.75 (rad/s)/V0.02/4.02 \times 10^{-4} = 49.75\ \text{(rad/s)/V}.
  • Shape: put the PI zero on the slow plant pole, Ki/Kp=106.1 s−1K_i/K_p = 106.1\ \text{s}^{-1}. Then L≈Kp⋅49.75⋅106.1s (1+s/1894)L \approx \frac{K_p \cdot 49.75 \cdot 106.1}{s\,(1 + s/1894)}: an integrator (−20 dB/decade-20\ \text{dB/decade} everywhere below 1894 rad/s1894\ \text{rad/s}) with infinite DC gain.
  • Gain: ∣L(j300)∣=1\lvert L(j300) \rvert = 1 gives Kp=0.0575 V/(rad/s)K_p = 0.0575\ \text{V/(rad/s)} and Ki=6.11 V/radK_i = 6.11\ \text{V/rad}.
  • Phase margin: 90∘−arctan⁡(300/1894)=81.0∘90^\circ - \arctan(300/1894) = 81.0^\circ.
  • Rejection: ∣S∣≈ω/300\lvert S \rvert \approx \omega/300 below crossover: 0.00330.0033 (−50 dB-50\ \text{dB}) at 1 rad/s1\ \text{rad/s}, 0.0330.033 at 10 rad/s10\ \text{rad/s}. Noise: ∣T(j5000)∣≈0.022\lvert T(j5000) \rvert \approx 0.022.

Check:

1 10 100 1k 10k -60 -40 -20 0 20 40 60 w rad/s dB |L| |S| |T| crossover 300 rad/s
python · try it yourself
import numpy as np
import control as ct

J, b, Ra, La, k = 2e-6, 1e-6, 2.0, 1e-3, 0.02
G = ct.tf([k], np.polyadd(np.polymul([J, b], [La, Ra]), [k * k]))
p_slow = -max(ct.poles(G).real)
wc = 300.0
s = 1j * wc
Gwc = k / np.polyval(np.polyadd(np.polymul([J, b], [La, Ra]), [k * k]), s)
Kp = 1 / abs(Gwc * (s + p_slow) / s)
C = ct.tf([Kp, Kp * p_slow], [1, 0])
L = C * G
gm, pm, wpc, wgc = ct.margin(L)
print(f"plant poles {np.round(ct.poles(G).real, 1)}, DC gain {ct.dcgain(G):.2f} (rad/s)/V")
print(f"Kp = {Kp:.4f} V/(rad/s), Ki = {Kp * p_slow:.3f} V/rad")
print(f"gain crossover {wgc:.1f} rad/s, phase margin {pm:.1f} deg, gain margin {gm:.3g}")
S, T = ct.feedback(1, L), ct.feedback(L, 1)
for w in (1, 10, 100, 300, 1000, 5000):
    print(f"w = {w:5d} rad/s: |L| = {abs(L(1j * w)):8.3f}, |S| = {abs(S(1j * w)):.4f}, |T| = {abs(T(1j * w)):.4f}")
print(f"closed-loop bandwidth {ct.bandwidth(T):.0f} rad/s")
plant poles [-1894.4  -106.1], DC gain 49.75 (rad/s)/V
Kp = 0.0575 V/(rad/s), Ki = 6.105 V/rad
gain crossover 300.0 rad/s, phase margin 81.0 deg, gain margin inf
w =     1 rad/s: |L| =  303.738, |S| = 0.0033, |T| = 1.0000
w =    10 rad/s: |L| =   30.373, |S| = 0.0329, |T| = 0.9996
w =   100 rad/s: |L| =    3.033, |S| = 0.3181, |T| = 0.9650
w =   300 rad/s: |L| =    1.000, |S| = 0.7699, |T| = 0.7699
w =  1000 rad/s: |L| =    0.269, |S| = 1.1034, |T| = 0.2964
w =  5000 rad/s: |L| =    0.022, |S| = 1.0205, |T| = 0.0220
closed-loop bandwidth 358 rad/s

The closed-loop bandwidth, 358 rad/s358\ \text{rad/s}, is close to the 300 rad/s300\ \text{rad/s} crossover, as the rule of thumb says. The gain margin is infinite (inf): with this model the phase never reaches −180∘-180^\circ, it only approaches it as ω→∞\omega \to \infty. Real loops always have more lag (the current loop, the PWM, the sampling delay), so do not believe an infinite margin; Sampled-Data Loops adds the delay that a microcontroller brings.

Intuition with the Bode lab

The Bode lab plots a loop with three real poles. At its defaults (K=20 dBK = 20\ \text{dB}, poles at 1010, 100100, 1000 Hz1000\ \text{Hz}) it reads a gain crossover of 77.98 Hz77.98\ \text{Hz} with a phase margin of 54.9∘54.9^\circ and a gain margin of 21.7 dB21.7\ \text{dB}. Raise KK to 30 dB30\ \text{dB}: crossover 162.9 Hz162.9\ \text{Hz}, phase margin 25.8∘25.8^\circ. At 40 dB40\ \text{dB}: 301.4 Hz301.4\ \text{Hz} and only 3.5∘3.5^\circ, because crossover has moved onto the −40-40 and −60 dB/decade-60\ \text{dB/decade} part of the curve. More gain bought speed (and smaller ∣S∣\lvert S \rvert at low frequency) at the price of margin: the central trade-off of loop shaping.

6040200-20-40-60-80|L| (dB)-270-180-90090100m1101001k10k100k1Mf (Hz)phase (deg)PM 54.9 degGM 21.7 dB|L| exactphase exactasymptotesunity-feedback closed loop: stable

Guided lab: measure the speed loop

Hand calculation. With your motor's measured RaR_a, kk and mechanical time constant, place the PI zero on the mechanical pole and choose KpK_p for a crossover a decade below the PWM and sample rates. Predict the closed-loop bandwidth (≈ωc\approx \omega_c) and the phase margin.

Simulation. Put your numbers in the program; check ∣S∣\lvert S \rvert at the frequencies of expected load changes.

What you would measure. A small brushed motor on a current-limited 12 V12\ \text{V} supply through an H-bridge, an encoder, and the PI running at 1 kHz1\ \text{kHz} on a microcontroller (see Discrete PID). Add a small sine to the speed command (±20 rad/s\pm 20\ \text{rad/s} around 300 rad/s300\ \text{rad/s}) at 55, 2020, 5050 and 100 Hz100\ \text{Hz} and log command and speed. Expect ∣T∣\lvert T \rvert near 11 below 20 Hz20\ \text{Hz}, about 0.70.7 (−3 dB-3\ \text{dB}) near the predicted bandwidth (300 rad/s=48 Hz300\ \text{rad/s} = 48\ \text{Hz}), within about 20 %: the motor constants have 10 % tolerances and the real loop carries extra delay.

Hazards and safe setup. Current limit about 1 A1\ \text{A}, motor clamped to the bench, no load that can fly off, a stop switch on the driver enable; keep the sine amplitude small so the driver stays out of saturation.

Pitfalls

  • Reading the plant's Bode plot instead of the loop's: margins and crossover belong to L=CGL = CG.
  • Treating crossover as the −3 dB-3\ \text{dB} bandwidth exactly: they agree only roughly, and less with small phase margin.
  • Asking for crossover beyond the frequencies where the model is trusted (unmodelled resonances, delays).
  • Expecting feedback to reduce noise: above crossover T≈LT \approx L passes it, below crossover T≈1T \approx 1 passes it unchanged.

Practice

  1. A loop has ∣L(jω)∣=100/ω\lvert L(j\omega) \rvert = 100/\omega. What is the error to a sinusoidal command at 2 rad/s2\ \text{rad/s}, approximately?
  2. Why does the PI design above have a phase margin close to 90∘90^\circ?
  3. To halve the disturbance effect at 10 rad/s10\ \text{rad/s} in the example, by how much must KpK_p grow (same zero), and where does crossover move?
Answer
  1. ∣S∣≈1/∣L∣=2/100=2 %\lvert S \rvert \approx 1/\lvert L \rvert = 2/100 = 2\,\% of the command amplitude.
  2. Around crossover LL behaves like an integrator (−20 dB/decade-20\ \text{dB/decade}, −90∘-90^\circ); the far plant pole at 1894 rad/s1894\ \text{rad/s} only adds 9∘9^\circ at 300 rad/s300\ \text{rad/s}.
  3. ∣S∣≈ω/ωc\lvert S \rvert \approx \omega/\omega_c, so double KpK_p; crossover moves to 581 rad/s581\ \text{rad/s} (a little less than 600600, since the 1894 rad/s1894\ \text{rad/s} pole starts to bend the curve), and the phase margin drops to 73∘73^\circ.

Test yourself

At frequencies where ∣L∣≫1\lvert L \rvert \gg 1, the sensitivity SS is approximately

  1. 1
  2. LL
  3. 1/L1/L
  4. 0 dB

Loop shaping aims for which slope of ∣L∣\lvert L \rvert near the gain crossover of a minimum-phase loop?

  1. 0 dB/decade
  2. −20-20 dB/decade
  3. −40-40 dB/decade
  4. −60-60 dB/decade

In the Bode lab's three-pole loop, raising KK from 20 dB to 30 dB moved the crossover from 78 Hz to 163 Hz and the phase margin to

  1. 54.9∘54.9^\circ
  2. 25.8∘25.8^\circ
  3. 3.5∘3.5^\circ
  4. 90∘90^\circ

Why is it wise to place a PI zero on the slow mechanical pole of a motor speed loop?

  1. it makes the loop unstable
  2. the loop becomes an integrator over a wide band, crossing 0 dB at −20-20 dB/decade
  3. it removes the need for a current limit
  4. it doubles the DC gain