Design and Embedded Implementation of a Power Management Controller for Wind-PV-Diesel Microgrid System

,


Introduction
Access to energy is now considered as a central issue in the fight against poverty and economic development.The proportion of the world's population with access to electricity has gradually increased in recent years.However, despite these improvements, 1.1 billion people are still deprived of this essential service, with the majority of these people located in Africa.Among those who have gained access to electricity in the world since 2010, only 20% live in rural areas [1].In Morocco, almost 1.3 million rural people are deprived of electricity; i.e., 88902 households do not have access to electricity [2].Most of these rural homes are located in isolated or hard-to-access locations and do not allow connection to an electrical grid since the investment cost is very large and online losses become significant.It is then necessary to be able to install the infrastructures for electrification in sparsely populated areas and away from the main grid.
In recent years, rural electrification has been achieved with DG or with stand-alone renewable energy sources, including photovoltaics and wind power, which have been considered promising to meet the growing demand for energy and play a very important role in the clean energy production.However, renewable energy depends to a large extent on wind speed or solar radiation.In order to provide a continuous supply by taking advantage of the complementary nature of the two sources of energy, one solution is to hybridize the types of sources in the form of the microgrid.
HMS were considered attractive and preferred alternatives; indeed, the development of microgrid in rural areas makes it possible to electrify villages located far from the distribution grid with renewable energy sources (RES) in a more sustainable way.Another major factor in the development of microgrid systems is the sharp drop in the cost of renewable energies, which makes these energies competitive with traditional fossil fuels.Similarly, energy storage solutions are currently undergoing significant development due to the improvement of different technologies and lower production costs.In addition to renewable energy sources, a HMGS may also incorporate an AC distribution system, a DC system, a storage system, power converters, loads, a ballast load, and an EMS or a supervisory system.In most cases, HMGS contain two buses: a DC bus for sources, DC loads, and batteries and an AC bus for AC generators and the distribution system.
The technoeconomic analysis of any hybrid renewable energy system (HRES) is highly essential to know its efficiency and economic viability, so several methods for optimal sizing have been proposed in the literature [3][4][5][6][7][8][9][10][11].These works across the world have shown that a HRES is more economical than stand-alone energy systems.However, the intermittent nature of renewable energy sources requires proper power management in order to improve overall performance and increase the lifespan of the microgrid components.Therefore, adequate management of the energy flow through the HRES and the establishment of a supervisory system are essential.
Various control strategies and topologies for an autonomous hybrid system have been reported in the literature [12][13][14][15][16][17].Mengi and Altas have proposed a new energy management technique for PV/wind/grid renewable energy system in [18]; likewise, an evaluation of three EMSs was carried out by [19] to identify the most effective one.In addition, [20] proposed four optimization techniques for resolving an economic dispatch problem; the application is made on the system connected and not connected to the grid.[21] seeks to develop a dynamic energy management model for microgrid-enabled production systems.[22,23] proposed management architectures multiagent based with both centralized and decentralized energy.[24] developed a coordinated control strategy for a stand-alone hybrid system with the aim of maintaining the battery state between 70% and 80% and maintaining the DG power above 40% of its nominal value.Likewise, a fuzzy logic technique is used to formulate a rebel control system for a HMGS [25][26][27].Other researchers create new management strategies to minimize the total and operating cost of stand-alone hybrid energy systems [28,29].A control strategy consisting of the high-pass filter-based droop controller is realized by [30].[31] came up with a mathematical formulation of the energy management problem and its implementation in a centralized EMS for isolated microgrid.For the grid connected microgrid systems, the energy management aims at reducing the dependence on the main distribution grid in the microgrid [32][33][34][35].
On the other hand, researchers proposed a microgrid power management system (PMS) in real time [36][37][38].An advanced real-time EMS for a microgrid is developed to maximize the power of the available RES while minimizing the energy cost and carbon dioxide emissions [39]; also, a multiobjective power management procedure for microgrid is carried out by [36].[40] developed a technical and economic analysis of home EMS incorporating a small-scale wind turbine and battery energy storage system; the EMS is expressed as a mixed integer nonlinear programming (MINLP) and solved by the cultural algorithm as an effective metaheuristic optimization algorithm.
A new field of research has appeared in recent years that has focused on the management of domestic energy [41,42].Novel home EMS using wireless communication technologies for carbon emission reduction within a smart-grid smooth power peak demand and diminish CO 2 emissions is carried out by [43].In the same way, three approaches are suggested for the rolling optimization by the home EMS, namely, mixed integer linear programming, continuous relaxation, and fuzzy logic controller [44].ZigBee-based energy measurement modules are used to monitor the energy consumption of home appliances and lights [45].Likewise, [46] developed a distributed multicontrol-center dynamic power flow algorithm based on an asynchronous iteration scheme.
Most of the articles cited above regarding power management are simulation work and theoretical formulation; few articles present a practical implementation.Experimental evaluation of a PMS for a HRES with hydrogen production presents a PMS based on a fuzzy control system takes into account the uncertainties of the load demand and the power production from renewable energy sources for a HRES [47].In an EMS implementation in Serbian manufacturing, the Plan-Do-Check-Act cycle approach with the aim to cut energy consumption and CO 2 emissions is proposed by [48].[49] present the energy box concept in the context of the V2G (vehicle-to-grid) technology to address the energy management needs of a modern residence, considering that the available infrastructure includes microrenewable energy sources in the form of solar and wind power.A real-time load management is developed to control unpredictable residential loads [50]; the developed control is implemented on an ARM Cortex-A9 processor of the ZYNQ device.Likewise, a supervisory PMS for a hybrid microgrid with HESS is presented by [51].
In this article, we consider the case study of a mosque located in a mountain area of Morocco.First, we perform an optimal sizing to identify the best combination of energy sources.Then, we perform a design and modelling using the LabVIEW software.Finally, we carry out an experimental evaluation of the PMS on a real-time platform that is the Raspberry-pi 3 equipped with a microprocessor ARMv8, 1.2 GHz 64-bit quad-core.
The aim of this work is to realize an optimal configuration of a hybrid PV-wind-diesel; a supervision system with the function of ensuring a secure, reliable, and efficient operation of the microgrid; and the implementation of a real-time PMS to verify the effect of the RES variation on the evolution of the system.
The contributions of this article are (i) feasibility study of a HMGS based on PV, wind turbine, and diesel generator using the actual solar radiation and the wind speed data to power a mosque located on an isolated site in Morocco (ii) modeling of the microgrid and the creation of a supervision dashboard to monitor the evolution of the system under the LabVIEW software (iii) implementation of the PMS on an embedded RPI3 platform 2 International Journal of Photoenergy

