Perturb and Observe MPPT algorithm only outputs maximum possible duty cycle

7 vues (au cours des 30 derniers jours)
I am trying to simulate a Perturb and Observe MPPT algorithm in simulink for an PV array.
However I am maxing up the PWM duty cycle to maximum possible value of duty cycle (i.e. 85%). If I manually set the duty cycle using pulse generator I get maximum power between 30% to 35% but in my simulation it does directly to 85%.
In C/C++ we can debug (Step Over/Into) the program using GDB. Kindly advice how I can debug this issue.
Code
function [duty_cycle, dp_pv, dv_pv] = fcn(v_pv, i_pv, delta)
duty_cycle_max = 0.85;
duty_cycle_min = 0.0;
persistent p_pv_n
if isempty(p_pv_n)
p_pv_n = 0.0;
end
persistent v_pv_n
if isempty(v_pv_n)
v_pv_n = 0.0;
end
persistent duty_cycle_old
if isempty(duty_cycle_old)
duty_cycle_old = 0.0;
end
duty_cycle = 0.0;
p_pv = v_pv * i_pv;
dp_pv = p_pv - p_pv_n;
dv_pv = v_pv - v_pv_n;
if(dp_pv == 0)
return;
end
if(dp_pv > 0)
if(dv_pv > 0)
duty_cycle = duty_cycle_old + delta;
else
duty_cycle = duty_cycle_old - delta;
end
else
if(dv_pv > 0)
duty_cycle = duty_cycle_old - delta;
else
duty_cycle = duty_cycle_old + delta;
end
end
if(duty_cycle > duty_cycle_max)
duty_cycle = duty_cycle_max;
elseif (duty_cycle < duty_cycle_min)
duty_cycle = duty_cycle_min;
end
v_pv_n = v_pv;
p_pv_n = p_pv;
duty_cycle_old = duty_cycle;
end

Réponse acceptée

Benjamin Thompson
Benjamin Thompson le 31 Jan 2022
If I create your MATLAB function block in a Simulink model and add your code, a MATLAB code editor window will open up. You can add debug breakpoints in here, using F12 key or using the menu or other ways. Then if you run the Simulink model the editor will stop at that breakpoint if it is reached. The editor will have buttons for step over, step in, step out, etc.

Plus de réponses (0)

Catégories

En savoir plus sur Simscape Electrical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by