Continuous

PIDController Block

Standard PID (Proportional-Integral-Derivative) controller for closed-loop control

Open PIDController in BlockWerk →

Description

The PID Controller block implements a standard Proportional-Integral-Derivative controller for closed-loop feedback control. It combines three control terms to regulate a process: proportional correction for immediate response, integral for eliminating steady-state error, and derivative for damping overshoot.

Mathematical Model

P term:  p(t) = Kp × e(t)
I term:  i(t) = Ki × ∫₀ᵗ e(τ) dτ
D term:  d(t) = Kd × N × s/(s+N) × e(t)   (filtered derivative)

Output:  u(t) = p(t) + i(t) + d(t)
Saturated: u = clamp(u, u_min, u_max)

Discrete approximation:

I[n] = I[n-1] + Ki × e[n] × Δt                              (Forward Euler)
D[n] = (Kd × N × (e[n] - e[n-1]) + D[n-1]) / (1 + N × Δt)  (Backward Euler filter)

The derivative filter transfer function is Kd × N × s / (s + N), where N is the filter coefficient. This low-pass filters the derivative action to reduce noise amplification. Higher N means less filtering (N → ∞ gives pure derivative). Typical values: N = 10–100.

Parameters

proportionalGain (Kp)

Proportional gain. Controls immediate response to error.

integralGain (Ki)

Integral gain. Eliminates steady-state error by accumulating error over time.

derivativeGain (Kd)

Derivative gain. Dampens oscillations by responding to error rate of change.

filterCoefficient (N)

Derivative filter coefficient. Controls the cutoff frequency of the derivative low-pass filter.

saturationMin

Lower output limit for anti-windup protection.

saturationMax

Upper output limit for anti-windup protection.

reset (optional)

Reset trigger. Set > 0 to reset the controller state.

Anti-Windup Behavior

The anti-windup mechanism prevents integral accumulation when the output would saturate:

Examples

Temperature Control (1 second)

Setpoint = 50°C, measured temperature ramps from 20°C. PID controller outputs heating signal, reducing error over time.

Motor Speed Regulation

Reference speed vs measured speed error fed to PID. Output drives motor command signal.

Remarks

See Also