AutotunerPID Toolkit Previous page

stepPIDcompare

PURPOSE ^

STEPPIDCOMPARE Comparison of step response on setpoint and load disturbance.

SYNOPSIS ^

function stepPIDcompare(num,den,tau)

DESCRIPTION ^

STEPPIDCOMPARE  Comparison of step response on setpoint and load
   disturbance with different autotuning methods
   
   The function is typically called through the GUI in AutotunerPID.mdl
   and provides a graphical comparison of four different autotuning
   methods (STEP/ZN(OL), STEP/KT, STEP/IMC, RELAY/ZN(CL)) in time domain.
   The response to a step on the setpoint at time t = 0 and the response
   to a step at 2/3 of the final time are simulated.
   By default the parameter Ms is set to 2 in KT methods, while the
   parameter lambda is set 1/5 of the settling time of the plant.
   
   STEPPIDCOMPARE(NUM,DEN,TAU) performs the comparative analysis directly
   considering the plant described by the transfer function
              NUM(s)
      P(s) = -------- * exp(-TAU*s)
              DEN(s)

   See also BODEPID

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function stepPIDcompare(num,den,tau)
0002 %STEPPIDCOMPARE  Comparison of step response on setpoint and load
0003 %   disturbance with different autotuning methods
0004 %
0005 %   The function is typically called through the GUI in AutotunerPID.mdl
0006 %   and provides a graphical comparison of four different autotuning
0007 %   methods (STEP/ZN(OL), STEP/KT, STEP/IMC, RELAY/ZN(CL)) in time domain.
0008 %   The response to a step on the setpoint at time t = 0 and the response
0009 %   to a step at 2/3 of the final time are simulated.
0010 %   By default the parameter Ms is set to 2 in KT methods, while the
0011 %   parameter lambda is set 1/5 of the settling time of the plant.
0012 %
0013 %   STEPPIDCOMPARE(NUM,DEN,TAU) performs the comparative analysis directly
0014 %   considering the plant described by the transfer function
0015 %              NUM(s)
0016 %      P(s) = -------- * exp(-TAU*s)
0017 %              DEN(s)
0018 %
0019 %   See also BODEPID
0020 
0021 %   Author:    William Spinelli (wspinell@elet.polimi.it)
0022 %   Copyright  2004 W.Spinelli
0023 %   $Revision: 1.0 $  $Date: 2004/02/27 12:00:00 $
0024 
0025 global PIDPARAMETERS
0026 
0027 % compute step response
0028 P = tf(num,den,'IODelay',tau);
0029 [y,t] = step(P);
0030 Ts = min(real(abs(pole(P))))/50;
0031 [y,t] = step(P,0:Ts:t(end));
0032 Tf = t(end);
0033 
0034 % identify a FOPDT model
0035 modelFOPDT = idareas(y,1,Ts);
0036 
0037 % identify the point of the frequency response with omega_n = -pi
0038 [Gm,Pm,Wcg,Wcp] = margin(P);
0039 modelPI.A = 2/Gm;
0040 modelPI.T = 2*pi/Wcg;
0041 
0042 % Set up the simulation environment
0043 load_system('steppidsupport')
0044 simhandle = 'steppidsupport';
0045 set_param([simhandle '/Plant'],'Numerator',['[' num2str(num) ']']);
0046 set_param([simhandle '/Plant'],'Denominator',['[' num2str(den) ']']);
0047 set_param([simhandle '/PlantDelay'],'DelayTime',num2str(tau));
0048 set_param([simhandle '/spWorkspace'],'SampleTime',num2str(Ts));
0049 set_param([simhandle '/cvWorkspace'],'SampleTime',num2str(Ts));
0050 set_param([simhandle '/pvWorkspace'],'SampleTime',num2str(Ts));
0051 set_param([simhandle '/toutWorkspace'],'SampleTime',num2str(Ts));
0052 set_param([simhandle '/ISA PID'],'Ts',num2str(Ts));
0053 set_param(simhandle,'StopTime',num2str(2*Tf));
0054 
0055 set_param([simhandle '/SetPoint'],'Time',num2str(0));
0056 set_param([simhandle '/SetPoint'],'After',num2str(1));
0057 set_param([simhandle '/Disturbance'],'Time',num2str(4/3*Tf));
0058 set_param([simhandle '/Disturbance'],'After',num2str(0.1));
0059 
0060 figure(...
0061    'Name',               'Step response',...
0062    'NumberTitle',        'off');
0063 
0064 % simulation of the step response with different autotuner
0065 % Ziegler & Nichols with Step identification
0066 [K,Ti,Td,N,b] = pid_tuning(modelFOPDT,'ZN (OL)',[],'PID');
0067 PIDPARAMETERS = [K,Ti,Td,N,b];
0068 sim('steppidsupport');
0069 subplot(211)
0070 plot(tout,pvVec,'b')
0071 set(gca,'XColor',[0.4 0.4 0.4],'YColor',[0.4 0.4 0.4],...
0072    'FontSize',8)
0073 hold on
0074 subplot(212)
0075 plot(tout,cvVec,'b')
0076 set(gca,'XColor',[0.4 0.4 0.4],'YColor',[0.4 0.4 0.4],...
0077    'FontSize',8)
0078 hold on
0079 
0080 % Kappa-Tau with Ms = 2
0081 % in order to obtain better performance
0082 [K,Ti,Td,N,b] = pid_tuning(modelFOPDT,'KT',2,'PID');
0083 PIDPARAMETERS = [K,Ti,Td,N,b];
0084 sim('steppidsupport');
0085 subplot(211)
0086 plot(tout,pvVec,'r')
0087 subplot(212)
0088 plot(tout,cvVec,'r')
0089 
0090 % Internal Model Control with lambda = Tf/5
0091 % this means that the closed loop model is made five time faster than the
0092 % original (open loop model)
0093 [K,Ti,Td,N,b] = pid_tuning(modelFOPDT,'IMC',Tf/10,'PID');
0094 PIDPARAMETERS = [K,Ti,Td,N,b];
0095 sim('steppidsupport');
0096 subplot(211)
0097 plot(tout,pvVec,'g')
0098 subplot(212)
0099 plot(tout,cvVec,'g')
0100 
0101 % Ziegler & Nichols with Relay identification
0102 [K,Ti,Td,N,b] = pid_tuning(modelPI,'ZN (CL)',[],'PID');
0103 PIDPARAMETERS = [K,Ti,Td,N,b];
0104 sim('steppidsupport');
0105 subplot(211)
0106 plot(tout,pvVec,'m',tout,spVec,'k:')
0107 title('Step and Load Disturbance Response',...
0108    'Color',[0 0 0],'FontSize',8)
0109 ylabel('Process Value',...
0110    'Color',[0 0 0],'FontSize',8)
0111 legend('STEP + ZN(OL)','STEP + KT','STEP + IMC','RELAY + ZN(CL)',4)
0112 subplot(212)
0113 plot(tout,cvVec,'m')
0114 xlabel('Time [sec]',...
0115    'Color',[0 0 0],'FontSize',8)
0116 ylabel('Control Variable',...
0117    'Color',[0 0 0],'FontSize',8)

Previous page  pid_tuning 

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