MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] 读PID程序遇到的问题 (https://www.labfans.com/bbs/showthread.php?t=10211)

zhangweiwei 2009-11-16 22:08

读PID程序遇到的问题
 
主程序:
%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);%系统的给定值

[COLOR="red"]para=u_1;
tSpan=[0 ts];
[tt,xx]=ode45('chap1_2f',tSpan,xk,[],para);
xk=xx(length(xx),:);
yout(k)=xk(1);[/COLOR]
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

子程序:
[COLOR="red"]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[/COLOR]


红色部分没有看明白,希望有前辈帮忙,谢谢


所有时间均为北京时间。现在的时间是 14:11

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.