Power Balance Modes and Dynamic Grid Power Flow in Solar PV and Battery Storage Experimental DC-Link Microgrid

In this paper, an energy management system, based on different power balance modes and dynamic grid power flow, is proposed to operate a DC-link microgrid based on a solar photovoltaic generator and battery storage, with the option to request variable power from the grid to meet the load demand. The energy management provides the required references, for each mode, based on the solar source availability, the battery status, the power losses, and the grid billing rate. A fuzzy logic system is developed to provide a dynamic grid power flow based on the grid price. Eight power balance modes are defined based on the power generation, storage, and grid affordability to meet the load demand. The objectives are to minimize the energy cost and increase the lifespan of the storage device. The microgrid is controlled to maintain a constant DC-link voltage and regulate the battery current depending on the mode of operation. The proposed energy management system, based on the power balance modes, is experimentally validated on a laboratory-scale DC-link microgrid for different conditions. The experimental results have shown the satisfactory performance of the microgrid and smooth transitions between the different power balance modes.

The last decade has been witnessed with small scale and smart microgrids based on renewable resources. About 4GW of energy comes from microgrid worldwide while only North America contributes 67% of the total production [1]. A microgrid is a miniature scale of self-sufficient and environmentally friendly energy grid that contains distributed renewable energy resources. It has the features of operating in grid-connected and islanded modes. Furthermore, a microgrid can work in parallel with the main utility grid eliminating high penetration constraints. Microgrid also aims for economic benefits, consumer independence, high VOLUME 8, 2020 This work is licensed under a Creative Commons Attribution 4.0 License. For more information, see https://creativecommons.org/licenses/by/4.0/ network efficiency, power-sharing, sustainable energy backup, etc. [2]- [4]. A microgrid can be constructed of a single or interlinking of multiple units. The major components in a microgrid are the generation, control, and communication units, where optimal use of the distributed energy resources (DER) can lead to economic and environmental benefits [5], [6]. Based on the point of common coupling (PCC), the microgrid can be DC-link, AC-link, or hybrid. For small scale generation, DC microgrids have been always preferable as the solar photovoltaic (PV), and the battery storage systems can be directly connected to the DC-link through power electronic converters with the least complexity [7]. In a microgrid system, there are different control layers and local controllers for generating units and an energy management system (EMS). As a top-level control, the EMS is sometimes referred to as supervisory control and data acquisition (SCADA) [2]- [5]. Several studies have been reported in the literature in the fields of microgrid control and EMS configurations. In [8], a near-optimal model-based control was proposed to control the battery storage system by introducing a dynamic electricity billing over a month. The reinforcement learning technique optimally solves the storage control problem under certain circumstances. The mathematical modeling focuses on electricity billing and the cost of energy. However, the battery state of charge (SOC) was ignored, which is a crucial factor in any cost function. In [9], a fuzzy-logic system (FLS) based microgrid was presented taking charging/discharging rate and electricity bills into account. The performance of the proposed FLS-based EMS was compared with the self-adaptive controller and mixed-integer linear programming (MILP) scheduling; however, the operating cost of the proposed method was higher than other methods due to the high computation. Similar work was addressed in [10], where the FLS controlled agent-based electric vehicle (EV) charging-discharging was reported without discussion about the computation burden. In [11], a modified unified interphase power controller, for both DC-link and AC-link microgrid, was implemented, where the power flow control was demonstrated without discussing the power losses in the different stages. The schedule layer and dispatch layer-based coordinated control approach were used for forecasting data and real-time simulation for economical microgrid energy management [12].
Similar studies regarding isolated microgrid, were pursued in [13] and [14], where the stochastic nature of distributed renewable resources and the load was considered in the EMS modeling. Both works focus on cost factors and active-reactive power impact in the mixed-integer quadratic programming problem-based designation. A real microgrid is presented in [13] for comparison and validation, whereas operational scenarios for zone-based multiple microgrids were considered in [14]. Despite the computational challenge and instability in the online application, mixed-integer quadratic programming problem seems effective in the EMS formulation [13], [14]. Niching evolutionary algorithm was used, as an optimal dispatching technique, for mediumvoltage islanded microgrid with the storage system [15]. Low-level decentralized control was used for local distributed generators control, whereas high-level centralized control solved the bidirectional power share and communication with the generators. Similar control strategy and EMS was implemented in [16], where both grid-tied and islanded mode were studied with a supervisory control that compensates the mismatch between the offline and the real-time scheduling. In [16]- [19], multi-agent decentralized EMS and intelligent control were investigated for autonomous poly-generation microgrids. These agents employed Fuzzy cognitive maps for the implementation of the desalination system. Decentralized control was used for PV and battery storage power DC microgrids, and the results were only provided in a simulation environment.
In [20]- [22], hierarchical EMS models for DER using centralized and decentralized control techniques were demonstrated, where advanced optimization methods such as swarm optimization, neural network, and sequential quadratic programming were used in simulation or hardwire in the loop (HIL) environment. The robustness of the decentralized control with low communication bandwidth for sudden connection and disconnection was assured in [23]; however, in the EMS, limited factors were considered in the comparison analysis. In [24], a static synchronous compensator (STATCOM), controlled by a decentralized control technique, was investigated for a hybrid AC/DC microgrid. Moreover, the proposed method was compared with the droop control method to verify its superiority. The advanced optimization algorithms may characterize multi-agent-based large hybrid microgrid; however, it is yet to determine their performance in physical implementation as they require longer computational time. An integrated approach to compare the economic benefit of microgrids between lead-acid and the lithium-ion batteries was presented in [25]. The usage of lithium-ion battery seems 6% more beneficial when the price of the grid power, SOC, and power balance modes were considered in EMS. In a similar manner, the battery storage and the cost efficiency in EMS were discussed in [26] with the only addition of forecasting of 24 hours PV generation. A rule-based EMS for PV and energy storage microgrid was experimentally evaluated in [27] and [28], where the physical implementation of laboratory-scale microgrid was presented with adaptive control. In these experiments, importance was given to the SOC, the load variation, and the mode switching without any consideration about the electricity price.
The works, in [29] and [30], presented an overall review of ongoing major microgrid projects carrying out all over the world mostly in the USA, Europe, and Japan in R&D and field level. Different microgrid architectures, including gridconnected, islanded, decentralized control, centralized control, were analyzed for residence, electric vehicle (EV), ship, solar plant and windmill applications. In [31]- [33], laboratory scale DC-microgrids were implemented using hysteresis control for simplicity and effective operation. In these works, priorities were given to the battery life and size, efficiency, and price compensation in the EMS.
The major issue in the microgrid operation is the non-availability of technical details in the experimental/hardware implementation of the EMS while taking into consideration the dynamic grid price, battery states, and inconsistent renewable generation. In order to overcome these drawbacks, of integrating the EMS algorithm into the control system, this work focuses on proposing an EMS with multiple modes to efficiently operate the microgrid under different conditions.
The aim of this paper is to investigate the power balance in a small-scale experimental microgrid for various cases. The significance of the battery storage, concerning grid price, is demonstrated in this work by implementing practical scenarios. The contribution of the grid power to supply the load demand from a dynamic grid price is determined by an optimization factor achieved using a fuzzy logic technique.
Another key point of the work is to develop a rule-based EMS scheme, based on multiple power balance modes to achieve optimum operation by considering the grid price, the battery state, the PV generation, and the load demand. This paper is organized as follows: Section II describes the microgrid configuration and the dynamics of its components. In section III, the local control units for the PV and the battery storage are explained with the required references. Section IV focuses on the proposed energy management system, where all the operating conditions are taken into consideration to provide the reference current for the battery storage system. Furthermore, the implementation of the optimization factor is discussed in this section. Experimental results for the validation of the EMS and the control behavior are given and discussed in Section V. Section VI concludes this paper.

