Course materials · Control Engineering II

PID Control · Lesson

English translation

Execution setup

The Python option uses python-control. If the module is missing, run %pip install control==0.10.2 in a Colab or Jupyter code cell.

Topics covered

Selecting a gain based only on response speed can leave the system vulnerable to overshoot or model changes. Compare different performance metrics.

Overall workflow

Reference and error → P, I, D commands → input limits → response and integrator state

Current, accumulated, and changing error

PID is expressed as u=Kpe+Ki∫edt+Kddedtu=K_pe+K_i\int e\,dt+K_d\frac{de}{dt}. P responds to current error, I accumulates remaining error, and D responds to rapid changes. Gain effects depend on the plant and observation interval, so compare using the same input and time axis.

u(t)=Kpe(t)+Ki∫e(t)dt+Kdde(t)dtu(t)=K_pe(t)+K_i\int e(t)\,dt+K_d\frac{de(t)}{dt}

Practical control with input limits

Output voltage and torque have limits. If the integral keeps accumulating when u is already at its maximum, a large command may persist after the reference is lowered.

Conditional integration is one way to stop integral accumulation that would worsen the error while the input is saturated.

Why accumulate error?

Compare P=2P=2 and PI=2+1s\mathrm{PI}=2+\frac1s for G(s)=1s+1G(s)=\frac1{s+1}. First examine steady-state error with a simple plant, then use a motor in the practice activity.

import numpy as np
import matplotlib.pyplot as plt
import control as ctl
s=ctl.tf('s')
G=1/(s+1);t=np.linspace(0,12,601)
for name,C in [('P',2),('PI',2+1/s)]:
    closed=ctl.feedback(C*G,1);tm,y=ctl.step_response(closed,t)
    plt.plot(tm,y,label=name);print(name,'DC gain',ctl.dcgain(closed))
plt.axhline(1,color='gray',linestyle='--');plt.xlabel('Time [s]');plt.ylabel('Output');plt.grid();plt.legend()
P DC gain 0.6666666666666666
PI DC gain 1.0
실행 결과

Reference example

View more examples

Reference materials