Skip to content

PID Controller

Proportional-Integral-Derivative controller: out = Kp·e + Ki·∫e dt + Kd·de/dt. Setting any gain to zero disables that term and the icon label shrinks to the active letters (e.g. "PI" when Kd = 0). Two optional clamps are available: an anti-windup clamp on the I term's contribution and a saturation clamp on the final output. Each clamp turns on its own little saturation-curve icon inside the body so the active limits are visible at a glance.

Category: Continuous

Keywords: PID, controller, PI, PD, P, I, D, proportional, integral, derivative, feedback, control, Kp, Ki, Kd, anti-windup, saturation, clamp, limit

Ports

NameDirectionValue typeNotes
ininputdouble
outoutputdouble

Parameters

NameLabelTypeDefaultUnitsDescription
kpKpdouble1Proportional gain. Set to 0 to disable the P term (the icon label drops the 'P').
kiKidouble0.1Integral gain. Set to 0 to disable the I term (the icon label drops the 'I' and the integrator stops accumulating even if Ki is later restored; the saturation toggle and limits remain in the dialog and are honoured when Ki is non-zero).
kdKddouble0.01Derivative gain (backward-difference). Set to 0 to disable the D term (drops the 'D' from the icon).
initial_integratorI₀double0Initial value of the integrator state at sim_time = 0.
i_saturationI saturationenum (Off / On)0Clamp the integral term's contribution (Ki·∫e dt) to [I_min, I_max]. Standard anti-windup: once the contribution hits a limit, the integrator state itself is back-solved so further input in the same direction cannot grow it.
i_upper_limitI_maxdouble1Upper saturation limit on Ki·∫e dt.
i_lower_limitI_mindouble-1Lower saturation limit on Ki·∫e dt.
out_saturationOutput saturationenum (Off / On)0Clamp the final summed output (P + I + D) to [Out_min, Out_max] after every step. Independent of the I-term anti-windup clamp above — you can use either, both, or neither.
out_upper_limitOut_maxdouble1Upper saturation limit on the final output.
out_lower_limitOut_mindouble-1Lower saturation limit on the final output.

Implemented in C++ class SimCompCtlPid (components/control/CSim_comp_ctl_pid/sim_comp_ctl_pid.h).

Released under the MIT License.