Studied System
The energy system studied in this paper is a stand-alone hybrid system that contains RES (PV panels and a wind turbine) associated with a standby diesel generator and storage battery.The structure of this AC/DC microgrid is shown in Figure 1.The PV and the battery are connected to the DC bus and the wind turbine; the GD and the loads are connected to the AC bus on the other side.

Sizing of the HMGS
In this study, we chose an isolated load under real operating conditions.It is a mosque located in the center of Morocco (33 °45 ′ 11 ″ N latitude; 04 °30 ′ 57 ″ W longitude), with a daily load of 77 kWh/day; the detail of the consumption and the description of the major economic input data used in the model to define the optimal size of the different component of the hybrid energy system are given in Table 1 and Table 2, respectively.The daily profile of the load is shown in Figure 2. In this work, the load is modelled by its demand per power hour.
In order to supply this load, it is necessary to identify the optimum system between the various possible combinations (diesel only, PV-diesel, wind-diesel, and PV-wind-diesel).For this reason, a sizing of the hybrid system was carried out with HOMER-Pro software, for a 25-year project lifetime, using actual solar radiation data, wind speed, and economic data of the various components.

Modelling of the Proposed System
4.1.Photovoltaic Module.The photovoltaic output power depends on the incident solar radiation, and the hourly output power of the PV panel at any time t is calculated using the following equation: where P PV,STC is the power provided by the PV array under standard test conditions (STC) (kW), D f,PV is the number of the derating factor (%), R i is the solar radiation incident  3 International Journal of Photoenergy on the PV array in the current time step (kW/m 2 ), and R i,STC is the incident radiation at STC (1 kW/m 2 ).
Figure 3 shows the output power profile by the set of photovoltaic panels sized in this study: 4.2.Wind Turbine Modelling.At a specific site, the output power provided by the wind turbine depends on the wind turbine's power curve (WTPC) and wind speed at the hub height W h .The power curve of the wind turbine used in this work is shown in Figure 4, and the wind speed at the hub height W h is calculated using the following equation: where W a is the wind speed at anemometer height (m/s) derived from the wind speed data (Figure 5), H h = 30 m is the hub height of the wind turbine (m), A h = 20 m is the anemometer height (m), and s is the surface roughness length (m).
Figure 5 shows the wind speed profile and the power supplied by the wind turbine for a typical day.

Battery
Modeling.The optimum system found when dimensioning contains a storage battery to provide the necessary power when the RESs are insufficient to meet the load needs, if, of course, the amount of battery charge is sufficient.It is calculated by the following equation: where P a ðtÞ is the battery charge at time t, P a ðt − 1Þ is the battery charge at time t − 1, P S ðt − 1Þ is the charge quantity to be stored at time t − 1, P t ðt − 1Þ is the total energy to be provided by the battery at time t, C bat is the battery charge efficiency, and C inv is the inverter charge efficiency.State of charge (SOC) of the battery depends on the load requirement and the power provided by the RES, and it is calculated using the following equations: (i) For the charging mode, (ii) For the discharging mode, where SOCðtÞ is the state of charge of the battery at time t, P bat ðtÞis power exchange during the time step Δt, C char is the battery charge efficiency, C dis is the battery discharge efficiency, and P N is the battery nominal capacity.

