👨🎓个人主页:研学社的博客
💥💥💞💞欢迎来到本博客❤️❤️💥💥
🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。
⛳️座右铭:行百里者,半于九十。
📋📋📋本文目录如下:🎁🎁🎁
目录
💥1 概述
![](https://i-blog.csdnimg.cn/blog_migrate/68f1c7a41e642fa50f29ec5e7446210e.png)
📚2 运行结果
主函数代码:
close all;
clear all;
clc;
%parametry symulacji
k_start = 4;
k_stop = 800;
%parametry modelu
alfa1 = -1.645679;
alfa2 = 0.675125;
beta1 = 0.01098;
beta2 = 0.009632;
%wartosci poczatkowe zmiennych
u = zeros(1,k_stop);
y = zeros(1,k_stop);
x1 = zeros(1,k_stop);
x2 = zeros(1,k_stop);
e = zeros(1,k_stop);
y_zad = [0.5*ones(1,k_stop/4) -0.35*ones(1,k_stop/4) 0.4*ones(1,k_stop/4) -1.2*ones(1,k_stop/4)];
%% Regulator PID nastrojony metoda Zieglera-Nicholsa
T=1;
Tosc = 16.8; %(192-24)/10 <-- usrednione dla 10 okres贸w
kkr = 3.7;
k_p = 0.6*kkr;
Ti_p = 0.5*Tosc;
Td_p = 0.125*Tosc;
% Niegasnace oscylacje:
% Ti_p = inf;
% Td_p = 0;
% k_p = kkr;
% Nastawy regulatora PID w wersji dyskretnej
r2=(k_p*Td_p)/T;
r1=k_p*((T/(2*Ti_p))-((2*Td_p)/T)-1);
r0=k_p*(1+(T/(2*Ti_p))+(Td_p/T));
E = 0;
for k = k_start:k_stop
%model nieliniowy
g1 = (exp(5*u(k-3))-1)/(exp(5*u(k-3))+1);
x1(k) = -alfa1*x1(k-1) + x2(k-1) + beta1*g1;
x2(k) = -alfa2*x1(k-1) + beta2*g1;
g2 = 1-exp(-1.5*x1(k));
y(k) = g2;
e(k)=y_zad(k) - y(k);
u(k)=r2*e(k-2)+r1*e(k-1)+r0*e(k) + u(k-1);
if (u(k)>1)
u(k)=1;
end
if (u(k)<-1)
u(k)=-1;
end
E = E + (y_zad(k) - y(k))^2;
end
display(sprintf('Wskaznik jakosci E = %f',E))
y1 = y;
u1 = u;
disp('Nacisnij spacje aby kontynuowac');
pause;
%% Regulator PID nastrojony PSO
%
%parametry regulatora obliczone w pliku pid_pso_tun.m
r0 = 1.2230
r1 = -1.4218
r2 = 0.2628
u = zeros(1,k_stop);
y = zeros(1,k_stop);
x1 = zeros(1,k_stop);
x2 = zeros(1,k_stop);
e = zeros(1,k_stop);
E = 0;
for k = k_start:k_stop
%model nieliniowy
g1 = (exp(5*u(k-3))-1)/(exp(5*u(k-3))+1);
x1(k) = -alfa1*x1(k-1) + x2(k-1) + beta1*g1;
x2(k) = -alfa2*x1(k-1) + beta2*g1;
g2 = 1-exp(-1.5*x1(k));
y(k) = g2;
e(k)=y_zad(k) - y(k);
u(k)=r2*e(k-2)+r1*e(k-1)+r0*e(k) + u(k-1);
if (u(k)>1)
u(k)=1;
end
if (u(k)<-1)
u(k)=-1;
end
E = E + (y_zad(k) - y(k))^2;
end
%%
figure(1)
clf
subplot(2,1,1)
plot(y);
title('Porownanie przebiegow sygnalow wyjsciowych i wejsciowych regulatora PID nastrojonego dwiema metodami')
hold on
plot(y1,'m')
hold on
plot(y_zad,'r--')
legend('PID PSO','PID Z-N')
ylabel('y(k)')
xlabel('k');
grid on
subplot(2,1,2)
plot(u)
hold on
plot(u1,'m')
grid on
ylabel('u(k)')
xlabel('k');
🎉3 参考文献
部分理论来源于网络,如有侵权请联系删除。
[1]杨雨彬,任天宇,邓宏敬,蔡子龙,杨子墨.基于优化粒子群神经PID的双变量解耦控制[J].科技资讯,2023,21(03):1-5.DOI:10.16661/j.cnki.1672-3791.2206-5042-5807.
[2]李欢欢,刘辉,盖江涛,李训明.基于粒子群优化算法PID参数优化的双电机耦合驱动履带车辆转向控制研究[J/OL].兵工学报:1-8[2023-04-22].
[3]李春亚,杨辰飞.基于粒子群算法和PID相结合的船舶电喷柴油机自动控制[J].舰船科学技术,2023,45(01):147-150.