PDF

PID Controller Setup
Introduction
A PID (proportional-integral-derivative) controller is the most common form of feedback controller (if you exclude simple on-off controllers). It continuously calculates the error, e(t) = cset − c(t), between a setpoint variable, cset, and the measured variable output, c(t). The control signal, u, is generated from three terms:
The proportionality constants are chosen so that the controlled system settles quickly. The integral term is needed to eliminate a steady-state error. The derivative terms can be sensitive to noise and is therefore often turned off or modified with a high-frequency filter. Also, the setpoint is typically not part of the derivative term (its derivative is zero except for changes in the setpoint).
There are two basic forms of a PID controller: the position form, which provides the control signal u itself, and the velocity form, from which the output is the time derivative of the control signal, in a discrete form adapted for digital process control. The PID Controller Setup add-in provides both forms of a PID controller.
In its most general form, which includes a bias constant ubias, the algorithm for a PID controller in position form provided by this add-in reads
In the velocity form, the PID controller algorithm reads
where the error En = csetc(tn).
If you want to use the velocity form, you must select the Use output solution for the time operators checkbox in the Advanced section of the Time-Dependent Solver node in the solver configuration. Otherwise, the built-in timestep variable is not available. It is also recommended to use a fixed time step in the time stepping for a PID controller on velocity form. Also, it is possible that the time-stepping tolerances need some adjustment.
You can use a PID controller to control any model variable or parameter. The requirements for using the PID Controller Setup add-in is that the model contains at least one component with some physics to control. You define the measured variable output c(t) by adding a probe, typically a domain point probe or boundary point probe, representing a process measurement. Once the add-in has been imported from the COMSOL Multiphysics Add-in Library, it can be added to the model from the Add-ins menu on the Developer tab. The PID Controller Setup add-in can create multiple PID controllers, which appears as special PID Controller components in the model tree.
Add-in Library path: COMSOL_Multiphysics/pid_controller_setup
PID Controller Setup
Once you have defined all the controller parameters, click the Create button () to add a PID Controller component that implements the controller using global equations. When the creation of the PID controller is successful, you get a message about the available control variable (such as comp2.u_in_ctrl) and the deduced unit for the controller. It is important to make sure that all controller quantities have compatible units; otherwise, a unit consistency error appears.
You can change the inputs and parameter values for the PID controller and click the Create button again to create another PID controller as another PID Controller component. If you want to update or replace a PID controller, delete its PID Controller component before creating it anew.
Equation
From the PID controller algorithm list, choose Position (the default) for a PID controller in position form, or choose Velocity for a PID controller in velocity form.
This section also displays the control algorithm and defines the names of the variables and constants that you can specify.
Component Selection
Select the desired component from the Component list. When applying the PID controller, a new PID Controller component will be added to your model with variables and global equations that implement the PID controller, and you will be presented with the name of the control variable. This variable can then be used in your model as the actuator; for example, the velocity at an inlet for a transport model.
Measured Variable Output
Before applying the PID controller, you need to define a probe that measures the controlled variable output. When available, select it from the Probe list.
If the selected probe is a Domain Point Probe or a Boundary Point Probe, also select the desired expression from the Probe expression list.
Controller Parameters
Select the Bias checkbox to include a bias that you enter in the ubias text field. If the Bias checkbox is cleared, the bias is ignored. This setting is only available for the position form.
Define the controller constants kp, ki, and kd in the Proportional gain, Integral gain, and Derivative gain text field, respectively. Leaving kd at its default zero value gives a PI controller. Defining these controller constants as global parameters makes it easy to change them without recreating the PID controller.
In the Reference value text field you specify the setpoint, cset.
Select or clear the Lower limit and Upper limit checkboxes to restrict the lower and upper limits of the control value to the values umin and umax, respectively.
Anti-Windup and Prefiltering
Select the Enable integral anti-windup checkbox and enter a time constant Tt (SI unit: s) in the Time constant field to enable integral anti-windup. Integral windup can occur when the control variable (actuator) reaches a limit. The control error will then continue to be integrated and become very large (that is, it “winds up”). This phenomenon means that an actuator saturation can cause large transients for a controller with an integral action. The anti-windup scheme keeps the integrator at a value so that the controller output is exactly at the limit, and no windup occurs. You can control the amount of anti-windup with the time constant; the smaller the value of Tt, the faster the reset of the integrator, but a too small value may cause some loss of stability when a derivative action is included in the PID controller.
Select the Enable filtering of derivative checkbox and enter a time constant Tf (SI unit: s) in the Time constant field to enable filtering of the derivative term. Such a filter works as a high-frequency filter that avoids that the derivative term becomes large due to high-frequency noise and instead only acts as a derivative for low-frequency components of the feedback signal. The larger the time constant, the more filtering is added for the high-frequency noise.
Information
This section displays information about the name of the control variable and the deduced unit for the controller. It also contains warning messages, if present.