Extremum seeking control of PV system based on least- squares approach (real-time optimization)

Today renewable energy has become an absolute necessity taking into account the price of fossil energies and the pollution resulting from her large exploitation. Solar radiation can be converted directly into electrical energy, in the form of direct current, by means of a solar cell. Finding the maximum power point is an essential part in photovoltaic systems. Indeed, the output power varies greatly depending on illumination, temperature, but also the overall aging of the system. In order to operate a PV generator as often as possible at its optimum power, we must introduce a controller and a static converter which will act as an adapter between the source and the load. Many works review the different maximum power methods to adjust the optimal output power and improve the efficiency of the PV system. These methods are broadly classified into several categories. In this paper, such an experimental regulator based on a power mathematical technique is proposed, which is founded on least squares method to estimate the maximum power when operating sub-optimally. This technique makes it possible to compare experimental data, generally tainted with measurement errors, with a mathematical model supposed to write these data. This study gives the opportunity to experimentally test a mathematical method with a PV system which mainly uses a BOOST chopper. The DC / DC converter and the regulator are designed and produced within the research unit while using an STM32F4 microcontroller over sun. The results obtained from the use of this optimization technique clearly show the very high fidelity between the real values of the current and voltage and their optimal estimated values with a certain uncertainty which does not exceed almost 2%, which shows a good agreement. In the same way, this approach makes it possible to minimize the oscillations around the MPP, which already makes it possible to improve the efficiency of the system which is very close to 100% in experimental tests.


Introduction
The consumption of electrical energy is nowadays more and more increasing in all five continents. This increase affects both developing and industrialized countries. We live in a time of great concern in search of new solutions for the production of electricity; cleaner and more sustainable solutions than the energy produced by standard power plants using oil, gas and uranium. These resources are polluting on the one hand and they are increasingly depleted on the other. The solutions adopted today are mainly based on wind and solar powers. For the latter type of energy, it is estimated that the energy available annually on the ground covers more than six thousand times the world's annual electricity consumption. In 2006, the world production of photovoltaic energy reached 5.2 GW and it is expected to reach 1000 GW in 2030. Several countries have invested well in this area namely, France, Spain, Germany, Japan and many others. Today renewable energy has become an absolute necessity taking into account oil prices and the resulting pollution from the large exploitation of these energies.
The photovoltaic effect was discovered in 1839 by Antoine Becquerel. He notices that a certain substance of materials in the presence of light causes a spark to appear, which is "the effect of converting light energy into electrical energy". As a result, terrestrial photovoltaic technology has progressed steadily by setting up several power plants of a few megawatts. This technology has also become familiar to consumers: watches, calculators, radio and weather beacons, pumps and solar refrigerators (Alayi et al., 2022;Almallahi et al., 2022;AlShabi et al., 2021;Gorji et al., 2017;Jabbar and Mansor, 2013;Kouro et al., 2015;Li et al., 2016;Maleki et al., 2020). The output characteristics of a photovoltaic generator are influenced by environmental factors on the one hand. Maximum output power is generated for a certain operating voltage and current on the other hand. The optimum operating point is called the "maximum power point" MPP. So to extract the maximum power an adaptation of the PV panels to the load is necessary. Hence, the insertion of a static converter makes it possible to achieve this adaptation, but this converter must be controlled by a maximum power point tracking mechanism "Maximum Power Point Tracking" (MPPT). Many works review the different maximum power methods. These methods are broadly classified into several categories: Indirect methods and direct methods, variable structure and intelligent methods, (Premila and Krishna Kumar, 2019;Raja Mohamed et al., 2018).
Indirect methods use databases grouping together the characteristics of photovoltaic (PV) panels in different climatic conditions (temperature, sunshine, etc.) but also empirical mathematical equations making it possible to determine the maximum power point. These methods are often specific to each type of panel and therefore difficult to generalize, (Carreño-Ortega et al., 2017;Pradeep Kumar Yadav et al., 2012). Direct methods are methods that use the voltage and current measurements of the panels and whose algorithm is based on the variation of these measurements. The advantage of these algorithms is that they do not require prior knowledge of the characteristics of PV panels, (Baharudin et al., 2018;Sellami et al., 2018). There is also the family of variable structure methods. The developments presented in these works, (Ayub et al., 2014;Gammoudi et al., 2015), show the principle of the methods. The principle of this approach consists essentially in forcing the system to reach a given surface called "sliding surface" and to stay there until reaching equilibrium. There is also the family of intelligent methods such as "'The genetic algorithm, Neural network, Fuzzy logic..". The advantage of techniques based on fuzzy logic is that they can work with imprecise input values and they do not need a high precision mathematical model. In addition, they can deal with nonlinearities, (Femia et al., 2005;Islam et al., 2018). In recent years, the use of control by neural networks, in various fields of application, does not cease increasing because it operates from a black box which does not require detailed information on the functioning of the system. (Balamurugan et al., 2012;Gammoudi et al., 2014;Karami et al., 2017;Kerekes et al., 2009). Genetic algorithms are very relevant for global structural optimization problems (problems with several constraints). As they allow great freedom in the configuration and implementation of the various processing operations (Jantsch et al., 1997).
This project allows setting up a test bench for the extraction of maximum photovoltaic power. It is recommended that the bench be as complete as possible in terms of equipment and logistics for control and optimization to ensure a core of research and development to enhance this type of application. This work is mainly based on the development of a mathematical method of maximum power extraction which makes it possible to control a boost chopper. The proposed technique is based on the Least squares method. This work gives a detailed development of the proposed approach accompanied by simulation results which show the effectiveness of this type of control. An experimental validation is added to prove the good functioning of our regulator which is designed and produced within the research unit. The control part is provided by a STM32F4 microcontroller to automatically generate the control signal to the DC / DC converter. The test bench that is the subject of this study is part of the equipment of the ERCO research unit located at INSAT in Tunis. This bench naturally includes the power part, interfacing modules, measurement and the control software part. The sensors and adaptation modules were produced by researchers from the research unit.
This work focuses on the following points: • Detailed study and development of the mathematical method proposed for the extraction of maximum power, • Verification and simulation of this technique, • The establishment and realization of an experimental test bench of the PV system based on a boost chopper and a microcontroller, • Results interpretation.

