Control and EMS of a Grid-Connected Microgrid with Economical Analysis

Recently, significant development has occurred in the field of microgrid and renewable energy systems (RESs). Integrating microgrids and renewable energy sources facilitates a sustainable energy future. This paper proposes a control algorithm and an optimal energy management system (EMS) for a grid-connected microgrid to minimize its operating cost. The microgrid includes photovoltaic (PV), wind turbine (WT), and energy storage systems (ESS). The interior search algorithm (ISA) optimization technique determines the optimal hour-by-hour scheduling for the microgrid system, while it meets the required load demand based on 24-h ahead forecast data. The control system consists of three stages: EMS, supervisory control and local control. EMS is responsible for providing the control system with the optimum day-ahead scheduling power flow between the microgrid (MG) sources, batteries, loads and the main grid based on an economic analysis. The supervisory control stage is responsible for compensating the mismatch between the scheduled power and the real microgrid power. In addition, this paper presents the local control design to regulate the local power, current and DC voltage of the microgrid. For verification, the proposed model was applied on a real case study in Oshawa (Ontario, Canada) with various load conditions.


Introduction
The main goals of sustainability in the energy system are economic operation, reliability, and environmental impact.Recently, the concept of microgrid (MG) and its applications have become important topics.MG is a small grid that can aggregate conventional generators, renewable energy systems (RESs), and energy storage systems (ESS) along with different loads, to form a self-sufficient and flexible system [1][2][3].MG can operate in grid-connected mode or in islanded mode (i.e., for remote areas and in case of grid failure) [4].One of the main advantages of the MG technology is that it can supply the customers with the electricity demand and guarantee the reliability and intelligence of the power system.
There are various topologies and designs for MGs in the literature.An AC MG is the standard choice for MG designers [5][6][7] due to the flexibility to transform AC voltage level into other levels, in addition to the majority of the loads being AC type.Nowadays, due to the increase of using DC loads, DC MGs have been created due to their advantages in terms of efficiency and cost reduction [8][9][10].However, to reduce the amount of multiple conversion stages and to connect the AC Energies 2018, 11, 129 2 of 21 and DC sources and loads in a efficient/economic way, AC/DC MGs have become an ideal choice to connect the MGs [11].
There are many challenges that face microgrids operation.The first challenge is to minimize the operational cost of the MG.Secondly, the intermittency of RESs such as photovoltaic (PV) and wind turbine (WT) because of the weather variation which may cause power imbalance and power-quality problems.Therefore, the decision makers are focusing on finding a solution to make the MG operate in a stable and economic way.
To operate the MG in an economic and reliable manner there are two steps to be considered.The first is to select the best connection to the physical model components, which include RES, ESS, loads, grid components (i.e., transformers, transmission lines and circuit breakers) and power converters which connect all the system components together [12].The second step is to design the suitable control system to ensure the stability, reliability, and economic operation of the MG.The proposed control system consists of two parts: scheduling and control.
The energy management system (EMS) plays a key role in controlling the generation and/or flow of power in microgrids and thus minimizes the operating cost.EMS controls the power flow in the MG based on optimal cost and provides the scheduled, reference values to the local controller of the MG.The power scheduling problem to provide reference values to the local controllers has been studied before [12][13][14].However, they focused only on the action of the current values, and also did not take into consideration the cost minimization [15].Reference [16] suggests that the first priority for load demand is to be supplied from the MG sources as the utility grid will be the final choice.They did not consider market electricity prices.Other papers have focused on the off-line scheduling of the power flow of MG.But they do not consider the mismatch between the scheduled power based on the forecasted data profile and the dynamic operation of the control devices and the generated power profiles [17][18][19].
Many optimization algorithms have been proposed to solve the cost minimization problem.These methods include game theory [20], mixed integer linear programming (MILP) [21], and heuristic optimization methods [22].Heuristic optimization algorithms are among the most common techniques used by researchers due to: simplicity, flexibility, not relying on derivativeness, and the ability of achieving the near-optimal value for the fitness function.There are several types of heuristic algorithms that are used in EMS such as genetic algorithm (GA), simulated annealing algorithm (SA), cuckoo search algorithm (CSA), particle swarm optimization (PSO) and interior search algorithm (ISA).Ref. [23] offers a comparison among these methods and concludes that ISA is the best heuristic optimization technique to solve the cost minimization problem.
Several control models consider RES as non-dispatchable resources, and therefore, the ESS is used to balance the shortage between the generation and the demand [24,25].They neglect the feed-in-tariff (FIT) constraint of the main grid which imposes a limit for purchasing power from any MG.Therefore, if the generated power from the MG is higher than these limits, the RES should reduce the generated power to keep the system balanced.The proposed control method can work in two operating strategies: grid interactive mode and grid non-interactive mode to maintain system stability.The grid non-interactive mode requires that each RES works as a non-dispatchable supply which is useful if the MG's generated power is within the main grid constraints.The other mode, grid interactive is used in large MGs.It considers each RES as a dispatchable supply, which means that the RES can be controlled depending on the system objectives and constraints.In this paper, a small MG is proposed, therefore the MG operates in non-interactive mode, although the control system is designed to work for both operating strategies.This paper proposes an economic operating strategy of MGs to minimize the operating cost based on 24-h ahead forecast data.The EMS is responsible for predicting the day ahead generated power and load demand based on wavelet neural network (WNN) method.In addition, the optimal power flow is calculated based on economic analysis using heuristic optimization method.It presents a local control strategy to control the voltage and power of the MG and to enhance the stability of the system in the dynamic mode.Supervisory control is integrated to the proposed control model to compensate the mismatch between the scheduled power flow and the real power flow by adjusting the reference power of the ESS.
The paper is organized as follows: Section 2 explains the MG structure and operation.Section 3 describes the case study.Section 4 provides the simulation results of the proposed model.Section 5 summarizes the main outcomes of this paper.

