Main Content

pidstddata

Access coefficients of standard-form PID controller

Description

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

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

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

example

[Kp,Ti,Td,N,Ts] = pidstddata(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.

example

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 PID controller that has random coefficients.

rng('default');    % for reproducibility
C = pidstd(rand,rand,rand,rand);

Extract the PID coefficients and filter divisor.

[Kp,Ti,Td,N] = pidstddata(C);

Create a PID controller in parallel form.

C = pid(2,3,4,10)
C =
 
             1            s    
  Kp + Ki * --- + Kd * --------
             s          Tf*s+1 

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

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

[Kp,Ti,Td,N] = pidstddata(C);

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 dynamic system that represents a valid standard-form PID controller.

The following values form a discrete-time zero-pole-gain model that represents a PID controller in standard form.

zeros = [0.5 0.6];
poles = [1,-0.8];
gain = 1;
sys = zpk(zeros,poles,gain,0.1)
sys =
 
  (z-0.5) (z-0.6)
  ---------------
   (z-1) (z+0.8)
 
Sample time: 0.1 seconds
Discrete-time zero/pole/gain model.

Extract the PID coefficients and filter divisor of the model.

[Kp,Ti,Td,N,Ts] = pidstddata(sys);

For a discrete-time system, pidstddata 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 a 2-by-3 array of standard-form PI controllers with random values of Kp and Ti.

rng('default');    % for reproducibility
C = pidstd(rand(2,3),rand(2,3),0,10);

Extract the coefficients from the array.

[Kp,Ti,Td,N] = pidstddata(C);

The parameters are also 2-by-3 arrays. For example, examine Ti.

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] = pidstddata(C,2,1);

Each of these outputs is a scalar.

Ti21
Ti21 = 
0.5469

Input Arguments

collapse all

PID controller in standard form, specified as a pidstd controller object, a dynamic system model, or a dynamic system array. If sys is not a pidstd controller object, it must represent a valid PID controller that can be written in standard PID form. For these controllers, pidstddata returns Kp, Ti, Td and N values of a standard-form controller equivalent to sys.

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 pidstd controllers or dynamic system models that represent PID controllers. The following command extracts the data for entry (2,3) in the array.

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

Output Arguments

collapse all

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

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

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

  • If sys is a pidstd controller object, then Ti is the Ti value of sys.

  • If sys is not a pidstd object, then Ti is the integral time constant of the standard-form PID controller that is equivalent to sys.

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

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

  • If sys is a pidstd controller object, then Td is the Td value of sys.

  • If sys is not a pidstd object, then Td is the derivative time constant of the standard-form PID controller that is equivalent to sys.

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

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

  • If sys is a pidstd controller object, then N is the N value of sys.

  • If sys is not a pidstd object, then N is the filter divisor of the standard-form PID controller that is equivalent to sys.

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

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

  • If sys is a pidstd controller object, then Ts is the c value of sys.

  • If sys is not a pidstd object, then Ts is the sample time of the standard-form PID controller that is equivalent to sys.

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

Version History

Introduced in R2010b

See Also

| |