Problem identification
When the photovoltaic generator is directly coupled to a load, the power supplied results from the intersection between the electrical characteristic of the photovoltaic generator and that of the load. The power transmitted directly to the load does not necessarily correspond to the maximum power that the photovoltaic generator can provide.
In fact, it can be noted in Figure 1 that the maximum power is obtained for specified voltage and current. This operating point is effectively obtained for a given illumination and temperature. If these change, the load must be adapted to changes in climatic factors. Therefore, we must look for a solution to obtain the maximum power and supply it to the load regardless of the variation in climatic factors. The most suitable solution is to add a static converter, which acts as an adapter between the source and the load "impedance adapter". The adaptation stage must be provided with a command to track the operating point while acting automatically on the duty cycle of the chosen static converter. These commands are generally named «Maximum Power Point Tracking". These techniques essentially consist to bring each time the operating point of the photovoltaic generator to the Maximum power point, whatever the sudden variations in the load or the weather conditions, (Martins et al., 1998;Selvan et al., 2016;Yamaya et al., 2015).

Modeling of solar conversion chain
In this work, we will use a mathematical method which takes into account the phenomenon of optimization of a PV system. The structure most used in the bibliography is represented by the synoptic diagram given in Figure 2.
This structure is mainly composed of a purely resistive load supplied by a PV generator via a (BOOST) chopper. This converter is controlled by a duty cycle delivered automatically by the control technique adopted.

PV cell characteristics under normal condition
A PV cell is generally modeled by the following equivalent electrical diagram, Figure 3: Within the meaning of this diagram, the mathematical model of a solar cell is provided by the equation

