Main Content

piddata2

Access coefficients of parallel-form 2-DOF PID controller

Description

example

[Kp,Ki,Kd,Tf,b,c] = piddata2(sys) returns the PID gains Kp,Ki, Kd, the filter time constant Tf, and the setpoint weights b and c of the parallel-form 2-DOF PID controller represented by the dynamic system sys.

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

If sys is not a pid2 object, then each output argument is the corresponding coefficient of the parallel-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,Ki,Kd,Tf,b,c,Ts] = piddata2(sys) also returns the sample time Ts. For discrete-time sys that is not a pid2 object, piddata2 calculates the coefficient values using the default ForwardEuler discrete integrator formula for both IFormula and DFormula. See the pid2 reference page for more information about discrete integrator formulas.

example

[Kp,Ki,Kd,Tf,b,c,Ts] = piddata2(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 2-DOF PID controller that has random coefficients.

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

Extract the PID coefficients, filter time constant, and setpoint weights.

[Kp,Ki,Kd,Tf,b,c] = piddata2(C2);

Create a 2-DOF PID controller in standard form.

C2 = pidstd2(2,3,4,10,0.5,0.5)
C2 =
 
                       1      1                      s      
  u = Kp * [(b*r-y) + ---- * --- * (r-y) + Td * ------------ * (c*r-y)]
                       Ti     s                  (Td/N)*s+1 

  with Kp = 2, Ti = 3, Td = 4, N = 10, b = 0.5, c = 0.5
 
Continuous-time 2-DOF PIDF controller in standard form

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

[Kp,Ki,Kd,Tf,b,c] = piddata2(C2);

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

Ki
Ki = 0.6667
Kd
Kd = 8

Extract coefficients from a two-input, one-output dynamic system that represents a valid 2-DOF parallel-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.

A = [1,0;0.09975,0.995];
B = [0.00625,-0.00625;0.1245,-0.1241];
C = [0,4];
D = [2.875,-5.75];
sys = ss(A,B,C,D,0.1)
sys =
 
  A = 
            x1       x2
   x1        1        0
   x2  0.09975    0.995
 
  B = 
             u1        u2
   x1   0.00625  -0.00625
   x2    0.1245   -0.1241
 
  C = 
       x1  x2
   y1   0   4
 
  D = 
          u1     u2
   y1  2.875  -5.75
 
Sample time: 0.1 seconds
Discrete-time state-space model.

Extract the PID gains, filter time constant, and setpoint weights of the model.

[Kp,Ki,Kd,Tf,b,c,Ts] = piddata2(sys);

For a discrete-time system, piddata2 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 2-DOF PI controllers with random values of Kp, Ki, and b.

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

Extract all the coefficients from the array.

[Kp,Ki,Kd,Tf,b,c] = piddata2(C2);

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

Ki
Ki = 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,Ki21,Kd21,Tf21,b21,c21] = piddata2(C2,2,1);

Each of these outputs is a scalar.

Ki21
Ki21 = 0.5469

Input Arguments

collapse all

2-DOF PID controller in parallel form, specified as a pid2 controller object, a dynamic system model, or a dynamic system array. If sys is not a pid2 controller object, it must be a two-input, one-output model that represents a valid 2-DOF PID controller that can be written in parallel 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 pid2 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,Ki,Kd,Tf,b,c,Ts] = piddata2(sys,2,3);

Output Arguments

collapse all

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

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

If sys is not a pid2 object, then Kp is the proportional gain of the parallel-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 gain of the parallel-form 2-DOF PID controller represented by sys, returned as a scalar or array.

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

Filter time constant 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 parallel-form 2-DOF PID controller represented by sys, returned as a scalar or array.

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

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

Version History

Introduced in R2015b