您好,欢迎访问三七文档
当前位置:首页 > 建筑/环境 > 工程监理 > 模糊PID参数自整定
1模糊PID参数自整定设被控对象为ssssGP1047035.87523500)(23采样时间为1ms,采样模糊PID控制进行阶跃响应,在第300个采样时间时控制加1.0的干扰,相应的响应结果如下图:Ki的录属度函数-0.06-0.04-0.0200.020.040.0600.20.40.60.81kiDegreeofmembershipNBNMNSZPSPMPBKp的录属度函数-0.25-0.2-0.15-0.1-0.0500.050.10.150.20.2500.20.40.60.81kpDegreeofmembershipNBNMNSZPSPMPB2-3-2-1012300.20.40.60.81eDegreeofmembershipNBNMNSZPSPMPBe的录属度函数-3-2-1012300.20.40.60.81ecDegreeofmembershipNBNMNSZPSPMPBec的录属度函数下面是系统在外界有干扰输入时普通PID和模糊PID参数自整定控制的阶跃响应曲线:300.050.10.150.20.250.30.350.40.450.500.20.40.60.811.21.4time(s)rin,yout模糊PID控制阶跃响应00.050.10.150.20.250.30.350.40.450.500.20.40.60.811.21.4time(s)rin,yout普通PID控制阶跃响应.从上面的仿真图可以看出,经过模糊PID参数自整定后,在外界干扰输入时,可以得到很好的控制效果。下面是PID参数的整定曲线:.400.050.10.150.20.250.30.350.40.450.50.30.320.340.360.380.40.42time(s)kpKp的自整定调整00.050.10.150.20.250.30.350.40.450.5-0.00500.0050.010.0150.020.025time(s)kiKi的自整定调整00.050.10.150.20.250.30.350.40.450.5-0.200.20.40.60.811.2time(s)kdKd的自整定调整5程序文本:%FuzzyTunningPIDControlclearall;closeall;a=newfis('fuzzpid');a=addvar(a,'input','e',[-3,3]);%Parameterea=addmf(a,'input',1,'NB','zmf',[-3,-1]);a=addmf(a,'input',1,'NM','trimf',[-3,-2,0]);a=addmf(a,'input',1,'NS','trimf',[-3,-1,1]);a=addmf(a,'input',1,'Z','trimf',[-2,0,2]);a=addmf(a,'input',1,'PS','trimf',[-1,1,3]);a=addmf(a,'input',1,'PM','trimf',[0,2,3]);a=addmf(a,'input',1,'PB','smf',[1,3]);a=addvar(a,'input','ec',[-3,3]);%Parametereca=addmf(a,'input',2,'NB','zmf',[-3,-1]);a=addmf(a,'input',2,'NM','trimf',[-3,-2,0]);a=addmf(a,'input',2,'NS','trimf',[-3,-1,1]);a=addmf(a,'input',2,'Z','trimf',[-2,0,2]);a=addmf(a,'input',2,'PS','trimf',[-1,1,3]);a=addmf(a,'input',2,'PM','trimf',[0,2,3]);a=addmf(a,'input',2,'PB','smf',[1,3]);a=addvar(a,'output','kp',[-0.3,0.3]);%Parameterkpa=addmf(a,'output',1,'NB','zmf',[-0.3,-0.1]);a=addmf(a,'output',1,'NM','trimf',[-0.3,-0.2,0]);a=addmf(a,'output',1,'NS','trimf',[-0.3,-0.1,0.1]);a=addmf(a,'output',1,'Z','trimf',[-0.2,0,0.2]);a=addmf(a,'output',1,'PS','trimf',[-0.1,0.1,0.3]);a=addmf(a,'output',1,'PM','trimf',[0,0.2,0.3]);a=addmf(a,'output',1,'PB','smf',[0.1,0.3]);a=addvar(a,'output','ki',[-0.06,0.06]);%Parameterkia=addmf(a,'output',2,'NB','zmf',[-0.06,-0.02]);a=addmf(a,'output',2,'NM','trimf',[-0.06,-0.04,0]);a=addmf(a,'output',2,'NS','trimf',[-0.06,-0.02,0.02]);a=addmf(a,'output',2,'Z','trimf',[-0.04,0,0.04]);a=addmf(a,'output',2,'PS','trimf',[-0.02,0.02,0.06]);a=addmf(a,'output',2,'PM','trimf',[0,0.04,0.06]);a=addmf(a,'output',2,'PB','smf',[0.02,0.06]);a=addvar(a,'output','kd',[-3,3]);%Parameterkp6a=addmf(a,'output',3,'NB','zmf',[-3,-1]);a=addmf(a,'output',3,'NM','trimf',[-3,-2,0]);a=addmf(a,'output',3,'NS','trimf',[-3,-1,1]);a=addmf(a,'output',3,'Z','trimf',[-2,0,2]);a=addmf(a,'output',3,'PS','trimf',[-1,1,3]);a=addmf(a,'output',3,'PM','trimf',[0,2,3]);a=addmf(a,'output',3,'PB','smf',[1,3]);rulelist=[1171511;1271311;1362111;1462111;1553111;1644211;1744511;2171511;2271311;2362111;2453211;2553211;2644311;2734411;3161411;3262311;3363211;3453211;3544311;3635311;3735411;4162411;4262311;4353311;4444311;4535311;4626311;4726411;5152411;5253411;5344411;5435411;75535411;5626411;5727411;6154711;6244511;6335511;6425511;6526511;6627511;6717711;7144711;7244611;7325611;7426611;7526511;7617511;7717711];a=addrule(a,rulelist);a=setfis(a,'DefuzzMethod','mom');writefis(a,'fuzzpid');a=readfis('fuzzpid');%PIDControllerts=0.001;sys=tf(5.235e005,[1,87.35,1.047e004,0]);dsys=c2d(sys,ts,'tustin');[num,den]=tfdata(dsys,'v');u_1=0.0;u_2=0.0;u_3=0.0;y_1=0;y_2=0;y_3=0;x=[0,0,0]';error_1=0;e_1=0.0;ec_1=0.0;kp0=0.40;kd0=1.0;8ki0=0.0;fork=1:1:500time(k)=k*ts;rin(k)=1;%UsingfuzzyinferencetotunningPIDk_pid=evalfis([e_1,ec_1],a);kp(k)=kp0+k_pid(1);ki(k)=ki0+k_pid(2);kd(k)=kd0+k_pid(3);u(k)=kp(k)*x(1)+kd(k)*x(2)+ki(k)*x(3);ifk==300%Addingdisturbance(1.0vattime0.3s)u(k)=u(k)+1.0;endifu(k)=10u(k)=10;endifu(k)=-10u(k)=-10;endyout(k)=-den(2)*y_1-den(3)*y_2-den(4)*y_3+num(1)*u(k)+num(2)*u_1+num(3)*u_2+num(4)*u_3;error(k)=rin(k)-yout(k);%ReturnofPIDparameters%u_3=u_2;u_2=u_1;u_1=u(k);y_3=y_2;y_2=y_1;y_1=yout(k);x(1)=error(k);%CalculatingPx(2)=error(k)-error_1;%CalculatingDx(3)=x(3)+error(k);%CalculatingIe_1=x(1);ec_1=x(2);9error_2=error_1;error_1=error(k);endshowrule(a)figure(1);plot(time,rin,'b',time,yout,'r');xlabel('time(s)');ylabel('rin,yout');figure(2);plot(time,error,'r');xlabel('time(s)');ylabel('error');figure(3);plot(time,u,'r');xlabel('time(s)');ylabel('u');figure(4);plot(time,kp,'r');xlabel('time(s)');ylabel('kp');figure(5);plot(time,ki,'r');xlabel('time(s)');ylabel('ki');figure(6);plot(time,kd,'r');xlabel('time(s)');ylabel('kd');figure(7);plotmf(a,'input',1);figure(8);plotmf(a,'input',2);figure(9);plotmf(a,'output',1);figure(10);plotmf(a,'output',2);figure(11);plotmf(a,'output',3);plotfis(a);fuzzyfuzzpid.fis
本文标题:模糊PID参数自整定
链接地址:https://www.777doc.com/doc-7139891 .html