PID Controller
ContinuousPIDController 方块实现了用于闭环反馈控制的标准比例-积分-微分(PID)控制器。它结合了三个并联的控制项以精确调节过程:比例作用用于快速响应,积分作用用于消除稳态误差,微分作用用于阻尼超调。
视频教程
数学模型
离散数值近似:
I[n] = I[n-1] + Ki × e[n] × Δt (前向欧拉法)
D[n] = (Kd × N × (e[n] - e[n-1]) + D[n-1]) / (1 + N × Δt) (后向欧拉滤波)
微分滤波器的传递函数为 Kd × N × s / (s + N),其中 为滤波系数。该低通滤波器可防止测量噪声被过度放大。较大的 意味着更少的滤波( 退化为纯微分环节)。常用取值范围为 。
输入与输出
| Direction | ID | Label | 类型 | Status |
|---|---|---|---|---|
| → In | error |
Error | number | Required |
| → In | reset |
Reset | number | Optional |
| ← Out | out |
Output | number | Output |
| ← Out | p |
P | number | Output |
| ← Out | i |
I | number | Output |
| ← Out | d |
D | number | Output |
参数
| 参数 | Label | 类型 | 默认值 | 描述 |
|---|---|---|---|---|
kp |
Proportional Gain (Kp) | number | 1 |
Controls immediate response to error |
ki |
Integral Gain (Ki) | number | 0.1 |
Eliminates steady-state error over time |
kd |
Derivative Gain (Kd) | number | 0.1 |
Dampens oscillations by responding to error rate of change |
n |
Filter Coefficient (N) | number | 100 |
Derivative filter cutoff frequency. Higher = less filtering |
form |
PID Form | select | parallel |
Parallel: u = Kp·e + Ki·∫e + Kd·de/dt. Series: u = Kp·(1 + 1/(Ti·s) + Td·s)·e |
min |
Saturation Min | number | -1000000000000000 |
Lower output limit for anti-windup protection |
max |
Saturation Max | number | 1000000000000000 |
Upper output limit for anti-windup protection |
showComponents |
Show P/I/D Outputs | boolean | false |
Expose individual Proportional, Integral, and Derivative term outputs |
使用示例
烤箱温度控制
设定值 (200°C) → [+]
\
测量温度 → [-] → 误差 → PIDController (Kp: 2, Ki: 0.05, Kd: 1) → 加热执行器
伺服电机位置控制
针对阶跃位置目标,引入 能有效防止电机越过目标位置并在其附近发生震荡。
说明与最佳实践
- 工业基石: 工业中绝大多数连续控制回路均基于 PID 控制原理构建。
- 参数整定 (Tuning): 可使用属性面板中的 Auto-Tune 按钮在您的超调上限和安全裕度内自动计算 ,也可先只调 ,再依次加入 和 。
- 仿真步长: 各项增益的计算均在内部根据仿真步长 进行了归一化,与时间步长无关。
常见工程问题解答 (FAQ)
Q: How does PID anti-windup clamping work and when should I use back-calculation?
Clamping (conditional integration) halts integration whenever the actuator output saturates AND the control error has the same sign as the saturated output. This prevents the integrator state from accumulating error that cannot be physically actuated. Back-calculation continuously discharges the integrator state via a feedback gain proportional to the difference between demanded and saturated control output (). Clamping is ideal for hard physical limits (valves, PWM duty cycle) to eliminate severe overshoot upon setpoint recovery.
Q: What is the derivative filter coefficient N in the PID block?
An ideal derivative term has infinite high-frequency gain, amplifying sensor noise and causing actuator chatter. BlockWerk implements a real, band-limited derivative filter: . The parameter (typically chosen between 8 and 20) places a low-pass roll-off pole at frequency rad/s, providing derivative phase lead at control frequencies while attenuating high-frequency noise.
相关模块
- Integrator: 独立积分环节
- Derivative: 独立微分环节
- TransferFunction: 连续传递函数模型(用于被控对象建模)
- Saturation: 外部幅值限幅方块