3.5.39Guidance, Navigation & Control (GNC)

PID tuning — Ziegler-Nichols, loop shaping

2,114 words10 min readdifficulty · medium1 backlinks

1. What is a PID controller (WHAT / WHY)

  • P (proportional): reacts to the present error. Bigger error ⇒ bigger push. Alone it leaves steady-state error (offset) and can oscillate if too large.
  • I (integral): accumulates past error. It kills steady-state error because it keeps pushing until the accumulated error is zero. But it adds phase lag ⇒ can destabilise.
  • D (derivative): predicts the future from the slope. It adds damping / phase lead, reducing overshoot, but amplifies noise.

2. Ziegler-Nichols: the ultimate-gain method (HOW, derived)

Procedure (closed-loop / ultimate-gain method):

  1. Set Ki=0, Kd=0K_i=0,\ K_d=0 (pure P control).
  2. Slowly increase KpK_p until the output shows sustained, constant-amplitude oscillation.
  3. Record that gain as the ultimate gain KuK_u and the oscillation period TuT_u.
  4. Read the gains from the table.

Where do Ku,TuK_u,T_u come from analytically?

At the stability edge the open loop L(jω)=KuG(jω)L(j\omega)=K_u\,G(j\omega) satisfies G(jωu)=180°,Ku=1G(jωu),Tu=2πωu.\angle G(j\omega_u) = -180°,\qquad K_u = \frac{1}{|G(j\omega_u)|},\qquad T_u=\frac{2\pi}{\omega_u}.

Derivation for a test plant G(s)=1(s+1)3G(s)=\dfrac{1}{(s+1)^3}:

  • Phase: G(jω)=3arctanω\angle G(j\omega) = -3\arctan\omega. Set =180°=π=-180°=-\pi: arctanωu=π/3ωu=tan60°=3\arctan\omega_u=\pi/3 \Rightarrow \omega_u=\tan 60°=\sqrt3.
  • Magnitude: G(jωu)=(ωu2+1)3/2=(3+1)3/2=43/2=1/8|G(j\omega_u)|=(\omega_u^2+1)^{-3/2}=(3+1)^{-3/2}=4^{-3/2}=1/8.
  • So Ku=1/G=8K_u=1/|G|=8 and Tu=2π/33.63T_u=2\pi/\sqrt3\approx3.63\,s.

3. Ziegler-Nichols: the open-loop (reaction-curve) method

Approximate the step response by a delay LL and slope. Model: G(s)KeLsTs+1G(s)\approx \dfrac{K\,e^{-Ls}}{Ts+1}. Let R=K/TR=K/T (max slope / step-height). Then:

Why these? LL (dead time) governs how much phase lag you can tolerate; larger LL ⇒ smaller gain. The ratios 2L,0.5L2L,\,0.5L mirror the closed-loop TuT_u ratios because Tu ⁣ ⁣4LT_u\!\sim\!4L for such plants.


4. Loop shaping (the "understand it" method)

PID as a loop-shaping filter:

  • The integral term Ki/sK_i/s boosts low-frequency gain (slope 20-20dB/dec, phase 90°-90°).
  • The derivative term adds phase lead near ωc\omega_c — you deliberately place the zero of C(s)C(s) below ωc\omega_c so its +90°+90° phase counters plant lag and raises the phase margin.

5. Common mistakes (Steel-manned)


6. Active recall

Recall Quick self-test (hide and answer)
  • What two numbers does closed-loop ZN measure, and how? (→ KuK_u: gain at sustained oscillation; TuT_u: its period.)
  • Why does integral action reduce phase margin? (→ adds 90°-90° lag.)
  • Define phase margin and target range. (→ 180°+L(ωc)180°+\angle L(\omega_c); 303060°60°.)
  • How does D action help loop shaping? (→ adds phase lead near ωc\omega_c, raises PM, adds damping.)
Recall Feynman: explain to a 12-year-old

Imagine steering a toy car to a line on the floor. P: turn the wheel more the farther you are from the line. I: if a wind keeps blowing you off, keep turning a little extra until you finally sit on the line. D: if you're rushing at the line fast, ease off early so you don't zoom past. Tuning is picking how strong each of these reactions is. Ziegler-Nichols is like: "turn the P knob up until the car wobbles side to side forever, note how fast it wobbles, then use that to set all three knobs." Loop shaping is: "draw a picture of how the car reacts to fast vs slow wiggles, and adjust the knobs so slow mistakes get fixed strongly but fast jitter is ignored."


Connections


Flashcards

