Phase Balancing and Reactive Power Support Services for Microgrids

: Alternating current (AC) microgrids are expected to operate as active components within smart distribution grids in the near future. The high penetration of intermittent renewable energy sources and the rapid electriﬁcation of the thermal and transportation sectors pose serious challenges that must be addressed by modern distribution system operators. Hence, new solutions should be developed to overcome these issues. Microgrids can be considered as a great candidate for the provision of ancillary services since they are more ﬂexible to coordinate their distributed generation sources and their loads. This paper proposes a method for compensating microgrid power factor and loads asymmetries by utilizing advanced functionalities enabled by grid tied inverters of photovoltaics and energy storage systems. Further, a central controller has been developed for adaptively regulating the provision of both reactive power and phase balancing services according to the measured loading conditions at the microgrid’s point of common coupling. An experimental validation with a laboratory scale inverter and a real time hardware in the loop investigation demonstrates that the provision of such ancillary services by the microgrid can signiﬁcantly improve the operation of distribution grids in terms of power quality, energy losses and utilization of available capacity. allow the proper provision of ancillary services by the new inverter. The proposed inverter with new ancillary services capabilities has been validated using experimental tests in a laboratory scale inverter. Thereafter, a real-time simulation was carried out to investigate the e ﬀ ectiveness of the MGCC during an entire day. The results indicate that the proposed solution achieves signiﬁcant beneﬁts for the distribution system operator by enhancing the power quality and e ﬃ ciency and utilization of existing capacity of the distribution grid.


Introduction
Smart grids are proposed to drive forward the traditional electrical grids to a more flexible, secure, reliable and efficient networks. The development of smart grids requires complex frameworks which should be supported by the appropriate infrastructure (e.g., advanced metering, information and communication technology (ICT)). In addition, renewable energy sources (RES) are able to play a key role in the sustainability of future grids. However, their variable and unpredictable nature cannot be easily handled in a global context. Moreover, the electrification of thermal loads and the expected increase of electrical vehicles (EVs) will increase significantly the already rising demand. To satisfy this climbing demand, improvements will be required on the current infrastructure, adding significant costs to the distribution system operator (DSO) and grid owner. Alternating current (AC) microgrids (MGs) are introduced to deal with all these issues since a better coordination among the distributed energy resources (DERs) can be achieved to support the local loads and enable the more efficient utilization of existing infrastructure. advanced capabilities to compensate prosumer asymmetries. This solution requires additional sensors to measure the loading asymmetries at each building. In addition, the buildings that are not equipped with PVs or ESS with enhanced capabilities cannot compensate the asymmetries imposed by their loads. In Reference [27], the authors proposed the measurement of the loading asymmetries at every building within the MG and developed an unbalance current sharing control algorithm to compensate the current unbalances on the loads. The development of such approach requires intense communication traffic since measurements from every building need to be collected. A centralized phase balancing controller is proposed in Reference [28] for low voltage distribution grids. The total asymmetric current of the grid is allocated according to the availability of each inverter using adaptive weights. However, the authors did not consider reactive power compensation. In the literature, there are also sensor-less control approaches for compensating asymmetries [29][30][31]. The authors in Reference [29] propose a novel estimation of the prosumer negative sequence current and then utilize this knowledge to compensate asymmetries at building level using an advanced PV grid tied inverter controller. Further, a sensor-less voltage unbalance compensation scheme is proposed in References [30,31]. The voltage asymmetries are measured locally at every PV or ESS to balance the asymmetries of the MG. However, voltage unbalance compensation is applicable only in islanded operation where the grid impedances are quite higher than in grid connected mode and hence will have greater impact on voltage unbalance.
The contribution of this paper is the development of a novel microgrid central controller (MGCC) (secondary level controller) for fair compensation between reactive power (Q) and phase balancing (PB) at the MG's' PCC. In addition, another contribution of this paper is the development of a new PV/ESS inverter controller to enable the provision of Q and PB ancillary services. The inverters should be able to intentionally deliver reactive power and asymmetrical currents while injecting the active power of the PV or ESS into the grid. The existing solutions in the literature prioritize reactive power support and in case of available capacity by the inverter then it is utilized for phase balancing [24]. Therefore, the compensation of asymmetric currents is limited according to the provision of reactive power support. In this paper a novel sharing algorithm is developed at the local controller for sharing the Q support and PB according to the loading conditions at the MG's PCC. Therefore, the available capacity of each inverter is distributed for each ancillary service according to the loading conditions. The proposed MGCC requires ICT technology to be able to receive measurements from a smart meter installed at the MG's PCC and send the estimated set-points for compensating MG's asymmetries and reactive power to the PV/ESS inverters. Finally, the proposed MGCC and the advanced inverter sharing strategy can bring significant benefits for the distribution system operator regarding its power quality, efficiency and maximization of its capacity through fair provision of Q-PB compensation.
The rest of the paper is organized as follows. The MG architecture is demonstrated in Section 2. Section 3 presents the proposed sharing algorithm and experimental results in a laboratory scale inverter. Section 4 demonstrates the centralized controller and the effectiveness of the solution through a real-time hardware in the loop investigation. The paper concludes in Section 5.