Microgrid Structure and Operation
The proposed MG is shown in Figure 1, which consists of a WT, PV generator, battery-based ESS and the load demand.The MG works in grid-connected mode.
As mentioned before, this research proposes an AC/DC MG to reduce the number of conversion stages.The main grid is connected to the AC bus, so it controls the voltage and frequency in the AC bus, and manages any unbalance between the generated and consumed power.On the other hand, the distributed energy resources (DERs) are connected to the DC bus, and because of the variation of the generated power the DC bus must be regulated by the local controller.In this case, DC loads can be connected to the DC bus and AC loads can be connected to the AC bus.The power can be transferred between AC and DC buses by a bidirectional converter.compensate the mismatch between the scheduled power flow and the real power flow by adjusting the reference power of the ESS.The paper is organized as follows: Section 2 explains the MG structure and operation.Section 3 describes the case study.Section 4 provides the simulation results of the proposed model.Section 5 summarizes the main outcomes of this paper.

Microgrid Structure and Operation
The proposed MG is shown in Figure 1, which consists of a WT, PV generator, battery-based ESS and the load demand.The MG works in grid-connected mode.
As mentioned before, this research proposes an AC/DC MG to reduce the number of conversion stages.The main grid is connected to the AC bus, so it controls the voltage and frequency in the AC bus, and manages any unbalance between the generated and consumed power.On the other hand, the distributed energy resources (DERs) are connected to the DC bus, and because of the variation of the generated power the DC bus must be regulated by the local controller.In this case, DC loads can be connected to the DC bus and AC loads can be connected to the AC bus.The power can be transferred between AC and DC buses by a bidirectional converter.The EMS sends the scheduled reference power to the controllers to control the power flow in the MG based on the optimization algorithm.These reference values could be defined by two types of operation (grid-interactive or grid non-interactive strategy) [26].In grid non-interactive mode, the RESs follow the maximum power point tracking (MPPT) algorithm set point and do not take into consideration the scheduled reference power from the EMS.Otherwise, when in grid-interactive mode the RES will follow the EMS's reference power after being adjusted by the supervisory control.
With respect to Ontario's FIT program, the utility grid has a power limit to accept power from an external MGs.If there is any surplus power from a MG and its transferred power to the main utility grid has reached its maximum limit, the MG will work in the grid-interactive strategy to balance the power in the power system.
The MG configuration as shown in Figure 2 consists of three parts: (1) EMS which gives the day-ahead scheduled power; (2) Design of the local control model to control the power and voltage of the entire system to satisfy the system stability; and The EMS sends the scheduled reference power to the controllers to control the power flow in the MG based on the optimization algorithm.These reference values could be defined by two types of operation (grid-interactive or grid non-interactive strategy) [26].In grid non-interactive mode, the RESs follow the maximum power point tracking (MPPT) algorithm set point and do not take into consideration the scheduled reference power from the EMS.Otherwise, when in grid-interactive mode the RES will follow the EMS's reference power after being adjusted by the supervisory control.
With respect to Ontario's FIT program, the utility grid has a power limit to accept power from an external MGs.If there is any surplus power from a MG and its transferred power to the main utility grid has reached its maximum limit, the MG will work in the grid-interactive strategy to balance the power in the power system.
The MG configuration as shown in Figure 2 consists of three parts: (1) EMS which gives the day-ahead scheduled power; (2) Design of the local control model to control the power and voltage of the entire system to satisfy the system stability; and (3) Adjusting the reference power using the supervisory control.
(3) Adjusting the reference power using the supervisory control.

EMS (Day-Ahead Scheduling)
This part discusses the EMS strategy that used in the proposed MG.EMS is responsible for providing the control system with the optimum day-ahead scheduling power flow between the MG sources, batteries, loads and the main grid based on an economic analysis.The EMS consisted of two parts: the hourly load and weather forecasting for the day-ahead and the optimal power flow in the MG based on heuristic optimization technique.