What is the PID control law in the time domain?
u(t)=Kpe+Kiedt+Kde˙u(t)=K_p e + K_i\int e\,dt + K_d\,\dot e, with e=rye=r-y.
In closed-loop ZN, what are KuK_u and TuT_u?
The proportional gain that produces sustained constant-amplitude oscillation, and the period of that oscillation.
ZN PID gains from Ku,TuK_u,T_u?
Kp=0.6Ku, Ti=Tu/2, Td=Tu/8K_p=0.6K_u,\ T_i=T_u/2,\ T_d=T_u/8 (then Ki=Kp/Ti, Kd=KpTdK_i=K_p/T_i,\ K_d=K_p T_d).
Why does adding integral action reduce stability margin?
Each 1/s1/s term adds 90°-90° phase lag, cutting the phase margin near crossover.
Define phase margin.
PM=180°+L(jωc)\text{PM}=180°+\angle L(j\omega_c) where ωc\omega_c is the gain-crossover frequency (L=1|L|=1).
What condition marks the edge of instability for L(s)L(s)?
L(jω)=1|L(j\omega)|=1 and L(jω)=180°\angle L(j\omega)=-180° simultaneously.
For G=1/(s+1)3G=1/(s+1)^3, find ωu,Ku,Tu\omega_u,K_u,T_u.
ωu=3\omega_u=\sqrt3, Ku=8K_u=8, Tu=2π/33.63T_u=2\pi/\sqrt3\approx3.63 s.
What is "derivative kick" and its fix?
A step in reference makes de/dtde/dt spike; fix by taking derivative of the measurement Kdy˙-K_d\dot y and filtering it.
What does high open-loop low-frequency gain buy you in loop shaping?
Small steady-state error and good disturbance rejection.
Target gain margin in loop shaping?
6\ge 6 dB (factor of 2).
Classic ZN targets what response shape?
Quarter-amplitude decay (~25% overshoot) — aggressive, often needs detuning.
ZN open-loop PID from FOPDT (LL=delay, RR=slope/step)?
Kp=1.2/(RL), Ti=2L, Td=0.5LK_p=1.2/(RL),\ T_i=2L,\ T_d=0.5L.

Concept Map

drives

Kp reacts to present

Ki kills offset

Kd adds damping

needs choosing

recipe method

understanding method

crank Kp to instability

look up

edge of stability at

reshape

too much lag can

Error e=r-y

PID controller C of s

Steady-state offset

Integral phase lag

Overshoot reduced, noise amplified

Tuning goal: fast, stable, low overshoot

Ziegler-Nichols

Loop shaping

Measure Ku and Tu

ZN gain table

Gain=1, phase=-180 deg

Bode: gain, phase margin, bandwidth

Destabilise loop

Hinglish (regional understanding)

Intuition Hinglish mein samjho

PID tuning ka matlab hai teen knobs — Kp,Ki,KdK_p, K_i, K_d — ko aise set karna ki system fast bhi ho, stable bhi rahe, aur overshoot zyada na kare. P present error dekhta hai, I past errors ko jodta jaata hai (isliye steady-state offset khatam karta hai), aur D future ko predict karta hai (slope se), damping deta hai. Dhyaan rakho: I zyada karoge to phase lag (90°-90°) aata hai aur system oscillate karne lagta hai.

Ziegler-Nichols ek recipe hai. KiK_i aur KdK_d ko zero karke sirf KpK_p badhaao jab tak output constant-amplitude oscillation dikhaye. Us gain ko KuK_u (ultimate gain) aur oscillation ke period ko TuT_u bolo. Phir table se: Kp=0.6KuK_p=0.6K_u, Ti=Tu/2T_i=T_u/2, Td=Tu/8T_d=T_u/8. Yeh seconds mein starting point de deta hai, par yeh aggressive hota hai (~25% overshoot), to baad mein thoda detune karna padta hai.

Loop shaping samajhdaari wala tareeka hai. Yahan hum open-loop L(s)=C(s)G(s)L(s)=C(s)G(s) ka Bode plot dekhte hain. Chahiye: low frequency pe high gain (accuracy ke liye), high frequency pe low gain (noise reject karne ke liye), aur crossover ωc\omega_c pe achha phase margin (303060°60°) taaki stable rahe. Integral term low-frequency gain badhaata hai, aur derivative term ωc\omega_c ke aas-paas phase lead deta hai jisse margin badhta hai. Matlab tum jaante ho kyun har knob kya kar raha hai — yeh ZN se zyada control deta hai. Practical tip: Ki/KpK_i/K_p ko ωc\omega_c se kaafi neeche rakho, aur derivative ko measurement pe lagaao (error pe nahi) taaki "derivative kick" na ho.

Go deeper — visual, from zero

Test yourself — Guidance, Navigation & Control (GNC)

Connections