PID
Parallel PID with a filtered derivative term.
- signal
- Gradara equations
- 2 ports
- 4 parameters
pidLibraryControlDescription
A continuous parallel PID controller acting on an error input. The derivative term is filtered by a first-order low-pass with time constant tf.
The block has no output limit or anti-windup.
Example
PI and PID loops The same first-order plant under a sampled PI, a continuous PID, and a sampled PID controller.
Also in this example:SubtractStepPI controllerGainLow-pass filterDiscrete PID
Ports
Inputs 1
-
e
uControl error, typically reference minus measurement.
Outputs 1
-
y
Controller output.
Parameters
-
Proportional gain
kp1Proportional gain.
-
Integral gain
ki0.5Integral gain, per second.
-
Derivative gain
kd0.05Derivative gain, in seconds.
-
Derivative filter
tf0.01 s≥ 0.0001
Derivative filter time constant, in seconds, at least 0.1 ms. Smaller values give a purer derivative and more noise gain.
Equations
dxi/dt = u, xi(0) = 0 dxf/dt = (u − xf)/tf, xf(0) = 0 y = kp · u + ki · xi + kd · (u − xf)/tf Transfer function: y/u = kp + ki/s + kd · s/(tf · s + 1)
Implementation
Real xi(start=0, fixed=true); Real xf(start=0, fixed=true); der(xi) = u; der(xf) = (u - xf)/tf; y = kp*u + ki*xi + kd*(u - xf)/tf;
Assumptions and limitations
- No output saturation and no anti-windup: the integral grows without bound while the error persists.
- The derivative acts on the error, so a step in the reference produces a derivative kick of kd/tf times the step.
- The filter state xf starts at 0, so a nonzero error at t = 0 also gives an initial derivative kick of kd · u(0)/tf.
Tips
- To limit the output, follow the block with Saturation, keeping in mind the integral still winds up.
Used in
These larger examples use it too. Open them from Examples in the app.
- EV drivetrain
See also
Select a block in Gradara and press F1 to open its page offline.