WOLFRAM SYSTEM MODELER
LimPIDP, PI, PD, and PID controller with limited output, antiwindup compensation, setpoint weighting and optional feedforward 
SystemModel["Modelica.Blocks.Continuous.LimPID"]
This information is part of the Modelica Standard Library maintained by the Modelica Association.
Via parameter controllerType either P, PI, PD, or PID can be selected. If, e.g., PI is selected, all components belonging to the Dpart are removed from the block (via conditional declarations). The example model Modelica.Blocks.Examples.PID_Controller demonstrates the usage of this controller. Several practical aspects of PID controller design are incorporated according to chapter 3 of the book:
Besides the additive proportional, integral and derivative part of this controller, the following features are present:
The parameters of the controller can be manually adjusted by performing simulations of the closed loop system (= controller + plant connected together) and using the following strategy:
Initialization
This block can be initialized in different ways controlled by parameter initType. The possible values of initType are defined in Modelica.Blocks.Types.Init.
Based on the setting of initType, the integrator (I) and derivative (D) blocks inside the PID controller are initialized according to the following table:
initType  I.initType  D.initType 
NoInit  NoInit  NoInit 
SteadyState  SteadyState  SteadyState 
InitialState  InitialState  InitialState 
InitialOutput and initial equation: y = y_start 
NoInit  SteadyState 
In many cases, the most useful initial condition is SteadyState because initial transients are then no longer present. If initType = Init.SteadyState, then in some cases difficulties might occur. The reason is the equation of the integrator:
der(y) = k*u;
The steady state equation "der(x)=0" leads to the condition that the input u to the integrator is zero. If the input u is already (directly or indirectly) defined by another initial condition, then the initialization problem is singular (has none or infinitely many solutions). This situation occurs often for mechanical systems, where, e.g., u = desiredSpeed  measuredSpeed and since speed is both a state and a derivative, it is natural to initialize it with zero. As sketched this is, however, not possible. The solution is to not initialize u_m or the variable that is used to compute u_m by an algebraic equation.
When initializing in steadystate, homotopybased initialization can help the convergence of the solver, by using a simplified model a the beginning of the solution process. Different options are available.
controllerType 
Value: .Modelica.Blocks.Types.SimpleController.PID Type: SimpleController Description: Type of controller 

k 
Value: 1 Type: Real Description: Gain of controller 
Ti 
Value: 0.5 Type: Time (s) Description: Time constant of Integrator block 
Td 
Value: 0.1 Type: Time (s) Description: Time constant of Derivative block 
yMax 
Value: Type: Real Description: Upper limit of output 
yMin 
Value: yMax Type: Real Description: Lower limit of output 
wp 
Value: 1 Type: Real Description: Setpoint weight for Proportional block (0..1) 
wd 
Value: 0 Type: Real Description: Setpoint weight for Derivative block (0..1) 
Ni 
Value: 0.9 Type: Real Description: Ni*Ti is time constant of antiwindup compensation 
Nd 
Value: 10 Type: Real Description: The higher Nd, the more ideal the derivative block 
withFeedForward 
Value: false Type: Boolean Description: Use feedforward input? 
kFF 
Value: 1 Type: Real Description: Gain of feedforward input 
initType 
Value: Init.InitialState Type: Init Description: Type of initialization (1: no init, 2: steady state, 3: initial state, 4: initial output) 
xi_start 
Value: 0 Type: Real Description: Initial or guess value for integrator output (= integrator state) 
xd_start 
Value: 0 Type: Real Description: Initial or guess value for state of derivative block 
y_start 
Value: 0 Type: Real Description: Initial value of output 
homotopyType 
Value: Modelica.Blocks.Types.LimiterHomotopy.Linear Type: LimiterHomotopy Description: Simplified model for homotopybased initialization 
strict 
Value: false Type: Boolean Description: = true, if strict limits with noEvent(..) 
controlError 
Default Value: u_s  u_m Type: Real Description: Control error (set point  measurement) 

u_s 
Type: RealInput Description: Connector of setpoint input signal 


u_m 
Type: RealInput Description: Connector of measurement input signal 

y 
Type: RealOutput Description: Connector of actuator output signal 

u_ff 
Type: RealInput Description: Optional connector of feedforward input signal 
addP 
Type: Add Description: Output the sum of the two inputs 


addD 
Type: Add Description: Output the sum of the two inputs 

P 
Type: Gain Description: Output the product of a gain value with the input signal 

I 
Type: Integrator Description: Output the integral of the input signal with optional reset 

D 
Type: Derivative Description: Approximated derivative block 

gainPID 
Type: Gain Description: Output the product of a gain value with the input signal 

addPID 
Type: Add3 Description: Output the sum of the three inputs 

addI 
Type: Add3 Description: Output the sum of the three inputs 

addSat 
Type: Add Description: Output the sum of the two inputs 

gainTrack 
Type: Gain Description: Output the product of a gain value with the input signal 

limiter 
Type: Limiter Description: Limit the range of a signal 

Dzero 
Type: Constant Description: Generate constant signal of type Real 

Izero 
Type: Constant Description: Generate constant signal of type Real 

FFzero 
Type: Constant Description: Generate constant signal of type Real 

addFF 
Type: Add Description: Output the sum of the two inputs 
Modelica.Blocks.Examples Demonstrates the usage of a Continuous.LimPID controller 

Modelica.Electrical.Machines.Examples.SynchronousMachines Test example: ElectricalExcitedSynchronousMachine with voltage controller 

Modelica.Electrical.Machines.Examples.SynchronousMachines Test example: ElectricalExcitedSynchronousMachine with rectifier 

Modelica.Electrical.Machines.Examples.DCMachines Test example: DC with permanent magnet starting with current controller 

Modelica.Magnetic.FundamentalWave.Examples.BasicMachines.SynchronousMachines Test example: ElectricalExcitedSynchronousMachine with voltage controller 

Modelica.Magnetic.FundamentalWave.Examples.BasicMachines.SynchronousMachines Test example: ElectricalExcitedSynchronousMachine with rectifier 

Modelica.Fluid.Examples.TraceSubstances Demonstrates a room volume with CO2 controls 