II. MICROGRID CONFIGURATION
The microgrid configuration is depicted in Fig. 1. The solar PV array is connected to the DC-link via the boost DC-DC converter. The battery storage system (BSS), including the battery bank and the buck-boost converter, is connected to the DC-link. The AC side includes the inverter, the resistiveinductive (RL) filter and the grid. A three-phase variable load is connected to the point of common coupling (PCC).
The power of the solar PV system is carried out by The power of the battery is provided by The voltage-current dynamics of the is governed by where, I bat dt is the extracted capacity, dt is the time step in hours, R b is the internal resistance, A is the exponential zone amplitude, B is the exponential zone time constant inverse. The battery energy is characterized by its state of charge (SOC) carried out by The battery storage has the following constraint where, SOC min and SOC max are the minimum and the maximum allowable states based on the battery characteristics. The power at the inverter side, under the assumption of the voltage alignment (v d = V ; v q = 0), is expressed by where, v d and v q are the dq-components of the voltage at the inverter output, and i d and i q are the dq-components of the current at the inverter output. From (6), the active power can be controlled by the current i d and the reactive power by the current i q .
In grid-tied operation, the required grid power, to meet the load demand, is carried out by where,P L is the load demand, P F represents the power losses in the RL filter, the converters, and other devices in the network.
In this work, the power losses are not for carried out for each component but quantified by using a loss compensation factor to be explained in the section about the energy management system.

