您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > 实验二面向结构图的仿真
1/8实验二、面向结构图的仿真一、实验过程1.线性系统仿真(1)定义参数并为参数赋值,求解Kc、bc、Kd、ad、a1、K1、a2、K2等参数;(2)为uc(1、ud(1、u1(1、u2(1、xc(1、xd(1、x1(1、x2(1、yd(1、yc(1、y1(1、y2(1参数赋值为0;b5E2RGbCAP(3)迭代求解uc(k、ud(k、xck)、xdk)等输入输出变量;(4)将液位高度转换为转换为百分比高度;(5)绘制响应曲线;6)用MATLAB求出从输入到输出的传递函数,并将其用c2d函数,利用双线性变换法转换为离散模型,再用dstep(函数求离散模型的阶跃响应,阶跃幅值为3。p1EanqFDPw2.含有非线性环节的控制系统仿真非线性环节控制系统与线性控制系统实验方法相同,但离散化模型存在不同,同时需要增加饱和环节判断。二、实验程序1、线性系统仿真clcclearall%%%%%%%%%%%%%%%%%%%%%定义参数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%DXDiTa9E3dA=2。%水箱横截面积ku=0.1/0.5。%阀门流量系数H10=1.5。%水箱1的平衡高度2/8H20=1.4。%水箱2的平衡高度alpha12=0.25/sqrt(H10。%水箱1流向水箱2流量系数alpha2=0.25/sqrt(H20。%水箱2流出水流量系数R12=2*sqrt(H10/alpha12。%线性化数学模型中的参数R2=2*sqrt(H20/alpha2。%线性化数学模型中的参数H1SpanLo=0。%水箱1量程下限H2SpanLo=0。%水箱2量程下限H1SpanHi=2.52。%水箱1量程上限H2SpanHi=2.52。%水箱2量程上限Kp=1.78。%PI控制器比例系数Ti=85。%PI控制器积分时间常数Kc=Kp/Ti。%式(4中参数bc=Ti。%式(4中参数Kd=1/A。%式(5中参数ad=1/(A*R12。%式(5中参数a1=1/(A*R12。%式(6中参数K1=ku/A。%式(6中参数a2=1/(A*R2。%式(7中参数K2=1/(A*R12。%式(7中参数%%%%%%%%%%%%%%%%%%%%%%%%%%%赋初值%%%%%%%%%%%%%%%%%%%%%%%%%RTCrpUDGiTuc(1=0。ud(1=0。u1(1=0。u2(1=0。xc(1=0。xd(1=0。x1(1=0。x2(1=0。yd(1=0。yc(1=0。y1(1=0。y2(1=0。k=2。Qd=0。%干扰流量H20_percent=(H20-H2SpanLo/(H2SpanHi-H2SpanLo*100。5PCzVD7HxAH2=80。tend=700。%总长T=10。%%%%%%%%%%%%%%%%%%%迭代求解输入输出变量%%%%%%%%%%%%%%%%%%%%%fort=T:T:tenduc(k=(H2-(y2(k-1+H20-H2SpanLo/(H2SpanHi-H2SpanLo*100/100。jLBHrnAILgud(k=Qd。u1(k=yc(k-1。u2(k=y1(k-1。%扰动为零xc(k=xc(k-1+Kc*T*uc(k-1。yc(k=xc(k+bc*Kc*uc(k。xd(k=exp(-ad*T*xd(k-1+Kd/ad*(1-exp(-ad*T*ud(k。xHAQX74J0Xyd(k=xd(k。x1(k=exp(-a1*T*x1(k-1+K1/a1*(1-exp(-a1*T*u1(k。LDAYtRyKfEy1(k=x1(k。x2(k=exp(-a2*T*x2(k-1+K2/a2*(1-exp(-a2*T*u2(k。Zzz6ZB2Ltky2(k=x2(k。3/8k=k+1。%递增end%%%%%%%%%%%%%%%%%%%转换为百分比高度%%%%%%%%%%%%%%%%%%%%%%%Hlevel(:,1=(y1+H10-H1SpanLo/(H1SpanHi-H1SpanLo*100。dvzfvkwMI1Hlevel(:,2=(y2+H20-H2SpanLo/(H2SpanHi-H2SpanLo*100。rqyn14ZNXIyc=(yc+0.5*100。H2setpoint=H2*ones(size(y1'。%%%%%%%%%%%%%%%%%%%%%%%%%%%%绘图%%%%%%%%%%%%%%%%%%%%%%%%%%EmxvxOtOcotextPositionH1=max(Hlevel(:,1。textPositionH2=max(Hlevel(:,2。H2Steady=Hlevel(size(Hlevel(:,1,1,1*ones(size(y1'。SixE2yXPq5scrsz=get(0,'ScreenSize'。gca=figure('Position',[510scrsz(3-10scrsz(4-90]。6ewMyirQFLset(gca,'Color','w'。plot(0:T:tend,Hlevel(:,1,'r','LineWidth',2holdonplot(0:T:tend,Hlevel(:,2,'b','LineWidth',2holdonplot(0:T:tend,yc,'k','LineWidth',2holdonplot(0:T:tend,H2setpoint,'g','LineWidth',2holdonplot(0:T:tend,H2Steady,'y','LineWidth',2line([500525],[105105],'Color','r','LineWidth',6kavU42VRUstext(525,105,'第1个水箱的液位H1','FontSize',16line([500525],[101101],'Color','b','LineWidth',6y6v3ALoS89text(525,101,'第2个水箱的液位H2','FontSize',16line([500525],[9797],'Color','g','LineWidth',6text(525,97,'第2个水箱的液位给定值','FontSize',16line([500525],[9393],'Color','k','LineWidth',6text(525,93,'阀位变化情况','FontSize',16axis([070050110]。text(145,112,'实验二不考虑阀位饱和特性时的控制效果','FontSize',22grid2、线性系统仿真采用c2d函数)clcclearall%%%%%%%%%%%%%%%%%%%%%定义参数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%M2ub6vSTnPA=2。%水箱横截面积ku=0.1/0.5。%阀门流量系数H10=1.5。%水箱1的平衡高度H20=1.4。%水箱2的平衡高度alpha12=0.25/sqrt(H10。%水箱1流向水箱2流量系数4/8alpha2=0.25/sqrt(H20。%水箱2流出水流量系数R12=2*sqrt(H10/alpha12。%线性化数学模型中的参数R2=2*sqrt(H20/alpha2。%线性化数学模型中的参数H1SpanLo=0。%水箱1量程下限H2SpanLo=0。%水箱2量程下限H1SpanHi=2.52。%水箱1量程上限H2SpanHi=2.52。%水箱2量程上限Kp=1.78。%PI控制器比例系数Ti=85。%PI控制器积分时间常数Kc=Kp/Ti。%式(4中参数bc=Ti。%式(4中参数Kd=1/A。%式(5中参数ad=1/(A*R12。%式(5中参数a1=1/(A*R12。%式(6中参数K1=ku/A。%式(6中参数a2=1/(A*R2。%式(7中参数K2=1/(A*R12。%式(7中参数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%0YujCfmUCwnumc=[Kc*bc,Kc]。denc=[1,0]。numd=[Kd]dend=[1,ad]num1=[K1]den1=[1,a1]num2=[K2]den2=[1,a2]Gc=tf(numc,denc。G1=tf(num1,den1。G2=tf(num2,den2。Sysq=Gc*G1*G2。SysG=feedback(Sysq,1。GG=c2d(SysG,10,'tustin'。dstep(3*GG.num{1},GG.den{1}。3、含有非线性环节的控制系统仿真clcclearall%%%%%%%%%%%%%%%%%%%%%定义参数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%eUts8ZQVRdA=2。%水箱横截面积ku=0.1/0.5。%阀门流量系数H10=1.5。%水箱1的平衡高度H20=1.4。%水箱2的平衡高度alpha12=0.25/sqrt(H10。%水箱1流向水箱2流量系数alpha2=0.25/sqrt(H20。%水箱2流出水流量系数5/8R12=2*sqrt(H10/alpha12。%线性化数学模型中的参数R2=2*sqrt(H20/alpha2。%线性化数学模型中的参数H1SpanLo=0。%水箱1量程下限H2SpanLo=0。%水箱2量程下限H1SpanHi=2.52。%水箱1量程上限H2SpanHi=2.52。%水箱2量程上限Kp=1.78。%PI控制器比例系数Ti=85。%PI控制器积分时间常数Kc=Kp/Ti。%式(4中参数bc=Ti。%式(4中参数Kd=1/A。%式(5中参数ad=1/(A*R12。%式(5中参数a1=1/(A*R12。%式(6中参数K1=ku/A。%式(6中参数a2=1/(A*R2。%式(7中参数K2=1/(A*R12。%式(7中参数%%%%%%%%%%%%%%%%%%%%%%%%%%%赋初值%%%%%%%%%%%%%%%%%%%%%%%%%A=2。sQsAEJkW5Tuc(1=0。uv(1=0。ud(1=0。u1(1=0。u2(1=0。xc(1=0。xv(1=0。xd(1=0。x1(1=0。x2(1=0。yc(1=0。yv(1=0。yd(1=0。y1(1=0。y2(1=0。nCounter=70。T=10。k=1。deltaQd=0。c=0.5。H20_percent=(H20-H2SpanLo/(H2SpanHi-H2SpanLo*100。GMsIasNXkAH2set_percent=80。tend=nCounter*T。%%%%%%%%%%%%%%%%%%%迭代求解输入输出变量%%%%%%%%%%%%%%%%%%%%%fort=T:T:tendk=k+1。uc(k=(H2set_percent-(y2(k-1+H20-H2SpanLo/(H2SpanHi-H2SpanLo*100/100。TIrRGchYzguv(k=yc(k-1。ud(k=deltaQd。ifuv(kcyv(k=c。endifuv(k-cyv(k=0。endifuv(k=c&uv(k=-cyv(k=uv(k。6/8endu1(k=yv(k。u2(k=y1(k-1。xc(k=xc(k-1+Kc*T*uc(k-1。yc(k=xc(k+bc*Kc*uc(k。xd(k=exp(-ad*T*xd(k-1+Kd/ad*(1-exp(-ad*T*ud(k。7EqZcWLZNX
本文标题:实验二面向结构图的仿真
链接地址:https://www.777doc.com/doc-5183173 .html