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 gainsKp,Ki,Kd, the filter time constantTf, and the setpoint weightsbandcof the parallel-form 2-DOF PID controller represented by the dynamic systemsys.

Ifsysis apid2controller object, then each output argument is the corresponding coefficient insys.

Ifsysis not apid2object, then each output argument is the corresponding coefficient of the parallel-form 2-DOF PID controller that is equivalent tosys.

Ifsysis an array of dynamic systems, then each output argument is an array of the same dimensions assys.

example

[Kp,Ki,Kd,Tf,b,c,Ts] = piddata2(sys)also returns the sample timeTs. For discrete-timesysthat is not apid2object,piddata2calculates the coefficient values using the defaultForwardEulerdiscrete integrator formula for bothIFormulaandDFormula. See thepid2reference 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 insys, wheresysis an N-dimensional array of dynamic systems. The indicesJspecify the array entry to extract.

Examples

collapse all

Typically, you extract coefficients from a controller obtained from another function, such aspidtuneorgetBlockValue. For this example, create a 2-DOF PID controller that has random coefficients.

rng('default');% for reproducibilityC2 = 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,piddata2calculates the coefficient values using the defaultForwardEulerdiscrete integrator formula for bothIFormulaandDFormula.

Typically, you obtain an array of controllers by usingpidtuneon an array of plant models. For this example, create an 2-by-3 array of 2-DOF PI controllers with random values ofKp,Ki, andb.

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

Ki
Ki =2×30.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 apid2controller object, a dynamic system model, or a dynamic system array. Ifsysis not apid2controller 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 arraysys, specified as positive integers. Provide as many indices as there are array dimensions insys. For example, supposesysis a 4-by-5 (two-dimensional) array ofpid2controllers 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 bysys, returned as a scalar or array.

Ifsysis apid2controller object, thenKpis theKpvalue ofsys.

Ifsysis not apid2object, thenKpis the proportional gain of the parallel-form 2-DOF PID controller that is equivalent tosys.

Ifsysis an array of dynamic systems, thenKpis an array of the same dimensions assys.

Integral gain of the parallel-form 2-DOF PID controller represented bysys, returned as a scalar or array.

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

Filter time constant of the parallel-form 2-DOF PID controller represented bysys, returned as a scalar or array.

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

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

Sample time of thepid2controller, dynamic systemsys, or dynamic system array, returned as a scalar.

Introduced in R2015b