pidstddata2

Access coefficients of standard-form 2-DOF PID controller

Syntax

[Kp,Ti,Td,N,b,c] = pidstddata2(sys)
[Kp,Ti,Td,N,b,c,Ts] = pidstddata2(sys)
[Kp,Ti,Td,N,b,c,Ts] = pidstddata2(sys,J1,...,JN)

Description

example

[Kp,Ti,Td,N,b,c] = pidstddata2(sys) returns the proportional gain Kp, integral time Ti, derivative time Td, the filter divisor N, and the setpoint weights b and c of the standard-form 2-DOF PID controller represented by the dynamic system sys.

If sys is a pidstd2 controller object, then each output argument is the corresponding coefficient in sys.

If sys is not a pidstd2 object, then each output argument is the corresponding coefficient of the standard-form 2-DOF PID controller that is equivalent to sys.

If sys is an array of dynamic systems, then each output argument is an array of the same dimensions as sys.

example

[Kp,Ti,Td,N,b,c,Ts] = pidstddata2(sys) also returns the sample time Ts. For discrete-time sys that is not a pidstd2 object, pidstddata2 calculates the coefficient values using the default ForwardEuler discrete integrator formula for both IFormula and DFormula. See the pidstd2 reference page for more information about discrete integrator formulas.

example

[Kp,Ti,Td,N,b,c,Ts] = pidstddata2(sys,J1,...,JN) extracts the data for a subset of entries in sys, where sys is an N-dimensional array of dynamic systems. The indices J specify the array entry to extract.

Examples

collapse all

Typically, you extract coefficients from a controller obtained from another function, such as pidtune or getBlockValue. For this example, create a standard-form 2-DOF PID controller that has random coefficients.

rng('default');    % for reproducibility
C2 = pidstd2(rand,rand,rand,rand,rand,rand);

Extract the PID coefficients, filter divisor, and setpoint weights.

[Kp,Ti,Td,N,b,c] = pidstddata2(C2);

Create a 2-DOF PID controller in parallel form.

C2 = pid2(2,3,4,10,0.5,0.5)
C2 =
 
                       1                s    
  u = Kp (b*r-y) + Ki --- (r-y) + Kd -------- (c*r-y)
                       s              Tf*s+1 

  with Kp = 2, Ki = 3, Kd = 4, Tf = 10, b = 0.5, c = 0.5
 
Continuous-time 2-DOF PIDF controller in parallel form.

Compute the coefficients of an equivalent parallel-form PID controller.

[Kp,Ti,Td,N,b,c] = pidstddata2(C2);

Check some of the coefficients to confirm that they are different from the parallel-form coefficients.

Ti
Ti = 0.6667
Td
Td = 2

Extract coefficients from a two-input, one-output dynamic system that represents a valid 2-DOF standard-form PID controller.

The following A, B, C, and D matrices form a discrete-time state-space model that represents a 2-DOF PID controller in standard form.

A = [1,0;0,0.5];
B = [0.1,-0.1;-0.25,0.5];
C = [4,400];
D = [220,-440];
sys = ss(A,B,C,D,0.1)
sys =
 
  A = 
        x1   x2
   x1    1    0
   x2    0  0.5
 
  B = 
          u1     u2
   x1    0.1   -0.1
   x2  -0.25    0.5
 
  C = 
        x1   x2
   y1    4  400
 
  D = 
         u1    u2
   y1   220  -440
 
Sample time: 0.1 seconds
Discrete-time state-space model.

Extract the PID coefficients, filter divisor, and setpoint weights of the model.

[Kp,Ti,Td,N,b,c,Ts] = pidstddata2(sys);

For a discrete-time system, pidstddata2 calculates the coefficient values using the default ForwardEuler discrete integrator formula for both IFormula and DFormula.

Typically, you obtain an array of controllers by using pidtune on an array of plant models. For this example, create an 2-by-3 array of standard-form 2-DOF PI controllers with random values of Kp, Ti, and b.

rng('default');
C2 = pidstd2(rand(2,3),rand(2,3),0,10,rand(2,3),0);

Extract all the coefficients from the array.

[Kp,Ti,Td,N,b,c] = pidstddata2(C2);

Each of the outputs is itself a 2-by-3 array. For example, examine Ki.

Ti
Ti = 2×3

    0.2785    0.9575    0.1576
    0.5469    0.9649    0.9706

Extract only the coefficients of entry (2,1) in the array.

[Kp21,Ti21,Td21,N21,b21,c21] = pidstddata2(C2,2,1);

Each of these outputs is a scalar.

Ti21
Ti21 = 0.5469

Input Arguments

collapse all

2-DOF PID controller in standard form, specified as a pidstd2 controller object, a dynamic system model, or a dynamic system array. If sys is not a pidstd2 controller object, it must be a two-input, one-output model that represents a valid 2-DOF PID controller that can be written in standard form.

Indices of entry to extract from a model array sys, specified as positive integers. Provide as many indices as there are array dimensions in sys. For example, suppose sys is a 4-by-5 (two-dimensional) array of pidstd2 controllers or dynamic system models that represent 2-DOF PID controllers. The following command extracts the data for entry (2,3) in the array.

[Kp,Ti,Td,N,b,c,Ts] = piddstdata2(sys,2,3);

Output Arguments

collapse all

Proportional gain of the standard-form 2-DOF PID controller represented by sys, returned as a scalar or array.

If sys is a pidstd2 controller object, then Kp is the Kp value of sys.

If sys is not a pidstd2 object, then Kp is the proportional gain of the standard-form 2-DOF PID controller that is equivalent to sys.

If sys is an array of dynamic systems, then Kp is an array of the same dimensions as sys.

Integral time constant of the standard-form 2-DOF PID controller represented by sys, returned as a scalar or array.

Derivative time constant of the standard-form 2-DOF PID controller represented by sys, returned as a scalar or array.

Filter divisor of the parallel-form 2-DOF PID controller represented by sys, returned as a scalar or array.

Setpoint weight on the proportional term of the standard-form 2-DOF PID controller represented by sys, returned as a scalar or array.

Setpoint weight on the derivative term of the standard-form 2-DOF PID controller represented by sys, returned as a scalar or array.

Sample time of the pidstd2 controller, dynamic system sys, or dynamic system array, returned as a scalar.

Introduced in R2015b