III. CONTROL SYSTEM
The control system includes the local control units for the PV system, the battery storage system, and the voltage source inverter, as shown in Fig. 1. VOLUME 8, 2020 The PV system is considered operating under maximum power point tracking (MPPT) to extract the maximum power available for the solar irradiance. The PV local control unit operates the PV array at a specific operating voltage and current. In general, the DC-link is the distribution point and it requires higher voltage for the AC distribution; hence, the MPPT forces the boost converter to operate the PV at a lower voltage around the maximum power-point [33]- [35]. In this work, the perturb and observe (PO) algorithm is used to provide the pulse S d1 for the boost converter [36].
In the BSS, the buck-boost converter operates by controlling the battery current to track a reference. Its local control unit, depicted in Fig. 1, includes a current controller based on a proportional-integral (PI) controller such as where, ctrl bat is the control output,k pb and k ib are the proportional and integral parameters, and I * bat is the battery current reference to be generated by the EMS.
The inverter control unit regulates the DC-link voltage, to be maintained constant, and the inverter AC currents. The DC-link voltage regulator is based on a PI controller such as where, k pv and k iv are the proportional and integral parameters, respectively. The DC-link voltage reference is given by [31] where, V LL is line-to-line voltage at the (PCC) and m a is considered as a unity. The inverter control unit is completed by a hysteresis current controller, where the references are the current reference i * d , carried from (9) for proper active power transfer, and i * q carried out from (6) by where,Q * g is the requested reactive power from the grid. In case of pure resistive load, the microgrid is operated under a unity power factor and i * q = 0. The hysteresis current controller regulates the AC currents and generates the pluses S 1 · · · S 6 for the inverter as shown in Fig. 2.
In this work, the energy management system includes the operational modes based on the required active power to meet the load demand. The reactive power is not taken into consideration in this analysis. Therefore, faults in the energy system requiring the injection of reactive power are not considered in this EMS. Furthermore, the control system varies, in case of grid faults, to include active power curtailment and reactive power injection. This issue will be investigated in future work.

IV. ENERGY MANAGEMENT SYSTEM
The energy management system provides the current reference for the battery in order to proceed with the battery charge-discharge to meet the load demand. Based on the available power from the PV source, the battery SOC, and the grid power price, the microgrid is operated under a power balance mode to meet the load demand while optimizing the use of the battery storage.
The decision about the power balance mode is considered based on the following factors: (1) Grid availability and price of per unit energy.
(3) PV availability and load profile. (4) System efficiency and optimization. In this work, the microgrid is controlled to operate under a unity power factor due to the resistive load. Only the active power is considered in the EMS due to the nature of the grid price evaluated by /kWh. However, modes for reactive power balance can be generated based on (11).

A. POWER BALANCE MODES
The proposed EMS generates references to the control system, where the distribution of energy follows the predefined instructions. According to the defined rules, conditions, and scenarios, the EMS includes eight power balance modes: (i) Grid suit mode (GSM). For the dynamic power flow, different rates have been considered for the grid price such as the off-peak rate $ L , the on-peak rate $ H , and the standard rate $ std . These rates will be used in deciding the power flow of the battery and the grid using an optimization factor β for the battery contribution. This factor is proportional to the price, β ∝ $, and takes values within the interval [0 1], where β ≈ 0.5 for prices $≈$ std , β < 0.5 for $<$ std and β > 0.5for $>$ std . The mechanism to select the value of β is described in the sub-section IV.B.
The microgrid experiences power losses at different points of the network. Therefore, a loss compensation factor has been integrated with the reference signals, generated by the EMS, to take the power losses into account and satisfy the load demand. In this EMS scheme, it is considered that the solar PV system always operates at MPPT condition and the grid is an ideal voltage source.
The proposed EMS is developed based on the solar PV availability, battery status, grid price, and load demand. It includes the following operational modes: (i) GSM: In this mode, if the PV power is close to zero or minimum, the load demand is supplied by the BSS, if its SOC is within the range [SOC min SOC max ], and the grid. Furthermore, the consumption of grid power is regulated by the per-unit utility price. The GSM refers to a condition where the actual per unit energy price ($) is less than the standard grid price ($ std ). In this condition, the contribution of the battery is less and regulated by the optimization factor, β (β < 0.5), as the demand is preferably to be met by the grid. Moreover, a loss compensation factor, α (α < 1), is considered in the expression of the battery current reference I * bat to compensate the power losses P F . The battery current reference is expressed by (ii) BSM: This mode is like the GSM except for the perunit energy price ($), where this price is higher than the standard grid price ($ std ). Since the grid price is high, a large amount of the battery power is supplied to minimize the grid power contribution. This condition is satisfied by increasing the optimization factor β (β > 0.5). The battery current reference is expressed by (iii) ISM: This condition represents the non-availability of power from the grid. The PV and BSS supply the load demand. In this work, as the PV always operates at MPPT for any irradiance, the PV provides the generated power to the network. Furthermore, the network receives no power from the grid and operates under zero-grid current. This condition is valid if enough battery power is available to meet the demand; otherwise, load shedding is required for power balance. The battery current reference is expressed by (iv) IBM: In the PV and BSS based grid-tied converter, it is a common scenario where the battery tends to deep charge or deep discharge due to the excessive or inadequate power in the DC-side. In general, any EMS is required to take into consideration the battery constraints related to the SOC for safety. In this EMS, the battery remains standstill or idle, and provides no power to the network, if the SOC is less than the minimum limit. In this case, the battery current reference is In this mode, the demand is met by the PV source and the grid without any consideration about the price.
(v) ECM: In this mode, the grid price is close to the offpeak price, the PV power is available and the battery SOC is not at the maximum limit. In this period, since the grid has power at a low rate, the load demand can be met and the battery can be charged at the maximum rated current (I bat_max ) to reach the limit (SOC max ). The battery current reference is given by

(vi) ENM:
In case of the grid-tied condition, where the grid price is high and the load demand can be met by the PV generator, the available energy in the microgrid can be sold to the grid for profit. This scenario normally occurs during on-peak hours to take advantage of the high price ($ H ). In this mode, the battery can be discharged at the maximum rated current (I bat_max ) until reaching the limit (SOC min ) if required. The battery current reference is given by (vii) DPM: This mode refers to the condition when the load demand is higher than the generated power. The battery is required to be discharged to contribute to this demand. Furthermore, this mode considers the grid price between the low and high rates. In this case, the battery discharge is optimized based on the grid price by assigning the optimization factor (β) a value proportional to the grid price. The battery current reference is expressed by (viii) SPM: In case of excess power from the PV source than the load demand, and the grid price is between the low and high rates, the battery can be charged at an optimum rate and selling the remaining power to the grid. For both DPM and SPM, the rate of charging and discharging of the battery, as well as the grid contribution, depends on the optimization factor (β). The battery current reference is expressed by The power balance modes of the EMS are summarized in Table 1. Furthermore, the EMS, to operate the microgrid, is detailed in the flowchart illustrated in Fig. 3.

