Intelligent Control of a Photovoltaic Generator for Charging and Discharging Battery Using Adaptive Neuro-Fuzzy Inference System

,


Introduction
With the depletion of reserves of fossil energy sources [1], the economic crises due to soaring oil prices, and the accidents of nuclear power plants such as those of Three Mile Island (USA, 1979) or Chernobyl (USSR, 1986), public interest in renewable energies continues to grow [2,3]. Of the various sources of renewable energy, photovoltaics occupies a prominent place [4,5]. Photovoltaic generators (PVG) only provide electrical power during the day; then, many applications (loads) require energy at night. PVG are therefore generally coupled to a storage system ensuring continuous energy availability. The most used storage type in this system is the lead acid battery. The maturity of this technology and its low cost compared to others are the main reasons for its use [6][7][8].
The PVG battery link is provided by a static interface consisting of Continuous-Continuous Static Converters (CCSC). A Maximum Power Point Tracking (MPPT) command will be used to extract the optimal power of the PVG regardless of the variation in weather conditions [9]. Several optimization techniques are developed in the literature [10].
They are classified into two types: deterministic methods and stochastic methods. Among the first, we can mention the method perturbation and observation (P&O) and the method of the Incremental Conductance (InC) [11]. Stochastic methods consist of heuristics and metaheuristics. Among them are methods based on artificial intelligence (AI) such as fuzzy logic (FL), Artificial Neural Networks (ANR), and ANFIS types.
The P&O algorithm is the most popular optimization method [12]. It is used in [4] for the control of a trimming converter. The results show a relatively small Root Mean Square Error (RMSE) between a reference power and that produced by the PVG. It is also used in reference [13] in two different ways for controlling a boost converter. The authors implemented it on an Arduino board. They then made the comparison between a P&O algorithm with a fixed perturbation step and another with a variable disturbance step. The results showed that the P&O algorithm with variable pitch has the best performance. The P&O algorithm converges rapidly towards the maximum power point (MPP) but with large oscillations around [14]. In addition to sudden changes in climatic conditions and/or load, this method sometimes presents misinterpretations in the direction to be followed to reach the MPP. To correct this, the InC algorithm has been developed. Its simple structure makes it the object of several works [15]. In [16], the authors used InC to pursue the MPP of a PVG connected to a distribution power grid. Extraction of the maximum power allowed them to make a good injection into the network with an overall Harmonic Distortion Rate (TDH) of 2,39%. In practice, like the P&O algorithm, the InC algorithm also exhibits oscillations around the MPP because it is difficult to fill up the condition for which the derivative of the power with respect to the voltage is zero. As a result, the system is still searching for the MPP, so the calculation time will be longer.
Despite their ease of understanding and implementation, deterministic algorithms are losing their place for optimization problems. This is due to the fact that these algorithms tend to converge towards a local optimum [17]. Thus, to overcome this, researchers are moving towards stochastic methods. These methods are based on artificial intelligence (AI). Among them, there is the neuro-fuzzy hybrid-type adaptive neuro-fuzzy inference system (ANFIS). It is a combination of ANN and fuzzy logic (FL) [11,18,19]. In [20], the authors used ANFIS to extract the maximum available power across the PVG. The results obtained show the robustness and performance of the ANFIS command compared to the InC with response times of 2,4 ms and 401 ms, respectively.
In reference [11], the ANFIS model is presented as part of the continuation of the MPP of a PV pumping system. An evaluation of the system with or without ANFIS is performed. The results show that the ANFIS command increases PVG power from 20,1% to 82,7%. In [21], ANFIS is used to control a CSHS. The method used consists of simulating with an illumination of 500 W/m 2 and an illumination of 600 W/m 2 . The comparison of the results shows that the power of the PVG increases by 83% for an illumination of 500 W/m 2 and 97% for an illumination of 600 W/m 2 with the MPPT command-type ANFIS. ANFIS is compared with the MPPT P&O command in [22]. Used to extract the maximum power from a PV system, the results showed that under varying lighting conditions, the best performances are obtained with ANFIS. The latter has fewer oscillations than P&O, and its convergence speed is smaller. Five MPPT techniques are proposed in [23]. These include FL methods, P&O, and ANFIS. The results indicate that ANFIS is better than the others. It is faster and achieves a 99,4% return while the FL gives a return of 98,1% and the P&O a yield of 97,5%.
In reference [24], ANFIS is proposed for controlling the charging and discharging of a battery for a PV system connected to the three-phase network. The first model is used to control the charging process of the battery while the second manages the injection to the network. The results presented show that the control manages the charge-discharge cycle of the battery with successive connection-disconnection steps of the load and regulates the injection into the electrical network.
In this work, we focus on the ANFIS hybrid neuro-fuzzy algorithm. This algorithm will be used simultaneously for the continuation of the MPP of the PVG and also for the supervision of the charging process of the battery. According to our bibliographic review, such a scenario with ANFIS has not yet been published. Thus, our work will be structured in four parts. After Introduction (Section 1), Section 2 presents the modeling of the different elements of the energy chain. Section 3 presents the MPPT control algorithm and battery management algorithm. Section 4 presents the results and conclusion.

Mathematical Modeling
The system studied in this work consists of a PVG, a battery, a DC load, and two DC-DC converters ( Figure 1). One is a boost converter. It adapts the voltage delivered by the PVG to the load and the battery. The other is a bidirectional converter. Its use is justified by the intention to operate the battery in charge-discharge depending on the possible mode of operation.

2.1.
Modeling of Photovoltaic Generator. The equivalent circuit of the solar cell is given in [25].
A single photovoltaic cell produces an output voltage of less than 1 V and about 0,6 V for crystalline-silicone (SI) cells. To reach the output voltage desired, the PV cells are connected in series/parallel forming which is called the module photovoltaic.
The relationship between the current and the voltage of the PVG is given by equation (1). This latter represents the current delivered by the PV cell.
The PVG power at the MPP is calculated using equation (2) [26] by a connected series/parallel cell.
where STC is the standard test condition (E = 1000 W/m 2 , T = 25°C) and γ is the temperature coefficient.

2.2.
Modeling of the Booster Converter. The booster converter gives a voltage at the output greater than that at the input. The mathematical model of the parallel converter is obtained by the application of the laws of Kirchhoff on the basic scheme of the converter, represented in Figure 1 and compared to the regime of operation and condition of the switch k [7].  Switches interface S1 S1 S2 S3

International Journal of Photoenergy
The equations of the system (3) are derived from its two operating sequences in continuous conduction.
The dynamic equations of the converter are derived for the current in the inductance and the voltage across the capacitor in continuous conduction regime. Let x 1 = i L and x 2 = V bat ; then, the equations of state become In the state space, we have the matrix representation given by 2.3. Modeling of the Buck-Booster Converter. The buck-boost converter is used for charging and discharging the battery. The presentation of the operation of this type of converter by mathematical equations must be performed taking into account the state of the switch k in Figure 2. When the switch is in the on state, then T on = α * T s . As a result, the energy stored in the inductor increases. When S is blocked, then T off = ð1-αÞ * T s and the energy accumulated in the inductance is transferred to the capacitance and the load. It also presents two operating sequences in continuous conduction (7). Equation (8) gives the system state matrix. x 1 2.4. Modeling of the Battery. The voltage of the battery (V bat ) is given by where E b is the vacuum voltage (open-circuit voltage) of the battery and R b is the internal resistance of the battery. Equation (10) gives the capacity of the battery (C bat ) as a function of a reference capacitor C 10 . It serves as a reference for determining the state of charge (SOC) of the battery [25].
C bat = C 10 1, 76 1 + 0,005 * ΔT ð Þ 1 + 0, 67 * I bat /I 10 where ΔT is the temperature difference. The power of the battery (P bat ) can be expressed as a function of the power delivered by the PVG (P pv ) (equation (11)). They are linked by a factor k (switching state of the Mosfet switch) [27].
The SOC (%) of the battery can be written: where Q d is the amount of charge missing to the battery, given by where t is the operating time of the battery with an I bat current.

Command and Supervision
In this part, the MPP search is performed using an ANFIS algorithm. The supervision of the battery is also ensured by the same algorithm. Thus, a single ANFIS algorithm is used simultaneously to find the maximum power point of the PVG and to control the charging and discharging of the battery (Figure 3). It generates the control signals of the CCSC and the switches K 1 , K 2 , and K 3 . A photovoltaic generator is a generator whose characteristic I = f (U) is strongly nonlinear. Consequently, for the same sunshine, the power delivered will be different depending on the load. An MPPT controller is used to control the static converter, connecting the PVG of the battery [4] to obtain at any time the maximum power of the PVG. In this work, this task is performed using an AI-type ANFIS algorithm. It is an intelligent method combining FL and ANN [28][29][30][31]. The learning of our controller is done through the retropropagation algorithm, in order to determine the parameters of the premises (adjustment parameters related to the membership functions) and the estimation of the consequent parameters by the least squares method. The simultaneous use of these two algorithms (backpropagation and least square methods) makes the optimization method chosen for learning the ANFIS algorithm a hybrid method. The training of the ANFIS network is thus carried out by a two-step algorithm where we first estimate the consequent parameters by a technique of least squares and then the network weights by a   During the reverse phase, the algorithm of backpropagation error is applied to adjust the weight of different layers.
When backtracking, the retroalgorithm error propagation is applied to update the weights of the antecedents of the rules. During the forward phase, the consequent parameters are adapted while the antecedent parameters are kept constant; during the back phase, the roles are exchanged.
The ANFIS structure used in this work consists of four inputs and one output (Figure 4). The first two inputs, namely, the current and voltage delivered by the PVG, are part of the MPP research. The last two, with the information relayed by the first two on the optimal search for power, provide supervision. All this information will be processed by the hidden intermediate layers (2, 3, and 4). The latter with their calculating mechanisms and their tools (Gaussian membership functions, fuzzy rules (Figures 2 and 5)) make the necessary calculations before transmitting the information to the output layer. The latter gives us the cyclic control ratio of the boost converter. This report manages the closing and opening time of the power switch (MOSFET) so that the maximum power available at the terminals of the PVG can be obtained at any time. Figures 5(a)-5(d), respectively, give the Gaussian membership functions of V pv , I pv , V dc , and SOC. In ANFIS learning, the membership function parameters are extracted from a dataset that describes the behavior of the system.

Supervision of the Charge and Discharge of the Battery.
The main decision factors for the supervisory strategy are PVG supplied power (P pv ) and battery charge status (SOC). The use of the supervisor makes it possible to produce maximum power from the PVG, to protect the batteries against overloads and deep discharges, and essentially to satisfy the energy needs [25]. The same ANFIS algorithm as that of the MPP search is used. So the ANFIS algorithm used for the control/supervision process consists of two cascaded algorithms ( Figure 6).
The system has several possible modes of operation depending on the switches that are operated.
(Mode 1) The available power to the PV generator (P available ≥ 0) is totally enough to power the load and charge the batteries (Mode 2) The power supplied by the PV generator is insufficient (0 < P pv < P c ); in this case, the    The logic states of the relays are given in Table 1.
From the energy management model presented in Figure 1, we can determine the logical equations of load (14), discharge (15), charge/discharge (16), and load in functions of the control switches (K 1 , K 2 , and K 3 ). The different powers (P i ) (equations (14)-(17)) can be expressed in terms of different switches considered as Boolean values 0 or 1).
(i) Battery charge power (K 1 high) (ii) Battery discharge power (K 3 high) (iii) Charging/discharging power of the battery (K 1 and K 3 in a high state) (iv) Load power (K 2 high) Equation (18) gives the RMSE for ANFIS learning.
The Gaussian MsF equation is given by where a i and b i are parameters of the membership functions. a i is the center of the Gaussian function, and b i is the slope of the function (variance); μ is the Gaussian membership function. Figure 6 shows the hybrid algorithm for maximum PVG power search and battery supervision. Table 2 gives the ANFIS learning results with the ANFIS edit interface of MATLAB.
3.3. DC Voltage Regulation. The DC bus voltage regulation is, in some cases like ours, a necessary condition for a good supervision of the battery. In this work, two control loops are used (Figure 7). An external loop or slow loop to correct the error between the bus voltage and its reference. An inner loop or quick loop is used to regulate the current of the battery.

Simulation Results
The PVG is composed of six panels of 120 Wc. Its parameters are given in Table 3. The Simulink model is given in Figure 3.
Equation (20) gives the transfer function (GðsÞ) of the bidirectional converter obtained from a MATLAB script.
From this equation, the parameters of the PID and the PI correctors are obtained ( Table 4). The PID corrector is used to regulate the DC bus voltage. It corrects the error between the output voltage of the converter and a reference voltage of 50 V. The PI corrector is used to regulate the battery current. The phase margin is 60°. Table 5 presents the simulation parameters obtained with the mathematical modeling of the various components of the system.
The profiles of sunshine (E) and temperature (T) are represented in Figure 8. They are the two most influential parameters on how the PVG works. Sunshine ranges from 1000 to 500 W/m 2 and the temperature ranges from 25°C to 35°C. This is, for example, the case of the spontaneous passage of a cloud that may take a few seconds (3 s, for example).   International Journal of Photoenergy The variations of the powers (P pv , P bat , and P load ) are subject to those of the climatic conditions (E and T) (Figure 9). The P pv curve (in blue) shows that the MPPT ANFIS command extracts the optimal available power from the PVG. Negative battery power is noted between 0 and 1 s (in red), which leads to say that the charge is disconnected from the battery. It is powered by the PVG directly (mode 1) (Figure 10). The latter also charges the battery (Figure 8). Switches K 1 and K 2 are closed (Figures 11  and 12). During this charging phase, the voltage increases to its nominal value ( Figure 13). The power generation of the PVG is sufficient, but the instruction of the supervision module is such that it goes into power compensator mode which is explained by a negative current ( Figure 14). This is to protect the battery.
Over the time interval 1 to 2 s, the power of the GPV decreased with the sunshine until approaching that of the load. The battery always feeds the load which presents a power superior to its own. This is the compensation mode (mode 2). Switches K 3 and K 2 are closed.
Over the period of time 2 to 3 s, the increase in the level of sunshine causes a charge of the battery (Figure 15). The latter has not reached the SOC min and always feeds the load with the PVG. The three switches K 1 , K 2 , and K 3 (Figures 11-16) are all closed (mode 1).
It is therefore apparent that the energy flow management is correctly performed by the supervision module. Figure 17 shows that the voltage across the load is well regulated at its reference value which is 50 V even with changing weather conditions.

Conclusion
In this article, an intelligent command and control strategy has been proposed. It is based on the hybrid ANFIS method. The ANFIS method has made it possible to extract the    maximum power, thus considerably improving the efficiency of the installation. It has also enabled rigorous energy management by managing the charging and discharging of the battery. The various components of the system have been modeled for the purpose of performing a simulation on MATLAB/Simulink. The transfer function was obtained thanks to a small MATLAB program which made it possible to regulate the DC bus voltage. The latter is maintained at the value of 50 V. The results obtained show the effectiveness of the proposed method. Energy is always available depending on the operating mode of the system.
At the end of these results, we aim to do an experimental validation of this model using the same command (ANFIS).

I pv :
Photovoltaic generator current V pv : Photovoltaic generator voltage I ph : Photo current I o : Reverse saturation current q: Charge of an electron n: Ideality factor of the diode k: Boltzmann's constant A: Nonlinear impact of irradiance T c : Cell operating temperature R s , R p : Series, parallel resistance P mpp : Maximum power point power V bat : Battery voltage L: Inductor V dc : DC link voltage C: Capacitor i L : Current of the inductor E: Irradiation α: Duty ratio C 1 /C 2 : Boost input/output capacitor SOC: State of charge

13
International Journal of Photoenergy C bat : Battery capacitor C 10 : Nominal capacitor of the battery I 10 : Nominal current of the battery K: Switch P bat : Battery power Ref: Reference μ: Gaussian membership function GðsÞ: Transfer function.

Data Availability
The data used to support the findings of this study are included within the article.