RobotGuide

Robotics core · topic B5 · 45 hours

Classical control (PID / frequency domain / stability)

80% of loops in industry still run PID. It is not sophisticated; it is the fallback layer beneath everything sophisticated.

Core stage · Intermediate
Algorithm · Hands-on System software · Hands-on Embedded & controls · Proficient Mechanical · Aware

What to learn

The lesson · plain words

PID is the one thing in robotics you can tune without understanding — and never tune well without it. Three knobs, suspiciously simple, holding up 90% of industrial control loops.

This page memorizes no formulas. It does three things: what each knob is actually doing, why adding a filter slows the loop down, and the correct order for tuning.

What the three knobs do

P reads «how far off are we right now» — the further off, the harder it pushes. I reads «how long have we been off» — it kills steady-state error and is prone to overshoot. D reads «is the gap shrinking or growing» — it acts as the brake and is prone to amplifying noise.

Drag the three sliders below: raise P and watch the response start ringing; add D and the ringing is damped but the response goes sluggish; finally a little I and the steady-state error falls to zero. That is the entire feel of tuning.

Interactive figure · drag it and see

What this figure shows: a live step response under three sliders (Kp, Ki, Kd) with overshoot, ringing, and steady-state error all read out. Takeaway: P sets how hard the loop pushes, I removes the last error, D damps the ringing — push P too far and only D or lower gains save you.

The frequency domain: why adding a filter slows the loop

A low-pass filter suppresses noise — and brings phase lag along with it. Accumulate enough lag to reach 180° and negative feedback turns into positive feedback: the loop oscillates on its own.

So «add a filter so it stops jittering» works short-term and plants a mine. The correct sequence: find which band the noise lives in, then choose the filter cutoff relative to the controller bandwidth — deliberately, not by feel.

Interactive figure · drag it and see

What this figure shows: a 3 Hz sine sampled below the Nyquist line reads back as a fake alias frequency (sweep the sampling rate and watch the alias appear), and a moving average flattens spikes while delaying true changes by about (N−1)/2 samples. Takeaway: every filter buys calm with lag or aliasing — set cutoffs from the measured noise band, never by intuition.

Stability: a race between gain and lag

Higher gain corrects harder but leaves less room for lag. Phase margin measures «how much more lag can this loop afford»: below 30° you start sweating, below 15° you wait for the oscillation.

This answers a common confusion: why does adding load (larger inertia) make the system oscillate more easily? Because the same gain is now relatively «harder» against a larger inertia.

The tuning order — do not improvise

Inside-out (current loop → velocity loop → position loop); P before D before I; change one parameter at a time and run a full step response after every change. Slow, but the only way that never gets lost.

One more discipline: get gravity and friction compensation right, and measure the sensor noise, before touching the gains. Treat PID as a cure-all and you will tune until you doubt your sanity.

Three questions — do you really get it?

1. Which term eliminates steady-state error?

  • AP
  • BI
  • CD
Show answer

B. The integral accumulates history: as long as error persists it keeps pushing, until the error reaches zero. The cost is phase lag and overshoot.

2. The main side effect of the D term?

  • AAmplifies sensor noise
  • BGrows steady-state error
  • CSlows the loop to uselessness
Show answer

A. D differentiates the error; noise is high-frequency and gets differentiated just the same. So the D term almost always ships with a low-pass.

3. Why can adding a low-pass filter make a loop oscillate?

  • AThe filter changes the gain
  • BThe filter lowers the sampling rate
  • CThe filter adds phase lag
Show answer

C. Phase lag eats phase margin. At 180° of accumulated lag, negative feedback becomes positive and the loop self-oscillates.

Keep going deeper

Links without a marker stay on this site; the rest point to the Chinese edition until its translation batch lands.

How it fails in the field

You have learned enough when

You can tune a real loop and justify every step, read a Bode plot for stability margins, and name two ways to handle integral windup.

The Chinese edition carries the full topic page for Classical control (PID / frequency domain / stability), including the complete outline, depth requirements per career track, and further derivations: robotguide.dev/k/B5/.