AutotunerPID Toolkit Previous page   Next Page

pid_tuning

PURPOSE ^

PID_TUNING Tune the parameters of a ISA-PID regulator with some well-befined autotuning methods.

SYNOPSIS ^

function [K,Ti,Td,N,b] = pid_tuning(model,method,param,regStruct,As)

DESCRIPTION ^

PID_TUNING Tune the parameters of a ISA-PID regulator with some
   well-defined autotuning methods 

   [K,Ti,Td,N,b] = PID_TUNING(MODEL,MEETHOD,PARAM,REGSTRUCT) returns the
   parameters of a ISA-PID regulator.
   MODEL is a structure describing the plant, with the following fields:
      - MODEL.m, MODEL.L, MODEL.T for a model based method (namely the
        parameters of a FOPDT model M(s) = m*exp(-sL)/(1+s*T))
      - MODEL.A, MODEL.T for a characteristic based method (amplitude and
        period of the oscillation generated by a relay in the loop)
   METHOD is a flag indicating the desired tuning method while PARAM gives
   additional parameters (if required), according to the following table

    Tuning method          |   METHOD   | PARAM
   ------------------------------------------------------------------------
    First Ziegler-Nichols  | 'ZN (OL)'  | none  
    method (open loop)     |            |
                           |            |
    Kappa-Tau method       |    'KT'    | Ms : required magnitude margin
                           |            |
    Internal Model Control |   'IMC'    | lambda : time constant of the
    method                 |            |          filter F(s) 
                           |            |   
    Second Ziegler-Nichols | 'ZN (CL)'  | none
    method (closed loop)   |            |
   -----------------------------------------------------------------------

   REGSTRUCT is a flag selecting the regulator structure ('PI' or 'PID')

   Author:    William Spinelli (wspinell@elet.polimi.it)
   Copyright  2004 W.Spinelli
   $Revision: 1.0 $  $Date: 2004/02/27 12:00:00 $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [K,Ti,Td,N,b] = pid_tuning(model,method,param,regStruct,As)
