Asia/Kolkata
Posts

Adaptive MPPT for Partial Shading: Switching Between INC and PSO

January 24, 2026
Rooftop solar installations are rarely clean. Shadows from water tanks, nearby trees, utility poles, or passing clouds create uneven sunlight across an array. When part of a PV array is shaded, bypass diodes inside the panels turn on to prevent hotspots. That protects the panels, but it distorts the electrical profile of the array. The power-voltage (P-V) curve stops having a single clean peak. Instead, it becomes a bumpy landscape with multiple local maxima (false peaks) and one global maximum, which is the actual point you want. Traditional MPPT algorithms like Incremental Conductance (INC) or Perturb & Observe (P&O) are local search methods. They walk "uphill" until they find a peak. Under partial shading, they often get stuck on a lower local peak and miss a significant amount of harvestable energy.
Adaptive MPPT schematic and algorithm flow
To solve this, I designed a controller that uses a hybrid algorithm. The system shifts between two modes depending on the state of the solar array:
  1. Incremental Conductance (INC): Active under uniform sunlight. It is fast, settles without oscillations, and uses minimal computational power.
  2. Particle Swarm Optimization (PSO): A global search algorithm inspired by the movement of bird flocks. When partial shading occurs, the controller runs PSO to sweep the entire voltage range, find the true global maximum, and set the duty cycle there.
The controller runs on an ESP32, which has enough processing speed to handle the math of both algorithms without strain. The real challenge is not running both algorithms; it is knowing when to switch. Running PSO constantly is wasteful because it requires sweeping the voltage range, which briefly interrupts power delivery. The controller monitors the array's electrical signatures in real time:
  • Power Deviation: The controller tracks the expected relationship between open-circuit voltage (Voc) and current. A sudden power drop without a matching temperature change is a strong shading indicator.
  • Voltage Ripple Analysis: Under partial shading, the high-frequency switching ripple on the input capacitors changes shape due to bypass diode conduction. The ESP32's ADC samples this ripple to detect distortion.
In testing, this shading detection method achieved 94.7% accuracy, flagging partial shading events in an average of 2.3 seconds. Once the controller detects shading, it triggers a PSO sweep to find the new global peak. When conditions stabilize and the distortion clears, the system shifts back to high-speed INC tracking. Particle Swarm Optimization works by initializing a group (swarm) of "particles," where each particle represents a candidate duty cycle value.
  1. Each particle evaluates the power generated at its current duty cycle.
  2. The particles share their individual best position (P_best) and the swarm's overall best position (G_best).
  3. The particles update their positions and velocities to converge toward the global best point.
  • Velocity Update: New Velocity = Current Velocity + Inertia + Cognitive Acceleration + Social Acceleration
  • Position Update: New Position = Current Position + New Velocity
Because the particles spread across the full duty cycle range (e.g., 10% to 90%), they can cross the valley of a local minimum and find the higher global peak on the other side.
Adaptive MPPT prototype board
I tested this adaptive controller on a 1.2kW rooftop array with simulated partial shading, covering 15% and 30% of the panels with mesh screens.
  • Energy Yield: The adaptive INC-PSO controller improved energy harvest by 12% to 18% compared to a fixed-INC controller under partial shading.
  • Tracking Time: The PSO sweep takes about 1.8 seconds to locate the global maximum, after which the controller settles.
  • Overhead: CPU usage on the ESP32 during the active PSO phase peaked at just 14% on Core 0, leaving Core 1free for data logging and communication.
  • Hardware: ESP32-WROOM-32E, Synchronous Buck Converter, ACS712-30A current sensor (calibrated), voltage divider feedback loops.
  • Software Architecture: FreeRTOS task structure. Core 0 runs the ADC sampling and the MPPT state machine (INC/PSO loop every 100ms). Core 1 runs the telemetry logging via MQTT over Wi-Fi.
  • Protection: Over-voltage, over-current, and reverse polarity protection built into the analog front-end.