Inc Cond Variable Step Size Questions

18 views (last 30 days)
Micaela
Micaela on 5 Feb 2025
Edited: MULI on 12 Feb 2025
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

Answers (1)

MULI
MULI on 12 Feb 2025
Edited: MULI on 12 Feb 2025
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:

Categories

Find more on Wind Power in Help Center and File Exchange

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!