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

NameDomainDirection
usignalin
ysignalout

Parameters

NameUnitDefaultRangeDescription
kp11Proportional gain
ki1/s1Integral gain
kds0Derivative gain
Tds0.010 to ∞Derivative filter time constant
ymax11000000Upper output limit
ymin1-1000000Lower output limit

Variables

NameUnitDescription
I1Integral term
xd1Filtered 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))