B. OPTIMIZATION FACTOR
The dynamic power flow between the battery and the grid is based on the grid price through the optimization factor (β).
In general, the relationship between the optimization factor (β) and the grid price ($) can be evaluated using a mathematical expression through interpolation based on the available data. In this work, the relationship is evaluated, as nonlinear, using a fuzzy logic system (FLS) with the grid price ($) as the input and the optimization factor (β) as the output. Based on the power sources contributions, the design aims to minimize the energy cost as follows (20) where, C PV , C bat are the operational costs of the PV, and the battery, respectively, C g is the cost of energy from the grid, and E bat is the energy consumed from the battery.
In this FLS, three profiles (low, average, high) are considered for the energy price from the grid. The factor (β) is considered in the range [0, 1], where close to 0 represents a low price, around 0.5 represents an average, or standard, price and close to 1 represents a high price. The membership functions for the input and the output are provided in Fig. 4. The FLS rules are expressed in Table 2. From these rules, it can be observed that the optimization factor (β) is proportional to the price ($), where the increase in energy price from the grid will result in increasing the contribution of the battery storage, and vice versa, to meet the load demand.  In the developed EMS, the battery contribution, to meet the load demand, depends on the optimization factor β. This factor reduces the use of the battery storage when the energy price, from the utility grid, is low. Furthermore, the battery deep discharge will not occur in short periods of time as the EMS checks the battery SOC and the grid price to switch between modes and minimize the use of the battery storage. This mechanism, to balance the grid and battery usage, contributes to expand the battery lifespan.