Weather and Load Forecasting
The day-ahead forecasting stage provides the optimization stage with the necessary input data.The forecasting tool predicts the load demand and the weather conditions (irradiance and wind speed which are the input parameters to the PV and WT models respectively).The more accurate the forecasting system the more efficient the EMS.There are many techniques have been used in the

EMS (Day-Ahead Scheduling)
This part discusses the EMS strategy that used in the proposed MG.EMS is responsible for providing the control system with the optimum day-ahead scheduling power flow between the MG sources, batteries, loads and the main grid based on an economic analysis.The EMS consisted of two parts: the hourly load and weather forecasting for the day-ahead and the optimal power flow in the MG based on heuristic optimization technique.

Weather and Load Forecasting
The day-ahead forecasting stage provides the optimization stage with the necessary input data.The forecasting tool predicts the load demand and the weather conditions (irradiance and wind speed which are the input parameters to the PV and WT models respectively).The more accurate the forecasting system the more efficient the EMS.There are many techniques have been used in the forecasting stage to minimize the forecasting error [27][28][29].One of the most accurate techniques is WNN which has been used to predict the day-ahead load demand and weather conditions [30]. Figure 3 illustrates the results from the forecasting model.
forecasting stage to minimize the forecasting error [27][28][29].One of the most accurate techniques is WNN which has been used to predict the day-ahead load demand and weather conditions [30]. Figure 3 illustrates the results from the forecasting model.

Economic Power Flow Optimization
To determine the optimal output power set points for DERs, an efficient optimization method has been proposed.The purpose of the EMS is to minimize the operating cost.Thus, it aims to purchase the power from the grid during the off-peak time, when electricity prices are at their lowest, to store the surplus power in the ESS.This power can be used again to cover the shortage from the MG during the high peak period.On the other hand, if the load demand is smaller than the MG generated power, the surplus power from the RES and ESS will be sold to the grid during high peak periods.The ISA has been used to minimize the operating cost.It chooses the best period to sell/purchase the power to/from the grid and to charge/discharge the ESS to minimize the total operating cost during the day.
As shown in Figure 2, the input parameters to the optimization method are generated power of the PV and WT, load demand, state of charge (SOC) of the battery, the grid tariff and system constraints.The output variables of the ISA are the scheduled power for the next day based on the minimum operating cost.The system constraints and the objectives are as follows:

Economic Power Flow Optimization
To determine the optimal output power set points for DERs, an efficient optimization method has been proposed.The purpose of the EMS is to minimize the operating cost.Thus, it aims to purchase the power from the grid during the off-peak time, when electricity prices are at their lowest, to store the surplus power in the ESS.This power can be used again to cover the shortage from the MG during the high peak period.On the other hand, if the load demand is smaller than the MG generated power, the surplus power from the RES and ESS will be sold to the grid during high peak periods.The ISA has been used to minimize the operating cost.It chooses the best period to sell/purchase the power to/from the grid and to charge/discharge the ESS to minimize the total operating cost during the day.
As shown in Figure 2, the input parameters to the optimization method are generated power of the PV and WT, load demand, state of charge (SOC) of the battery, the grid tariff and system constraints.The output variables of the ISA are the scheduled power for the next day based on the minimum operating cost.The system constraints and the objectives are as follows:

Objective Function
The objective function of the EMS is used to determine the total operating cost of the proposed MG.ISA has been presented to minimize this cost based on optimal economic power flow.The cost function can be determined as follows: Energies 2018, 11, 129 6 of 21 The time of the optimization method is T (24-h) with time interval t (i.e., 1 h).The input variables and parameters of the optimization model is presented in Table 1.In order to minimize the objective function, ISA optimization choose the optimum set point for the PV, WT and ESS.Also, it decides when exactly the power will be purchased/sold from/to the grid.

System Constraints
To solve the optimization problem, the following constraints and limits should be considered in the optimization process.These technical power limits control the state variables of the optimization method.
(a) System Power Balance Power balance equation identify the relationship between the generated power and load power in the MG at each time interval: There are losses on the MG due to converter and transmission lines etc.But these losses are not considered as the supervisor controller adjusts any mismatch between the output power of the EMS and the dynamic model.

(b) DER Constraints
To maintain the stability of system, the output power of the DER must be within the convenient limits.Also, the charging or discharging power of the battery and the amount of stored energy must be limited to prevent any damage and to maximize the lifetime of the battery:

(c) Heuristic Optimization Technique
Heuristic optimization technique is one of the powerful optimization methods to determine the optimal power flow.ISA is one of the heuristic optimization techniques which carry out a trade off between accuracy and optimization time range.ISA is a new, fast, reliable, and flexible method given in Ref. [31].The state variables of ISA are the output power of each DER of the MG at each time interval for one day.The flowchart of ISA optimization is illustrated in Figure 4.

(c) Heuristic Optimization Technique
Heuristic optimization technique is one of the powerful optimization methods to determine the optimal power flow.ISA is one of the heuristic optimization techniques which carry out a trade off between accuracy and optimization time range.ISA is a new, fast, reliable, and flexible method given in Ref. [31].The state variables of ISA are the output power of each DER of the MG at each time interval for one day.The flowchart of ISA optimization is illustrated in Figure 4.  ISA is described in the following steps [32]: Step 1: generate the initial population of the input variables x j i randomly within the given limits.Then calculate the fitness value f (x j i ) for these chosen variables, where j is the iteration number and i is the population number.Step 2: find the minimum fitness value at each iteration and the element which has the minimum fitness value is called the current best (x j gb ).
Step 3: The other elements are divided randomly into two groups, composition and mirror group.The elements go to the composition group when r 1 ≥ α, else they go to the mirror group.
Where r 1, r 2 , r 3 and r n between (0,1) and they are a random number, α is a parameter which is tuned with respect to ref. [30].
Step 4: For the elements in composition group, change the elements randomly within the range of limited constraint (lower bounds (LB) and upper bounds (UB)): Step 5: In the mirror group, put a mirror between each element and the current best element randomly.Use Equation ( 8) to evaluate the position of the mirror: The new element location depends on the location of the mirror.Use Equation ( 9) to calculate it: Step 6: Search around the current best location using Equation (10) to get a new current best location: where λ is a scale factor and it is equal 0.01 × (UB − LB).
Step 7: Calculate the fitness function of the new and old element.If the fitness value of the new element is less than the old one, replace it, else keep the old element.
Step 8: Repeat these steps from 2 to 7 until reach to the maximum number of iterations.

Local Controllers
The proposed MG is AC/DC hybrid system which works in grid-connected mode as shown in Figure 2. Therefore, the DC and AC bus voltages must be controlled to protect the loads from voltage variations.In grid-connected mode, the AC bus voltage and frequency are fixed by the grid as mentioned earlier.The local controller controls the local power, current and DC voltage of the MG where the purpose of the local controller is to follow the set point of the supervisory controller.
There are two types of operation for DERs, grid-interactive and non-interactive.The operating mode depends on the case study and the operating conditions.If the surplus power generated from the MG is more than the FIT program power limits, the sold power must not exceed the grid active power constraints.In this case, the MG will operate in the grid-interactive mode.The generated power from RES does not follow the MPPT algorithms and follows the scheduled power reference by EMS, to insure the system stability.In the non-interactive operating mode, the generated power from the RESs follows the MPPT algorithm to ensure extracting the maximum generated power from each RES.In this paper, the proposed model of RESs is smaller than the active power limits of the grid, therefore, the RESs operate in non-interactive mode.
There are four converters in the proposed model.Three converters connect the RES and ESS with the DC bus and a DC/AC bidirectional converter (grid side converter) connects the DC bus to the AC bus.
The grid side converter is responsible for two tasks: (1) to regulate the DC bus voltage to 500 V and (2) to synchronize the MG components with the main grid at the point of common coupling using phase locked loop (PPL) as shown in Figure 5.The other three converters are responsible for: (1) controlling the power generated from each DER; and (2) connecting the DERs to the DC bus by boosting the DC voltage or converting the AC voltage to DC voltage.Also, the ESS converter is a bidirectional converter which controls the charging and discharging power of the battery according to the predefined reference set point.  Figure 6 shows the block diagram of the WT generation system using a DC/DC boost converter with a three-phase diode rectifier [33], which is used to connect the WT generator with the DC bus and to control the power output from the permanent magnet synchronous generator (PMSG).Using this converter reduces the cost of the system by reducing the number of conversion stages in addition to the simplicity of its control.Three variables should be controlled: the DC bus voltage, the generator active power, and the grid reactive power.The DC bus voltage and the grid reactive power are controlled by the inverter as shown in Figure 5.The generated power of the PMSG is controlled by regulating the duty cycle (D) of the boost converter via a proportional integrator (PI) controller.Ref. [34] presents the MPPT algorithm for the WT generator.Figure 6 shows the block diagram of the WT generation system using a DC/DC boost converter with a three-phase diode rectifier [33], which is used to connect the WT generator with the DC bus and to control the power output from the permanent magnet synchronous generator (PMSG).Using this converter reduces the cost of the system by reducing the number of conversion stages in addition to the simplicity of its control.Three variables should be controlled: the DC bus voltage, the generator active power, and the grid reactive power.The DC bus voltage and the grid reactive power are controlled by the inverter as shown in Figure 5.The generated power of the PMSG is controlled by regulating the duty cycle (D) of the boost converter via a proportional integrator (PI) controller.Ref. [34] presents the MPPT algorithm for the WT generator.Figure 6 shows the block diagram of the WT generation system using a DC/DC boost converter with a three-phase diode rectifier [33], which is used to connect the WT generator with the DC bus and to control the power output from the permanent magnet synchronous generator (PMSG).Using this converter reduces the cost of the system by reducing the number of conversion stages in addition to the simplicity of its control.Three variables should be controlled: the DC bus voltage, the generator active power, and the grid reactive power.The DC bus voltage and the grid reactive power are controlled by the inverter as shown in Figure 5.The generated power of the PMSG is controlled by regulating the duty cycle (D) of the boost converter via a proportional integrator (PI) controller.Ref. [34] presents the MPPT algorithm for the WT generator.Figure 7 illustrates the PV connection to the MG.A DC/DC boost converter of PV system has two tasks [35]: (1) changing the DC voltage level and (2) ensuring that the PV panel works at maximum power point (MPP).The MPPT algorithm determine the maximum power and voltage value at this point.The output voltage of the PV system is regulated using a PI controller and hence control the output power by adjusting the duty cycle of the pulse width modulation (PWM).The control design for the ESS's converter is illustrated in Figure 8.A bidirectional buck/boost converter is designed to control the charging/discharging power of the battery.The converter consists of four switches with a PWM control circuit.When S1 is off and S2 is on, the converter works in buck mode.In this case, power is transferred from the DC bus to charge the battery.On the other hand, when S1 is switched on and S2 switched off, the converter works in boost mode and power is discharged from the battery and transferred to the DC bus.There are two control loops to control the charging/discharging power of the battery.The reference power, which is obtained from the supervisory controller, is regulated by a proportional integrator (PI) controller.A second PI controller is used to regulate the current of the battery to protect the battery.

