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

NameDomainDirection
rsignalin
msignalin
ysignalout

Parameters

NameUnitDefaultRangeDescription
kp11Proportional gain
ki1/s1Integral gain
kds0Derivative gain
Tfs0.011e-9 to ∞Derivative filter time constant
Tts11e-9 to ∞Anti-windup tracking time
b11Setpoint weight of the proportional term
ymax11000000Upper output limit
ymin1-1000000Lower output limit

Variables

NameUnitDescription
I1Integral term
xf1Filtered measurement for the derivative term
v1Controller 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