Microgrid Architecture
The work presented in this paper is part of the 3DMicroGrid project, which is funded through the ERANETMED initiative. The main objective of the project is to design and develop a pilot MG by modifying a part of the main campus of the Malta College of Arts, Science and Technology (MCAST). The future pilot MG is illustrated in Figure 1, where it can be seen that it can be separated into four main parts-(A) the energy demand side, (B) the energy generation side, (C) the energy storage side and (D) the MGCC.

A. Energy Demand
The MG demand is actually consisted by the consumption of Blocks D, F and J. A crucial property for the successful implementation and operation of a MG is the capability of shedding loads whenever it is needed (e.g., during islanding and optimal scheduling) [32]. Therefore, all the loads of the MG are Appl. Sci. 2019, 9, 5067 4 of 17 considered to be controllable. This can further provide the opportunity to apply a load categorization on the demand.

B. Energy Generation
An important aspect for granting full autonomy to the MG during islanding conditions is the inclusion of DERs into the system. These can be separated into conventional and renewable generation units. The former includes a 100 kVA diesel generator (DG) which is located in Block J. Note that the DG is utilized here for accommodating the intermittent nature of the renewables and for re-synchronization purposes. The latter represents the existence of PVs on the top of each building with a total rated power of 63 kW peak (21 kW in each building).

C. Energy Storage
The implementation of a flexible microgrid requires the existence of an ESS, which will absorb or provide energy according to the energy needs of the MG. Therefore, an energy storage system of 50 kW and with a usable capacity of 100 kWh is considered to be located in Block D.

D. Microgrid Central Controller (MGCC)
The proposed MGCC is responsible, among others, for the Q and PB compensation at the MG's PCC as shown in Figure 1. A smart meter installed at the PCC sends its measurements to the MGCC using Modbus TCP/IP communication. It should be noted that the use of an independent local area network (LAN) is highly suggested for the communication between MGCC, smart meter and inverters in order to minimize cyber-security threats. The MGCC also requires the knowledge of the real-time availability of each PV or ESS for ancillary services provision in order to allocate the compensated currents. In addition, the same communication protocol is utilized to send to each inverter a sharing constant, which is used by the inverters for fair allocation between Q-PB provision according to the real-time loading conditions and the reference signals for reactive power and negative sequence current.

B. Energy Generation
An important aspect for granting full autonomy to the MG during islanding conditions is the inclusion of DERs into the system. These can be separated into conventional and renewable generation units. The former includes a 100 kVA diesel generator (DG) which is located in Block J. Note that the DG is utilized here for accommodating the intermittent nature of the renewables and for re-synchronization purposes. The latter represents the existence of PVs on the top of each building with a total rated power of 63 kW peak (21 kW in each building).

C. Energy Storage
The implementation of a flexible microgrid requires the existence of an ESS, which will absorb or provide energy according to the energy needs of the MG. Therefore, an energy storage system of 50 kW and with a usable capacity of 100 kWh is considered to be located in Block D.

D. Microgrid Central Controller (MGCC)
The proposed MGCC is responsible, among others, for the Q and PB compensation at the MG's PCC as shown in Figure 1. A smart meter installed at the PCC sends its measurements to the MGCC using Modbus TCP/IP communication. It should be noted that the use of an independent local area network (LAN) is highly suggested for the communication between MGCC, smart meter and inverters in order to minimize cyber-security threats. The MGCC also requires the knowledge of the real-time availability of each PV or ESS for ancillary services provision in order to allocate the compensated currents. In addition, the same communication protocol is utilized to send to each inverter a sharing constant, which is used by the inverters for fair allocation between Q-PB provision according to the real-time loading conditions and the reference signals for reactive power and negative sequence current.

Advanced PV/ESS Controller
The proposed MGCC requires the development of an enhanced inverter controller for enabling the fair compensation of reactive power and unbalance phase currents. It should be highlighted that at the moment there are not commercially available inverters that can intentionally inject asymmetric currents in grid-following mode and thus, it is crucial to propose a new inverter controller for enabling there required functional modes. The new controller is based on a DNαβ-PLL [13], a current