Supervisory Controller
The main purpose of the supervisory controller is to compensate the mismatch between the main power transferred from/to the grid ( ) and scheduled power obtained from EMS ( ).Therefore, it modifies incremental values ( ∆ , ∆ ) to the scheduled power from the EMS ( ). Figure 9 shows the schematic diagram of the supervisor control.In non-interactive mode, each RES employs its respective MPPT algorithm, thus the supervisory controller only Battery The control design for the ESS's converter is illustrated in Figure 8.A bidirectional buck/boost converter is designed to control the charging/discharging power of the battery.The converter consists of four switches with a PWM control circuit.When S1 is off and S2 is on, the converter works in buck mode.In this case, power is transferred from the DC bus to charge the battery.On the other hand, when S1 is switched on and S2 switched off, the converter works in boost mode and power is discharged from the battery and transferred to the DC bus.There are two control loops to control the charging/discharging power of the battery.The reference power, which is obtained from the supervisory controller, is regulated by a proportional integrator (PI) controller.A second PI controller is used to regulate the current of the battery to protect the battery.Figure 7 illustrates the PV connection to the MG.A DC/DC boost converter of PV system has two tasks [35]: (1) changing the DC voltage level and (2) ensuring that the PV panel works at maximum power point (MPP).The MPPT algorithm determine the maximum power and voltage value at this point.The output voltage of the PV system is regulated using a PI controller and hence control the output power by adjusting the duty cycle of the pulse width modulation (PWM).The control design for the ESS's converter is illustrated in Figure 8.A bidirectional buck/boost converter is designed to control the charging/discharging power of the battery.The converter consists of four switches with a PWM control circuit.When S1 is off and S2 is on, the converter works in buck mode.In this case, power is transferred from the DC bus to charge the battery.On the other hand, when S1 is switched on and S2 switched off, the converter works in boost mode and power is discharged from the battery and transferred to the DC bus.There are two control loops to control the charging/discharging power of the battery.The reference power, which is obtained from the supervisory controller, is regulated by a proportional integrator (PI) controller.A second PI controller is used to regulate the current of the battery to protect the battery.

Supervisory Controller
The main purpose of the supervisory controller is to compensate the mismatch between the main power transferred from/to the grid ( ) and scheduled power obtained from EMS ( ).Therefore, it modifies incremental values ( ∆ , ∆ ) to the scheduled power from the EMS ( ). Figure 9 shows the schematic diagram of the supervisor control.In non-interactive mode, each RES employs its respective MPPT algorithm, thus the supervisory controller only

Supervisory Controller
The main purpose of the supervisory controller is to compensate the mismatch between the main power transferred from/to the grid (P Mes grid ) and scheduled power obtained from EMS (P sch grid ).Therefore, it modifies incremental values (∆P RES , ∆P bat ) to the scheduled power from the EMS (P sch PV P sch WT P sch bat ). Figure 9 shows the schematic diagram of the supervisor control.In non-interactive mode, each RES employs its respective MPPT algorithm, thus the supervisory controller only modifies the reference set point for the battery.On the other hand, in grid-interactive mode, the supervisory controller dictates the reference set points for each RES and ESS.
modifies the reference set point for the battery.On the other hand, in grid-interactive mode, the supervisory controller dictates the reference set points for each RES and ESS.The input values to the supervisory controller are the scheduled power from the EMS ( ) and the measured values from the MG ( ).The output values are the reference set points for the MG which are in case of grid-interactive mode and in case of grid non-interactive mode.
The difference between and represents the deviation between the scheduled power and MG power: When is positive this means that the purchased power from the grid is greater than the scheduled power therefore, the charging of the battery should be minimized and the generated power from each RES should be increased to regulate this increase in the grid power.This error is divided between all RESs and ESS according to the maximum power limit for the RESs and SOC of the battery.If the SOC of the battery exceeds the battery constraints, there will not be any change in the battery reference set point.In this way, the supervisory controller is used to connect EMS with the MG by regulating any mismatch between the scheduled power and the MG power flow by adjusting the reference power of the DERs.

