Main Content

Discrete PI Controller

Discrete-time PI controller with external anti-windup input

  • Discrete PI Controller block

Simscape / Electrical / Control / General Control


The Discrete PI Controller block implements discrete PI control with external anti-windup input.

This diagram is the equivalent circuit for the controller with external anti-windup input.


The Discrete PI Controller block calculates the control signal using the backward Euler discretization method:



  • u is the control signal.

  • Kp is the proportional gain coefficient.

  • Ki is the integral gain coefficient.

  • Kaw is the anti-windup gain coefficient.

  • Ts is the sampling period.

  • e is the error signal.

To prevent excessive overshoot, the block can use back calculation to implement an external anti-windup mechanism. It inputs du(k), the difference between the saturated control signal, usat(k), and the calculated unsaturated control signal, u(k). It then multiplies the difference by the anti-windup coefficient and adds the amplified signal from the integral gain.




expand all

Error signal, e(k), obtained as the difference between the reference, r(k), and measurement, y(k), signals.

Data Types: single | double

Difference, du(k), between the saturated u^sat(k) and the unsaturated control signals, u(k). If du(k) is zero, the anti-windup is disabled.


Data Types: single | double

External reset (rising edge) signal for the integrator.

Data Types: single | double


expand all

Control signal, u(k).

Data Types: single | double


expand all

Proportional gain, Kp, of the PI controller.

Integral gain,Ki, of the PI controller.

Anti-windup gain, Kaw, of the PI controller.

Value of the integrator at simulation start time.

Time interval between samples. If the block is inside a triggered subsystem, inherit the sample time by setting this parameter to -1. If this block is in a continuous variable-step model, specify the sample time explicitly. For more information, see What Is Sample Time? and Specify Sample Time.


[1] Åström, K. and T. Hägglund. Advanced PID Control. Research Triangle Park, NC: ISA, 2005.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2017b