V. EXPERIMENTAL RESULTS
A laboratory scale microgrid is used to validate the proposed EMS and the control system. The experimental testbed is depicted in Fig. 5. It includes a photovoltaic power profile emulator (PPPE), to mimic the solar array, power electronics converters, a battery bank, a variable load and a grid emulator based on a bidirectional AC power supply. The properties of the setup components are available in [32]. Voltages and currents measurements and converters pulses are processed by the data acquisition device (OP8660). The EMS and the control system are implemented in the OPAL-RT software environment combined with the MATLAB/Simulink. Then, they are executed in the real-time digital simulator (OP5600), which communicates with the electrical system through the OP8660. The real time simulator (OP5600) operates at a sampling time of 2 µsec, and the data is simultaneously stored in the workspace of the MATLAB environment, which requires memory space. For this reason, the experimental setup was run for only 60 sec. Furthermore, due to the limited execution time of 60 sec, the variation of the battery SOC will be slow, and only the SOC, within its limit SOC min ≤ SOC ≤ SOC max , is taken into consideration in the conducted experiments. The purpose of the experiments is to assess the transitions between the power balance modes.
In order to simulate different irradiances, two PV power profiles (low and high) are implemented in the PPPE interface as shown in Fig. 6. The high irradiance is simulated using 65V for the open-circuit voltage and 1.5A for the short circuit current. The low irradiance is simulated using 57V and 1.4A.
For the dynamic power flow of the grid, the price reference ($), is considered from the electricity utility Nova Scotia Power, NS, Canada and is provided in Table 3. These values are used in the FLS, Fig. 4(a), and its output-input relationship is shown in Fig. 7.  In the proposed EMS, depicted in Fig. 3, the microgrid can be operated under eight power balance modes. In order to simplify the analysis, two tests are conducted using four modes in each test. In both tests, results for real power, DC voltages, DC currents, grid and load currents are provided and discussed in this analysis.
Each test is carried out for 60 sec, and every 15 sec, the operating mode is changed based on the PV source availability and the grid power price. The purpose of these changes is showing the precision of controller dynamics, at the mode transitions, and the seamless operation of the microgrid.
A. TEST 1 This experiment includes the four modes (GSM, BSM, ISM, and IBM) to meet a constant load demand. During the time interval, t = 0 sec to t = 15 sec, the GSM is conducted under a low solar irradiance, characterized by the activation of the low PV power profile at the PPPE interface. From the power responses, shown in Fig. 8, it can be observed that the load power is served by the battery and the grid as the PV power is extremely low. Moreover, in this mode, as the grid price is lower than the standard price, the grid contributes more power than the battery as can be observed in Fig. 8 under the GSM. The battery current reference, generated by (12), and its control tracking are depicted in Fig. 9, where it can be observed a good tracking performance with no overshoot. Furthermore, the DC-link voltage is well regulated as shown in Fig. 10. The SOC during the battery discharge declines from 60% to 59.9% as observed in Fig. 11. At t = 15 sec, the system switches to BSM, when the grid price is higher than the standard rate, which increases the power contribution of the battery in order to satisfy the load demand compared to the previous mode. The power delivery from the battery and the grid, shown in Fig. 8, is regulated by (13) and easily can be changed by selecting an appropriate value for the factor β from the FLS. The battery current is higher to meet the demand as shown in Fig. 9. The DC-link voltage is still well regulated as shown in Fig. 10, despite the disturbance due to mode change. The SOC is declining in Fig. 11, from t = 15 sec to t = 30 sec, at a higher rate since the battery discharge is higher as shown in Fig. 9. At t = 30 sec, the PV profile is upgraded to a high irradiance and at the same time the microgrid switches to zero-power from the grid. Because of the changes in the mode and the PV profile, a small transition is experienced at t = 30 sec in all results. In ISM, the grid power is nearly zero due to the increase in the PV power, and the battery current reference is calculated by (14) to provide the required power to meet the load. From t = 30 sec to t = 45 sec, the power flows of the different units, and the SOC variation can be   observed in Fig. 8 and 11, respectively. Moreover, it can be observed, from Fig. 9, that, in the ISM operation, the battery discharges at a higher rate, which confirms the zero-power consumption from the grid. In the last mode, from t = 45 sec to t = 60 sec, the controller follows the algorithm where the SOC reaches the low limit and the battery becomes standstill. As the execution is carried out for only 60 sec long, the SOC change is subtle, so the SOC L and SOC H are considered as 59.53 % and 60.2%, respectively. From Fig. 9 and 11, it can be easily observed that, when SOC is lower than the SOC L , the battery current becomes zero and the power delivery from the battery is nul as shown in Fig. 9. In this mode, the grid and the PV provide power to the load to maintain the power balance. Fig. 10 depicts the DC-link voltage, the battery voltage and the PV voltage at each mode. The PV voltage is operating at 57V according to the MPPT and the battery voltage is nearly constant at the rated voltage of 48V. A small change in the battery voltage is observed with the variations of the SOC. Despite the power changes, the DC-link voltage is constant at 110V, however, negligible overshoot is observed at the transition times t = 15 sec, t = 30 sec and t = 45 sec. The current injection in the grid is presented in Fig. 12. It can be observed that the grid three-phase currents change with the changes in the generation unit; however, the direction of the current flow depends on the power balance mode of the network. A transition is experienced in the grid-side current at t = 30 sec, as the operating modes are changing at that time instant. Grid currents and load currents are given in Fig. 12 and 13, respectively. Currents zooms are provided to show the dynamics of the energy system at the PCC. The load three-phase currents are always constant and independent of the other parameters.  Concerning the control performance, it can be observed a good tracking, for the battery current controller, with a smooth transition between the modes as shown in Fig. 9. Furthermore, the DC-link voltage tracking, shown in Fig. 10, occurs with a fast disturbance rejection at the transitions due to the mode changes.

