PID controller
signal.pid
Parallel PID control of the error input: y = kp u + I + D, where I' = ki u and D = kd s / (Td s + 1) u. The output is limited to the range from ymin to ymax, and the integral term is clamped to the same range so it cannot wind up.
Ports
| Name | Domain | Direction |
|---|---|---|
u | signal | in |
y | signal | out |
Parameters
| Name | Unit | Default | Range | Description |
|---|---|---|---|---|
kp | 1 | 1 | Proportional gain | |
ki | 1/s | 1 | Integral gain | |
kd | s | 0 | Derivative gain | |
Td | s | 0.01 | 0 to ∞ | Derivative filter time constant |
ymax | 1 | 1000000 | Upper output limit | |
ymin | 1 | -1000000 | Lower output limit |
Variables
| Name | Unit | Description |
|---|---|---|
I | 1 | Integral term |
xd | 1 | Filtered error for the derivative term |
Equations
der(I) = if I >= ymax then (if ki * u > 0 then 0 else ki * u) else if I <= ymin then (if ki * u < 0 then 0 else ki * u) else ki * u when I >= ymax then reinit(I, ymax) when I <= ymin then reinit(I, ymin) Td * der(xd) = u - xd y = max(ymin, min(ymax, kp * u + I + kd * (u - xd) / Td))