1716
Energy Exploration & Exploitation 40 (6) The current of the diode i d is characterized by the following equation: This current depends essentially on its saturation value i s and the thermal voltage v t which are governed by equations (1) and (2): With: v t1 = K I K B / Q and T j is the temperature of the junction (°K). The index (r) used in the preceding equations indicates that the value corresponds to the STC regime (Es = 1000 W / m 2 , T = 25°C).
The current emitted by solar photons is given by equation (5). This current is strongly dominated by the variation in solar irradiance.
All the quantities which are related to the physical model of the PV cell are given by Table 1: Finally, the electrical behavior in charge of the solar cell is described by the relation f(ipv, vpv) = 0, (equation (6)).

Case study
A TITAN-12-50 type photovoltaic panel is available at the ERCO research unit. It is located on the roof with two temperature and irradiation sensors. The external current-voltage characteristic of a solar panel is obviously similar to that of an elementary cell. Figure 4 gives the evolution of current and voltage quantities for an illumination equal to 400 W / m 2 and a temperature of 28°C. This characteristic is recorded using a digital oscilloscope of the METRIX-OX 7104 type. The current-voltage characteristic of this panel with the same climatic conditions is given by Figure 5: Photovoltaic panels are characterized by the non-linearity of their output characteristics which are influenced by environmental factors (temperature and irradiation) as shown in Figures 6 and 7.
To show the influence of irradiation on the I pv (V pv ) characteristic, the curves in Figure 6 were recorded with a constant temperature and different irradiation (from 400 to 1000 W/m 2 ). From Figure 6, it can be seen that the short-circuit current varies in the same direction as the solar radiation while the open-circuit voltage varies slightly with the irradiation.
To show the influence of temperature on the current-voltage characteristic, the curves of Figure 7 have been recorded with constant illumination and different temperature values (from 18 to 35°C). From Figure 7, it can be seen that the short-circuit current is not sensitive to the temperature variation. On the other hand, the no-load voltage varies in the inverse direction of the temperature.
These characteristics show the strong dependence between the powers supplied by a PV panel and the climatic factors, which makes the addition of a control system for optimal point tracking is necessary.

General overview of the least squares method principle
In order to reach the maximum power point which corresponds to the optimum power generated by the PV generator, various commands are generally referred to in the literature. These techniques essentially consist in bringing each time the operating point of the photovoltaic generator to the MPP whatever the abrupt variations in the load or the weather conditions, (Lee et al., 2012).
The method used in this work is a mathematical method called "least square method". The least squares method makes it possible to compare experimental data, generally tainted with measurement errors, with a mathematical model supposed to describe these data.This method then helps to minimize the impact of experimental errors by "adding information" to the measurement process.
In the most common case, the theoretical model is a family of functions f (x; θ) of one or more dummy variables x, indexed by one or more unknown parameters θ. The method of least squares makes it possible  to select among these functions the one which best reproduces the experimental data. We speak in this case of adjustment by the method of least squares. If the parameters θ have a physical meaning, the adjustment procedure also gives an indirect estimate of the value of these parameters.
The method consists of a prescription (initially empirical), which is that the function f(x; θ) which "best" describes the data is the one which minimizes the quadratic sum of the deviations of the measurements from the predictions of f (x; θ). If, for example, we have N measures (yi) i = 1,…, N, the "optimal" parameters θ in the sense of the least squares method are those which minimize the quantity: ri (θ) is the difference between the measure yi and the prediction f (xi; θ) given by the model. S(θ) can be thought of as a measure of the distance between the experimental data and the theoretical model that predicts these data. The least squares prescription requires this distance to be a minimum.
If, as is generally the case, we have an estimate of the standard deviation σi of the noise which affects each measurement yi, it is used to "weight" the contribution of the measurement to χ 2 . A measurement will have all the more weight the lower its uncertainty: The quantity wi, the inverse of the variance of the noise affecting the measure yi, is called the weight of the measure yi. The above quantity is called chi-square or chi-square. Its name comes from the statistical law it describes. Its extreme simplicity means that this method is very commonly used nowadays in experimental sciences. A common application is the smoothing of experimental data by an empirical function (linear function, polynomials or splines). However, its most important use is probably the measurement of physical quantities from experimental data, (Ankaiah and Nageswararao, 2013;Cucchiella et al., 2017;Gammoudi et al., 2018aGammoudi et al., , 2018bKerekes et al., 2009). Analysis of the proposed approach with the Pv system in two steps • Step 1: We will define "e i " as the distance between the experimental data (measurement) and the mathematical theoretical model used for the prediction of the maximum power point.
This principle can be better explained by Figure 8: This distance must be minimal; therefore, we will try to minimize this error as shown by the following equations: So, we can extract the following model: Figure 8. Principle of the least square method.
• Step2: From the principle explained by the Figure 8, we will find the slope of the line which makes it possible to cancel the error "e i ". This second step is based primarily on determining the slope A and the intercept B while minimizing the sum of the squares of the distances between the observed and predicted values. This method allows you to find the best line passing through the points with the best fit. From the equation (12) and (13), we have determined the following two expressions: The equality between the last two equations, allows us to find the expression which determines the intercept Bas shown by the following relation: We will define the following quantity Δ to simplify the calculations: So, we obtain : In the same way, we determined the expression of the slope A:

Simulation results
To verify the performance of the proposed method, a MATLAB-SIMULINK model of the PV system is initially developed. The parameters of the TITAN STP-50-01 type PV module are used for the photovoltaic generator model (specifications are listed in Table 2). In the first part, we tested this approach under fixed climatic conditions (Es = 800 W/ m 2 , T = 20°C ). Figures 9 and 10 show, for a duration of 5 s, the evolution respectively of the real and optimal estimated voltages and the evolution of real and optimal estimated currents of a PV generator.
These results show that the actual current and voltage of a PV generator always remains around its references (I_pv_opt and V_pv_opt). These references are estimated from climatic factors (illumination and temperature). These estimates are based on empirical relationships such as the following equations: With I CC is the short-circuit current which is already obtained from the illumination (via the intermediary of a database of the TITAN-12-50 type solar panel used in practice).
Now the optimum voltage is determined directly from the open-circuit voltage which is strongly   Figure 11 allows to better seeing the evolution of the real current around its reference. This last figure clearly proves the good following of the current with acceptable ripples. Similarly, Figure 12 shows a zoom of the movement of the real voltage of the PV generator. This voltage always oscillates around the optimum voltage and this confirms the effectiveness of this control mode.
A major factor can be used to better quantify the accuracy and the goodness and evaluate the performance of the proposed mathematical method, which is the mean relative error of obtained sizes. The mean relative error is expressed as follows: Where: Xest and Xreal are respectively the estimated and real values of current and tension of PVG.  Figure 13 presents the evolution of the mean relative error and a zoom of the latter for the case of currents (real and optimal). It's found that the proposed approach agree very well with the optimal values with some uncertainty. Figure 14 also shows the evolution of Ex but this time for the case of tensions (real and optimal). The Ex of the proposed approach presents weak errors for our model. The Ex is close to 1-2% which shows a good agreement with the optimal value of PV tension.

Comparaison with another MPPT technique
The method that we have chosen to compare it with our developed "least square" method, is the most used technique and the easiest to implement "P&O". This approach is based mainly on the periodic disturbance of current or voltage quantities and to observe the influence of this disturbance on the power. If the power approaches to the maximum power, therefore, we keep the same direction of disturbance if not we reverse it. This technique is focused on finding the sign of the following quantity: ∂P / ∂V p . To better show the reliability of our approach adopted in this work, we compared it with the "P&O" technique. The following simulation results are taken for a lighting scenario given by Figure 15.
We tried to compare the two methods and to verify the reliability of each approach especially the monitoring of the optimal power, response time and oscillation. The two Figures 16 and 17 show Figure 11. Zoom of evolution of real and optimal currents of PVG.
the evolution of the power as a function of the voltage V pv and the change of the two powers, real and estimated, as a function of time for the conventional "P&O" method.
The same results were recorded with the "Least square" method as shown in Figures 18 and 19. These results clearly show that the "least square" mathematical method makes it possible to minimize the oscillation around the maximum power point compared to the conventional "P&O" method. It should be noted here that this minimization also makes it possible to improve the response time especially at start-up. This already makes it possible to attack the optimum operating point as quickly as possible. All of these improvements also improve the performance of the system.

