I have noticed that your MPPT algorithm using the Perturb and Observe (P&O) method with a variable step size is experiencing power tracking instability due to the following issues:
Incorrect Fixed Step Condition
- The condition which you have mentioned "(p >= 29 || p <= 30)" is always true, causing the algorithm to frequently apply the fixed step size (0.035), leading to inconsistent MPPT performance.
- To fix this you can modify the condition to ensure the fixed step size is applied only when power is between 29 and 30.
Duty Cycle Instability at 0.7
- When using "delta = (N * abs(dp))", the duty cycle gradually increases until 0.7, then starts fluctuating unpredictably, disrupting stable power tracking.
- To fix this you can implement adaptive step size scaling to reduce step size as the duty cycle approaches "duty_max"
scale_factor = 1 - (duty_old / duty_max);
delta = (N * abs(dp)) * scale_factor;
Duty Cycle Freezing at Limits
- The condition "(duty >= duty_max || duty <= duty_min)" prevents the duty cycle from updating, which can stall the MPPT algorithm.
- Instead of freezing duty adjustments at the limits you can allow small corrective steps.
For an optimized approach, you can refer to this MATLAB File Exchange implementation of an "Enhanced Variable Step P&O MPPT Algorithm" for solar panel systems: