Lim PID

P, PI, PD, and PID controller with limited output, anti-windup compensation and setpoint weighting

Description

The Lim PID component models a proportional-integral-derivative (PID) controller. It differs from the PID Controller in that the proportional gain is coupled with the integral and the derivative gain. This type of setup is more common in an industrial controller.

Anti-windup compensation is incorporated to drive the integrator to 0 if the output is near the saturation points, and the high-frequency derivative gain is limited to avoid excessive amplification of measurement noise.

Setpoint weighting is present, allowing you to specify the setpoint weight in the proportional and the derivative parts independently from the measurement. The controller responds to load disturbances and measurement noise independently of this setting (${w}_{p}$ and ${w}_{d}$), however, setpoint changes depend on this setting. For example, for the derivative part, it is useful to specify the setpoint weight, ${w}_{d}$ to 0 if steps occur in the setpoint signal.

The Signal Size parameter allows the block to operate on a vector of signals rather than a single signal.

Initialization

Based on the setting of the Initial Values parameter, the integrator (I) and derivative (D) components in the PID controller are initialized according to the following table.

 Setting Integrator initType Derivative initType none NoInit NoInit steady states SteadyState SteadyState initial states InitialState InitialState initial outputs NoInit SteadyState integrator states InitialState NoInit

In many cases, the most useful initial condition is steady states because initial transients are no longer present. If $\mathrm{initType}=\mathrm{InitPID}\cdot \mathrm{SteadyState}$, then in some cases difficulties might occur. The reason is the equation of the integrator, $\stackrel{.}{y}=ku$. The steady state equation, $\stackrel{.}{x}=0$ leads to the condition that the input to the integrator is 0. If the input $u$ is already (directly or indirectly) defined by another initial condition, the initialization problem is singular (that is, has none or infinitely many solutions). This situation occurs often in mechanical systems, where, for example, $u=\mathrm{desiredSpeed}-\mathrm{measuredSpeed}$. Because speed is both a state and a derivative, it is natural to initialize it with 0. As sketched, this is not possible. The solution is to not initialize ${u}_{m}$ or the variable that is used to compute ${u}_{m}$ by an algebraic equation. If the parameter Limits At Initial is $\mathrm{false}$, the limits at the output of this component are removed from the initialization problem, which leads to a much simpler equation system. After initialization has been performed, it is checked with an assert whether the output is in the defined limits.

 Equations $y=\left\{\begin{array}{cc}{y}_{\mathrm{min}}& {y}^{*}\le {y}_{\mathrm{min}}\\ {y}^{*}\phantom{\rule[-0.0ex]{1.0ex}{0.0ex}}& {y}_{\mathrm{min}}<{y}^{*}<{y}_{\mathrm{max}}\\ {y}_{\mathrm{max}}& {y}_{\mathrm{max}}\le {y}^{*}\end{array}$ ${y}^{*}=k\left({e}_{p}+\frac{{e}_{i}}{{T}_{i}s}+{e}_{d}{T}_{d}s\right)$ ${e}_{p}={w}_{p}{u}_{s}-{u}_{m}$ ${e}_{d}={w}_{d}{u}_{s}-{u}_{m}$ ${e}_{i}={u}_{s}-{u}_{m}+\frac{1}{k{N}_{i}}\left(y-{y}^{*}\right)$

Connections

 Name Description Modelica ID ${u}_{s}$ Setpoint input signal u_s ${u}_{m}$ Measurement input signal u_m $y$ Actuator output signal y

Parameters

 Name Default Units Description Modelica ID Signal Size $1$ Dimension of input and output signals signalSize Controller Type PID Type of controller: P, PI, PD, or PID controllerType k $1$ $1$ Gain of controller k ${T}_{i}$ $0.5$ $s$ Time constant of Integrator block Ti ${T}_{d}$ $0.1$ $s$ Time constant of Derivative block Td ${y}_{\mathrm{max}}$ $1$ Upper limit of output yMax ${y}_{\mathrm{min}}$ $-{y}_{\mathrm{max}}$ Lower limit of output yMin ${w}_{p}$ $1$ Set-point weight for Proportional block (0..1) wp ${w}_{d}$ $0$ Set-point weight for Derivative block (0..1) wd ${N}_{i}$ $0.9$ ${N}_{i}{T}_{i}$ is time constant of anti-windup compensation Ni ${N}_{d}$ $10$ The greater Nd, the more ideal the derivative block Nd Initial Values NoInit Type of initialization (see Initialization section) initType Limits At Initial $\mathrm{true}$ False means limits are ignored during initialization limitsAtInit ${x}_{{i}_{0}}$ $0$ Initial or guess value value for integrator output (= integrator state) xi_start ${x}_{{d}_{0}}$ $0$ Initial or guess value for state of derivative block xd_start ${y}_{0}$ $0$ Initial value of output y_start $\mathrm{strict}$ $\mathrm{false}$ True means use strict limits with noEvent(..) strict