# State Feedback Control Based Seamless Switch Control for Microgrid Inverter
## 3 Proposed Control
### Frequency-Locked Loop  
Frequency-locked Loop (FLL) is critical to the proposed switch control method. As the link between voltage control and current control, when the switch from current control to voltage control occurs is important. The FLL, as shown in Figure 8, is also designed via the complex controller (10). The superscript \"*\" denotes the complex conjugate.  
The FLL is first analyzed in complex frequency domain. Assuming \(\hat{\omega}~{}=~{}\omega\), where \(\omega\) represents the frequency of input signal, then the input-output complex transfer function of the closed-loop filter shown in Figure 8 can be derived as  
\[G_{FLL}~{}=~{}\frac{\hat{\mathbf{u}}_{g}}{\mathbf{u}_{g}}~{}=~{}\frac{\mu\omega G_{c}}{ 1+~{}\mu\omega G_{c}}~{}=~{}\frac{\mu\omega}{s~{}+~{}\mu\omega-j\omega} \tag{12}\]  
where \(\mu\) denotes the gain coefficient. Figure 9 shows the bode plot of \(G_{FLL}\) with different gains. From Figure 9, \(G_{FLL}\) is a band pass filter with the center frequency of \(\omega\). Therefore, it can extract the positive sequence component as \(\hat{u}_{g}~{}=~{}\hat{u}_{g\alpha}~{}+~{}\hat{j}\hat{u}_{g\beta}\). The less \(\mathbf{\mu}\) is set, the more attenuation for different frequency signal is achieved, while the bandwidth is narrower (the slower dynamic response will be manifested). To reach a compromise between the attenuation ability and bandwidth, the gain \(\mathbf{\mu}\) is set to \(0.8\omega\).  
When \(\hat{\omega}~{}\
eq~{}\omega\), the frequency adaption law is designed to estimate the frequency  
\[\hat{\omega}~{}=~{}\gamma\frac{\mu\hat{\omega}}{V^{2}}x_{a1}=\gamma\frac{\mu \hat{\omega}}{V^{2}}\text{Im}\Big{(}\epsilon_{g}\hat{u}_{g}^{*}\Big{)} \tag{13}\]  
where \(\gamma\) can be set as 90 [24]. The detailed FLL design can refer [24].  
Figure 8: Block diagram of the FLL adopted in the switch control.  
Figure 7: Bode diagram of the open-loop gain of the current control with: (**a**) \(K_{IR}\) and (**b**) \(K_{iI}\) change.  
In the proposed control frame, when the system operates in GC mode, the input signal is the grid voltage \(\mathbf{u}_{g}\). Then, FLL extracts the fundamental positive sequence voltage component to calculate power/current reference under grid-feeding mode. In complex domain, the complex power can be expressed as \(\mathbf{s}=p+j\mathbf{q}=\mathbf{u}_{g}\mathbf{t}^{*}\). Therefore, the current reference in GC mode can be computed as  
\[\dot{\mathbf{i}}_{r}\ =\ \left(\frac{\mathbf{s}_{r}}{\dot{\mathbf{u}}_{g}}\right)^{*} \tag{14}\]  
where \(\mathbf{s}_{r}=p_{r}+jq_{r}\) is the power reference. Meanwhile, the FLL also estimates the frequency of the fundamental positive sequence voltage for the current controller. When the system transfers into SA mode, the input signal will shift to capacitor voltages automatically. In this condition, the control is changed to voltage control, and meanwhile set \(\mu\) to 0 at the instant of switch. This action cuts off the input of FLL to keep the FLL on zero-input response. When \(\mu\) is set to 0, the response of the FLL is dependent on (10) and its initial values. Equation (10) can be rewritten as  
\[\dot{\mathbf{x}}_{c}\ =\ j\omega\mathbf{x}_{c} \tag{15}\]  
whose time-domain solution is \(\mathbf{x}_{c}=V_{0}e^{\theta}=V_{0}(\cos\theta+j\sin\theta)\). The amplitude \(V_{0}\) and phase \(\theta\) are successive to the value before \(\mu\) is set to 0. Hence, \(\mathbf{x}_{c}\) can be adopted as the voltage reference at the switch instance. However, considering the controllability of the voltage, the voltage reference can be computed as  
\[\mathbf{u}_{r}\ =\ \ V_{r}\frac{\hat{\mathbf{u}}_{g}}{V_{0}}|_{\mu\ =\ 0}\ =\ \ V_{r}\frac{\hat{\mathbf{u}}_{g}}{\sqrt{\hat{u}_{g \alpha}^{2}\ +\ \hat{u}_{g\beta}^{2}}}|_{\mu\ =\ 0} \tag{16}\]  
where \(V_{r}\) is the amplitude reference of the voltage.