PID control and compensation
Введено
8:27
Системы управления
This course closes the loop. Signals and systems gave us the open-loop transfer function; now we ask how to make the output follow the input quickly…
Озвучивание на английском · переключаемые субтитры на английском и китайском языках
В этом уроке
| English | Значение |
|---|---|
| PID controller/ˌpiː aɪ ˈdiː kənˈtrəʊlə/ | PID-регулятор |
| proportional/prəˈpɔːʃənl/ | пропорциональный |
| integral/ˈɪntɪɡrəl/ | интеграл |
| derivative/dɪˈrɪvətɪv/ | производный |
| lead compensator/liːd ˈkɒmpənseɪtə/ | опережающее звено коррекции |
| anti-windup/ˈænti ˈwɪndʌp/ | антинасыщение |
The controller you will tune most
- Most industrial loops run a PID. It is the first controller an engineer tunes, and the one tuned most often.
- Each of its three terms gives one useful behaviour and has one known cost.
Three terms
- A PID controller PID 控制器 acts on the error $e = r - y$: $u = K_{p}e + K_{i}\displaystyle\int e\,dt + K_{d}\dfrac{de}{dt}$.
- Proportional 比例 reacts now. Integral 积分 remembers, removing steady-state error. Derivative 微分 anticipates, adding damping.
Match each term to what it does.
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
Each term improves one behaviour, and each has a cost.
Ziegler–Nichols tuning
- Raise the proportional gain until the loop just oscillates. Record the ultimate gain $K_{u}$ and the period $T_{u}$.
- The PID row of the table: $K_{p} = 0.6K_{u}$, $T_{i} = T_{u}/2$, $T_{d} = T_{u}/8$. In parallel form, $K_{i} = K_{p}/T_{i}$ and $K_{d} = K_{p}T_{d}$.
A loop oscillates at K_u = 20 with period T_u = 4 s. What integral time T_i does the Ziegler–Nichols PID row give, in s?
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
$T_{i} = T_{u}/2 = 2$ s, with $K_{p} = 0.6 \times 20 = 12$ и $T_{d} = T_{u}/8 = 0.5$ s.
K_p = 28.8 and T_i = 1.11 s. What is the parallel integral gain K_i? Give 1 decimal place.
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
$K_{i} = K_{p}/T_{i} = 28.8/1.11 = 25.9$ per second.
What each term costs
- Each term's benefit comes with a price:
| Term | Gives | Costs |
|---|---|---|
| P | a fast response | may leave steady-state error |
| I | zero steady-state error | phase lag, more overshoot |
| D | damping | amplifies measurement noise |
- Take the derivative of the measurement, not the error, or every setpoint step kicks the actuator.
Taking the derivative of the error, instead of the measurement, makes a setpoint step kick the actuator.
Сложность 1/5 · 100 монет + небольшой бонус за первое завершение сегодня
A step in r has an infinite slope, so de/dt spikes. The measured output moves smoothly, so derivative on y avoids the kick.
Worked example: Ziegler–Nichols
- The running plant oscillates at $K_{u} = 48$, $T_{u} = 2.22$ s, so $K_{p} = 28.8$, $T_{i} = 1.11$ s, $T_{d} = 0.278$ s.
- P alone overshoots 65% and leaves a ramp error of $8/K_{p} = 0.278$. The PID (all three terms on the error) removes that error but still rings at 60%: a starting point, not a final design.

