Discrete-Time Proportional-Integral-Derivative (PID) Controllers
All the PID controller object types, pid
, pidstd
, pid2
,
and pidstd2
, can represent PID controllers in
discrete time.
Discrete-Time PID Controller Representations
Discrete-time PID controllers are expressed by the following formulas.
Form | Formula |
---|---|
Parallel (pid ) |
where:
|
Standard (pidstd ) |
where:
|
2-DOF Parallel (pid2 ) |
The relationship between the 2-DOF controller’s output (u) and its two inputs (r and y) is: In this representation:
|
2-DOF Standard (pidstd2 object) |
In this representation:
|
In all of these expressions, IF(z)
and DF(z) are the discrete integrator
formulas for the integrator and derivative filter, respectively. Use
the IFormula
and DFormula
properties
of the controller objects to set the IF(z)
and DF(z) formulas. The next
table shows available formulas for IF(z)
and DF(z). Ts is
the sample time.
IFormula or DFormula | IF(z) or DF(z) |
---|---|
ForwardEuler (default) |
|
BackwardEuler |
|
Trapezoidal |
|
If you do not specify a value for IFormula
, DFormula
,
or both when you create the controller object, ForwardEuler
is
used by default. For more information about setting and changing the
discrete integrator formulas, see the reference pages for the controller
objects, pid
, pidstd
, pid2
,
and pidstd2
.
Create Discrete-Time Standard-Form PID Controller
This example shows how to create a standard-form discrete-time Proportional-Integral-Derivative (PID) controller that has Kp = 29.5, Ti = 1.13, Td = 0.15 N = 2.3, and sample time Ts 0.1 :
C = pidstd(29.5,1.13,0.15,2.3,0.1,... 'IFormula','Trapezoidal','DFormula','BackwardEuler')
This command creates a pidstd
model with and .
You can set the discrete integrator formulas for a parallel-form
controller in the same way, using pid
.
Discrete-Time 2-DOF PI Controller in Standard Form
Create a discrete-time 2-DOF PI controller in standard form, using the trapezoidal discretization formula. Specify the formula using Name,Value
syntax.
Kp = 1; Ti = 2.4; Td = 0; N = Inf; b = 0.5; c = 0; Ts = 0.1; C2 = pidstd2(Kp,Ti,Td,N,b,c,Ts,'IFormula','Trapezoidal')
C2 = 1 Ts*(z+1) u = Kp * [(b*r-y) + ---- * -------- * (r-y)] Ti 2*(z-1) with Kp = 1, Ti = 2.4, b = 0.5, Ts = 0.1 Sample time: 0.1 seconds Discrete-time 2-DOF PI controller in standard form
Setting Td
= 0 specifies a PI controller with no derivative term. As the display shows, the values of N
and c
are not used in this controller. The display also shows that the trapezoidal formula is used for the integrator.