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
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.
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.
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.
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.
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.
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.