被控对象为三阶传递函数:
低通滤波器为:
采样时间为1ms,噪声信号加在对象的输出端。
分三种情况进行:
M=1 时,为未加噪声信号;
M=2时,为加噪声信号未加滤波;
M=3时,为加噪声信号加滤波。阶跃响应结果如图1~图3所示。
图1 普通PID控制阶跃响应(M=1)
图2 无滤波器时PID控制阶跃响应(M=2)
图3 加入滤波器后PID控制阶跃响应(M=3)
仿真程序:
clear all;
close all;
ts=0.001;
sys=tf(5.235e005,[1,87.35,1.047e004,0]);
dsys=c2d(sys,ts,z');
[num,den]-tfdata(dsys,'v');
u_1=0;u_2=0;u_3=0;u_4-0;u_5=0;
y_1=0;y_2=0;y_3=0;yn_1-0;
error_1=0;
error_2=0;
ei=0;
kp=0.20;
ki=0.05;
sys1=tf([11,[0.04,1D; %Low Freq Signal Filter
dsys1=c2d(sys1,ts,'tucsin');
[num1,den1]=tfdata(dsys1,v);
f_1=0;
M=3;
for k=1:1:1000
time(k)=k*ts;
yd(k)=20; %Step Signal
%Linear model
y(k)=-den(2)*y_1-den(3)*y_2-den(4)*y_3+num(2)*u_1+num(3)*u_2+num(4)*u_3;
if M==1
error(k)=yd(k)-y(k);
filty(k)=y(k);
end
n(k)=5.0*rands(1); %Noisy signal
yn(k)=y(k)+n(k);
if M==2
filty(k)=yn(k);
error(k)=yd(k)-filty(k);
end
if M==3
filty(k)=-den1(2)*f_1+numl(1)*(yn(k)+yn_1);
error(k)=yd(k)-filty(k);
end
%l separation
if abs(error(k))=0.8
ei=ei+error(k)*tsl;
else
ei=0;
end
u(k)=kperror(k)+ki*ei;
%---------------------Return of PID parameters--------------------%
yd_1=yd(k);
u_5=u_4;u_4=u_3;u_3=u_2;u_2=u_1;u_1=u(k);
y_3=y_2:y_2=y_l:y 1=y(k);
f_1=filty(k);
yn_1=yn(k);
error_2=error_1;
error_1=error(k);end
figure(1);
subplot(211);
plot(time,yd,'r,time,filty, 'k:', linewidth',2);xlabel('time(S));ylabel('yd,y');
legend('Ideal position signal',Position tracking');subplot(212):
plot(time,u,'r.linewidth',2);xlabel('time(s)');ylabel('u');figure(2);
plot(time,n,'r, linewidth ,2);
xlabel('time(s)2;ylabel(Noisy signal');