Inc Cond Variable Step Size Questions

5 次查看(过去 30 天)
Micaela
Micaela 2025-2-5
编辑: MULI 2025-2-12
Our code is creating odd values, for example this code, without the absolute value for the step creates the graph shown in fig 1, but with it creates a graph that is shown in fig 2, we are a bit confused why it is not creating a solid graph that remains around one value without such large spikes
%CODE 1
function out = fcn(V, I, Vo, Io, d)
N = 0.000005;
dv = V - Vo;
di = I - Io;
%step = 0.00005;
step = N * abs(di/dv + I/V); % THIS LINE
change = di*V;
cond = -I*dv;
if(dv == 0)
if(di == 0)
out = d;
else
if(di > 0)
%increase duty cycle
d=d-step;
else
%decrease duty cycle
d=d+step;
end
out = d;
end
else
if(change == cond)
out = d;
else
if(change > cond)
%decrease duty cycle
d=d-step;
else
%increase duty cycle
d=d+step;
end
out = d;
end
end
Fig 1
Fig 2

回答(1 个)

MULI
MULI 2025-2-12
编辑:MULI 2025-2-12
I understand that your MPPT function "fcn" behaves differently depending on whether you use "abs()" in the step size formula, leading to erratic behavior in duty cycle. You can consider the below suggestions to eliminate this:
Step Size Instability
  • The formula "step = N * abs(di/dv + I/V)" can become large when dv is very small, since di/dv shoots up.
  • To eliminate this you can limit the step to prevent huge jumps as given below:
step = min(max(N * abs(di/dv + I/V), 0.000001), 0.00005);
Handling dv == 0 Condition
  • If dv is zero or extremely small, you risk division by zero or no updates at all.
You can add a tiny offset so dv never stays at zero like as shown below:
if abs(dv) < 1e-6
dv = sign(dv) * 1e-6; % Small offset
end
Duty Cycle Adjustment is Too Reactive
  • The simple “if change > cond then d = d - step, else d = d + step” responds too quickly to minor fluctuations.
  • To fix this you can smooth out changes using a factor alpha (closer to 1 = slower change):
alpha = 0.8;
if change > cond
d = alpha * d + (1 - alpha) * (d - step);
else
d = alpha * d + (1 - alpha) * (d + step);
end
This softens how fast the duty cycle moves, avoiding wild swings.
By limiting the step size, handling dv near zero, and smoothing duty cycle changes, your MPPT loop will stay more stable and settle around the maximum power point without large spikes.
You can also refer to below filexchnage models on Perturb and Observe (P&O) MPPT:

类别

Help CenterFile Exchange 中查找有关 Wind Power 的更多信息

标签

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by