## 3 Coordinated Control Scheme for the Energy Router  
### Control Methods of the DC/AC Converter  
The energy router-based HEMS can operate in either grid-connected or isolated mode. In grid-connected mode, the voltage and frequency of the AC bus keep synchronous with the power grid, so the DC/AC converter (shall be referred as \"main converter\" in the rest of this paper) can achieve power balance by PQ control. In the \(dq\) rotation coordinate system, the power transferred to the AC side can be expressed as,  
Figure 3: Power electronic converters in the energy router.  
\[\left\{\begin{array}{l}P_{\text{ac}}=u_{sd}i_{d}+u_{sq}i_{q}\\ Q_{\text{ac}}=u_{sq}i_{d}-u_{sd}i_{q}\end{array}\right. \tag{1}\]  
where \(u_{sd}\) and \(u_{sq}\) are the \(d\) axis and \(q\) axis components of the AC voltage \(u_{s}\) respectively, \(i_{d}\) and \(i_{q}\) are the \(d\) axis and \(q\) axis components of the AC current \(i_{abc}\) respectively. If the direction of \(d\) axis coincides with the sinusoidal vector of the power grid, the \(q\) axis component of the AC voltage will be zero. Then Equation (1) can be simplified as follows,  
\[\left\{\begin{array}{l}P_{\text{ac}}=u_{sd}i_{d}\\ Q_{\text{ac}}=-u_{sd}i_{q}\end{array}\right.\Rightarrow\left\{\begin{array}[] {l}i_{d\text{ref}}=\frac{P_{\text{ref}}}{u_{sd}^{\text{ref}}}\\ i_{q\text{ref}}=-\frac{Q_{\text{ref}}}{u_{sd}}\end{array}\right. \tag{2}\]  
where \(P_{\text{ref}}\) and \(Q_{\text{ref}}\) are the active and reactive reference power, respectively. Equation (2) indicates that active power and reactive power transferred to the AC side can be controlled through \(i_{d}\) and \(i_{q}\).  
Since the capacitor branch in LCL filter is utilized to filter the harmonic current around the switching frequency, the effect of capacitor branch on fundamental components can be neglected. Aimed at the fundamental components, the output voltage of the main converter under \(dq\) rotation coordinate system can be derived through the following equation,  
\[\left\{\begin{array}{l}u_{d}=u_{sd}+\omega Li_{q}+L\frac{di_{d}}{dt}\\ u_{q}=u_{sq}-\omega Li_{d}+L\frac{di_{d}}{dt}\end{array}\right. \tag{3}\]  
where \(L\) is the filter inductance. According to Equation (3), the inner current loop can be realized through PI regulators as Equation (4) shows,  
\[\left\{\begin{array}{l}u_{d}=u_{sd}+\omega Li_{q}+(k_{pd}+\frac{k_{id}}{s}) (i_{d\text{ref}}-i_{d})\\ u_{q}=u_{sq}-\omega Li_{d}+(k_{pq}+\frac{k_{iq}}{s})(i_{q\text{ref}}-i_{q}) \end{array}\right. \tag{4}\]  
The schematic of the PQ control module is shown in Figure 4.  
As in isolated mode, the voltage and frequency of the AC bus will be stabilized under the V/f control of the main converter, which is also shown in Figure 4. The reference current in \(d\) and \(q\) axis of the V/f controller derived through PI regulators can be expressed as,  
\[\left\{\begin{array}{l}i_{d\text{ref}}=(k_{pd}+\frac{k_{id}}{s})(u_{sd \text{ref}}-u_{sd})\\ i_{q\text{ref}}=(k_{pq}+\frac{k_{iq}}{s})(u_{sq\text{ref}}-u_{sq})\end{array}\right. \tag{5}\]  
where \(u_{sd\text{ref}}\) and \(u_{sq\text{ref}}\) are the reference components of the AC voltage \(u_{s}\) in \(d\) axis and \(q\) axis.  
The inner current loop can be used to restrain the influence of load disturbances and improve dynamic response of the AC system. It works based on the reference current value generated by V/f control and can also be expressed by Equation (4). Unlike PQ control, a virtual phase-locked loop is utilized by the V/f controller to acquire a constant frequency, and sinusoidal signal generated by the virtual phase-locked loop is taken as the reference vector. As stated above, the direction of \(d\) axis coincides with this vector, then \(u_{sq\text{ref}}\) should be zero.