Diesel Generator
Modeling.The diesel generator used in this study is of the genset type with a maximum power of 10 kW; its function is to deliver the power difference between the power generated by the RES and the load profile when the battery is discharged; it always works near its rated power, to increase its lifetime and to minimize emissions and consumption.This consumption is given by the following equation: where α and β are the coefficients of the straight line presented in Figure 6.P out and P nom are the output power and the nominal power of the DG, respectively.

Energy Management System
5.1.Proposed Energy Management Scheme Based on Power Flow Control.Energy management in a microgrid is the way to distribute energy between different components and to meet the load requirement in all climatic conditions.In this paper, the microgrid is insulated and consists of several power sources; the control system must ensure the maximum supply of the load by the RES (wind turbine, PV).The diagram of the EMS proposed in this article is shown in Figure 7.It allows to control the energy flow between the different components and to display the indicators for the user.The main tasks of the control system can be summarized as follows:  (i) PV mode (P L < P PV ): the power supplied by the PVs is sufficient to supply the load.This mode is the highest priority in our case, if it is activated, the power produced by the PV panels is greater than the requested power by the load; in this case, the load is powered by the PVs and the wind turbine is disconnected if the battery is charged (SOC; SOC max ) or charging the battery if SOC < SOC max (ii) Wind mode (P PV < P L and P L < P W ): the power provided by the wind turbine is sufficient for the 6 International Journal of Photoenergy power supply.This mode is activated if the power provided by the PVs is not sufficient.The load is fed by the wind turbine.The PVs load the battery if SOC < SOC max and they are disconnected otherwise (iii) PV/wind hybrid mode (P PV < P L and P L < P W and P PV + P W > P L ): the load is fed by the two RESs (wind and PV).This mode is on if the first two modes are not activated.In this case, the battery is charged by the remaining power if SOC < SOC max .Otherwise, the rest of power feeds a ballast load (iv) PV/wind/battery hybrid mode (P PV < P L and P L < P W and P PV + P W < P L and SOC min < SOC ≤ SO C max ): in this case, the RESs are not able to ensure the requirement of the load; the battery ensures the lack of power (v) PV/wind/diesel hybrid mode (P PV < P L and P L < P W and P PV + P W < P L and SOC ≤ SOC min ): the load cannot be fed by the two RESs (wind and PV) and the battery is discharged.This mode is activated if the preceding modes are not activated; in this mode, the DG is started to complete the lack of energy

LabVIEW Code for Controlling the Power Flow of the
Microgrid.Simulation step must be performed prior to implementation.In this study, the operation of the HMGS is tested using the LabVIEW software, for a typical day. Figure 9 shows the power management program, consisting of 3 parts: (i) System inputs: the load profile (Figure 2), the power generated by the PVs (Figure 3), the power supplied by the wind turbine (Figure 5), and the SOC of the battery for each one-minute time space (ii) Controller: corresponds to the operation defined by the algorithm shown in Figure 8 (iii) System outputs: corresponds to the actuators and to displays that indicate the status of each source and load (dashboard).

Hardware Implementation
After sizing a HRES to justify the choice of the PV-winddiesel system, we developed a management algorithm and we carried out a successful simulation on LabVIEW, using real radiation and wind speed data.The simulations show the feasibility of such a system.
In this section, we implement the energy control system on an embedded platform such as the Raspberry-pi 3. Figure 10    8 International Journal of Photoenergy and load are connected to the Raspberry-pi through an Arduino.Part of the Raspberry pins will control the relays, which are wired directly to the sources, and other pins will control the different loads.
6.1.Raspberry-Pi.Raspberry-pi 3 ( RPI3) is an open hardware platform and is a low-cost ARM-based palm-size computer, featuring a quad-core 1.2 GHz processor, 1 GB of RAM memory, 4 USB, 10/100 Ethernet, GPIO, HDMI and composite video outputs, and SD card slot.RPI is small in size and it consumes 5 V electricity at 1 A current due to which power consumption of the Raspberry-pi is less.It allows the execution of several variants of the free GNU/Linux operating system and compatible software.We chose the Raspbian distribution Linux embedded operating system.The programming is done using the Python language wish is a structured and object-oriented programming language.It features dynamic typing, automatic memory management, and an exception management system.6.2.Relays.The relay circuit was designed to be able to switch the different sources, according to the program executed by the Raspberry, which translates the proposed algorithm.For the realization of this one, we used ISIS software as shown in Figure 11.
Four coils of the relay are powered by 5 V pin of the Rpi and the masses are isolated by transistors 2N2222.Each relay corresponds to a power source and the control is sent by the Rpi.A current passes to the base of the transistor, then the coil of the relay is energized; this will make it possible to use the energy of the chosen source.
After verifying the operation of the circuit on ISIS, we realized the printed circuit using ARES software.Thus, we have obtained the printed circuit indicated in Figure 12.