Advanced PV/ESS Controller
The proposed MGCC requires the development of an enhanced inverter controller for enabling the fair compensation of reactive power and unbalance phase currents. It should be highlighted that at the Appl. Sci. 2019, 9, 5067 5 of 17 moment there are not commercially available inverters that can intentionally inject asymmetric currents in grid-following mode and thus, it is crucial to propose a new inverter controller for enabling there required functional modes. The new controller is based on a DNαβ-PLL [13], a current controller [17][18][19][20][21][22][23] with capabilities of injecting asymmetrical currents and a new PQ controller to enable the provision of the ancillary services. The overall structure of the advanced grid tied inverter is shown in Figure 2. The current controller is developed in 2 synchronous reference frames to allow independent control of positive and negative sequence current. Such a current controller requires a decoupling network to decompose the currents into positive and negative sequence. The inverter controller is able to receive coordination signals by the MGCC to accordingly contribute towards the ancillary services provision of the MG. controller [17][18][19][20][21][22][23] with capabilities of injecting asymmetrical currents and a new PQ controller to enable the provision of the ancillary services. The overall structure of the advanced grid tied inverter is shown in Figure 2. The current controller is developed in 2 synchronous reference frames to allow independent control of positive and negative sequence current. Such a current controller requires a decoupling network to decompose the currents into positive and negative sequence. The inverter controller is able to receive coordination signals by the MGCC to accordingly contribute towards the ancillary services provision of the MG.

LC Filter
PWM Modulation

Proposed PQ Controller with Sharing Strategy for Ancillary Services
A new PQ controller is developed for enabling the operation of the inverter for injecting the produced PV or ESS power into the grid while providing phase balancing and reactive support services. The PQ controller calculates the available capacity ( ) of the inverter that can be used for ancillary services as defined in Equation (1), where is the projection of the positive sequence inverter current on the d-axis expressed in the synchronous reference frame (corresponds to the active power injection) and is the nominalrated current of the inverter. The available capacity for ancillary services is calculated by each inverter participating in the control scheme and is sent to the MGCC through Modbus TCP/IP protocol.
The MGCC online coordinates the available capacity of each inverter for ancillary services provision ( ), where n represents the n th inverter participating in the scheme and uses this information to properly allocate the required support to each smart inverter.
Further, the available current capacity for ancillary services of an inverter ( ) can be used for providing both reactive power compensation and phase balancing support while ensuring that the inverter rated current is never violated. The MGCC will be responsible to determine the fair sharing between the two ancillary services considering the real-time loading conditions of the MG. Therefore, a sharing constant (k) will be calculated by the MGCC as a ratio between the required reactive power compensation and the required phase balancing support that each inverter should provide in order to achieve the central controller objectives, as will be explained in detail in Section 4.1.
Therefore, the proposed PQ controller of each inverter considers the sharing constant (k) as an input for the MGCC that is able to coordinate the sharing strategy between the two ancillary services.

Proposed PQ Controller with Sharing Strategy for Ancillary Services
A new PQ controller is developed for enabling the operation of the inverter for injecting the produced PV or ESS power into the grid while providing phase balancing and reactive support services. The PQ controller calculates the available capacity (Î as ) of the inverter that can be used for ancillary services as defined in Equation (1) where i +1 d−inv is the projection of the positive sequence inverter current on the d-axis expressed in the synchronous reference frame (corresponds to the active power injection) and I nom is the nominal-rated current of the inverter. The available capacity for ancillary services is calculated by each inverter participating in the control scheme and is sent to the MGCC through Modbus TCP/IP protocol.
The MGCC online coordinates the available capacity of each inverter for ancillary services provision (Î as−n ), where n represents the n th inverter participating in the scheme and uses this information to properly allocate the required support to each smart inverter.
Further, the available current capacity for ancillary services of an inverter (Î as ) can be used for providing both reactive power compensation and phase balancing support while ensuring that the inverter rated current is never violated. The MGCC will be responsible to determine the fair sharing between the two ancillary services considering the real-time loading conditions of the MG. Therefore, a sharing constant (k) will be calculated by the MGCC as a ratio between the required reactive power compensation and the required phase balancing support that each inverter should provide in order to achieve the central controller objectives, as will be explained in detail in Section 4.1.
Therefore, the proposed PQ controller of each inverter considers the sharing constant (k) as an input for the MGCC that is able to coordinate the sharing strategy between the two ancillary services. When k > 1 then the reactive power compensation is prioritized, when k = 1 the sharing strategy equally distributes the ancillary services between reactive power compensation and phase balancing support and when k < 1 the strategy prioritizes the phase balancing service. As a result, the PQ controller needs to consider the sharing factor to determine the available current capacity for reactive power support (Î +1

Q inv
) and the available current capacity for negative sequence injection-phase balancing support (Î −1 inv ), while ensuring the rated current of the inverter (I nom ). For calculating the available current capacity for each ancillary service, a detail analysis of the current injection by the inverter is required. Under a multi-functional operation of the inverter, the current injection contains both positive and negative sequence current as shown in Equation (2), where i +1 dq−inv and i −1 dq−inv is the positive and negative sequence current injection by the inverter expressed in the dq-frame as they are calculated by the decoupling network [13,24]. The d-axis positive sequence current (i +1 d−inv ) corresponds to the positive sequence active power injection by the inverter (P +1 ) while the q-axis positive sequence current (i +1 q−inv ) corresponds to the positive sequence reactive power (Q +1 ) according to Equation (3), where q T is the grid voltage at the PCC expressed in dq-frame as estimated by the DNαβ-PLL. It should be noted that an assumption that v +1 q = 0, which is ensured by the PLL is made for the estimation of P +1 and Q +1 . On the other hand, the negative sequence current injection (i −1 dq−inv ) is required to enable the phase balancing support to symmetrize the loading conditions of the MG.
For the secure operation of the inverter, it is crucial that the nominal current of the inverter will never be violated and therefore, Equation (4) must always be valid.
The available current capacity for reactive power support can be considered as the upper bound for . and the available current capacity for phase balancing support can be considered Therefore, by introducing the upper bound in (4), the maximum current capacity for reactive power and phase balancing support can be expressed in terms of the nominal inverter current (I nom ) and of the real-time current that corresponds to the active power injection (i +1 d−inv ) as given in Equation (5).
Appl. Sci. 2019, 9, 5067 7 of 17 By considering the sharing factor (k) provided by the MGCC, the available current capacity for phase balancing support can be expressed in terms of the available current capacity for reactive power support, as given in Equation (6).Î Hence, if Equation (6) is replaced into Equation (5), then Equation (5) can be expressed as second order equation as given in Equation (7).
One can observe that, by solving the typical second order Equation (7), the available current capacity for phase balancing support can be calculated based on the inverter limits and real-time operating conditions and then by using Equation (6), the available current capacity for reactive power support can be calculated as well.
The aforementioned analysis is utilized to develop a new PQ controller for enabling the fair and secure provision of ancillary services by the smart inverter. The PQ controller utilizes the sharing factor provided by the MGCC and by considering the inverter operating conditions can calculate the reference positive and negative sequence currents for providing reactive power and phase balancing support without affecting the inverter active power and without violating the current limits of the inverter. Thus, the PQ controller calculates the positive and negative sequence reference currents (i +1 * dq ) and (i −1 * dq ) according to Equation (8) and Equation (9), where P +1 * inv is the active power reference as generated by the MPPT or ESS charging controller. Q +1 * inv and i −1 * dq−inv corresponds to the reactive power compensation reference and the negative sequence reference currents that are provided by the MGCC to enable the reactive support and phase balancing service. It is noted that the MGCC will generate a reactive support reference (Q +1 * inv−n ) and a negative sequence current reference (i −1 * dq−inv−n ) for each inverter able to provide ancillary services, where n corresponds to the n th inverter participating in the control scheme. Furthermore, the available current capacity for phase balancing support and reactive power compensation calculated by Equation (7) and Equation (6) respectively are used to limit the current injection in order to avoid violation of the inverter nominal current that can overload the inverter operation causing catastrophic failures. The overall structure of the proposed inverter among with the new PQ controller for enabling the fair provision of ancillary services is demonstrated in Figure 3.

Experimental Setup
An experimental setup has been developed to validate the inverter performance according to the proposed control scheme with ancillary services provision functionalities. The enhanced inverter controller with the advanced sharing capability has been developed as a firmware within a dSPACE DS-1104 digital signal processor (DSP) board with a sampling and switching frequency of 3.45 kHz and is associated with a three-phase 5 kVA SEMIKRON Semiteach (B6U+E1C1F+B6CI) grid tied inverter. Then, the DC input of the inverter has been connected with a DC power supply ELEKTRO-AUTOMATIC (EA-PS 9750-20) to emulate the PVs or the batteries connected at the DC-link. The AC output of the inverter has been connected with the power grid through an LC filter and a 5  Figure 4 and in Table 1 respectively. reference currents that are provided by the MGCC to enable the reactive support and phase balancing service. It is noted that the MGCC will generate a reactive support reference ( * ) and a negative sequence current reference ( * ) for each inverter able to provide ancillary services, where n corresponds to the n th inverter participating in the control scheme. Furthermore, the available current capacity for phase balancing support and reactive power compensation calculated by Equation (7) and Equation (6) respectively are used to limit the current injection in order to avoid violation of the inverter nominal current that can overload the inverter operation causing catastrophic failures. The overall structure of the proposed inverter among with the new PQ controller for enabling the fair provision of ancillary services is demonstrated in Figure 3.

MPPT/ESS Dispatch
Eq. (8) and Eq. (9) and Eq. (7) Proposed PQ Controller Figure 3. The structure of the enhanced inverter controller with additional fair sharing algorithm.

Experimental Setup
An experimental setup has been developed to validate the inverter performance according to the proposed control scheme with ancillary services provision functionalities. The enhanced inverter  Figure  4 and in Table 1 respectively.  The performance of the proposed sharing strategy has been validated using three sets of experiments. Initially, the positive sequence reactive power seen by the grid ( ) has been measured at 1200 VAr and the negative sequence current ( ) at 3.5 A rms. Then, the sharing constant (k) has been altered from 0.01 to 100 for investigating the performance of the proposed strategy. Figure 5 shows the experimental results for the three case studies. At the beginning of each  The performance of the proposed sharing strategy has been validated using three sets of experiments. Initially, the positive sequence reactive power seen by the grid (Q +1 grid ) has been measured at 1200 VAr and the negative sequence current (i −1 grid ) at 3.5 A rms. Then, the sharing constant (k) has been altered from 0.01 to 100 for investigating the performance of the proposed strategy. Figure 5 shows the experimental results for the three case studies. At the beginning of each case study, the PV system (or ESS) was producing 1000 W. In the first case study (Figure 5a), at t = 25.02 s a sharing constant k = 0.01 has been requested from the MGCC. According to Equation (6) and Equation (7), priority will be given to PB compensation. As can be seen in Figure 5a, at t = 25.025 s the PV's currents are becoming asymmetrical to compensate i −1 grid while Q +1 grid is not compensated since no reactive current capacity (Î +1 Q inv ) was available due to the low value of the sharing constant k. In the next case study, a sharing constant k = 100 has been requested from the MGCC at t = 14.78 s. According to (6), a large sharing constant illustrates that the available capacity should be utilized only for positive sequence reactive power injection. Particularly, Q +1 grid was compensated completely while i −1 grid remained unaffected as shown by Figure 5b. Finally, in Figure 5c, an equal capacity of reactive current and negative sequence current (Î −1 inv ) was requested by the MGCC (k = 1) at t = 4.02 s. The new PQ controller equally shares the capacity among the two ancillary services. As can be observed from, positive sequence reactive power was reduced from 1200 VAr to 400 VAr and the negative sequence current from 3.5 A to 0.5 A. Hence, the proposed PQ controller can share the inverter's available capacity among reactive and negative sequence current according to the sharing constant estimated by the MGCC in real-time.  Figure 5c, an equal capacity of reactive current and negative sequence current (̂− 1 ) was requested by the MGCC (k = 1) at t = 4.02 s. The new PQ controller equally shares the capacity among the two ancillary services. As can be observed from, positive sequence reactive power was reduced from 1200 VAr to 400 VAr and the negative sequence current from 3.5 A to 0.5 A. Hence, the proposed PQ controller can share the inverter's available capacity among reactive and negative sequence current according to the sharing constant estimated by the MGCC in real-time.

Microgrid Central Controller
This section firstly describes the structure of the MGCC. Thereafter, the under investigation MG among with the proposed solution was implemented in real-time simulation environment to validate its effectiveness for an entire day time frame.

Microgrid Central Controller
This section firstly describes the structure of the MGCC. Thereafter, the under investigation MG among with the proposed solution was implemented in real-time simulation environment to validate its effectiveness for an entire day time frame.

Microgrid Central Controller (MGCC)
The MGCC regulates the provision of Q-PB ancillary service at the MG's PCC according to the real-time loading conditions of the grid. A smart meter at the MG's PCC measures the exchanged positive sequence reactive power (Q +1 grid ) and the negative sequence current (i −1 grid ) between the main grid and the MG and sends the measurements through Modbus TCP/IP protocol to the MGCC. Typically, the reporting rate of a fast smart meter can be in the range of 200-500 ms [33]. A reporting rate of 200 ms was considered as a reporting rate and control period for the MGCC in this case study. In case where the smart meter is capable of performing sequence analysis, the positive sequence reactive power exchange with the grid (Q +1 grid ) and the negative sequence grid current (i −1 grid ) are estimated within the smart meter and sent to the MGCC. If the smart meter is not capable of performing sequence analysis, sequence transformation theory can be used to transform the per phase voltage and current measurements into positive and negative sequence quantities.
Three PI controllers were developed to compensate the positive sequence reactive power and negative sequence current at the PCC of the MG as shown in Figure 6. The following parameters (k p = 0.2 and k i = 2) have been selected for the tuning of the PI controllers using trial and error method to ensure stable operation of the MGCC. The outputs of the PI controllers are the total reactive power and negative sequence current references requested by the inverters. These reference values should be limited by the total reactive current capacity (Î −1 total ) and total negative sequence current capacity (Î +1 Q total ) to ensure that the PI's outputs are not exceeding the total capacities for Q-PB provision. The total capacities are defined as in Equation (10), where N represents the number of inverters participating in the ancillary services,Î +1 Q inv−n represents the reactive current capacity for each converter andÎ −1 inv−n represents the negative sequence capacity for each converter. Further, the PI controllers were equipped with anti-windup limiters to ensure stable operation under intense asymmetries or high reactive power consumption. Then, the total positive sequence reactive power (Q +1 * inv−s ) and the total negative sequence current (i −1 * inv−s ) are allocated to the inverters based on adaptive weights (w n ) according to Equation (11), where N denotes the number of units participating in the ancillary services. As can be observed, w n is highly related to the real-time operating conditions of the inverters. For instance, during a sunny day at noon, the allowable provision of ancillary services by the PV inverters will be lower compared to other hours of the day due to the intense production of active power (which always has the highest priority). The fair sharing of Q-PB is ensured using the real-time grid conditions. The sharing constant (k) that is used by each inverter participating in Q-PB service is estimated by the MGCC as given in Equation (12), where I +1 Q−grid is the positive sequence reactive current at the MG's PCC provided by the smart meter or calculated with the aid of Equation (3). The total reference currents (I +1 * Q inv−s and i −1 * inv−s ) are subtracted from the grid measurements to ensure that k is not affected by the current that is injected from the inverters due to the Q-PB service. Furthermore, the sharing constant was limited in the region [0.01 100] to ensure stable operation of the MGCC. The proposed central controller allows coordination of the PV and ESS inverters to provide Q-PB service, which can improve the power factor and asymmetries at the MG's PCC. Further, the MGCC estimates the priority that should be given to each ancillary service defined according to the sharing constant (k). priority).
The fair sharing of Q-PB is ensured using the real-time grid conditions. The sharing constant (k) that is used by each inverter participating in Q-PB service is estimated by the MGCC as given in Equation (12), (12) where − +1 is the positive sequence reactive current at the MG's PCC provided by the smart meter or calculated with the aid of Equation (3). The total reference currents ( − +1 * and − −1 * ) are subtracted from the grid measurements to ensure that k is not affected by the current that is injected from the inverters due to the Q-PB service. Furthermore, the sharing constant was limited in the region [0.01 100] to ensure stable operation of the MGCC. The proposed central controller allows coordination of the PV and ESS inverters to provide Q-PB service, which can improve the power factor and asymmetries at the MG's PCC. Further, the MGCC estimates the priority that should be given to each ancillary service defined according to the sharing constant (k).

Microgrid
Central Controller

Reactive Power Controller
Sharing Constant

Real-Time Simulation-Base Scenario
A real-time simulation of the MG has been developed in OPAL-RT (OP5707) to validate the effectiveness of the proposed MGCC to compensate current asymmetries and reactive power as illustrated in Figure 7. Two cores have been utilized to develop the MGCC (core #1) and the microgrid network (core #2) with a fixed control step of 200 µs and 50 µs respectively. Further, the MG model has been constructed with ARTEMIS library while RT-EVENTS library has been used to develop the detailed models of the grid tied inverters. In addition, a human machine interface (HMI) has been built using the LabVIEW to allow real-time management of the MG through the MGCC.
Initially, the proposed MGCC for ancillary services provision was deactivated to create a base scenario for our investigation. The real-time simulation was running for a whole day to investigate the loading conditions of the MG during a typical day according to field measurements. Figure 8 shows the per phase active (P a , P b , P c ) and reactive power (Q a , Q b , Q c ) at the buildings of the MG. As can be seen, a considerable amount of reactive power is absorbed by the buildings causing therefore reduction of the power factor and increase of the energy losses. In addition, asymmetries can be observed among the different phases (a,b,c) during the whole day of operation. These asymmetries reduce the utilization of the available capacity of the lines for active power and deteriorate the power quality of the grid. effectiveness of the proposed MGCC to compensate current asymmetries and reactive power as illustrated in Figure 7. Two cores have been utilized to develop the MGCC (core #1) and the microgrid network (core #2) with a fixed control step of 200 μs and 50 μs respectively. Further, the MG model has been constructed with ARTEMIS library while RT-EVENTS library has been used to develop the detailed models of the grid tied inverters. In addition, a human machine interface (HMI) has been built using the LabVIEW to allow real-time management of the MG through the MGCC. Initially, the proposed MGCC for ancillary services provision was deactivated to create a base scenario for our investigation. The real-time simulation was running for a whole day to investigate  Figure 9 demonstrates the average per minute samples of the active and reactive power produced by the PV plants and the active (P +1 grid ) and reactive power (Q +1 grid ) exchange at the MG's PCC. Considering the PVs energy production, the three PV systems were producing the same energy since the buildings are located very close to each other, so they share the same solar irradiation. Hence, Figure 9 shows the generated power only from one of the three PV systems. Further, the ESS was scheduled to operate according to the optimal energy management scheme developed in Reference [9]. It should be noted that other more advanced discharging strategies can also integrated within the ESS inverter to allow cooperation with the PV inverters considering building level energy optimization as in Reference [34]. More specifically, the ESS is scheduled to charge/discharge with 25 kW according to the electricity price. The ESS was scheduled to charge from 02:00-04:00 and 14:30-16:30 while it was scheduled to discharge from 09:00-11:00 and 19:00-21:00. It should be noted that an initial state of charge of 50% was assumed during the scenarios. Further, during the base scenario, there is not any control on the reactive power of the PV systems and ESS (Q PV = 0 kVAr and Q ESS = 0 kVAr).
Appl. Sci. 2019, 9, x FOR PEER REVIEW 12 of 17 the loading conditions of the MG during a typical day according to field measurements. Figure 8 shows the per phase active (Pa, Pb, Pc) and reactive power (Qa, Qb, Qc) at the buildings of the MG. As can be seen, a considerable amount of reactive power is absorbed by the buildings causing therefore reduction of the power factor and increase of the energy losses. In addition, asymmetries can be observed among the different phases (a,b,c) during the whole day of operation. These asymmetries reduce the utilization of the available capacity of the lines for active power and deteriorate the power quality of the grid.

Figure 8.
Active and reactive power per phase at each building. Figure 9 demonstrates the average per minute samples of the active and reactive power produced by the PV plants and the active ( +1 ) and reactive power ( +1 ) exchange at the MG's PCC. Considering the PVs energy production, the three PV systems were producing the same energy since the buildings are located very close to each other, so they share the same solar irradiation. Hence, Figure 9 shows the generated power only from one of the three PV systems. Further, the ESS was scheduled to operate according to the optimal energy management scheme developed in Reference [9]. It should be noted that other more advanced discharging strategies can also integrated within the ESS inverter to allow cooperation with the PV inverters considering building level energy optimization as in Reference [34]. More specifically, the ESS is scheduled to charge/discharge with 25 kW according to the electricity price. The ESS was scheduled to charge from 02:00-04:00 and 14:30-16:30 while it was scheduled to discharge from 09:00-11:00 and 19:00-21:00. It should be noted that an initial state of charge of 50% was assumed during the scenarios. Further, during the base scenario, there is not any control on the reactive power of the PV systems and ESS (QPV = 0 kVAr and QESS = 0 kVAr). The scheduling of the DG is performed every day according to the forecasted demand conditions when the MG is grid-connected. It should be noted that in grid-connected mode only the active power of the DG (PDG) is dispatched while the reactive power of the DG (QDG) is set to 0 kVAr. In cases where the MG is operating in islanded mode, the DG will be the master generator regulating the voltage and the frequency of the MG. In this case study, the active power of the DG was set at 15 kW according to the demand on that particular day and QDG was set to 0 kVAr since the MG was in gridconnected mode. The scheduling of the DG is performed every day according to the forecasted demand conditions when the MG is grid-connected. It should be noted that in grid-connected mode only the active power of the DG (P DG ) is dispatched while the reactive power of the DG (Q DG ) is set to 0 kVAr. In cases where the MG is operating in islanded mode, the DG will be the master generator regulating the voltage and the frequency of the MG. In this case study, the active power of the DG was set at 15 kW according to the demand on that particular day and Q DG was set to 0 kVAr since the MG was in grid-connected mode.
The active power (P +1 grid ) and reactive power (Q +1 grid ) at the MG's PCC during the case when the MGCC was disabled are also shown in Figure 9. The positive values of active and reactive power denote that energy is flowing from the main network to the MG while negative values denote that the MG is exporting energy to the distribution grid. As can be seen, a great amount of positive sequence reactive power is required by the main grid to cover the reactive power needs of the buildings causing reduction of the available capacity for transmitting active power.

Real Time Hardware In the Loop Investigation of the Proposed Solution
The proposed MGCC was enabled to validate its performance for the provision of Q-PB service. Figure 10 shows the average per minute samples of the estimated capacity for each ancillary service and the estimated reference values by the MGCC. It should be highlighted that the positive sequence reactive power capacity (Q +1 PV /Q +1 ESS ) and negative sequence current (Î −1 PV /Î −1 ESS ) capacity of the PV/ESS must be always less than their reference values to respect the nominal limits of the inverters. Therefore, the reference values generated from the MGCC respects the capacities estimated according to the new PQ controller presented in Section 3. As can be observed in Figure 10, theQ +1 PV andÎ −1 PV were reduced during the noon. The reason behind that is the increase of the positive sequence d-axis current of the PV systems caused by the increased solar irradiation that reduces the capacity for ancillary services according to Equation (7). Further, the ESS capacity for positive sequence reactive power (Q +1 ESS ) and negative sequence current (Î −1 ESS ) is affected from the ESS scheduled cycle. Therefore, the availability for ancillary services provision is considerably reduced when the ESS was charging/discharging.  Then, the positive sequence reactive power at the PCC ( +1 ) and the negative sequence current at the PCC ( −1 ) were evaluated in case when the MGCC was enabled (MGCC-ON) and in case of the base scenario where it was disabled (MGCC-OFF). The results of the average per minute samples are shown in Figure 11. As can be seen, the +1 and −1 were completely eliminated when the MGCC is activated. The proposed central controller concurrently compensates the positive sequence reactive power and negative sequence current according to the loading conditions while respecting the nominal capacities of the inverters. It should be noted that, in case the available capacity of the PVs/ESS is less than the requested reference reactive power and negative sequence current, the inverters would inject the maximum allowable current (Inom). Hence, the grid reactive power and negative sequence grid current would not be eliminated completely to ensure that the inverters are not over-loaded.
In case an existing solution (as the one used in Reference [25]) for the inverter controller is used to provide the Q-PB service, priority will always be given to reactive power support while unbalance As can be seen in Figure 10 the positive sequence reactive power reference of the PV inverters (Q +1 * PV ) was decreased during the noon due to the reduction of the weights (w n ) associated with the PV systems caused by the increase of their energy production (reduction of the available capacity for ancillary services (Î as )). This change on the adaptive weights is also reflected on the ESS in which its reference positive sequence reactive power (Q +1 * ESS ) was increased during that time to compensate the availability reduction of the PV systems. In a similar way, the magnitude of the negative sequence reference current of the PV systems ( i −1 * PV ) and ESS ( i −1 * ESS ) are also affected by the change of the weights.
Then, the positive sequence reactive power at the PCC (Q +1 grid ) and the negative sequence current at the PCC (i −1 grid ) were evaluated in case when the MGCC was enabled (MGCC-ON) and in case of the base scenario where it was disabled (MGCC-OFF). The results of the average per minute samples are shown in Figure 11. As can be seen, the Q +1 grid and i −1 grid were completely eliminated when the MGCC is activated. The proposed central controller concurrently compensates the positive sequence reactive power and negative sequence current according to the loading conditions while respecting the nominal capacities of the inverters. It should be noted that, in case the available capacity of the PVs/ESS is less than the requested reference reactive power and negative sequence current, the inverters would inject the maximum allowable current (I nom ). Hence, the grid reactive power and negative sequence grid current would not be eliminated completely to ensure that the inverters are not over-loaded.
the base scenario where it was disabled (MGCC-OFF). The results of the average per minute samples are shown in Figure 11. As can be seen, the +1 and −1 were completely eliminated when the MGCC is activated. The proposed central controller concurrently compensates the positive sequence reactive power and negative sequence current according to the loading conditions while respecting the nominal capacities of the inverters. It should be noted that, in case the available capacity of the PVs/ESS is less than the requested reference reactive power and negative sequence current, the inverters would inject the maximum allowable current (Inom). Hence, the grid reactive power and negative sequence grid current would not be eliminated completely to ensure that the inverters are not over-loaded.
In case an existing solution (as the one used in Reference [25]) for the inverter controller is used to provide the Q-PB service, priority will always be given to reactive power support while unbalance compensation would be provided only in case there would be enough available inverter capacity. On the other hand, the proposed solution enables the fair compensation of Q-PB service due to the new developed inverter controller while the priority is set according to the loading conditions at the MG's PCC. From the distribution system operator point of view, these remarkable improvements can have a great impact on the power quality, the energy losses and the effective utilization of the grid.  In case an existing solution (as the one used in Reference [25]) for the inverter controller is used to provide the Q-PB service, priority will always be given to reactive power support while unbalance compensation would be provided only in case there would be enough available inverter capacity. On the other hand, the proposed solution enables the fair compensation of Q-PB service due to the new developed inverter controller while the priority is set according to the loading conditions at the MG's PCC. From the distribution system operator point of view, these remarkable improvements can have a great impact on the power quality, the energy losses and the effective utilization of the grid.

Conclusions
The proposed MGCC allows concurrent provision of reactive power and phase balancing service by grid tied inverters. The solution requires advanced functionalities by the inverters that are not currently available in commercial inverter. Therefore, an advanced inverter controller is proposed to enable the on purpose asymmetric current injection. Further, a new PQ controller has been proposed and developed to estimate the available capacity for reactive power and negative sequence current according to its real time operating condition in order to allow the proper provision of ancillary services by the new inverter. The proposed inverter with new ancillary services capabilities has been validated using experimental tests in a laboratory scale inverter. Thereafter, a real-time simulation was carried out to investigate the effectiveness of the MGCC during an entire day. The results indicate that the proposed solution achieves significant benefits for the distribution system operator by enhancing the power quality and efficiency and utilization of existing capacity of the distribution grid.