My matlab code for PV P&O tracking algorithm has an error

26 visualizaciones (últimos 30 días)
Jirada Gosumbonggot
Jirada Gosumbonggot el 23 de Nov. de 2017
Comentada: MUSTAFA MOHAMMED el 29 de Mayo de 2021
Hello
I'm writing the code for P&O tracking as I want the output to be Power and Voltage where the max point is located. From the figure, I expected the max power to be at 51.53 W at 16.32 V.
But when I run the code, it always gives the result to the open-circuit voltage (last point of the curve) which is not correct, it gives me the result of 30.01 W at 19 V.
The code that I write is here, not sure I've done something wrong or not (I'm pretty new to matlab). The outputs are P and Vmpp
function [Vmpp,P] = PandO(V,I)
persistent Vold Pold Iold dV dI dP Power;
if isempty(Vold)
Vold =0; Iold = 0;
Pold = 0; dV = 0; dI = 0; dP = 0; Power = zeros(1000,1);
end
deltaV = 0.0001; % initialize
for i = 1:size(V,1)
Power(i) = V(i) .* I(i);
dV = V(i) - Vold;
dI = I(i) - Iold;
dP = Power(i) - Pold;
if dP ~= 0
if dP < 0
if dV <0
Vmpp = V(i) + deltaV;
else
Vmpp = V(i) - deltaV;
end
else
if dV < 0
Vmpp = V(i) - deltaV;
else
Vmpp = V(i) + deltaV;
end
end
else
Vmpp = V(i);
P = Power(i);
break
end
Vold = V(i);
Iold = I(i);
Pold = V(i).*I(i);
end
end
Any suggestion for me? thank you so much in advance

Respuestas (3)

Roshan Reji
Roshan Reji el 21 de Oct. de 2019
Did you find the solution please reply asap. I have the same problem.

mehmet salih fidaner
mehmet salih fidaner el 9 de En. de 2020
Did you find the solution please reply asap. I have the same problem.

M.Saud Khan
M.Saud Khan el 26 de En. de 2020
I think the problem is in deltaV. For some reason, my simulation worked with deltaV = 0.04. Decreasing below this value, resulted in Vmpp = open circuit voltage. I have disabled the "zero crossings" in the solver settings & simulated the system using ode23t solver (my system used power electronics blocks; ode23t & ode23tb are mostly used with power electronic blocks).
I'm not a fan of using array indexing & for-loops inside the simulink MATLAB function block. That's why I used the following code:
function [step, flag,Vmpp] = fcn(V,V_old, P,P_old)
flag = 5; % Arbitrary
Vmpp = 35; % Arbitrary
dV = 0.04;
% persistent Pold Vold dV
if isempty(V_old) || isempty(P_old)
V_old = 30; P_old = 800; % Initial conditions
end
delta_P = P - P_old;
delta_V = V - V_old;
if delta_P > 0
flag = 1;
if delta_V > 0
Vmpp = V + dV; % Increase voltage
elseif delta_V < 0
Vmpp = V - dV; % Decrease voltage
end
elseif delta_P < 0
flag = -1;
if delta_V > 0
Vmpp = V - dV; % Decrease voltage
elseif delta_V < 0
Vmpp = V + dV; % Increase voltage
end
elseif delta_P == 0
flag = 0;
Vmpp = V;
end
step = dV;
end
For V_old & P_old, I used the delay block & to produce the gate signal (duty ratio) of a MOSFET/IGBT, I used a PI controller. The PI gains were selected by hit & trial. All of this is in the picture below:
Capture.PNG
I have used a flag variable to note the state of delta_P. Results are not very accurate, however, it is working for me..
Hope this helps somebody..
  8 comentarios
At?l COSGUN
At?l COSGUN el 15 de En. de 2021
Could you pls mail me your this study. My mail adress is atilcosgun@gmail.com
MUSTAFA MOHAMMED
MUSTAFA MOHAMMED el 29 de Mayo de 2021
can you plese mail me daldoulmustafa3@gmail.com

Iniciar sesión para comentar.

Categorías

Más información sobre Spectral Measurements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by