Load Control Circuit.
To test the management program practically, we took lamps as the system load and a fan as the ballast load.The control circuit that controls these charges is realized.Figure 13 shows its diagram on ISIS and Figure 14 shows its implementation on ARES.
6.4.Arduino.It is a circuit whose main constitution is a microcontroller that can be programmed to perform very different tasks.Its programming is done using the Arduino integrated development environment, which is a free and cross-platform Java Application, which can be used as a code editor and a compiler, and which can transfer the firmware   International Journal of Photoenergy point of view (net present cost and the amount of greenhouse gas emissions).This figure shows the interest of using HMGS compared to the current situation of the diesel generator.Hybrid PV-wind-diesel system (PWDS) produces better results compared to the PV-diesel system (PDS), wind-diesel system (WDS), and diesel-only system (DS).The sizing result using the Homer-pro software shows that the optimal system is a hybrid system based on 5 kW panels, the wind turbine of 3 kWp, and a genset of 10 kW backup diesel generator, combined with a generic kWh storage battery Li-ion 1 kWh and a Leon s219cph 5 kW 48 Vdc bidirectional converter (BDI 1P).
Further information on the system inputs and other results of this dimensioning can be found in [52].

Modelling Results
. In order to test and monitor microgrid performance under real conditions, a simulation study is done using LabVIEW software.The simulation results consist mainly of 2 components: the user interface realized in the form of a dashboard that allows the user to see the state of the microgrid every minute.As shown in Figure 16, it is composed of (i) two tables:  Figure 17 shows the power supplied by the various energy sources.As can be seen, it corresponds to the required load profile.Figures 18 and 19 represent the power evolution provided by the wind turbine and the PV panels, respectively.
Figure 20 shows the state of the diesel generator; it is started 3 times during the day.

Experimental Result.
Figure 21 shows the first setup of our microgrid; it is a model realized with modest personal means.We have used potentiometers to vary the powers provided by energy sources on purpose to visualize the effect of this variation in real time.Similarly, for the load, we took 5 lamps and a fan as the ballast load.
Arduino receives the power values provided by the power sources and the battery (potentiometers); it handles the analogue digital conversion and then transfers them to the RPI3, which executes the power management program, and reacts to the loads according to the flow chart of Figure 8.

Conclusion and Future Work
This paper presents an implementation of real-time energy management systems (EMS) to maximize the efficiency of the electricity distribution in a microgrid.The grid serves a load with an off-grid hybrid renewable energy system made of photovoltaic modules, a battery energy storage system, a diesel generator, and a wind turbine.Furthermore, a proper power flow control is developed using LabVIEW software and embedded in a suitable platform for the real-time management of the hybrid energy system.The developed EMS is tested and validated through a small-scale application which accurately represents the case study of an isolated mosque located in a remote area of Morocco.
This system can be introduced into a microgrid to monitor its components.The system is realized and is equipped 12 International Journal of Photoenergy with a supervision dashboard, allowing the user to monitor the evolution of the hybrid system.In the future, these power systems will be able to take advantage of clean and renewable energy sources.
In the hardware implementation, we used the potentiometers to vary the RES powers and the load profile; in the next works, we will replace these potentiometers with current and voltage sensors to use the real panels and the wind turbine.Also, monitoring and control technologies must be developed to reduce energy consumption in renewable energy systems.Currently, we are developing a remote monitoring system and a control interface that allows the user to see  13 International Journal of Photoenergy the power variations and the state of the battery, thus controlling remote power sources.For this reason, we created a hosting server as well as its configuration; thus, we installed the PHP language and a web server named APACHE in order to communicate with the RPI3 using its IP address and to control it from afar.

Figure 5 :
Figure 5: Wind speed and wind power output.
shows the overall electrical scheme.Power sources

Figure 9 :Figure 10 :
Figure 9: LabVIEW code for controlling the power flow of the microgrid.

Figure 12 :
Figure 12: ARES diagram of the relay circuit.

Figure 13 :
Figure 13: ISIS diagram of the load control circuit.

Figure 14 :Figure 15 :
Figure 14: ARES diagram of the load control circuit.

Figure 16 :
Figure 16: LabVIEW user interface of the microgrid.

Table 2 0 0
Table 1 contains the actual values of the load as well as the powers of the renewable energy