This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

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.

FormFormula
Parallel (pid)

C=Kp+KiIF(z)+KdTf+DF(z),

where:

  • Kp = proportional gain

  • Ki = integrator gain

  • Kd = derivative gain

  • Tf = derivative filter time

Standard (pidstd)

C=Kp(1+1TiIF(z)+TdTdN+DF(z)),

where:

  • Kp = proportional gain

  • Ti = integrator time

  • Td = derivative time

  • N = derivative filter divisor

2-DOF Parallel (pid2)

The relationship between the 2-DOF controller’s output (u) and its two inputs (r and y) is:

u=Kp(bry)+KiIF(z)(ry)+KdTf+DF(z)(cry).

In this representation:

  • Kp = proportional gain

  • Ki = integrator gain

  • Kd = derivative gain

  • Tf = derivative filter time

  • b = setpoint weight on proportional term

  • c = setpoint weight on derivative term

2-DOF Standard (pidstd2 object)

u=Kp[(bry)+1TiIF(z)(ry)+TdTdN+DF(z)(cry)].

In this representation:

  • Kp = proportional gain

  • Ti = integrator time

  • Td = derivative time

  • N = derivative filter divisor

  • b = setpoint weight on proportional term

  • c = setpoint weight on derivative term

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 DFormulaIF(z) or DF(z)
ForwardEuler (default)

Tsz1

BackwardEuler

Tszz1

Trapezoidal

Ts2z+1z1

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 IF(z)=Ts2z+1z1 and DF(z)=Tszz1.

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.

See Also

| | |

Related Examples

More About