Description of test bench
The PV system studied in this article is essentially composed of a resistive load supplied by a GPV via a static converter. The chopper control is implemented through the use of an STM32F4 microcontroller. The block diagram of the proposed system is given in Figure 20.
The test bench that is the subject of this work is part of the equipment of the ERCO research unit located at INSAT in Tunis. This bench essentially comprises the power part, interfacing and measurement modules and the control software part. The sensors and adaptation modules were produced by researchers from the ERCO research unit. The photovoltaic generator used for our system is of type TITAN-12-50. It is essentially characterized by the association of ten panels in series. This GPV is installed on the roof of the ERCO-INSAT research unit as shown in Figure 21. The specifications of this type of panels are given in Table 2. The quantities are given under standard test conditions (STC).
The STM32F4 microcontroller ensures the implementation of the algorithm studied in this work. Figure 22 shows in detail the test bench that we used to implement the approach studied in this article which mainly comprises: A photovoltaic generator (PVG), a DC/DC converter (BOOST), resistive load, an STM32F4 microcontroller which ensures the implementation of the least squares approach, current and voltage sensors and a smoothing inductor to limit the ripple of the current I PV .
The main purpose of this manipulation is to observe and verify the efficiency of the mathematical method studied for a complete photovoltaic load-generator system in real time.

Results and discussion
• Scenario 1 : Variable insolation and constant load  The same illumination scenario was also recorded using a digital oscilloscope type METRIX OX-7104 as shown in Figure 25.
In the same way, we recorded over 200 s, the evolution of duty cycle. The Figure 26 clearly represents the values of the duty cycle during the change of insolation.
The two real and optimal powers are represented by Figure 27. The efficiency has also been recorded and given by the Figure 28. The ratio already between the two powers is very close to 1 which shows the agreement between Ppv and Pp_opt.
The optimal power that has been estimated from the following expression: The displacement of the operating point in the Ppv-Vpv plane was also recorded and shown by Figure 29. The trajectory of this point clearly shows that it has always remained in the vicinity of an "optimal voltage" and this can only confirm the effectiveness of this type of control.
• Scenario 2 : Constant insolation and variable load For this second experiment, we vary the value of the resistive load with almost constant illumination as shown in the Figure 30 whose Figure 31 shows the evolution of the temperature over 200 s.
The evolution of the duty cycle in this case was also recorded as shown in Figure 32. We can notice here that the change in the level of the load has a very great influence on the value of the duty cycle.
The following two Figures 33 and 34 respectively show the evolution of the powers Ppv and P_opt and the efficiency as a function of time.
Always, the fidelity between the powers as well as the efficiency allow us to conclude that this technique of optimization is very effective.
The movement of the operating point is also shown in the Figure 35. Still with this command, the MPP remains around the optimum voltage.

Conclusion
In this article, the interest of inserting an adaptation stage between the source and the load was discussed. The principle of a mathematical controller has been exposed, tested and implemented. These results make it possible to present the advantages of this control method which offer a good tracking of Maximum Power Point and above all a very good fidelity between the real current and voltage of the PVG and the reference values. This work is devoted to experimental tests about the problem of extracting the optimal power for a PV system over the sun. The bench is built around an STM32F4 microcontroller which makes it possible to implement the proposed approach. We have reviewed a description of all the test bench components and especially the implementation of the used technique. In this article, we tried to develop the principle of a mathematical technique of maximum power extraction based on the least squares method. This study provides the opportunity to experimentally validate the effectiveness of our approach. The simulation results are reinforced by a practical test to prove the proper functioning of this control with a test bench operating under random weather conditions. First of all, the simulation results clearly show the effectiveness of this mode of control from the reduction of oscillations and the follow-up between the real and optimal quantities (current and voltage) with a certain uncertainty (mean relative error). Then, the experimental results prove the very high fidelity between the real power and the optimal power with random conditions of illumination and temperature and also for a load variation. This fidelity gives rise to a very good yield which is sometimes very close to 100%. All these performances make it possible to have an operating point which always remains around the point of maximum power.