B. TEST 2
In this experiment, the other four modes are accomplished. From t = 0 sec to t = 15 sec, the grid price is nearly off-peak hour rate. As a result, the tendency is to charge the battery at the rated current and serve the load from the grid. From Fig. 14, it is observed that the PV provides nearly 90W and the grid supplies 45W to the load and 50W to the battery. The battery current is shown in Fig. 15, where it can be observed that the battery is charging at 1A. The DC-link voltage regulation is well achieved as shown in Fig. 16.   The SOC increased from 60% to 60.15% as shown in Fig. 17. In the second scenario, when the grid price is high, the objective is to supply the load mostly from the battery and the PV with less consumption of the grid power. In the ENM, shown in Fig. 14 and 15, the battery discharges at maximum current at 1A and supplies 50W power to the load. Here, the PV power is constant and the grid contribution is minimum. The battery current references (16) and (17) are used for the ECM and the ENM, respectively, and the contribution of the battery and the grid power is regulated by the factor β. In the ENM, the SOC declined at the highest slope from t = 15 sec to t = 30 sec as shown in Fig. 17. From t = 30 sec to t = 45 sec, the DPM is activated as the grid price is between off-peak and peak rates. In this condition, both the battery and the grid supply the load demand using the reference (18), and the selected factor (β) determines the ratio of contribution of battery current, which is nearly 0.7A as shown in Fig. 15. The power flow, in Fig. 14, and the SOC, in Fig. 16, concur with the mode conditions. The lattermost scenario SPM takes place from t = 45 sec to t = 60 sec, where the load variation in t = 45 sec is visible in the system responses and this is the only occasion when the load power is less than the PV power. In this case, the PV has a surplus amount of power, which supplies the load and charges the battery, even though it can inject power to the grid. The amount of the power injection to the grid or the battery charging depends on β as defined in (19). The observation of Fig. 14 shows that the power is injected to the grid and the battery after satisfying the load demand. In this case, the battery charges with 0.7A, and the SOC increases to 60%. From Fig. 16, it can be observed that the DC-link voltage is controlled at 110V and the PV voltage is at its MPPT point at 57V. The battery voltage is nearly 48V, however, the slight changes occur in the battery voltage based on the charge-discharge process reflected by the SOC variations. The three-phase currents, for the grid and the load, are illustrated in Fig. 18 and 19, respectively. Furthermore, zooms are provided to show the dynamics at PCC. It is noticeable that the load currents change at t = 45 sec from 2A to 0.3A as the load power is decreasing to 40W, and at that instant, the current direction is towards the grid. The regulation of the battery current and the DC-link voltage occurs with good performance, especially at the transitions between the modes, as shown in Fig. 15 and 16, respectively.

C. COST ANALYSIS
A simulation is performed to conduct the cost analysis of the microgrid based on the proposed EMS. In this analysis, an example is created to feed a load for 24 hours by assigning values to the characteristics of the load demand, the PV generation, the battery storage and the grid. Energies are calculated based on these characteristics and the cost is evaluated for the microgrid configurations: PV+grid, PV+battery+grid without EMS, and PV+battery+grid with EMS.
The characteristics of the microgrid components are provided in Table 4. The results for power from the PV, battery and grid and cost, of different microgrid configurations, are provided in Table 5. In all configurations, the load demand is greater than the PV power generation, and the PV power and cost are constant. In the PV+Grid configuration, the load demand is met by the grid, where the grid cost depends on the three price rates during the 24 hours and the total cost is $72.73. In the PV+Battery+Grid configuration, without the EMS, the load demand is met by the PV, the battery and the remaining power is from the grid. In this configuration, the grid operates during the 24 hours and its power cost is calculated using the three price rates given in Table 3. It can be observed that its total cost ($76.13) increased compared to the previous configuration due to the operational cost of the battery and the grid cost calculated using three price rates. For the same configuration, with the proposed EMS, the total cost is reduced to $70.63 because the battery is operated during the on-peak rate price of the grid. By decreasing the optimization factor (β), the contribution of the battery is reduced from 120 kWh to 90 kWh, the extra power, required to meet the demand, is extracted from the grid during standard and off-peak rates, and the total cost is reduced to $69.97. These results show that the optimization factor contributes to the reduction of battery usage and the cost of the power purchase from the grid.

VI. CONCLUSION
An experimental microgrid is implemented and operated using an EMS algorithm that takes into consideration the battery storage status, the grid power availability and the grid price. The EMS includes eight power balance modes with options of self-power generation and power transfer with the grid. The EMS response is enhanced by a dynamic power flow between the battery and the grid based on the grid price using a fuzzy logic system. The control system for the battery current and the DC-link voltage is performing well, especially at the transitions between the modes. Experiments are carried out for different solar profiles, battery status, and grid prices and provided good responses with smooth transitions between the modes. This experimental microgrid, and its EMS, can be used as a small-scale platform to study energy systems in residential and commercial applications. Future works may include the use of artificial intelligence tools such as adaptive neuro-fuzzy inference system (ANFIS) and bio-inspired optimization algorithms to find the optimum values for current references. Furthermore, it will be beneficial to add references for the reactive power in order to deal with abnormal conditions such as voltage dip and faults in the grid. The energy management system can be enhanced by integrating prediction techniques for solar irradiance and the load demand for load scheduling and minimizing a cost function related to the energy price and gas emissions.