MATLAB Answers

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

45 views (last 30 days)
Jirada Gosumbonggot
Jirada Gosumbonggot on 23 Nov 2017
Commented: Pavani environ 8 heures ago
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

  0 Comments

Sign in to comment.

Answers (3)

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

  0 Comments

Sign in to comment.


mehmet salih fidaner
mehmet salih fidaner on 9 Jan 2020
Did you find the solution please reply asap. I have the same problem.

  1 Comment

VENKATA ARAVINDA SATVIK MUVVALA
if you find any solution, please comment here ASAP. I also have same problem.

Sign in to comment.


M.Saud Khan
M.Saud Khan on 26 Jan 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..

  4 Comments

Show 1 older comment
M.Saud Khan
M.Saud Khan on 26 Jan 2020
Yeah, I have checked with Irr = 1200, 1000, 500, 200 Wb/m2. I don't think the value of irradiance has anything to do with the P&O algorithm. If you are receiving errors on irradinace value, probably check your PV model. I'm using the default Simulink PV model..
VENKATA ARAVINDA SATVIK MUVVALA
I am also using the default simulink model but i m getting wrong output. so, Can you please mail me your simulation file. It would be a great help for me to do my assignment.
My mail id: aravindmuvvala@gmail.com
Pavani
Pavani environ 8 heures ago
Sir, can you please mail me your simulation file.my mail id : pavani.vinnakota@gmail.com

Sign in to comment.

Sign in to answer this question.


Translated by