PID

Parallel PID with a filtered derivative term.

  • signal
  • Gradara equations
  • 2 ports
  • 4 parameters
BlockPIDKindpidLibraryControl

Description

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.

Set point (PI)PI (sampled)Plant (PI)y (PI)Set point (PID)ErrorPIDPlant (PID)y (PID)Set point (sampled PID)PID (sampled)Plant (sampled PID)y (sampled PID)
In Gradara, select a PID block and press F1, then choose Open example. It opens as a new model in My models, ready to run.

Also in this example:SubtractStepPI controllerGainLow-pass filterDiscrete PID

Ports

Inputs 1

  • eu

    Control error, typically reference minus measurement.

Outputs 1

  • y

    Controller output.

Parameters

  • Proportional gainkp1

    Proportional gain.

  • Integral gainki0.5

    Integral gain, per second.

  • Derivative gainkd0.05

    Derivative gain, in seconds.

  • Derivative filtertf0.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

Modelica
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

The block’s Modelica model
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.