how to tune pid controller using genetic algorithm?

조회 수: 32 (최근 30일)
SURESH PANDIYAN
SURESH PANDIYAN 2016년 3월 14일
답변: Abdel Aziz 2024년 11월 14일 13:37
Hi friends, I had designed longitudinal flight control system in simulink. In that model i want to tune PID controller by using Genetic algorithm.How can i get Kp,Ki,Kd values ?
anybody knows how to use GA in simulink, Pls help me...

답변 (2개)

Amirali Najafi
Amirali Najafi 2020년 5월 20일
Code credit to Steve Brunton
close all; clear all; clc
dt = 0.001;
PopSize = 25;
MaxGenerations = 10;
s = tf('s');
G = 1/(s*(s*s+s+1));
options = optimoptions(@ga,'PopulationSize',PopSize,'MaxGenerations',MaxGenerations);
[x,fval] = ga(@(K)pidtest(G,dt,K),3,-eye(3),zeros(3,1))
function J = pidtest(G,dt,parms)
s = tf('s');
K = parms(1) + parms(2)/s + parms(3)*s/(1+.001*s);
Loop = series(K,G);
ClosedLoop = feedback(Loop,1);
t = 0:dt:20;
[y,t] = step(ClosedLoop,t);
CTRLtf = K/(1+K*G);
u = lsim(CTRLtf,1-y,t);
Q = 1;
R = .001;
J = dt*sum(Q*(1-y(:)).^2+R*u(:).^2)
[y,t] = step(ClosedLoop,t);
plot(t,y,'LineWidth',2,'color','r')
drawnow
end
  댓글 수: 5
krishna
krishna 2023년 10월 31일
Hi friends, I had designed model of 6DOF quadcopter control system in simulink i'm using cascade PID controller . In that model i want to tune PID controller by using Genetic algorithm.How can i get Kp,Ki,Kd values ? any one give me code for this for tuning PID controller.
Abdel Aziz
Abdel Aziz 2024년 11월 14일 13:37
Hello, im working on a 6DOF quadcopter for solar panel cleaning in Matlab simulink using simscape multibody, and i am already tuned Altitude and Yaw controller,but when i try to tune pitch/Roll controller my model become unstable , please i need help to tune my Quad

댓글을 달려면 로그인하십시오.


Abdel Aziz
Abdel Aziz 2024년 11월 14일 13:37
Hello, im working on a 6DOF quadcopter for solar panel cleaning in Matlab simulink using simscape multibody, and i am already tuned Altitude and Yaw controller,but when i try to tune pitch/Roll controller my model become unstable , please i need help to tune my Quad

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by