Main Content

piddata

Access coefficients of parallel-form PID controller

    Description

    [Kp,Ki,Tf] = piddata(sys) returns the PID gains Kp,Ki,Kd and the filter time constant Tf of the parallel-form controller represented by the dynamic system sys.

    example

    [Kp,Ki,Kd,Tf,Ts] = piddata(sys)also returns the sample time Ts.

    example

    [Kp,Ki,Kd,Tf,Ts] = piddata(sys,J,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 PID controller that has random coefficients.

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

    Extract the PID gains and filter time constant.

    [Kp,Ki,Kd,Tf] = piddata(C)
    Kp = 
    0.8147
    
    Ki = 
    0.9058
    
    Kd = 
    0.1270
    
    Tf = 
    0.9134
    

    Create a PI controller in standard form.

    C = pidstd(2,3)
    C =
     
                 1      1 
      Kp * (1 + ---- * ---)
                 Ti     s 
    
      with Kp = 2, Ti = 3
     
    Continuous-time PI controller in standard form
    

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

    [Kp,Ki] = piddata(C)
    Kp = 
    2
    
    Ki = 
    0.6667
    

    Extract coefficients from dynamic system that represents a valid discrete-time parallel-form PID controller with a derivate filter.

    H(z)=(z-0.5)(z-0.6)(z-1)(z+0.8)

    H = zpk([0.5 0.6],[1,-0.8],1,0.1);

    Extract the PID gains and filter time constant.

    [Kp,Ki,Kd,Tf,Ts] = piddata(H)
    Kp = 
    0.4383
    
    Ki = 
    1.1111
    
    Kd = 
    0.0312
    
    Tf = 
    0.0556
    
    Ts = 
    0.1000
    

    For a discrete-time system, piddata 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 PI controllers with random values of Kp, Ki.

    rng('default');
    C = pid(rand(2,3),rand(2,3));

    Extract all the coefficients from the array.

    [Kp,Ki] = piddata(C);

    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.

    [Kp,Ki] = piddata(C,2,1)
    Kp = 
    0.9058
    
    Ki = 
    0.5469
    

    Input Arguments

    collapse all

    If sys is not a pid object, it must represent a valid PID controller that can be written in parallel PID 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.

    Example: For example, suppose sys is a 4-by-5 (two-dimensional) array of pid controllers or dynamic system models that represent PID controllers. The following command extracts the data for entry (2,3) in the array.

    [Kp,Ki,Kd,Tf,Ts] = piddata(sys,2,3);

    Output Arguments

    collapse all

    If sys is a pid controller object, the output Kp is equal to the Kp value of sys.

    If sys is not a pid object, Kp is the proportional gain of a parallel PID controller equivalent to sys.

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

    If sys is a pid controller object, then the output Ki is equal to the Ki value of sys.

    If sys is not a pid object, then Ki is the integral gain of a parallel PID controller equivalent to sys.

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

    If sys is a pid controller object, then the output Kd is equal to the Kd value of sys.

    If sys is not a pid object, then Kd is the derivative gain of a parallel PID controller equivalent to sys.

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

    If sys is a pid controller object, the output Tf is equal to the Tf value of sys.

    If sys is not a pid object, Tf is the filter time constant of a parallel PID controller equivalent to sys.

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

    Sample time of the dynamic system sys. Ts is always a scalar value.

    Tips

    • If sys is not a pid controller object, piddata returns the PID gains Kp, Ki, Kd and the filter time constant Tf of a parallel-form controller equivalent to sys.

    • For discrete-time sys, piddata returns the parameters of an equivalent parallel-form controller. This controller has discrete integrator formulas IFormula and DFormula set to ForwardEuler. See the pid reference page for more information about discrete integrator formulas.

    Version History

    Introduced in R2010b

    See Also

    | |