PID Controller
ContinuousThe 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
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.
Inputs & Outputs
| Direction | ID | Label | Type | Status |
|---|---|---|---|---|
| → In | error |
Error | number | Required |
| → In | reset |
Reset | number | Optional |
| ← Out | out |
Output | number | Output |
Parameters
| Parameters | Label | Type | Default | Description |
|---|---|---|---|---|
kp |
Proportional Gain (Kp) | number | 1 |
Controls immediate response to error |
ki |
Integral Gain (Ki) | number | 0.1 |
Eliminates steady-state error over time |
kd |
Derivative Gain (Kd) | number | 0.1 |
Dampens oscillations by responding to error rate of change |
n |
Filter Coefficient (N) | number | 100 |
Derivative filter cutoff frequency. Higher = less filtering |
form |
PID Form | select | parallel |
Parallel: u = Kp·e + Ki·∫e + Kd·de/dt. Series: u = Kp·(1 + 1/(Ti·s) + Td·s)·e |
min |
Saturation Min | number | -1000000000000000 |
Lower output limit for anti-windup protection |
max |
Saturation Max | number | 1000000000000000 |
Upper output limit for anti-windup protection |
Usage 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 & Best Practices
- Tuning: Start with Kp only (Ki=0, Kd=0), tune P for good response, add I to remove offset, add D for stability
- Anti-Windup: Uses conditional integration — integral only accumulates when doing so would not cause or worsen saturation
- Derivative Filter: The filtered derivative avoids noise amplification inherent in pure differentiation
- Sample Rate: All gains work correctly independent of simulation sample time (Δt is handled internally)
- Error Input: Connect (reference - measured) or similar error signal
- Classic Control: Foundation for most industrial feedback systems
Related Components
- Derivative: D-term computation
- Integrator: I-term alternative
- Saturation: Output limiting
- Subtraction: Error signal generation (reference - measured)