PID with setpoint weight and back-calculation
control.pid_back_calculation
Two-input PID for setpoint r and measurement m. The proportional term acts on b r - m, the integral on r - m, and the derivative on the measurement only, through a first-order filter with time constant Tf, so setpoint steps cause no derivative kick. The output is limited to ymin to ymax; while it is limited, the integral is pulled back by the excess divided by the tracking time Tt, so it does not wind up.
Ports
| Name | Domain | Direction |
|---|---|---|
r | signal | in |
m | 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 | |
Tf | s | 0.01 | 1e-9 to ∞ | Derivative filter time constant |
Tt | s | 1 | 1e-9 to ∞ | Anti-windup tracking time |
b | 1 | 1 | Setpoint weight of the proportional term | |
ymax | 1 | 1000000 | Upper output limit | |
ymin | 1 | -1000000 | Lower output limit |
Variables
| Name | Unit | Description |
|---|---|---|
I | 1 | Integral term |
xf | 1 | Filtered measurement for the derivative term |
v | 1 | Controller output before the limit |
Equations
der(I) = ki * (r - m) + (y - v) / Tt Tf * der(xf) = m - xf v = kp * (b * r - m) + I - kd * (m - xf) / Tf y = if v > ymax then ymax else if v < ymin then ymin else v