自动控制原理课程设计学院:电子信息学院学号:1340301229姓名:张鑫第一题:1.1.1二阶系统的时域、频域分析2、已知一个二阶系统其闭环传递函数如下Φ=k0.5s2+s+k求K=0.2、0.5、1、2、5时,系统的阶跃响应和频率响应。绘出阶跃响应曲线和频率响应曲线%%%%%%%%%%%%%%clc;clear;%%%%%%%%%%%%%k=[0.2,0.5,1,2,5];%%%%%%%%%%%%%fork1=kfigure(1),holdonsys=tf(k1,[0.5,1,k1])step(k1,[0.5,1,k1]);figure(2);holdonmargin(sys);end%%%%%%%%%%%%%%figure(1);gtext('k=0.2'),gtext('k=0.5'),gtext('k=1'),gtext('k=2'),gtext('k=5')figure(2);gtext('k=0.2'),gtext('k=0.5')gtext('k=1'),gtext('k=2'),gtext('k=5')gtext('k=0.2'),gtext('k=0.5'),gtext('k=1'),gtext('k=2'),gtext('k=5')程序结果显示:图像窗口:命令窗口:Transferfunction:0.2-----------------0.5s^2+s+0.2Transferfunction:0.5-----------------0.5s^2+s+0.5Transferfunction:1---------------0.5s^2+s+1Transferfunction:2---------------0.5s^2+s+2Transferfunction:5---------------0.5s^2+s+5%结论:随着k值的增大,波峰增大,瞬态响应加快,调节时间变短,稳定更快!第二题:1.1.2调试设计超前、滞后校正程序1.被控对象传递函数为G(s)=KS(S2+30S+200)设计超前校正环节,使系统性能指标满足如下要求:(1)速度误差常数=10(2)γ=45°源程序:clc;clear;num=2000;den=[1,30,200,0];Go=tf(num,den);w=0.1:0.1:2000;[gm,pm,wcg,wcp]=margin(Go);%在当前窗口绘制带GMPM的BODE图[mag,phase]=bode(Go,w);%计算出w=0-1000时对应mag,phase的值magdb=20*log10(mag);%换算为db值phiml=45;phim=phiml-pm+16;a=(1+sin(phim*pi/180))/(1-sin(phim*pi/180));%计算出α的值n=find(magdb+10*log10(a)=0.001);wc=w(n(1));%取符合要求的最小n值w1=wc/sqrt(a);w2=wc*sqrt(a);numc=[1/w1,1];denc=[1/w2,1];Gc=tf(numc,denc);g=Go*Gc;[gmc,pmc,wcgc,wcpc]=margin(g);gmcdb=20*log10(gmc);bode(Go,g);%比较Go和g的bode图holdonmargin(g)程序结果显示:图像窗口:第三题:2、被控对象传递函数为(s)=ks(s+5)设计滞后校正环节,使系统性能指标如下(1)单位斜坡稳态误差小于5%(2)闭环阻尼比ζ=0.707,wn=1.5rad/sclc;clear;num=100;den1=conv([1,0],[1,5]);go=tf(num,den1);margin(go);%画出含Gm和Pm的Bode图a=65.5246;b=5;c=a+b;w=0.01:0.01:1000;[mag,phase]=bode(go,w);%找出曲线上的点(mag,w)(phase,w),不画图n=find(180+phase-c=0.1);wc=w(n(1));%通过find(),找出符合条件的phase,再通过w(n(1))找到目标wc[mag,phase]=bode(go,wc);%找出(mag,wc),(phase,wc)magdb=20*log10(mag);%换算beta=10^(magdb/20);w2=wc/10;w1=w2/beta;gc=tf([1/w2,1],[1/w1,1]);g=go*gc;%修正后的系统bode(go,g);%比较校正前后bode图holdon;margin(g);holdoff;%%%%%%%%%%%%%%%%%%%%%下面的是系统gamma(Omega·c),以及Omega·c的计算过程%t=1/sqrt(2);t=0.707;wn=1.5;wcc=wn*sqrt(sqrt(4*t^4+1)-2*t*t)xiangjiao=atan(2*t/(sqrt(sqrt(4*t^4+1)-2*t*t)))%此处计算出的是弧度xiangjiao*180/pi程序结果显示:命令窗口:wcc=0.9655xiangjiao=1.1436ans=65.5246图像窗口:第四题:1.1.3(2)已知某随动系统固有特性开环传递函数为:试用频率特性法设计超前滞后校正装置,使校正后的系统满足如下性能指标:开环增益Kv=100,超调量σp30%,调节时间Ts=0.5s设计串联校正环节,使校正后的系统满足规定的性能指标。通过计算机仿真验证设计是否符合要求源程序代码如下%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%K%Go(s)=————————————,K=100,SIGMAp=0.3,Ts=0.5%s(0.1+1)(0.025+1)%%(1+s/w1)(1+s/w3)%Gc(s)=————————————,G(s)=Go(s)*Gc(s)%(1+s/w2)(1+s/w4)%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clear;clc;%相当于归零操作吧!——归零,清屏%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%传递函数num=100;den=conv([1,0],conv([0.1,1],[0.025,1]));G0=tf(num,den)[kg,gamma,wg,wc]=margin(G0)%含【(mag,wg),(phase,wc)】即含增益裕度和相位裕度的Bode图kgdb=20*log10(kg);(0.11)(0.0251)kGsssS%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%超前校正%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%w=0.001:0.001:1000;[mag,phase]=bode(G0,w);%算出Bode图中曲线上的每个点的值disp('未校正系统参数:20lgkg,wc,gamma'),[kgdb,wc,gamma],%此处的[kgdb,Wg],[gamma,wc]gammal=30;delta=24;phim=gammal-gamma+delta;alpha=(1+sin(phim*pi/180))/(1-sin(phim*pi/180));%求出a(alpha)magdb=20*log10(mag);%算出增益裕度n=find(magdb+10*log10(alpha)=0.0001);wcc=w(n(1));%找出目标Wcw3=wcc/sqrt(alpha);w4=sqrt(alpha)*wcc;numc1=[1/w3,1];denc1=[1/w4,1];Gc1=tf(numc1,denc1);G01=G0*Gc1;%超前校正后的函数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%滞后校正%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%[mag1,phase1]=bode(G01,wc);%含(mag1,wg),(phase1,wc)即增益裕度和相位裕度的Bode图Lhc=20*log10(mag1);%beta=10^(Lhc/20);w2=wcc/12;w1=w2/beta;numc2=[1/w2,1];denc2=[1/w1,1];Gc2=tf(numc2,denc2);Gc=Gc1*Gc2;%超前-滞后校正函数最终版G=Gc*G0;%校正后函数%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%后期处理工作[Gmc,Pmc,Wcgc,Wcpc]=margin(G);Gmcdb=20*log10(Gmc);disp('超前校正部分的传递函数'),Gc1,disp('滞后校正部分的传递函数'),Gc2,disp('串联超前滞后校正装置的传递函数'),Gc,disp('校正后整个系统的传递函数'),G,disp('校正后系统的参数:20lgkg,wc,r及a值'),[Gmcdb,Wcgc,Pmc,alpha],figure(1);bode(G0,G),holdon,margin(G),betaholdofffigure(2);G=feedback(G,1);step(G);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%数值来源计算公式%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%clc;clear;%SIGMAp=0.3;%t=(SIGMAp-0.16)/0.14%u=1/(1+t)%Y=asin(u)%0.5236%Y1=Y*180/pi%30%%%%%%%%%%%%%%%%%算出gamma(相位裕度)的值。用Y1表示%Ts=0.5%Wc=pi*(2+1.5*t+2.5*t^2)/Ts%37.6991程序结果显示:命令窗口输出情况:Transferfunction:100--------------------------0.0025s^3+0.125s^2+sWarning:Theclosed-loopsystemisunstable.Inlti.marginat89Indi4tiat21kg=0.5000gamma=-15.0110wg=20.0000wc=27.7975未校正系统参数:20lgkg,wc,gammaans=-6.020627.7975-15.0110超前校正部分的传递函数Transferfunction:0.09696s+1--------------0.003327s+1滞后校正部分的传递函数Transferfunction:0.2155s+1------------0.6169s+1串联超前滞后校正装置的传递函数Transferfunction:0.0209s^2+0.3125s+1---------------------------0.002052s^2+0.6202s+1校正后整个系统的传递函数Transferfunction:2.09s^2+31.25s+100------------------------------------------------------------5.131e-006s^5+0.001807s^4+0.08208s^3+0.7452s^2+s校正后系统的参数:20lgkg,wc,r及a值ans=19.1814104.350642.982729.1427beta=2.8625图像窗口显示: