zhangweiwei
2009-11-16, 22:08
主程序:
%Discrete PID control for continuous plant
clear all;
close all;
ts=0.001; %Sampling time
xk=zeros(2,1);
e_1=0;
u_1=0;
for k=1:1:2000
time(k)=k*ts
rin(k)=0.50*sin(2*pi*k?*ts);%系统的给定值
para=u_1;
tSpan=[0 ts];
[tt,xx]=ode45('chap1_2f',tSpan,xk,[],para);
xk=xx(length(xx),:);
yout(k)=xk(1);
e(k)=rin(k)-yout(k);
de(k)=(e(k)-e_1)/ts;
u(k)=20.0*e(k)+0.5*de(k) %PD控制
u_1=u(k);
e_1=e(k);
end
子程序:
function dy=PlantModel(t,y,flag,para)
u=para;
J=0.0067;B=0.1;%这两个数十被控对象的传递函数的分母的系数
dy=zeros(2,1);
dy(1)=y(2);
dy(2)=-(B/J)*y(2)+(1/J)*u
红色部分没有看明白,希望有前辈帮忙,谢谢
%Discrete PID control for continuous plant
clear all;
close all;
ts=0.001; %Sampling time
xk=zeros(2,1);
e_1=0;
u_1=0;
for k=1:1:2000
time(k)=k*ts
rin(k)=0.50*sin(2*pi*k?*ts);%系统的给定值
para=u_1;
tSpan=[0 ts];
[tt,xx]=ode45('chap1_2f',tSpan,xk,[],para);
xk=xx(length(xx),:);
yout(k)=xk(1);
e(k)=rin(k)-yout(k);
de(k)=(e(k)-e_1)/ts;
u(k)=20.0*e(k)+0.5*de(k) %PD控制
u_1=u(k);
e_1=e(k);
end
子程序:
function dy=PlantModel(t,y,flag,para)
u=para;
J=0.0067;B=0.1;%这两个数十被控对象的传递函数的分母的系数
dy=zeros(2,1);
dy(1)=y(2);
dy(2)=-(B/J)*y(2)+(1/J)*u
红色部分没有看明白,希望有前辈帮忙,谢谢