# Phase Balancing and Reactive Power Support Services for Microgrids
## 3 Advanced PV/ESS Controller
### Proposed PQ Controller with Sharing Strategy for Ancillary Services
The \(d\)-axis positive sequence current (\(i_{\textit{d-inv}}^{+1}\)) corresponds to the positive sequence active power injection by the inverter (\(P^{+1}\)) while the \(q\)-axis positive sequence current (\(i_{\textit{q-inv}}^{+1}\)) corresponds to the positive sequence reactive power (\(Q^{+1}\)) according to Equation (3),  
\[\text{P}^{+1}\ =\ \frac{3}{2}\Big{(}v_{d}^{+1}i_{\textit{d-inv}}^{+1}+v_{q}^{+ 1}i_{\textit{q-inv}}^{+1}\Big{)}\text{andQ}^{+1}\ =\ \frac{3}{2}\Big{(}v_{q}^{+1}i_{\textit{d-inv}}^{+1}-v_{d}^{+1}i_{\textit{q- inv}}^{+1}\Big{)} \tag{3}\]  
where \(\textbf{v}_{\textit{dq}}^{+1}=\left[ \begin{array}{cc}v_{d}^{+1}&v_{q}^{+1} \end{array} \right]^{T}\) is the grid voltage at the PCC expressed in \(dq\)-frame as estimated by the DN\(\alpha\beta\)-PLL. It should be noted that an assumption that \(v_{q}^{+1}\ =\ 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 (\(\textbf{i}_{\textit{dq-inv}}^{-1}\)) 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. \[\left|\textbf{i}_{\textit{inv}}\right|\ \leq\ \left|\textbf{i}_{\textit{dq-inv}}^{+1} \right|\ +\ \left|\textbf{i}_{\textit{dq-inv}}^{-1}\right|\ =\ \sqrt{\left(i_{\textit{d-inv}}^{+1}\right)^{2}+\left(i_{\textit{q-inv}}^{+1} \right)^{2}}\ +\ \sqrt{\left(i_{\textit{d-inv}}^{-1}\right)^{2}+\left(i_{\textit{q-inv}}^{-1} \right)^{2}}\ \leq\ I_{\textit{nom}} \tag{4}\]  
The available current capacity for reactive power support can be considered as the upper bound for \(i_{\textit{q-inv}}^{+1}\)\(\left(i_{\textit{d-inv}}^{+1}\right|\ \leq\ \hat{l}_{\textit{Q}_{\textit{inv}}}^{+1}\)). and the available current capacity for phase balancing support can be considered as the upper bound of \(\textbf{i}_{\textit{dq-inv}}^{-1}\)\(\left(\left|\textbf{i}_{\textit{dq-inv}}^{-1}\right|\ \leq\ \hat{l}_{\textit{inv}}^{-1}\right)\). 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_{\textit{nom}}\)) and of the real-time current that corresponds to the active power injection (\(i_{\textit{d-inv}}^{+1}\)) as given in Equation (5). \[\sqrt{\left(i_{\textit{d-inv}}^{+1}\right)^{2}\ +\ \left(i_{\textit{Q}_{\textit{inv}}}^{+ 1}\right)^{2}}\ +\ \hat{l}_{\textit{inv}}^{-1}\ =\ I_{\textit{nom}} \tag{5}\]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). \[\hat{I}_{Q_{inv}}^{+1}\ =\ k\hat{I}_{inv}^{-1} \tag{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). \[\left(k^{2}\ -\ 1\right)\left(\hat{I}_{inv}^{-1}\right)^{2}\ +\ 2I_{nom} \hat{I}_{inv}^{-1}\ +\ \left(\left(\hat{I}_{d-inv}^{+1}\right)^{2}\ -\ I_{nom}^{2}\right)\ =\ 0. \tag{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.