# Phase Balancing and Reactive Power Support Services for Microgrids
## 4 Microgrid Central Controller
### 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_{grid}^{+1}\)) and the negative sequence current (\(\textbf{i}_{grid}^{-1}\)) 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_{grid}^{+1}\)) and the negative sequence grid current (\(\textbf{i}_{grid}^{-1}\)) 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 (\(\hat{l}_{total}^{-1}\)) and total negative sequence current capacity (\(\hat{l}_{Q_{turb}}^{+1}\)) 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),  
\[\hat{l}_{total}^{-1}\ =\ \sum_{N}\hat{l}_{inv-n}^{-1}\,\text{and}\,\hat{l}_{Q_{turb }}^{+1}\ =\ \sum_{N}\hat{l}_{Q_{turb}-n}^{+1}, \tag{10}\]  
where \(N\) represents the number of inverters participating in the ancillary services, \(\hat{l}_{Q_{turb}-n}^{+1}\) represents the reactive current capacity for each converter and \(\hat{l}_{inv-n}^{-1}\) 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_{inv-s}^{+1*}\)) and the total negative sequence current (\(\textbf{i}_{inv-s}^{-1*}\)) are allocated to the inverters based on adaptive weights (\(w_{n}\)) according to Equation (11),  
\[w_{n}\ =\ \frac{l_{as-n}}{\sum_{N}l_{as-n}}, \tag{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),  
\[k\ =\ \frac{\hat{l}_{Q-grid}^{+1}\ -\ \hat{l}_{Q_{inv-s}}^{+1*}}{\textbf{i}_{grid }^{-1}\ -\ \hat{i}_{inv-s}^{-1}}, \tag{12}\]where \(I_{Q-grid}^{+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 (\(I_{Q_{imr-s}}^{+1*}\) and \(\mathbf{i}_{inv-s}^{-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.