The running plant 1/[s(s + 2)(s + 4)] runs with P control, K_p = 16. What is the steady-state error for a unit ramp?
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
$K_{v} = K_{p}/(2 \times 4) = 2$, so the ramp error is $1/K_{v} = 0.5$. An integrator would remove it.
Worked example: add derivative
- With $K_{p} = 28.8$ the PD polynomial is $s^{3} + 6s^{2} + (8 + K_{p}T_{d})s + K_{p}$: derivative adds to the damping term.
- At $T_{d} = 0.5$ s the poles are $-2$ and $-2 \pm j3.22$. With D on the measurement the step shows no overshoot and settles in 2.1 s.
One knob for gain, one for damping
Move Kp and Td and watch overshoot, settling and the Routh verdict move together; gain alone breaks the loop at 48, and damping repairs it.
With K_p = 20 and T_d = 0.3 s on the running plant, what is the s-coefficient of the PD characteristic polynomial?
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
$8 + K_{p}T_{d} = 8 + 6 = 14$. Derivative raises the damping term directly.
The lead compensator
- A lead compensator 超前校正装置 $\dfrac{1 + \tau s}{1 + \alpha\tau s}$, with $0 < \alpha < 1$, adds phase near one frequency: $\sin\phi_{m} = \dfrac{1 - \alpha}{1 + \alpha}$.
- For +45°, $\alpha = 0.172$. It also raises the high-frequency gain by $1/\alpha = 5.8$, which the design must absorb.
A lead network must add 30° at its peak. What α does it need? Give 3 decimal places.
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
$\alpha = (1 - \sin 30°)/(1 + \sin 30°) = 0.5/1.5 = 0.333$. Its high-frequency gain rises by $1/\alpha = 3$.
Anti-windup
- When the actuator saturates, the integrator keeps adding error it cannot use, then releases it as one big overshoot.
- Anti-windup 抗饱和 stops this: clamp the integrator while saturated, or feed back the saturation excess.
PID in code: one sample at a time
- A microcontroller runs the PID every sample period $T$. The integral becomes a running sum and the derivative a difference, taken on the measurement $y$:
e = r - y;
integ += e * T; /* I: running sum */
integ = clamp(integ, -IMAX, IMAX); /* anti-windup */
u = Kp*e + Ki*integ
- Kd*(y - y_prev)/T; /* D on y */
u = clamp(u, UMIN, UMAX); /* actuator limits */
y_prev = y;
- The Ziegler–Nichols gains in parallel form: $K_p = 28.8$, $K_i = 28.8/1.11 = 25.9$, $K_d = 28.8 \times 0.278 = 8.0$, with $T = 10$ ms.
- One sample: $e = 0.20$, the sum was 0.500 and becomes 0.502, and $y$ rose by 0.02 since the last sample.
- P term: $28.8 \times 0.20 = 5.76$. I term: $25.9 \times 0.502 = 13.0$.
- D term: $-8.0 \times 0.02/0.01 = -16.0$. Together $u = 5.76 + 13.0 - 16.0 = 2.8$.
- The noise problem: a measurement glitch of only 0.01 changes the D term by $8.0 \times 0.01/0.01 = 8.0$, nearly three times the whole output. Real controllers low-pass filter the derivative, or the actuator chatters.
Four common slips
- Ultimate gain on a plant that never oscillates. Use the step-response version of the table.
- Mixing tuning forms. $K_{p}, T_{i}, T_{d}$ are not the parallel gains.
- Forgetting the lead's $1/\alpha$. The extra high-frequency gain uses up the margin you gained.
- An unfiltered digital derivative. Dividing a small noisy difference by a short $T$ makes a large, noisy D term.
A digital PI has $K_p = 2$, $K_i = 5$ и $T = 0.1$ s. The running sum is 1.00 and this sample's error is 0.40. After adding $eT$ to the sum, what is $u$?
Сложность 2/5 · 140 монет + небольшой бонус за первое завершение сегодня
The sum becomes $1.00 + 0.40 \times 0.1 = 1.04$, so $u = 2 \times 0.40 + 5 \times 1.04 = 0.8 + 5.2 = 6.0$.
Recap
- P reacts, I remembers, D anticipates.
- Ziegler–Nichols gives a starting point; margins and simulation complete the design.
- Derivative on the measurement; anti-windup always.
- In code: a running sum for I, a difference over $T$ for D (filtered), and clamps on both the integral and the output.
Что пошло не так? Это увидит только команда сайта.