Case Study
The selected MG is applied to a variable load which is a real case study of a set of homes located in Oshawa (Ontario, Canada) as shown in Figure 3a.The historical data which is required for forecasting is real data from Ontario's independent electricity system operator (IESO) [36].As discussed in the previous section, the proposed MG consists of PV, WT and ESS.The rating and the operational & maintenance cost (O&M) of each RES unit is illustrated in Table 2. Also, the electricity time of use during a typical weekday in the winter season in Oshawa is given in Table 3 [37].The initial conditions, lower and upper limits of SOC (%) of the battery are set as 50%, 10%, and 90%, respectively.The input values to the supervisory controller are the scheduled power from the EMS (P sch PV P sch WT P sch bat P sch grid ) and the measured values from the MG (P Mes grid SOC).The output values are the reference set points for the MG which are P The difference between P Mes grid and P sch grid represents the deviation between the scheduled power and MG power: When ε is positive this means that the purchased power from the grid is greater than the scheduled power therefore, the charging of the battery should be minimized and the generated power from each RES should be increased to regulate this increase in the grid power.This error is divided between all RESs and ESS according to the maximum power limit for the RESs and SOC of the battery.If the SOC of the battery exceeds the battery constraints, there will not be any change in the battery reference set point.In this way, the supervisory controller is used to connect EMS with the MG by regulating any mismatch between the scheduled power and the MG power flow by adjusting the reference power of the DERs.

Case Study
The selected MG is applied to a variable load which is a real case study of a set of homes located in Oshawa (Ontario, Canada) as shown in Figure 3a.The historical data which is required for forecasting is real data from Ontario's independent electricity system operator (IESO) [36].As discussed in the previous section, the proposed MG consists of PV, WT and ESS.The rating and the operational & maintenance cost (O&M) of each RES unit is illustrated in Table 2. Also, the electricity time of use during a typical weekday in the winter season in Oshawa is given in Table 3 [37].The initial conditions, lower and upper limits of SOC (%) of the battery are set as 50%, 10%, and 90%, respectively.

PV Wind
Min limit (kW) 0 0 Max limit (kW) 100 60 O&M Cost ($/kW) [2] 0.01 0.01 In this paper, there are two case studies which have been selected to illustrate the objectives of using EMS and supervisory controller in regulating the power flow in economic way.Also, these case studies are prepared with and without the EMS to show the advantage of EMS in saving the operating cost.

Case 1. Low Demand Profile
In this case, the load demand is less than or equal to the generated power from the DERs of the MG, therefore there is enough power to supply the load.The main grid may sell/purchase power to/from the MG depending on the operating strategy of the system (with or without EMS).Without EMS all the surplus power will be sold to the main grid, but with EMS the MG participates in the open market, purchasing/selling power from/to the utility grid depending on the cost minimization.

Case 2. High Demand Profile
In this case, the load demand is higher than the generated power from DERs of the MG during some periods of the day.So, the power shortage is supplied from the main grid.The difference between working with or without EMS is the time of purchasing the power and the charging/discharging period of the battery to reduce the operating cost.

Results
In this section the results of the proposed system are presented.To ensure the accuracy of the proposed model, the generated power curves for the RESs in the scheduling stage have been determined based on a powerful forecasting tool.Figure 10 presents the generated power profile of PV and WT from the MG and the scheduled power from the EMS.The objectives of the proposed model are presented using these two case studies by comparing the results with and without the EMS.In this paper, there are two case studies which have been selected to illustrate the objectives of using EMS and supervisory controller in regulating the power flow in economic way.Also, these case studies are prepared with and without the EMS to show the advantage of EMS in saving the operating cost.

Case 1. Low Demand Profile
In this case, the load demand is less than or equal to the generated power from the DERs of the MG, therefore there is enough power to supply the load.The main grid may sell/purchase power to/from the MG depending on the operating strategy of the system (with or without EMS).Without EMS all the surplus power will be sold to the main grid, but with EMS the MG participates in the open market, purchasing/selling power from/to the utility grid depending on the cost minimization.

Case 2. High Demand Profile
In this case, the load demand is higher than the generated power from DERs of the MG during some periods of the day.So, the power shortage is supplied from the main grid.The difference between working with or without EMS is the time of purchasing the power and the charging/discharging period of the battery to reduce the operating cost.

Results
In this section the results of the proposed system are presented.To ensure the accuracy of the proposed model, the generated power curves for the RESs in the scheduling stage have been determined based on a powerful forecasting tool.Figure 10 presents the generated power profile of PV and WT from the MG and the scheduled power from the EMS.The objectives of the proposed model are presented using these two case studies by comparing the results with and without the EMS.

Results for Case 1
Figure 11 shows the output results from the proposed MG with and without EMS in the scheduling stage.In addition, it shows the purchased and sold power from/to the main grid during the day.
In the operation without EMS, the demand is supplied from the RESs, and the residual power charges the battery until it reaches its maximum limit.Any surplus power will be sold to the main grid to maintain system stability.Also, if the generated power from the RESs is lower than the load demand, the battery will supply this shortage as shown in Figure 11 (right side).In case of EMS, all the DERs and the main grid are participating in supplying the load, according to an optimization technique.This mean that the MG purchases/sells the power from/to the main grid depending on the cost function as shown in Figure 11 (left side).
Figure 12 represents the final output results from the proposed MG with and without EMS.In addition to comparing the scheduled power obtained by the EMS and the measured power obtained from the MG system.Curves were arranged as follows: grid power, battery power, load power and DC bus voltage.
The output results obtained by the first strategy (without EMS) are shown in Figure 12 (right side).In the period (00:00-9:00) the demand is higher than the generated power from the RESs, therefore the battery discharges the power to cover this shortage to prevent purchasing power from the grid.From 09:00 to15:00, the RESs generate more power than the load consumption, so the surplus power is stored in the battery until reaching the maximum limit.Any residual power is sold to the grid.In the period (15:00-20:00), the load increased so the power shortage is covered by the battery.Finally, the period from (20:00 to 22:00) and from (22:00 to 23:00) there is a variation on the wind speed, thus a variation in the WT generated power.Therefore, the battery charges and then discharges again to cover the demand.This means that the priority for this strategy is to reduce the amount of power purchased from the grid.
On the other hand, the results obtained by the proposed strategy (with EMS) show that the MG purchases power from the grid during off-peak period (00:00-07:00 and 19:00-23:59) to supply the load and store the generated power from RESs in the battery.During on-peak and medium-peak periods, all the stored power and the surplus power is sold to the grid as shown in Figure 12 (left side).Table 4 shows the operating cost and the electricity trade for both strategies.From the obtained results, the operating cost with the EMS shows the best results.
The results also show the mismatch between the scheduled grid power and MG grid power, as well as the task of supervisory control in adjusting the battery reference power to reduce purchased power from the grid.The obtained results show the power of the local control system in following the reference set points at any time and in regulating the DC bus voltage at a fixed value.

Results for Case 2
In this case, the demanded load is higher than the generated power of the MG, thus it is required to purchase power from the main grid during some periods of the day.The variable profiles shown in Figure 13 are like the variables used in case 1.Based on the results obtained from the MG with and without EMS, there is a significant difference between the two strategies in purchasing and selling the power from the grid during the day.The purchased power from the grid in the first strategy (without EMS) depends on the load demand, but in the proposed strategy (with EMS) it depends on the electricity price during the day.
The output power from the scheduling stage is presented in Figure 14 with and without EMS.It illustrates the purchased/sold power from/to the main grid during the day.In the first strategy, the MG uses the battery and the RESs to supply the load and any shortage is supplied from the grid.After the SOC of the battery reaches the minimum limit, the battery starts to charge so more power will be purchased from the grid, until battery can be charged from the RESs.Therefore, the MG absorbs power from the grid without taking into consideration the electricity price during the day.In the proposed strategy (with EMS) the battery is charged by the RESs during price periods and discharges during the high price periods.This means that the MG purchases more power from grid during the off-peak periods than the on-peak periods to reduce the operating cost.Also, if there is any surplus of generated power that is not required to serve the load demand, it will be sold to the grid with high price as shown in Figure 13 (left side).
In the same time, the results show the advantages of supervisory controller in adjusting the battery reference set point depending on the mismatch between the measured power from the grid and the grid scheduled power as illustrated in Figure 13.In addition, Figure 13 shows that the DC bus voltage is fixed at a certain value because of the powerful of the local controller.Table 4 gives the electricity trade results for both case studies, with and without EMS, and the advantages of using EMS.
In this way, the EMS uses an optimization method to reduce the operational cost by controlling the charging/discharging periods of the battery to manage the unbalance between the RES generated power and the load demand, based on the electricity price.Also, the results show how the supervisory controller adjusts the mismatch between the main grid power and the grid scheduled power by adjusting the reference set point for the battery in case of non-interactive operation.In case of grid-interactive operation, the supervisory control adjusts the reference set points for both RESs and battery as shown in Figure 9.

Conclusions
Using the EMS as part of the control design of a grid-connected microgrid can minimize the total operating cost.The proposed EMS has been implemented to ensure the best management of power for the MG sources based on a powerful heuristic optimization method (ISA).The optimization model is flexible so that different DGs can be added to the MG system.Supervisory control has been added to the control model to adjust any deviation between the main grid power and the scheduled reference power by modifying the reference set-point of the battery power given by the EMS.This paper presents a full local control design for the proposed system.The local controller controls the local power, current and DC voltage of the MG where the purpose of the local controller is to follow the setting point of the supervisor controller.The developed methodology is applied to a real case study of a set of homes located in Oshawa, Ontario, Canada.All the data required such as load demand, weather conditions for the day-ahead scheduling is forecasted using WNN which is not in the scope of this paper.Two cases of operating strategies have been used to verify the objectives of the proposed model.The operation of MG is tested with and without EMS to verify the advantages of using EMS in the control method.The proposed Control design solves the problem that faces the stockholders which is how to design a microgrid in a reliable and economical manner.

Figure 2 .
Figure 2. Energy management system (EMS) and control for the proposed MG.WNN: wavelet neural network; ISA: interior search algorithm.

Figure 2 .
Figure 2. Energy management system (EMS) and control for the proposed MG.WNN: wavelet neural network; ISA: interior search algorithm.

Energies 2018 ,
11, 129 9 of 20 bidirectional converter which controls the charging and discharging power of the battery according to the predefined reference set point.

Figure 5 .
Figure 5.Control design of the grid side converter.PWM: pulse width modulation; PLL: phase locked loop.

Figure 5 .
Figure 5.Control design of the grid side converter.PWM: pulse width modulation; PLL: phase locked loop.
controls the charging and discharging power of the battery according to the predefined reference set point.

Figure 5 .
Figure 5.Control design of the grid side converter.PWM: pulse width modulation; PLL: phase locked loop.

Figure 6 .
Figure 6.Control design for the wind turbine (WT) generator.PMSG: permanent magnet synchronous generator; MPPT: maximum power point tracking.

Figure 7
Figure7illustrates the PV connection to the MG.A DC/DC boost converter of PV system has two tasks[35]:(1) changing the DC voltage level and (2) ensuring that the PV panel works at maximum power point (MPP).The MPPT algorithm determine the maximum power and voltage value at this point.The output voltage of the PV system is regulated using a PI controller and hence control the output power by adjusting the duty cycle of the pulse width modulation (PWM).

Figure 6 .
Figure 6.Control design for the wind turbine (WT) generator.PMSG: permanent magnet synchronous generator; MPPT: maximum power point tracking.

Figure 7 .
Figure 7.Control design for PV system.

Figure 7 .
Figure 7.Control design for PV system.

Figure 6 .
Figure 6.Control design for the wind turbine (WT) generator.PMSG: permanent magnet synchronous generator; MPPT: maximum power point tracking.

Figure 7 .
Figure 7.Control design for PV system.
in case of grid-interactive mode and P re f bat in case of grid non-interactive mode.

Figure 10 .
Figure 10.(a,b) The scheduled and measured generation profiles for PV and WT, respectively.

Figure 10 .
Figure 10.(a,b) The scheduled and measured generation profiles for PV and WT, respectively.

Figure 11 .
Figure 11.(a,b) Microgrid scheduled power flow with and without EMS respectively in case 1. (c,d) The purchased/sold power from the grid during the day with and without EMS.

Figure 11 .
Figure 11.(a,b) Microgrid scheduled power flow with and without EMS respectively in case 1. (c,d) The purchased/sold power from the grid during the day with and without EMS.

Figure 12 .
Figure 12.The output variables of the proposed MG with (left side) and without (right side) EMS in case 1.Figure 12.The output variables of the proposed MG with (left side) and without (right side) EMS in case 1.

Figure 12 .
Figure 12.The output variables of the proposed MG with (left side) and without (right side) EMS in case 1.Figure 12.The output variables of the proposed MG with (left side) and without (right side) EMS in case 1.

Figure 13 .
Figure 13.The output variables of the proposed MG with side) and without (right side) EMS in case 2.Figure 13.The output variables of the proposed MG with (left side) and without (right side) EMS in case 2.

Figure 13 .
Figure 13.The output variables of the proposed MG with side) and without (right side) EMS in case 2.Figure 13.The output variables of the proposed MG with (left side) and without (right side) EMS in case 2.

Figure 14 .
Figure 14.(a,b) Microgrid scheduled power flow with and without EMS respectively in case 2. (c,d) The purchased/sold power from the grid during the day with and without EMS.

Figure 14 .
Figure 14.(a,b) Microgrid scheduled power flow with and without EMS respectively in case 2. (c,d) The purchased/sold power from the grid during the day with and without EMS.

Table 1 .
Parameters and variables of the model.WT: wind turbine; ESS: energy storage systems; PV: photovoltaic.

Table 4 .
Electricity trade results for different case studies with and without EMS.

Table 4 .
Electricity trade results for different case studies with and without EMS.