i have written the following code for pso based mppt but the simulink model gets stuck at one value and the duty does not change.... kindly suggest me the error

조회 수: 9(최근 30일)
puneet joshi
puneet joshi 2016년 4월 5일
답변: Nisar Ahmed 2020년 4월 30일
function D = PSO(Param, V, I)
% MPPT controller based on the Perturb & Observe algorithm.
% D output = Duty cycle of the boost converter (value between 0 and 1)
%
% V input = PV array terminal voltage (V)
% I input = PV array current (A)
%
% Param input:
%Dinit = Param(1); %Initial value for D output
Dmax = Param(2); %Maximum value for D
Dmin = Param(3); %Minimum value for D
deltaD = Param(4); %Increment value used to increase/decrease the duty cycle D
persistent D_mat_cur Power_old vel max_power_new max_power_old Power_new global_best_duty self_best_duty D_mat_new
pop_size=10;
vmin=-1*deltaD;
vmax=deltaD;
%%wmax=0.9;
%%wmin=0.4;
c1=2;
C=1;
c2=2;
if isempty(Power_old)
%%intiallize all matrices
Power_old=zeros(1,pop_size);
Power_new=zeros(1,pop_size);
vel=zeros(1,pop_size);
D_mat_new=zeros(1,pop_size);
D_mat_cur=rand(1,pop_size);
vel=rand(1,pop_size).*(vmax-vmin)+vmin;
for i=1 : pop_size
if (D_mat_cur(i)>Dmax)
D_mat_cur(i)=Dmax;
end
end
for i=1 : pop_size
if (D_mat_cur(i)<Dmin)
D_mat_cur(i)=Dmin;
end
end
for iter =1:pop_size
D=D_mat_cur(iter);
pause(0.0001)
Power_old(iter)=V*I;
end
[max_power_old,global_index]=max(Power_old);
self_best_duty=D_mat_cur;
global_best_duty=D_mat_cur(1,global_index);
end
iter=0;
max_iter=100;
while iter<max_iter
iter=iter+1;
%calculate power
for iter =1:pop_size
D=D_mat_cur(iter);
pause(0.0001)
Power_new(iter)=V*I;
end
%%update self best duty
for i=1:pop_size
if (Power_new(1,i)>Power_old(1,i))
Power_old(1,i)=Power_new(1,i);
self_best_duty(1,i)=D_mat_cur(1,i);
end
end
%%update global best duty
[max_power_new,index]=max(Power_old);
if (max_power_new>max_power_old)
max_power_old=max_power_new;
global_best_duty=D_mat_cur(1,index);
end
w=.001;
%%calculation of new velocity matrix
for i=1 :pop_size
vel(1,i)= C*(w.*vel(1,i) +c1*rand*(self_best_duty(1,i) - D_mat_cur(1,i)) +c2*rand*(global_best_duty-D_mat_cur(1,i)));
end
%%update positions
D_mat_new=D_mat_cur+ vel;
%%bring back the param that go out of the bounds
%%upper limit
for i=1 : pop_size
if (D_mat_new(1,i)>Dmax)
D_mat_new(1,i)=Dmax;
end
end
%%lower limit
for i=1 : pop_size
if (D_mat_new(1,i)<Dmin)
D_mat_new(1,i)=Dmin;
end
end
D_mat_cur=D_mat_new;
end
[~,global_ind]=max(Power_new);
D=D_mat_cur(1,global_ind);
  댓글 수: 14
halli aiissa
halli aiissa 2020년 3월 5일
can you send me the ...correct version ...of PSO algorithm.thi is my e-mail: haliaissa11@gmail.com
thank you very much

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

답변(3개)

Immad  Shams
Immad Shams 2019년 4월 15일
can i have the correct code plz. Many Thanks

doaa nabil
doaa nabil 2019년 6월 7일
can i have the correct code please

Nisar Ahmed
Nisar Ahmed 2020년 4월 30일
please send me these function codes
nisark37@gmail.com

커뮤니티

더 많은 답변 보기:  Power Electronics Community

Community Treasure Hunt

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

Start Hunting!

Translated by