⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 moto_data.m

📁 书籍代码:遗传演算法原理与应用_活用MATLAB(Source Code)
💻 M
字号:
% Design Data for Motorola 16-bit DSP
% Servo Control Design Example. 
% Use with motorola.mdl.
% moto_data.m

clear
% Motor data
Ke=70.61e-3; Tm=6.2e-3; Te=1.62e-3;
% DSP 
Ts=488e-6;Tc=30e-6;
% PID controller
P=0.16; I=5; D=1e-3;
a=Ts*I; b=-D/2/Ts;
K1=0.1875; K2=636.62;

% Plant
num=1/Ke; den=conv([Tm 1 0],[Te 1]);
plant=tf(num,den);
num=num/den(1); den=den/den(1);
% Due to mistakes in the original data, we
% modify the plant as
%num=1.7683392e8; 
%den=[1 778.574273 9.956193e4 0];
K=num;a1=den(2); a2=den(3);
disp('Plant TF:');
plant=tf(K1*K2*num,den)
f=logspace(0,2.301,100);f=f';w=2*pi*f;
[mag pha]=bode(plant,w); db=20*log10(mag);
db=db(:); pha=pha(:);
figure(1);subplot(211);semilogx(f,db);grid;
title('Plant Bode magnitude (dB) plot');
Line_n180=-180*ones(size(f));
figure(1);subplot(212);semilogx(f,[pha Line_n180]);grid;
title('Plant Bode phase (deg.) plot');
xlabel('Frequency (Hz)')

% Controller included
cl=P*plant/(1+P*plant);cl=minreal(cl);
figure(2);subplot(211);step(cl)
title(['Original design,P=' num2str(P) ',I=' num2str(I) ',D=' num2str(D)]);

% Use NCD, we found that
%P=0.4769; I=0.4292; D=0.0122; L1=40; L2=0.02;
P=0.4770; I=0.01; D=0.0123;L1=2.5;L2=5;
[T X Y]=sim('motorola',[0:Ts:0.6]);
figure(2);subplot(212);plot(T,Y);grid;
title(['Simulink result,P=' num2str(P) ',I=' num2str(I) ',D=' num2str(D)]);
xlabel('Time(s)')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -