Improved Fuzzy Logic Controller Implemented on FPGA Circuit for Photovoltaic Systems

Corresponding Author: Aouatif Ibnelouad Department of Applied Physics., Laboratory of Electrical Systems and Telecommunications, Cadi Ayyad University, Faculty of Sciences and Technologies, Marrakech, Morocco Email: aouatif.ibnelouad@ced.uca.ma Abstract: To be the photovoltaic arrays capable to transport the maximum power obtainable, it must be combined with Maximum Power Point Tracking (MPPT). To succeed, we will improve a Maximum Power Point Tracking (MPPT) method, based on intelligent technique such as Fuzzy Logic Controller (FLC), compared with a conventional method which is P&O. This improved method applied to a stand-alone photovoltaic system under loading conditions and atmospheric data (temperature and irradiance). The goal of this controller is to prove that the FLC is the best technique of MPPT to extract the maximum power of photovoltaic modules. The main objective of this work is the implementation on a “Cyclone II” circuit using “EP2C35F672C6” Development Board reconfigurable Field-Programmable Gate Array (FPGA) with Hardware Description Language (VHDL). Thus, we show the advantages of using the FPGA circuits, which are their short progress time, their low price and their suppleness of process. The close optimum design of this technique is based on the best choice membership functions and control rules for twoinput, one-output digital Fuzzy Logic Controller (FLC) based on “Mamdani” mechanism. The simulation and implementation results obtained respectively with waveform under Quartus software and on Cyclone II, both show a satisfactory performance and confirm the good tracking efficacy and speedy response to various atmospheric conditions.


Introduction
Photovoltaic (PV) energy is considered today as one of the most reliable renewable energies, daily and respectful of the environment the source (Chouder et al., 2008). Photovoltaic systems seem to be well established as a means of converting solar energy into electrical energy. Such a system consists of a field of modules and a set of components that adapt the electricity produced by the modules to the specifications of the receivers. Unfortunately, PV generation systems have two major problems: The first, particularly in low irradiation atmospheric conditions, the conversion productivity of electric power generation is very low. The second, many extrinsic factors influence the amount of electrical energy generated by solar panels, such as irradiance, temperature and load conditions. Due to the relatively high price of this type of energy, we must extract the maximum of power of PV arrays. This necessitates a mechanism for the pursuit of the Maximum Power Point (MPP) called Maximum Power Point Tracking (MPPT), so that maximum power is generated permanently (Chekireda et al., 2011). For confirms this permanence of power extraction, it must to adjust the duty cycle of a DC/DC Boost converter connected with the control unit and which is generally related between the PV arrays and the load (Kida et al., 1991). The point of maximum power passes rapidly to another curve, due to the rapid variation of solar irradiation over time. Therefore, the MPPT controller must also be capable to reach the MPP as quickly as possible in order to decrease the power output oscillations and power loss of the system.
In the literature, the subject of MPPT of PV systems has been touched on. During the various techniques proposed, it is worth mentioning the use of MPP trackers based on intelligent techniques. These have been recently developed and manipulated to improve or modify conventional tracking techniques based on the Perturb and Observe (P&O) method, the Incremental Conductance Method (Inc-Cond) or the Hill Climb method (HC) .
Fuzzy Logic Controller (FLC) methods have shown their important characteristics in MPP search implementations because of their heuristic nature associated with easiness and efficacy, for linear and nonlinear systems . Thus, the performance of the Fuzzy Logic Controllers (FLC) is tested using PV system for various atmospheric conditions, such as changing solar irradiation and temperature (Larbes et al., 2009). More recently, a considerable attention in the development of the Fuzzy Logic Controllers (FLC) hardware implementations has been shown (Deshmukh et al., 2006). This choice permits the integration and high-speed processing of such MPP tracker on relatively small systems. Nevertheless, the principal inconvenient of this approach is that it is only cost effective for high volume applications. A more achievable methodology for lower volume applications requires the use of general purpose or programmable hardware such as the FPGAs chips .
In addition, when the FLC is used as an MPPT controller for PV systems, a software implementation cannot be considered as a design solution suitable for this type of application. In such a situation, the FLC was generally implemented in microcontrollers and/or in Digital Signal Processors (DSPs) (Akkaya et al., 2007). These chips can provide reasonable performance, but they do not offer the potential benefits of Field-Programmable Gate Arrays (FPGAs) over the implementation of the MPPT control unit (Khaehintung et al., 2006). FPGAs offer lower cost because the various electronic functions required by the control unit could be integrated on the same FPGA chip, compared to DSP and microcontroller implementations unlike older chips, which can only perform DSP-related calculations (Mekki et al., 2010). To approve your existence in the advantages of competition; that it is possible to control several switches with a high processing speed. It is the objective to improve digital controllers in low-level programming devices (direct control of the hardware), such as FPGAs, in the control of power converters (Rodríguez-Andina et al., 2007). This is ideal when a very high switching frequency and bandwidth is required. At the same time, it is possible to operate the FPGA, if it is reconfigurable dynamically and partially, to reduce total energy consumption (Salgado-Herrera et al., 2017). On the other hand, during system operation, FPGA repairs can be performed in situ, providing great robustness. In addition to its robustness, this programmability can also provide a high degree of flexibility: The MPPT control system even while it is running can be easily updated or modified.
Its extensibility makes it possible to manage multichannel MPPT control systems. Unlike DSPs, programmability above also allows for virtual testing by simulating the entire process . It is widely recognized that FPGAs can be applied effectively in a wide variety of engineering applications. One reasons for this is that the increasing complexity of the systems makes it very difficult to ship designs without errors.
As a result, it has become important to be able to repair errors after fabrication and customizable devices, such as FPGAs, greatly facilitate this task. FPGAs always operate at lower clock rates than general-purpose computers and application-specific ICs. One of the most essential applications of FPGAs is improving performance. In other words, FPGAs often allow for faster and better-optimized designs (considering different criteria), but for some practical applications such improvements are not needed, and the most important features are simplicity and cost (Skliarova and Sklyarovbook, 2019).
The FPGA contains thousands of logic gates, some of which are assembled into a Configurable Logic Block (CLB) to make simpler the scheme of higherlevel circuits. An SRAM or external ROM describes gate interconnections. The easiness and programmability of the FPGA create it the best choice for prototyping an Application-Specific Integrated Circuit (ASIC). Permission for rapid prototyping of digital systems due to the advent of FPGA technology (Ying-Yu and Hau-Jean, 1997). In a low-power memory, configured with the predefined register in the FPGA, hardware reconfiguration makes it possible to store the functions that are constantly no required (Paulsson et al., 2008).
Besides, to describe the behavior of digital systems in an optimal way, we used the VHDL language (combination between Very High-Speed Integrated Circuits [VHSIC] and Hardware Description Language [HDL]) (Salgado-Herrera et al., 2017). Due to this advantage, an FPGA implementation of FLC is the aim objective at this work.
The remainder of the paper is organized as follows: Initially, we present a description of photovoltaic module and DC/DC converter. Next section, the proposed improved technique Fuzzy Logic Control is developed. Then, we provided the simulation results of P&O method and FLC approach under Quartus Software. Following by the analysis of these simulation results are explained. After that, the implementation experimental performance results of both methods display on FPGA chips. Following by the discussion results are shown in the next section. Conclusion is drawn in the end.

Photovoltaic Module
As shown in " Fig. 1a" the PV system constitutes of a solar array, DC/DC converter, resistive load and an MPPT control unit . The photovoltaic generator allows the conversion of solar energy into electrical energy. In its characteristic curve P-V, there is a maximum point connected between the current and the voltage of the photovoltaic generator generally called Maximum Power Point (MPP), at which the module produces the maximum output power Pmax in " Fig. 1b". To reach an operating point close to this MPP, a controlled DC-DC converter is generally used to adapt the duty cycle between the PV generator and the load . The main mission of MPP looking for and a control unit (MPPT Controller) delivers DC/DC boost converter operation, where one of the known MPP tracking algorithms is usually implemented. The electrical energy produced by a photovoltaic cell depends on the light it receives on its surface. Therefore, when the solar radiation increases in " Fig.  2", the voltage follows this increase. However, the electrical characteristics of a PV cell depend on the junction temperature at the exposed surface. The behavior of the PV cell as a function of temperature is complex. From where " Fig. 3" represents a decrease of the tension during the increase of its temperature.

DC/DC BOOST Converter
The boost converter is used for adapting the characteristics of the load with those of the solar panels according to the variation of the duty cycle in " Fig. 4". It is generally used to convert its input voltage to a higher output voltage according to the equation as indicated below (Ibnelouad et al., 2017): According to the "Equation 1", the output voltage of the converter depends only on the input voltage and the duty cycle α. Therefore, the converter is always a voltage booster, due of this duty cycle between 0 and 1 (Ibnelouad et al., 2017).

Fuzzy Logic Control Improved Technique
Fuzzy Logic Control is a method widely used in various non-linear systems, particularly photovoltaic systems.
This study is an improvement on this technical MPPT FLC implemented on "Cyclone II" circuit using "EP2C35F672C6" Develop reconfigurable Field-Programmable Gate Array (FPGA) Board with Hardware Description Language (VHDL). This implementation is developed on this software under 4 blocks, fuzzification block, inference block, defuzzification block and the main program. The block Fuzzification is based on the error E which depends on the variation of the atmospheric conditions (Solar radiation and Temperature). it is calculated as follows (dP/dV) which is represented on " Fig. 1b". The improvement principle of this method is based on the change inference rule table constituted of two inputs (E and CE) and one output which the better duty cycle calculated either on the quartus software, or on the MATLAB/Simulink software and the implementation on FPGA in a fast and efficient way compared to the P&O method.

P&O Method Setting
Perturb and Observe (P&O) method is very used in the literature, because its algorithm is very simple. The operating principle of this method is based on the measurement of the voltage Vpv and the current Ipv of the PV panel. For each instant varies the atmospheric conditions (Irradiatiation and Temperature), the algorithm can detect the maximum power and at this point and it can track the maximum power with oscillations around the MPP. The following shortened flowchart shows the algorithm of the P&O method.
At the begining, the voltage and current of the PV panel measure Vpv(k) and Ipv(k) respectively and the power Ppv(k) value calculated. Ppv(k-1) value calculated in the preceding cycle by Vpv(k-1) and Ipv(k-1) where, the duty cycle α is wanted output to use in Pulse Width Modulation "PWM" to control the boost. Therefore, the P&O work to generate the best duty cycle in " Fig. 5" (Soufi et al., 2017;Li, 2014).
In the 'PROCESS' structure of the VHDL language, we have put the relations which make it possible to calculate the power delivered by the panel and to compare it with the old one to give the duty cycle which will allow to approach the point of maximum power such as.
If the power increases, the voltage is adjusted in the same direction as in the previous cycle. That mean if the present voltage is higher than the previous one, so we will have an increase in the duty cycle to a step of 10% otherwise it will be decreased to 10%. On the other hand, if the power output decreases, the voltage is adjusted in the opposite direction than in the previous cycle while relying on the duty cycle. If the present voltage is higher than the previous one, then we will have a decrease in the duty cycle to a step of 10% otherwise it will increase to 10%.

FLC Method Setting
The intelligent Fuzzy logic technique was used in different applications, such as (Bhowmik et al., 2017). Fuzzy control is a non-linear control method. It is based on the principles of fuzzy Logic developed by Zadeh in 1965 (Timothy, 2004). The fuzzy control is based on two input variables which are the error E and the error change CE and an output variable Δα (variation of the duty cycle) which will be injected to the DC-DC converter to follow the point maximum power. The variable E (the error) is expressed as follows: The variable CE (change of error) is expressed as follows: where, P(k) is the instant power of PV generator Description Techniques for Improved FLC Figure 6 shows the PV system which constitutes of 4 blocks. The Current and voltage parameters from the output of the PV generator. After that, the improved MPPT FLC control block with the Pulse Width Modulation (PWM) block which calculate the duty cycle. Then, it transfers to the DC/DC boost converter and finally to the load after finding the best power output when achieved the maximum power point.
This improved FLC method is based on two inputs the error E, the error change CE and one output the duty cycle. The error E is developed on "Equation 2" which is (dP/dV) under variable atmospheric conditions (Solar radiation and temperature). The calculation of this error is due to the non-linearity of the PV generator which gives a characteristic P = f(V). To have the maximum power point of the PV generator, a variation of the two quantities mentioned above is required, which are measured from the output of the PV generator, the voltage and the power calculated using this formula (P = I * v).
The FLC inspects the output PV power at each sample (time k) and determines the variation in power compared to the voltage (dP/dV). If this value is greater than zero, the controller modifies the duty cycle of PWM to increase the voltage until the power is maximum or the value (dP/dV) = 0. If this same value is less than zero, the controller modifies the duty cycle of the PWM to decrease the voltage until the power is maximum as indicated in Fig. 7. The input error E (k) was mentioned if the loading operation point at instant k is positioned to the left or right of the maximum power point on the PV characteristic. while the input Change Error CE gives the direction of movement of this point. The duty cycle output is calculated from Table 1 of the FLC improved method at each instant k to reach the maximum power point.
The implementation of a FLC is realized in three steps (the fuzzification, the inference and the defuzzification (El kari, 2017).
The programming of the FLC requires the passage through the three steps already processed under Quartus Software with VHDL language. Then the development of this approach is made up of five Programs (the first one is the fuzzification, the second is inference, the third one is defuzzification, the fourth is PWM and the principal program as last one).
In fuzzification step, the VHDL program, which applied the conversion of the physical inputs that are the error E and the CE error change respectively, to linguistic values (NB_E...PB_CE). The projection of these real values on fuzzy sets characterizing the linguistic values taken by these variables. For this, the membership functions are in the form of 3 triangles and 2 trapezes. The " Fig. 8" shows these functions.
The programming of these membership functions in VHDL language is done by developing their mathematical equations, as follows: Similarly, the calculation of ZE_X and PP_X we based on "Equation 4", 5" and "Equation 6". To simulate this fuzzification VHDL program under waveforms simulator, we took the error equal to -30 and the error change equals -40 (negative). Therefore, it is logical comparing with the projection of these values (E and CE) on the fuzzy sets as it is presented in Fig. 9.
In Inference step, the VHDL program will be given from the linguistic inputs of E and CE provided by the fuzzification program, linguistic outputs that corresponds to the duty cycle. To ensure this transformation, we have programmed the inference method called "Min-Max" shown in Fig. 10. For that reason, the "AND" must be programmed in "MIN" and the "OR" in "MAX".
Rule in "Min-Max" method will become Δα = Min (NB_E, NB_CE) is represented in Table 1. A two -input rule of the Mamdani type has the form: IF Error is NB and Change-Error is NB then D is PB.    After the VHDL programming of the different rules by the MIN, we coded the combination between them using the MAX which gives us the following equations (called MAMDANI equations): NB_D = MAX (C 25 , C 24 , C 21 , C 22 ) NS_D = MAX (C 11 , C 12 , C 16 , C 17 , C 18 , C 19 , C 20 , C 23 ) ZE_D = MAX (C 13 ) PS_D = MAX (C 3 , C 6 , C 7 , C 8 , C 9 , C 10 , C 14 , C 15 ) PB_D = MAX (C 1 , C 2 , C 4 , C 5 ) In defuzzification step, the role of inverting the first conversion of the fuzzification i.e., that from the linguistic outputs given by the inference stage we must have a numerical duty cycle that we can inject into the booster chopper. To develop defuzzification in VHDL language, we must apply a method called "the center of gravity" whose principle is based on the calculation of the center of gravity of the fuzzy sets given by the program of the inference. Figure 11 shows the principle of this calculation.

Simulation Results
Under loading conditions and atmospheric data (temperature and irradiance), " Fig. 12 and 13" present the simulation results of P&O and FLC improved program respectively under quartus software. By doing the simulation under waveforms we find that, the numerical value of the output duty cycle that we can use practically is equal to 72 in FLC improved method, which belongs to the interval of the Positive Big. Therefore, we checked the inference table (for E_PB and EC_NB we find D is PB). After defuzzification step, the Pulse Width Modulation (PWM) signal called D is the output variable, which is transferred to the boost DC/DC converter to control the load. After the rules have been applied, the center of area as the defuzzification method is used to find the actual value of (D) as a linguistic output. The simulation under waveforms of the PWM is presented in Fig. 14

Analysis Results of Simulation
The simulation results on the Quartus software waveform presented in " Fig. 12" for the classical method P&O, approved that the algorithm has been well checked for a power increase. In addition, " Fig. 13" approved the effective response of the FLC command, for the atmospheric data and its speed for the orientation of the good path follows very well the expected maximum power point after a very short time. During the three steps of the FLC command, the fuzzification step, which ensures that logical inputs are chained to linguistic inputs. After this step, the table of rules, which summarizes the different rules of the FLC. Finally, " Fig. 13" presents defuzzification step that confirms the change of linguistic outputs to logical outputs, after that the PWM to transfer the value of duty cycle to converter DC/DC in " Fig. 14". Therefore, the results approved the efficiency of the designed FLC algorithm, simulation under quartus software. Under MATLAB/Simulink at various irradiation, we simulate the P&O and FLC improved technique. The simulation results of P&O method show in " Fig. 15", there is a response follow the irradiation but this track with a lot of oscillation around the Maximum Power Point (MPP) such as the current, Voltage and the power.
Forever, the FLC improved technique in " Fig. 16", proved the response at the short time (0.01s) with stability around the MPP, such as current, voltage and the power.
So, the FLC improved method shows the efficiency, accuracy and capacity of response for different irradiations various than the conventional MPPT method P&O executed under both software (Quartus and MATLAB/Simulink).

Implementation in FPGA Circuit
The inspiration of the implementation of the MPP tracker presented in preceding sections is the application in a FPGA chip. The general structured implementation under FPGA circuit is represented in "Fig. 17". The first block describes the calculation of inputs for the second block, which the Fuzzy logic controller proposed method presented in detail in " Fig. 16". A sequencer controls these inputs in block 3. A frequency divisor in block 4, unit used to adapt the frequency of the FPGA board and the sampling rate for the considered process drives this sequencer. After block 2, the crisp value is used to drive a simple PWM generator also implemented on the same chip in block 5.
The block diagram of the FPGA implemented MPPT present the inside of FPGA calculation as shown in " Fig. 18". Therefore, the MPPT includes three principal units: The Fuzzification, an inference engine (a rule selector, "MAMDANI" Max-Min Implication) and finally, the defuzzification. The inputs of the fuzzification step are the error and the change of error E and CE respectively. These expressions are calculated using the two equations (2) and (3) in previous sections. After that, the inference engine, calculate the different rules used for finding the duty cycle after the third block defuzzification.

Validation of Implementation on FPGA Circuit
To verify the results of the VHDL programs, we have made a cyclone II FPGA implementation by assigning the program inputs to the different switches on the board and the outputs to the different red and green LEDs.  The improved FLC method is too fast and precise because it is not based on a step of displacement as the classical method. In " Fig. 19" represents the accurate of using FLC improved technique than P&O.

Output of PWM under FPGA Circuit
After simulation all blocks diagram of our circuit under software quartus, we implemented the program to show the efficiency of the design algorithm to visualize the PWM on an oscilloscope of the PV system. Figure 20 shows the generated duty cycle presented in "PWM" form.

Final output result under FPGA Circuit
The improved FLC method under Quartus software, has been implemented under the FPGA circuit. This implementation represented on Fig. 21, consists of a "PC" containing the algorithm developed under the software Quartus of the improved method FLC, then the "FPGA Circuit" of altera to implement this algorithm after that, the connection with the "Oscilloscope" which we displays the result of the implementation of the developed FLC method. This implementation gives us a very important efficiency of improved FLC method.

Discussion and Analysis Results
The inspiration of the implementation of the MPP tracker presented in preceding sections is the application in a FPGA chip. This was motivated by the necessity to create a reasonable hardware implementation for use in PV systems. To do this, a Cyclone II EP2C35F672C6 Development Kit, has been used. Based on Cyclone II FPGA family provided us with an almost perfect solution to improve and develop designs and applications. Based on the high-speed integrated circuit built into Cyclone II Foundation ALTERA, the controller is calculated by using the VHDL (Hardware Description Language).
The "Cyclone II-EP2C35F672C6" waveform was used for simulation purposes. The classical method P&O allows to follow the point of the maximum power certainly, but its problem is related to the step of incrementing. If it is small the algorithm of the MPPT takes a long time to reach the MPP, in one hand. In the other hand, if it is wide the MPPT algorithm responds rapidly to sudden changes due to variations in weather conditions of operation. The result is we still have the risk of exceeding the MPP to the other side and staying oscillating around the optimal value and in both cases we have a loss of power and time.
Therefore, the intelligent Fuzzy logic basedmethod, which is the fuzzy logic, is robust, very precise and fast because of the good choice to the rule of inference, that we have already explained whatever the input it gives the suitable answer quickly.

Conclusion
In literature of PV panel which is non-linear system and it's hard to track the operating point of the PV panel at easy way. To resolve this problem, we apply the MPPT mechanism to follow this point and extract the maximum power from the regulation of the duty cycle adjusted by the BOOST then the PWM. In this work, we developed and implemented on FPGA circuit using the development board "Cyclone II, EP2C35F672C6", in photovoltaic systems the classical and intelligent MPPT techniques respectively P&O and Fuzzy Logic Controller. The simulation results validate the programs of Fuzzy logic controller better compared to classical MPPT method P&O before charging them on the FPGA. They also confirm that the intelligent controller performances under various atmospheric conditions for not only maximum power point tracking but also the response time and stability. In addition to the waveform simulations, an FPGA chip was also implemented to approve the hardware model of the global MPP tracker including the designed FLC. As this method we approved of the advantages mentioned above in terms of efficiency, performance and the simplicity of implementing on the FPGA circuit. However, there are some disadvantage to its implementation; indeed, it asks heavy programming in VHDL. After this step of work, we are going to install the experimental whole system to ensure the validation of the effectiveness of the proposed FLC in photovoltaic system.