how PID Tuning for Pitch Angle Control using PSO

11 views (last 30 days)
Hello,
I am working on a control system that includes a pitch angle control loop using a PID controller, and I want to tune the PID gains using Particle Swarm Optimization (PSO).
I am looking for a MATLAB (or Simulink) code that meets the following requirements:
Uses PSO to optimize the PID parameters (Kp, Ki, Kd)
Supports defining bounds or constraints on the PID gains
If anyone has a working example or template that I could build upon, I would greatly appreciate it.
Thank you in advance!
  6 Comments
douara ben ouadeh
douara ben ouadeh on 29 May 2025
Moved: Sam Chak on 30 May 2025
Thank you for the clarification and for your time.
To better explain what I’m aiming for, please refer to the following link:
Sam Chak
Sam Chak on 30 May 2025
@douara ben ouadeh, The user-supplied PSO code shared in the provided link is incomplete, preventing any testing. It is not surprising that you are experiencing issues. Have you tried using MATLAB built-in particleswarm()?
%% call PSO
fun = @costfcn;
nvars = 1;
lb = 0;
ub = 2;
Kbest = particleswarm(fun, nvars, lb, ub)
Optimization ended: relative change in the objective value over the last OPTIONS.MaxStallIterations iterations is less than OPTIONS.FunctionTolerance.
Kbest = 1.0000
%% Cost function
function J = costfcn(K)
J = (K - 1)^2;
end

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!