0002 %PID_TUNING Tune the parameters of a ISA-PID regulator with some
0003 %   well-defined autotuning methods
0004 %
0005 %   [K,Ti,Td,N,b] = PID_TUNING(MODEL,MEETHOD,PARAM,REGSTRUCT) returns the
0006 %   parameters of a ISA-PID regulator.
0007 %   MODEL is a structure describing the plant, with the following fields:
0008 %      - MODEL.m, MODEL.L, MODEL.T for a model based method (namely the
0009 %        parameters of a FOPDT model M(s) = m*exp(-sL)/(1+s*T))
0010 %      - MODEL.A, MODEL.T for a characteristic based method (amplitude and
0011 %        period of the oscillation generated by a relay in the loop)
0012 %   METHOD is a flag indicating the desired tuning method while PARAM gives
0013 %   additional parameters (if required), according to the following table
0014 %
0015 %    Tuning method          |   METHOD   | PARAM
0016 %   ------------------------------------------------------------------------
0017 %    First Ziegler-Nichols  | 'ZN (OL)'  | none
0018 %    method (open loop)     |            |
0019 %                           |            |
0020 %    Kappa-Tau method       |    'KT'    | Ms : required magnitude margin
0021 %                           |            |
0022 %    Internal Model Control |   'IMC'    | lambda : time constant of the
0023 %    method                 |            |          filter F(s)
0024 %                           |            |
0025 %    Second Ziegler-Nichols | 'ZN (CL)'  | none
0026 %    method (closed loop)   |            |
0027 %   -----------------------------------------------------------------------
0028 %
0029 %   REGSTRUCT is a flag selecting the regulator structure ('PI' or 'PID')
0030 %
0031 %   Author:    William Spinelli (wspinell@elet.polimi.it)
0032 %   Copyright  2004 W.Spinelli
0033 %   $Revision: 1.0 $  $Date: 2004/02/27 12:00:00 $
0034 
0035 if nargin<4
0036    error('Usage : [K,Ti,Td,N,b] = pid_tuning(model,method,param,regStruct)')
0037 end
0038 if nargin<5
0039    As = 1;
0040 end
0041 
0042 % synthesis of the PID parameters
0043 switch method
0044    case {'KT','kt'}
0045       % Kappa-Tau
0046       % FOPDT model parameters
0047       m = model.m; L = model.L; T = model.T;
0048       % tuning method parameter
0049       Ms = param;             % required magnitude margin
0050       
0051       if Ms==1.4
0052          % conservative tuning
0053          if strcmp(regStruct,'PI')
0054             A0 = 0.29;  A1 = -2.7;  A2 = 3.7;
0055             B0 = 8.9;   B1 = -6.6;  B2 = 3.0;
0056             C0 = 0;     C1 = 0;     C2 = 0;
0057             D0 = 0.81;  D1 = 0.73;  D2 = 1.9;
0058          elseif strcmp(regStruct,'PID')
0059             A0 = 3.8;   A1 = -8.4;  A2 = 7.3;
0060             B0 = 5.2;   B1 = -2.5;  B2 = -1.4;
0061             C0 = 0.89;  C1 = -0.37; C2 = -4.1;
0062             D0 = 0.4;   D1 = 0.18;  D2 = 2.8;
0063          end
0064       elseif Ms==2
0065          % more aggressive tuning
0066          if strcmp(regStruct,'PI')
0067             A0 = 0.78;  A1 = -4.1;  A2 = 5.7;
0068             B0 = 8.9;   B1 = -6.6;  B2 = 3.0;
0069             C0 = 0;     C1 = 0;     C2 = 0;
0070             D0 = 0.48;  D1 = 0.78;  D2 = -0.45;
0071          elseif strcmp(regStruct,'PID')
0072             A0 = 8.4;   A1 = -9.6;  A2 = 9.8;
0073             B0 = 3.2;   B1 = -1.5;  B2 = -0.93;
0074             C0 = 0.86;  C1 = -1.9;  C2 = -0.44;
0075             D0 = 0.22;  D1 = 0.65;  D2 = 0.051;
0076          end
0077       end
0078       
0079       a   = m*L/T;            % normalized gain
0080       tau = L/(L+T);          % normalized delay
0081       
0082       K  = A0/a*exp(A1*tau+A2*tau^2);
0083       Ti = L*B0*exp(B1*tau+B2*tau^2);
0084       Td = L*C0*exp(C1*tau+C2*tau^2);
0085       b  = D0*exp(D1*tau+D2*tau^2);
0086       N  = 5;
0087       
0088    case {'IMC','imc'}
0089       % Internal Model Control
0090       % FOPDT model parameters
0091       m = model.m; L = model.L; T = model.T;
0092       % tuning method parameter
0093       lambda = param;         % lambda
0094       
0095       Ti = T + L^2/(2*(L+lambda));
0096       K  = Ti / (m*(L+lambda));
0097       N  = T*(L+lambda) / (lambda*Ti) - 1;
0098       Td = lambda*L*N / (2*(L+lambda));
0099       if Td==0
0100          N=5;
0101       end
0102       % b is tuned according to KT rules for PID
0103       b  = 0.4*exp(0.18*(L/(L+T))+2.8*(L/(L+T))^2);
0104       
0105    case {'ZN (OL)','zn (ol)'}
0106       % Ziegler & Nichols (open loop)
0107       % FOPDT model parameters
0108       m = model.m; L = model.L; T = model.T;
0109       if L~=0
0110          if strcmp(regStruct,'PI')
0111             K = (0.9*T) / (m*L);
0112             Ti = 3*L;
0113             Td = 0;
0114          elseif strcmp(regStruct,'PID')
0115             K = (1.2*T) / (m*L);
0116             Ti = 2*L;
0117             Td = 0.5*L;
0118          end
0119       b  = 1;
0120       N  = 5;
0121       end
0122       
0123    case {'ZN (CL)','zn (cl)'}
0124       % Ziegler & Nichols (closed loop)
0125       % point of the frequency response
0126       A = model.A; T = model.T;
0127       
0128       Ku = 4*As/(pi*A);
0129 
0130       if strcmp(regStruct,'PI')
0131          K  = 0.4*Ku;
0132          Ti = T/1.2;
0133          Td = 0;
0134       elseif strcmp(regStruct,'PID')
0135          K  = 0.6*Ku;
0136          Ti = T/2;
0137          Td = T/8;
0138       end
0139       
0140       b  = 1;
0141       N  = 5;
0142       
0143    otherwise
0144       error(['Unknown method: ' method]);
0145 end

Previous page  pid_structure stepPIDcompare Next page

Generated on Wed 17-Mar-2004 09:29:44 by m2html © 2003