Simulation is a powerful tool for evaluating the theoretical performance of a system. Indeed, the latter can be tested under easily controllable conditions and its performance can be easily monitored. The simulation procedure links the two parts of design, namely, the theoretical study and the realization. To study the dynamic behavior of the complete system, modeling of each element is essential. We chose to work with the Simscape Toolbox in Matlab r2024a, used for the simulation of power electronics systems. This toolbox is used in order to be able to account for as many phenomena as possible during the operation of the system. It is therefore well suited to implement, test and evaluate digital MPPT systems and coding the neuro-fuzzy PSO algorithm. A pertinent dataset for simulating photovoltaic (PV) system performance is the Solar Power Generation Data available on Kaggle [
34]. This dataset encompasses detailed information on power generation and corresponding sensor readings from a solar power plant over a specified period. The power generation data is collected at the inverter level, with each inverter connected to multiple lines of solar panels. This granularity allows for an in-depth analysis of the power output across different sections of the solar array. The Kaggle dataset is structured into two primary files: one containing the power generation data and the other comprising sensor readings. The power generation file includes timestamps and the corresponding power output measurements, providing a time-series perspective of the energy produced. The sensor data file offers insights into various environmental and operational parameters, such as panel temperature, ambient temperature, and solar irradiance levels. This combination of data is invaluable for simulating and analyzing the performance of PV systems under varying environmental conditions. In this study, both real-world data and simulated data were utilized to ensure comprehensive testing and validation of the proposed ANFIS-PSO control strategy. The Solar Power Generation dataset from Kaggle was employed to extract environmental variables such as solar irradiance, ambient temperature, panel temperature, and actual power output, providing realistic input conditions for model evaluation. These real measurements were used to test the controller’s ability to respond accurately to practical fluctuations in solar conditions. In parallel, a synthetic dataset generated using MATLAB/Simulink simulations was used to test the ANFIS model. This approach ensured that the model could generalize well to unseen data.
2.1. Adaptive Neuro-Fuzzy Inference System
The ANFIS system (
Figure 2), or Adaptive Neuro-Fuzzy Inference System, provides a hybrid technology that utilizes the learning capacity of artificial neural networks (ANNs) and the structure of fuzzy logic systems (FLSs) built on rules and reasoning. As a result, the system is capable of responding in real-time control for applications such as harmonic distortion reduction in grid-connected inverters due to its adaptability to nonlinear, dynamically changing environments. ANFIS is applied in the proposed method to control the PWM switching signal to ensure that the THD of the injected current is as low as possible while smoothly and actively transferring power from the PV array to the grid. The training process of the ANFIS controller in this study begins with the initialization of a Sugeno-type fuzzy inference system (FIS), where each input—specifically the current error and its rate of change—is assigned five Gaussian membership functions (MFs), resulting in a total of 25 fuzzy rules. These rules are initially generated based on expert knowledge or uniformly distributed values across the input domain, forming a comprehensive rule base. The parameters of the membership functions, including their center and width, are then iteratively refined through a hybrid learning algorithm that combines gradient descent-based backpropagation and least squares estimation (LSE). This hybrid approach ensures that the premise (fuzzy sets) and consequent parameters (linear outputs) are adjusted simultaneously, allowing for adaptive learning. As the training proceeds using a dataset of 5000 samples derived from simulation scenarios, convergence is monitored based on a predefined error threshold or maximum epochs. The error function, typically the mean squared error (MSE) between the actual and predicted PWM duty cycle, gradually decreases, indicating that the system is learning to produce optimal PWM signals with reduced THD under varying grid conditions.
The core functionality of ANFIS lies in its adaptive capability, wherein it adjusts the parameters of the fuzzy logic membership functions using a backpropagation algorithm combined with a least squares estimation (LSE) method. This enables real-time tuning of the PWM control parameters, thereby improving the inverter’s response to dynamic grid conditions. The fuzzy inference system is structured as a Sugeno-type FIS, where each fuzzy rule is expressed in the form:
: If
is
and
is
, then:
where
and
represent the input variables (e.g., error and change in error of the current waveform),
and
are the fuzzy membership functions, and
is the output function defined by the linear parameters
. The neuro-adaptive learning algorithm optimizes these parameters through iterative training, ensuring that the control action aligns with the grid requirements. The parameters
, and
represent the linear coefficients of the output function in the ith fuzzy rule. However, within the context of an Adaptive Neuro-Fuzzy Inference System (ANFIS), these coefficients are adaptive parameters—they are not fixed. During the training process, ANFIS uses a hybrid learning algorithm that combines gradient descent (for premise parameters like membership functions) and least squares estimation (LSE) (for consequent parameters like
. This means that the system automatically adjusts
in each rule to minimize the error between the actual output and the predicted output, making them fully adaptive and data-driven. Thus, in the ANFIS framework,
are not static constants but trainable parameters that are optimized during the learning phase.
To mathematically model the impact of harmonic distortion and its reduction through ANFIS-based control, the current injected into the grid can be represented as:
where
represents the fundamental current component at grid frequency, and
are the higher-order harmonic components. The objective of the proposed neuro-fuzzy controller is to minimize the total harmonic distortion, which is mathematically defined as:
where
is the RMS value of the fundamental current component, and the summation accounts for the harmonic distortion across higher frequencies. By continuously adjusting the PWM duty cycle based on the ANFIS output, the controller reduces
for all
, thereby minimizing THD. The ANFIS-based PWM control strategy is designed to generate optimal switching pulses for the transistorized full-bridge inverter, ensuring that the output waveform closely matches a pure sinusoidal waveform. This is achieved by modifying the switching function, which determines the duty cycle
based on real-time feedback:
where
represents the error between the desired and actual grid current, and
is its rate of change. The adaptive learning mechanism updates the fuzzy rule parameters to minimize the control error:
where
denotes the parameter vector (including membership function shapes and rule coefficients),
is the error function, and
is the learning rate. The ANFIS training process iteratively refines these parameters, ensuring rapid convergence towards an optimal control strategy.
The training methodology of the ANFIS controller in this study was carefully structured to ensure real-time adaptability and robustness in dynamic PV system environments. The input selection—specifically, the use of the error (difference between reference and actual current) and the change in error—is based on well-established control theory principles used in fuzzy and neural controllers. These two inputs effectively capture the system’s current deviation from optimal behavior and the rate at which this deviation is evolving, allowing the controller to anticipate and correct trends before they escalate. This dual-input strategy enables faster convergence and smoother regulation compared to single-input systems, particularly when operating under variable irradiance, shading, or load disturbances. Regarding the membership function (MF) types, the ANFIS model employs Gaussian membership functions for both inputs. Gaussian MFs are selected due to their smoothness, differentiability, and suitability for gradient-based optimization methods such as backpropagation. These characteristics make them ideal for neuro-fuzzy systems, as they provide continuous transitions between fuzzy sets and facilitate more stable learning compared to non-differentiable alternatives like triangular or trapezoidal MFs. Each input variable is assigned five Gaussian MFs, leading to a total of 25 fuzzy inference rules in a full grid partitioning scheme. However, the use of 25 rules, while comprehensive, may be excessive for real-time embedded applications, where memory and computation are limited. To address this, rule reduction techniques can be employed to preserve control performance while reducing complexity. One such method is subtractive clustering or fuzzy c-means clustering, which identifies the most significant data clusters and generates a reduced rule base accordingly. Alternatively, orthogonal least squares (OLS) analysis can be used to evaluate the contribution of each rule to output prediction and eliminate redundant or low-impact rules. These reduction strategies can significantly reduce the number of active rules—potentially from 25 down to 9 or fewer—without compromising accuracy, thus improving the system’s viability for deployment on digital signal processors (DSPs) or FPGA-based controllers.
One of the most notable benefits of implementing ANFIS on PWM optimization is how well it manages grid disturbances and non-derivative related issues. Sudden power changes, sudden changes in load, sudden changes in voltage levels, and varying levels of power injection all become issues with adaptability for fuzzy controllers with fixed rules. Nevertheless, the neuro-adaptive tuning with ANFIS permits the system to optimize itself in real time, which, along with output feedback control, provides the required support to ensure that current output distortion is low for a stable grid current. Further examination can be performed in the frequency domain utilizing FFT to analyze the ANFIS-based PWM control efficiency related to harmonic distortion reduction. The inverter output current spectrum, represented as “
I”, for the inverter output current spectrum yields:
By applying adaptive filtering techniques within the ANFIS framework, undesired harmonic components are selectively attenuated, resulting in a cleaner waveform. The control system ensures that the inverter operates within the IEEE 519 harmonic limits, which specify:
The controller operates independently of grid-side dynamics, focusing solely on the DC side of the system to track the Maximum Power Point (MPP) by adjusting the duty cycle of the DC-DC converter. The observed reduction in current distortion (i.e., lower THD) is a result of the controller’s ability to produce smooth and stable PWM signals, which lead to cleaner switching behavior when passed through the inverter. Nonetheless, it is important to acknowledge that in practical grid-connected applications—particularly in microgrids or weak grids—the current injected into the grid is also affected by external disturbances such as voltage fluctuations, load switching, and impedance mismatches. Therefore, while the controller contributes to improved power quality, its ability to minimize THD is not solely determined by its own design but also influenced by real-time grid conditions. Future experimental validation should thus account for such factors to provide a more holistic evaluation of current distortion under realistic grid behavior.
2.2. PSO Algorithm
Various life forms like flocks of birds and schools of fish inspired the development of Particle Swarm Optimization (PSO), which is a metaheuristic optimization algorithm of high relevance in the field. While PSO has been widely employed for MPPT (Maximum Power Point Tracking) purposes in the context of power electronics and renewable energy systems, its use in connection with Pulse Width Modulation (PWM) control in grid-connected inverters is still lacking. This study applies PSO for the dynamic optimization of PWM switching with respect to minimal Total Harmonic Distortion (THD) current injection into the grid, ensuring stable and efficient power transfer. As for the implementation of PSO, we have a swarm of particles that “navigate” through the search space, where every particle or individual is a prospective solution. In any step, particles modify their positions in the search space relative to the best-placed neighbors, taking into account their personal best experiences as well. To achieve this, the position and velocity of the mth particle is updated in an
N-dimensional search space with the equations provided:
where:
is the position of particle at iteration , representing a potential PWM parameter set.
is the velocity of the particle at iteration .
is the best position found by the particle itself.
is the best global position found by any particle in the swarm.
is the inertia weight that controls the balance between exploration and exploitation.
and are acceleration coefficients, which determine the influence of personal and global best positions.
are random numbers uniformly distributed in .
In the context of PWM optimization for grid-connected inverters, the fitness function for PSO is designed to minimize THD while ensuring compliance with grid voltage and frequency constraints. The objective function can be defined as:
where:
THD is the total harmonic distortion of the injected current.
represents the deviation from the reference grid voltage.
is the power loss in the inverter due to switching.
are weighting factors that prioritize different aspects of optimization.
The selection of these weights is guided by the relative importance of each objective in the context of gridconnected PV systems:
(THD penalty weight): THD has the most critical impact on power quality and must comply with grid standards such as IEEE 519. A higher weight (e.g., ) is justified to ensure that the PSO prioritizes minimizing THD, which, if neglected, can lead to system instability, increased thermal losses, and grid non-compliance.
(Voltage deviation penalty weight): Voltage regulation is important for maintaining grid synchrony and proper inverter operation, but small deviations are often tolerable within regulatory margins (e.g., ). Hence, a moderate weight (e.g., ) allows for some flexibility while still ensuring voltage quality.
(Power loss penalty weight): While minimizing switching losses is desirable to improve efficiency, the absolute magnitude of these losses is typically much smaller compared to the other two terms. Therefore, a lower weight (e.g., ) is sufficient to guide the optimizer without overshadowing more critical objectives.
These weight values (e.g.,
) were empirically selected through trial simulations to balance power quality, stability, and efficiency. Sensitivity analysis could further validate or refine these weights to adapt the fitness function for specific hardware constraints or regulatory frameworks. The proposed PSO-based PWM control algorithm works by initializing a population of particles, where each particle represents a potential set of duty cycle values for the PWM switching signals. The swarm iteratively updates its duty cycle parameters to minimize THD, ensuring a near-sinusoidal grid current.
where
represents the duty cycle vector governing the PWM switching function:
Here,
is the error between the reference and actual current, and
is its rate of change. The PSO controller optimally selects the switching instants to minimize unwanted harmonics, ensuring compliance with IEEE 519 standards, which set a THD limit of:
for grid-connected inverters.
The advantages of using PSO for PWM control over traditional methods like hysteresis current control or fixed-rule fuzzy logic include:
Global Search Capability: Unlike local optimization methods, PSO performs a global search for the best PWM switching parameters, reducing the risk of local minima trapping.
Fast Convergence: Due to its swarm intelligence, PSO rapidly converges to an optimal solution, making it suitable for real-time inverter control applications.
Robustness to Load and Grid Variations: Since PSO continuously updates duty cycle values based on real-time feedback, it adapts dynamically to variations in grid impedance, voltage fluctuations, and load disturbances.
Computational Efficiency: Unlike deep learning-based controllers that require high computational resources, PSO achieves fast and lightweight optimization, making it implementable on low-power DSPs or FPGA-based controllers.
To further enhance performance, dynamic PSO variants such as Adaptive PSO (APSO) and Chaotic PSO (CPSO) were integrated into the control loop. APSO dynamically adjusts inertia weight
and acceleration coefficients
to improve convergence speed, while CPSO introduces chaotic sequences into particle updates, enhancing diversity in search space exploration.
Figure 3 further illustrates the proposed PSO modification:
The Particle Swarm Optimization (PSO) algorithm plays a crucial role in enhancing the performance of the ANFIS-based PWM control by globally optimizing the fuzzy membership function parameters and rule weights. Beyond its standard use in function minimization, PSO is employed here to navigate the multi-dimensional parameter space associated with PWM signal generation, specifically targeting the reduction of Total Harmonic Distortion (THD), ensuring grid compliance, and minimizing switching losses. Each particle in the swarm represents a candidate solution—a unique combination of PWM duty cycle parameters. The fitness function evaluates these candidates based on a composite objective that includes THD level, voltage deviation from the reference, and inverter switching losses. Unlike purely gradient-based methods that risk local minima entrapment, PSO uses velocity and position updates driven by both individual (cognitive) and swarm-wide (social) knowledge to explore the parameter space. Additionally, advanced variants such as Adaptive PSO (APSO) and Chaotic PSO (CPSO) were integrated to dynamically adjust inertia and inject nonlinear perturbations, thereby increasing convergence speed and preventing stagnation in suboptimal regions. This enables the algorithm to efficiently determine optimal PWM patterns even under highly dynamic or nonlinear system conditions.
2.3. Simulation Parameters
In order to analyze the performance of the AI-integrated strategy for reducing harmonic distortion, a grid-connected photovoltaic (PV) system simulation was developed using MATLAB/Simulink, including a transistorized full-bridge inverter. Its particular encapsulation included an electric grid model, PV array, inverter, PSO-based PWM optimization, and ANFIS controller geared toward dynamic system simulations. From a pragmatic standpoint, the parameter values chosen were those commonplace in industry, and tailored to guarantee efficient system function under changing grid dynamics. The electric grid model was established to represent a typical low-voltage distribution system, operating at 230 V RMS, 50 Hz, with a total short-circuit power of 5 MVA to reflect realistic grid impedance and reactance values. The grid impedance was set with a resistance of 0.1 Ω and an inductance of 0.5 mH to model practical transmission losses as summarized in
Table 3. The simulations were conducted using a controlled and idealized grid environment in order to isolate and evaluate the behavior of the MPPT controller under standard conditions—particularly its impact on power tracking accuracy and Total Harmonic Distortion (THD). While the grid was modeled as stable and well behaved to ensure a clean baseline for performance comparison, this does not imply that the controller’s effectiveness is limited to such conditions. Rather, it was a necessary first step to validate the controller’s intrinsic capabilities. Acknowledging this limitation, future work will focus on testing the system under more realistic and dynamic grid conditions—such as voltage sags, load fluctuations, and harmonic contamination—to establish the robustness and credibility of the controller in practical deployment scenarios.
The PV array is composed of 200 commercially available panels, each rated at approximately 41.0 V and 12.2 A at maximum power point (MPP), with a power rating of 500 W (e.g., Canadian Solar HiKu CS3W-500MS). The Canadian Solar HiKu CS3W-500MS solar module was sourced from Canadian Solar Inc., a globally recognized solar manufacturer headquartered in Guelph, Ontario, Canada. The company designs and manufactures high-efficiency photovoltaic modules and provides solar energy solutions worldwide. This specific model, known for its high power output and durability, is part of Canadian Solar’s HiKu product line, which is engineered to meet the demands of both utility-scale and commercial solar installations. To achieve the target DC-link voltage of 600–700 V, a series–parallel configuration was implemented. Specifically, 20 series-connected panels per string were used, with 10 parallel strings, resulting in a total system capacity of 100 kW, a nominal voltage of approximately 820 V, and an output current of about 122 A as illustrated in
Table 4. This configuration aligns with realistic inverter design constraints and ensures compatibility with MPPT algorithms and grid-tied control systems. The panel model and its electrical characteristics were selected based on standard commercial products to ensure simulation accuracy and relevance to practical deployment scenarios.
In the proposed intelligent MPPT control scheme, the PWM (Pulse Width Modulation) parameter that is primarily adjusted is the duty cycle (D) of the DC-DC converter. This duty cycle directly controls the operating voltage of the PV array, which in turn determines the operating point on the I-V curve. By continuously adjusting the duty cycle, the controller attempts to align the PV operating point with the Maximum Power Point (MPP), maximizing energy extraction efficiency. From an energy extraction standpoint, the duty cycle must be finely tuned to minimize the deviation from the ideal
Vmp (voltage at maximum power point). An inaccurate or unstable duty cycle leads to operation away from the MPP, resulting in suboptimal power output. The intelligent adaptation schemes, such as ANFIS in this work, learn the nonlinear relationship between power variations and optimal duty cycles, allowing for faster and more accurate convergence to the MPP under changing conditions like irradiance or temperature shifts. In terms of Total Harmonic Distortion (THD), the duty cycle indirectly affects the harmonic content of the inverter’s output current. A well-regulated, smooth, and stable duty cycle leads to cleaner switching behavior and consistent current injection into the grid. Conversely, erratic or oscillatory duty cycle adjustments—often seen in conventional MPPT methods—cause high-frequency switching artifacts and ripple, increasing THD. The intelligent controller, by learning to minimize unnecessary duty cycle fluctuations and rapidly locking into stable operating regions, helps maintain waveform integrity, thus reducing THD while also enhancing overall energy conversion efficiency. To obtain the P(V) characteristic of the panel, we varied the voltage at the panel output from 0 V to Voc.
Figure 4 illustrates the simulation environment developed in Simulink™ for implementing and testing the proposed MPPT control strategy.
Figure 4a shows the complete control model, including the photovoltaic array, boost converter, ANFIS-PSO-based MPPT controller, inverter, and grid interface. This model enables end-to-end evaluation of the controller’s performance under different environmental and load conditions.
Figure 4b displays the PID controller tuning window, used here as a supplementary tuning interface during early-stage simulations or for baseline comparisons, not for modeling PV panel characteristics as previously described.
We utilized the Canadian Solar HiKu CS3W-500MS for the simulation, a 500-watt commercial-grade photovoltaic (PV) solar panel widely adopted in utility-scale, commercial, and high-efficiency residential solar installations. This module is known for its high energy yield, robust design, and reliability under varying environmental conditions. The CS3W-500MS panel uses advanced monocrystalline PERC cell technology, which enhances light capture and improves overall power conversion efficiency. The panel’s peak power output (Pmax) is 500 W, measured under Standard Test Conditions (STC): irradiance of 1000 W/m
2, cell temperature of 25 °C, and air mass of 1.5 bar. The maximum power point voltage (Vmp) is approximately 41.0 V, and the maximum power point current (Imp) is about 12.2 A, making it well suited for high-capacity series–parallel configurations. These characteristics ensure efficient energy conversion, stable performance under partial shading or temperature variation, and compatibility with MPPT-based control strategies. The electrical behavior of the panel, including its I-V and P-V characteristics, is illustrated in
Figure 5. The dual-axis layout illustrates the typical behavior of a photovoltaic (PV) module: current remains relatively constant up to a certain voltage, beyond which it drops sharply—resulting in the peak of the power curve. This peak represents the Maximum Power Point (MPP), a critical target for MPPT algorithms. The graph provides a visual reference for the electrical behavior of PV systems and is essential for understanding how controllers optimize performance by adjusting operating voltage.
Figure 6 illustrates the Simulink models of both inverting (top) and non-inverting (bottom) buck-boost converter topologies, used to regulate output voltage through duty cycle modulation. The diagram on the right displays the duty cycle control block and its corresponding equation, which governs the output voltage as a function of the input voltage and switching duty cycle
, following the relation
. These models enable the analysis of voltage regulation strategies in various converter configurations and form the foundation for testing the performance of MPPT algorithms in PV-integrated DC-DC converter systems.
An LC filter (
,
) was implemented at the inverter output to smooth out the voltage and current waveforms, reducing high-frequency switching harmonics before grid injection. The inverter’s modulation index was controlled dynamically using the ANFIS-PSO-based PWM strategy to optimize power quality. While the LC filter implemented at the inverter output plays a crucial role in attenuating high-frequency switching harmonics and improving power quality, it operates downstream from the MPPT controller and thus has minimal impact on energy extraction efficiency. The MPPT logic, implemented via the ANFIS-PSO controller, functions on the DC side and is not directly constrained by the LC filter’s dynamic behavior. However, in real-world systems, excessive filtering—especially in the signal acquisition stage—can introduce phase delays that affect the responsiveness of the MPPT. In this study, no additional adaptive filtering (e.g., Kalman or LMS) was applied to measurement signals, but this remains an area for future enhancement. Overall, the LC filter improves grid compatibility without significantly impairing energy harvesting, provided its cutoff frequency is properly tuned relative to the switching frequency and MPPT control bandwidth.
Table 5 summarizes the filter parameters in the proposed system.
The particle swarm optimization (PSO) algorithm was set to a population size of 50 particles. This was chosen to improve computational efficiency while still providing a good particle solution diversity. The inertia weight w started at 0.9 and was decreased linearly to 0.4 during iterations to increase convergence speed. The w value was set for the purposes of cognitive and social acceleration as c1 = 1.5 and c2 = 1.7, which were chosen to balance between exploration and exploitation. For the PSO algorithm, both were performed for a set of 100 iterations with a fitness function designed to minimize total harmonic distortion (THD) while ensuring grid voltage compliance as illustrated in
Table 6. Adaptive PSO (APSO) modifications changed the inertia weight to adaptively alter the convergence based on changes to the convergence trend, while Chaotic PSO (CPSO) implemented non-linear dynamics to introduce chaos-driven perturbation to further obliterate the set local minima.
The choice of PSO parameters was carefully selected to balance exploration and exploitation, computational feasibility, and convergence reliability. A population size of 50 particles was chosen to ensure sufficient diversity in the search space while keeping the computational overhead manageable for real-time implementation on embedded systems or DSPs. A smaller swarm might risk premature convergence, while a significantly larger swarm would increase processing time without proportionate gains in accuracy. The number of iterations was set to 100, which was empirically found to be sufficient for the fitness function to stabilize across multiple test scenarios without unnecessary computational burden. The inertia weight was linearly decreased from 0.9 to 0.4 to allow a gradual transition from exploration to exploitation. The acceleration coefficients (c1 = 1.5, c2 = 1.7) were selected based on common practice in PSO literature, offering a balanced influence from both personal and global best positions. These values were validated through convergence analysis during preliminary simulations, ensuring that the PSO-optimized ANFIS controller consistently minimized THD and enhanced system response across varying solar and grid conditions.
The current implementation of the PSO algorithm utilizes fixed parameter values—specifically, an inertia weight linearly decreasing from 0.9 to 0.4, and acceleration coefficients set at
(cognitive) and
(social). While these values are commonly adopted in PSO literature and have demonstrated good empirical performance in the presented simulations, they may not represent the optimal configuration for all dynamic operating conditions. To enhance the robustness and generalizability of the proposed method, a sensitivity analysis shown in
Figure 7 was conducted.
This analysis would involve systematically varying each PSO parameter across a predefined range while observing the impact on MPPT efficiency, THD, convergence speed, and computational overhead. For instance, testing inertia weights in the range [0.3–0.9] can reveal how exploration versus exploitation tradeoffs affect tracking stability under partial shading or rapidly changing irradiance. Similarly, tuning and in the range [1.0–2.5] would help determine the influence of personal versus global learning tendencies on the optimizer’s ability to escape local optima and converge efficiently. Preliminary results from such a sensitivity analysis could also justify the integration of adaptive PSO variants, where these coefficients are dynamically adjusted based on convergence behavior. Incorporating such insights would not only justify the original parameter choices but also provide a data-driven foundation for further improving the controller’s adaptability and real-time performance in uncertain or nonlinear grid conditions.
The controller was designed with two inputs—current error and the change of current error—and one output, which was responsible the adjusting the PWM duty cycle. The fuzzy inference system which was implemented was a Sugeno type FIS with five membership functions (MFs) per input, giving 25 rules total. The training was carried out with an ANFIS model using a hybrid backpropagation and least squares estimation method, with a learning rate set to 0.01 and a training dataset of 5000 samples generated from off-line simulation. The membership function parameters were altered throughout the training process to guarantee optimal results under different grid conditions as illustrated in
Table 7.
To assess system performance, simulations were performed with changing solar irradiance (200 W/m2 to 1000 W/m2) and grid disturbances (±10% voltage sag/swell). As mentioned earlier, the response time of the controller and the level of THD were checked along with other compliances with the grid and power efficiency to verify the robustness of the method.
2.4. MPPT Module in MATLAB/Simulink Simulation
The Maximum Power Point Tracking (MPPT) module, as set forth in this research, serves as a vital component in MPPT control systems for photovoltaic (PV) energy systems. Its purpose is tracking the operating point of the PV array in a way that maximally extracts power and dynamically adjusts to the environmental changes. In this work, the control strategy of the MPPT is based on ANFIS (Adaptive Neuro-Fuzzy Inference System) with optimization performed by Particle Swarm Optimization (PSO). In opposition to conventional methods such as Perturb and Observe (P&O), Incremental Conductance (INC), or others that oscillate at steady state, this hybrid method achieves faster convergence. For the purpose of this research, the detailed model includes a PV model, a DC-DC boost converter, and the ANFIS-PSO-based MPPT controller developed in MATLAB R2023a in Simulink with the Simscape Power Systems toolbox. The objective of the work described in this document was to formulate the MPPT algorithm in such a way that optimal PWM output corresponding to duty cycle of the boost converter is generated, so that the losses are minimized while the system seamlessly tracks the maximum power point (MPP) of the photovoltaic system.
Figure 8 illustrates the overall ANFIS-PSO–based MPPT control scheme and its Simulink realization. In
Figure 8a, the high-level diagram shows a photovoltaic (PV) array feeding a bidirectional DC–DC converter that supplies both a load and a battery. At each sampling instant, the measured PV voltage (Vpv) and current (Ipv) feed into an objective-function block, which passes these measurements to a particle swarm optimizer (PSO). PSO evaluates candidate duty-cycle settings within a constrained range and selects the best-performing candidate based on the instantaneous PV power (Ppv = Vpv·Ipv). That optimal duty-cycle guess is then refined by an Adaptive Neuro-Fuzzy Inference System (ANFIS), whose fuzzy rules have been trained offline to minimize oscillations around the maximum power point (MPP). The final ANFIS-adjusted duty signal (d) is sent to a PWM generator, which produces a gate waveform that drives the DC–DC converter’s switching transistor. In
Figure 8b, the actual Simulink layout is shown in detail: three PV modules (PV1, PV2, PV3), each receiving its own irradiance and temperature inputs, output Vpv and Ipv measurements through sensor blocks, which feed directly into a MATLAB-Function block implementing the PSO routine and into an imported “Fuzzy Logic Controller” block that executes the trained ANFIS.fis file. The duty-cycle output of ANFIS passes to a PWM block that drives the converter’s MOSFET (labeled VT), whose inductor (L) and diode (VD) feed energy into a smoothing capacitor (Cn), the battery block, and the load. A PowerGUI discrete-solver block ensures a fixed 1 × 10
−7 s time step for accurate switching dynamics. Inset detail shows how PSO’s candidate duty, Vpv, and Ipv are compared inside ANFIS’s fuzzy-inference network to produce a corrected duty. Together, these two subfigures capture both the conceptual flow and the precise Simulink implementation of the ANFIS-PSO MPPT controller.
The ANFIS model consists of two input variables, error
and change in error
, which are defined as:
where
and
are the instantaneous power and voltage of the PV array. These inputs are used to adjust the duty cycle (D) of the boost converter, ensuring that the PV array maintains its MPP voltage (
). The ANFIS structure was trained using 5000 data points, covering various irradiance and temperature conditions to generalize well across different operating scenarios.
The PSO algorithm was integrated into the MPPT controller to optimize the fuzzy membership functions and rule base of ANFIS, ensuring an adaptive learning process. The PSO optimization process was formulated as follows:
Particle Representation: Each particle represents a potential set of fuzzy membership function parameters for ANFIS. Fitness Function: The objective function for PSO minimizes the tracking error and power loss, defined as:
where
is the theoretical maximum power,
is the actual output power, and
represents the total harmonic distortion in the injected current.
Velocity and Position Update: The PSO algorithm updates each particle’s position according to:
where
and
are the best local and global solutions, and
are the inertia weight and acceleration coefficients.
Adaptive Learning: Over multiple iterations, PSO optimizes the ANFIS rule base, ensuring fast convergence and high tracking efficiency.
The boost converter was designed to step up the PV voltage to match the DC link voltage. The parameters (
Table 8) were selected to ensure high efficiency and minimal ripple. The inductor (
) and capacitor (
) were chosen to maintain stable voltage conversion, while the PWM switching frequency was set at 10 kHz to reduce switching losses.
The MATLAB/Simulink implementation consisted of:
A detailed PV model representing a 100 kW PV system with varying irradiance (200–1000 W/m2).
An ANFIS-PSO-based MPPT controller implemented using Simulink’s Fuzzy Logic Toolbox and custom PSO optimization scripts.
A PWM generator producing optimized switching signals for the boost converter.
A grid model ensuring that the output meets IEEE 519 THD standards (< 5%).
In the proposed system, Particle Swarm Optimization (PSO) is primarily employed during the offline training phase to optimize the parameters of the ANFIS controller—specifically, the shapes and positions of the membership functions and the consequent rule weights. The goal of this optimization is to ensure that the ANFIS model is well-tuned to minimize MPPT tracking error and total harmonic distortion (THD) before deployment. Once the optimal parameter set is identified through iterative PSO runs on the training dataset, these parameters are fixed and used during real-time operation. Therefore, PSO is not active during the runtime of the controller. This design choice significantly reduces computational overhead during operation, making the system suitable for real-time embedded implementation.
2.5. Controller Algorithm and Design
The core of the proposed controller is a hybrid intelligent MPPT system built upon an Adaptive Neuro-Fuzzy Inference System (ANFIS) framework, whose parameters are optimized using Particle Swarm Optimization (PSO). The controller is designed to dynamically adjust the PWM duty cycle of the DC-DC converter to ensure that the photovoltaic (PV) system operates at or near its Maximum Power Point (MPP) under varying environmental conditions. Unlike conventional MPPT controllers such as Perturb and Observe (P&O) or Incremental Conductance (INC), which rely on deterministic search behavior, the proposed system leverages the learning capability of ANFIS to capture the nonlinear mapping between input features (error and change in error) and the optimal control action. The ANFIS model serves as the primary decision-making unit. It receives two inputs: the instantaneous error, defined as the difference between the reference and actual power or current, and the change in error over time. These inputs are passed through Gaussian membership functions, and a rule base (initially composed of 25 Sugeno-type fuzzy rules) is used to infer the most suitable duty cycle. The outputs of the ANFIS, after being defuzzified, are used to adjust the switching signal of the DC-DC converter. This allows the system to adapt its behavior based on recent trends in PV performance rather than fixed logic, enhancing responsiveness and reducing steady-state oscillation. To ensure that the ANFIS rule base and membership functions are optimally configured, a PSO algorithm is applied during the offline training phase. Each particle in the swarm represents a candidate parameter set (e.g., centers and widths of Gaussian MFs, linear coefficients of output functions). The PSO evaluates these candidates using a multi-objective fitness function that balances MPP tracking error, voltage deviation, and Total Harmonic Distortion (THD) in the output waveform. Through iterative position and velocity updates, the swarm converges to a globally optimal set of parameters that are then embedded into the ANFIS structure. The controller outputs a modulated PWM duty cycle, which is sent to the gate driver of the DC-DC boost converter. This duty cycle directly determines the operating voltage of the PV module or array. By adapting in real time to irradiance and temperature changes, the system ensures that the voltage stays close to the MPP voltage (Vmp), thereby maximizing power output while maintaining low THD and fast response. In summary, the design combines fuzzy logic’s ability to handle uncertainty, neural networks’ learning capability, and PSO’s global optimization strength into a cohesive and adaptive control structure. This hybrid architecture provides a flexible and intelligent solution for real-time MPPT in grid-connected PV systems, especially under rapidly changing or partially shaded conditions. The ANFIS network is constructed as a first-order Sugeno-type fuzzy inference system with two inputs—PV voltage and PV current —and one output, which is the corrective term to be applied on top of the PSO-suggested duty. To begin, we collect a comprehensive training dataset that spans the full expected operating range of the PV array under varying irradiance ( in increments of ) and module temperature ( in increments of ). For each irradiance–temperature combination, we run an offline high-resolution P&O algorithm on the PV I-V curve (with voltage steps of 0.1 V and a convergence tolerance of 0.01 W) to determine the ground-truth maximum-power duty cycle . We sample 5000 distinct pairs uniformly across the continuous P-V curve within each environmental condition. Each sample pair is assigned the corresponding value, producing a labeled dataset of roughly 150,000 rows. Before training, both and inputs are normalized linearly to the interval based on the minimum and maximum values observed in the collected data; the target output is likewise scaled to .
Once the dataset is normalized, the ANFIS architecture is defined with exactly three Gaussian membership functions for each input. Thus, there are a total of fuzzy rules. For each input variable, the three Gaussian MFs are initialized as follows: their means are set to the 33rd and 66th percentiles (i.e., 0.33 and 0.66) of the normalized training samples’ distribution in that variable, and their standard deviations are set to 0.2. Concretely, for , the three membership functions are , and . Likewise, for , the Gaussian means are set at 0.33, 0.66, and 1.00 (since the maximum normalized current is 1.00), with equal standard deviation 0.2. These initial parameters ensure good coverage of the input space without overlapping excessively. All consequent functions are first-order linear (Sugeno) of the form , where . The initial consequent coefficients are set to zero.
Training is performed within MATLAB’s Fuzzy Logic Toolbox using the hybrid learning algorithm that alternates least-squares estimation (LSE) for the consequent coefficients and gradient descent (backpropagation) for the premise (MF) parameters. We allocate of the normalized dataset for training and reserve for validation. The training runs for a maximum of 100 epochs, with the following settings: learning rate for backpropagation , minimum step size , and tolerance on root-mean-square error (RMSE) of . After each epoch, the validation RMSE is computed; if the validation RMSE fails to decrease for 10 consecutive epochs, early stopping is triggered. At the end of training, the final RMSE values are typically on the order of (in normalized duty units). The resulting ANFIS model is saved to a file “ANFIS_MPP.fis”, which contains all optimized MF parameters and consequent coefficient triplets for .
To deploy the trained ANFIS in the Simulink environment, we import “ANFIS_MPP.fis” into a “Fuzzy Logic Controller” block. This block accepts two inputs—normalized and —and outputs a normalized correction . In practice, because the PSO algorithm already proposes a base duty cycle , the final duty is computed in Simulink as . We choose so that ANFIS can adjust PSO’s suggestion up or down by at most in normalized duty units. This clipping ensures that remains in the valid interval . The “Fuzzy Logic Controller” block internally performs fuzzification by computing the nine rule firing strengths , then normalizes them , evaluates each consequent linear function , and computes .
Internally, each Gaussian MF is implemented by the block’s precompiled C-code, using the stored pair of parameters
. The Simulink sample time for the “Fuzzy Logic Controller” is set identically to the PSO block’s sample time (
) so that at each discrete step, the ANFIS block receives updated
and
values and yields a new
. Because
is bounded by the linear combination of consequents (which remain small due to the hybrid training limiting coefficient magnitudes to
), the “clip” operation ensures that the combined
never exceeds the converter’s safe operating range. Finally, before exporting the duty to the PWM block, we implement a one-sample-delay filter—i.e.,
—to smooth any sudden jumps in duty arising from PSO drift. This smoothing coefficient of 0.2 was chosen empirically to reduce audible switching noise and to limit current spikes in the inductor while preserving rapid MPP tracking. As a result, the combined ANFIS-PSO MPPT controller operates within the Simulink model as follows: at each time step, PSO produces a candidate
, ANFIS refines it by
, the result is clipped and low-pass filtered, and the final
drives the PWM generator. Algorithm 1 explains the proposed ANFIS-PSO-based MPPT control algorithm in a step-by-step pseudocode format:
Algorithm 1: ANFIS-PSO-Based MPPT Control Strategy |
Input: |
| : Instantaneous PV voltage : Instantaneous PV current : Instantaneous PV power : Control time step
|
|
Offline Phase (PSO-Based Training): |
| 1. Initialize PSO parameters: swarm size , inertia weight , acceleration coefficients , number of iterations. |
| 2. Generate initial particles, where each particle encodes ANFIS parameters (membership functions and rule coefficients. |
| 3. For each particle: |
| ● Train ANFIS model with synthetic PV dataset. |
| ● Compute fitness using: |
| |
| 4. Update particle velocity and position using PSO update rules. |
| 5. Repeat steps 3-4 until convergence or max iterations. |
| 6. Store the best-performing ANFIS parameters for use in the online phase. |
|
Online Phase (Real-Time MPPT Operation): |
| 1. Loop at each control cycle: |
| 1.1 Measure , and compute . |
| 1.2 Compute error: |
| |
1.3 Compute change in error: |
| |
1.4 Feed and into trained ANFIS. |
1.5 Obtain duty cycle output from ANFIS. |
1.6 Update PWM signal of DC-DC converter using . |
2. End Loop |
Return: Real-time duty cycle ensuring optimal power extraction and low THD. |
Algorithm 1 outlines the complete workflow of the proposed ANFIS-PSO-based MPPT control strategy, divided into an offline training phase and an online real-time operation phase. During the offline phase, the Particle Swarm Optimization (PSO) algorithm is used to fine-tune the parameters of the Adaptive Neuro-Fuzzy Inference System (ANFIS), including the shape and location of membership functions and rule coefficients. Each particle in the swarm represents a unique configuration of ANFIS parameters and is evaluated using a fitness function that incorporates Total Harmonic Distortion (THD), voltage deviation, and power loss. The best-performing particle is selected as the final trained model. In the online phase, real-time measurements of PV voltage and current are used to calculate the instantaneous power and its error relative to a reference value. These two values (error and its rate of change) are input to the trained ANFIS, which outputs the optimal PWM duty cycle to control the DC-DC converter. This dynamic adjustment allows the system to track the Maximum Power Point (MPP) effectively, even under variable irradiance or partial shading, ensuring high power efficiency and minimal waveform distortion.