## 3 Controller Design
### Control of Islanding Mode of DC Sub-Grid  
In Section 2.5, the global model during the islanding mode of DC sub-grid is presented. It is clear that VSI side will not be utilized during this mode, and hybrid renewable energy sources and battery provides the necessary power to the loads. Islanded mode of the microgrid is activated when the switch \(S_{L}\) is OFF as shown in the Figure 6. The following equation can express the tracking errors to make sure the stable operation of the DC sub-grid as:\[\left\{\begin{array}{l}e_{1}\\ e_{2}\\ e_{3}\\ e_{4}\end{array}\right\}=\left\{\begin{array}{l}x_{1}-I_{uref}\\ x_{2}-V_{preref}\\ x_{4}-I_{butref}\end{array}\right\} \tag{46}\]  
where \(I_{uref}\), \(V_{preref}\), \(I_{butref}\), and \(V_{dref}\) are the reference values of wind current, PV current, battery current, and the reference voltage of common DC bus, respectively. Assuming the time derivative in Equation (46) will give the following expressions:  
\[\dot{e_{1}}=\ \frac{V_{in}}{L_{w}}-\frac{R_{w}x_{1}}{L_{w}}-\frac{x_{5}(1-\mu_{1})}{L _{w}}-I_{uref}\dot{+}\ \dot{\theta_{1}} \tag{47}\]  
\[\dot{e_{2}}=\frac{I_{PV}}{C_{PV}}-\ \mu_{2}\frac{x_{3}}{C_{pv}}-V_{preref}\dot{+} \dot{\theta_{2}} \tag{48}\]  
\[\dot{e_{3}}=\frac{V_{bat}}{L_{bat}}-\frac{R_{bat}}{L_{bat}}\ x_{3}-\mu_{34} \frac{x_{5}}{L_{bat}}-I_{butref}\dot{+}\ \dot{\theta_{3}} \tag{49}\]  
\[\dot{e_{4}}=\ (1-\ \mu_{1})\frac{x_{1}}{C_{dc}}+(1-\mu_{2})\frac{x_{3}}{C_{ dc}}+(\mu_{34})\frac{x_{4}}{C_{dc}}-\frac{I_{o}}{C_{dc}}-V_{dref}\dot{+}\ \dot{\theta_{4}} \tag{50}\]  
where \(\dot{\theta_{1}},\dot{\theta_{2}},\dot{\theta_{3}}\) and \(\dot{\theta_{4}}\) are the untiled bounds and uncertain dynamics and the deftness of the controller tends to remove these parameters adaptively. From Equations (47)-(49), the control laws can be derived as:  
\[\mu_{1}=1+\frac{L_{w}}{x_{5}}\bigg{(}\frac{V_{in}}{L_{w}}-\frac{R_{w}x_{1}}{ L_{w}}-I_{uref}\dot{\cdot}\bigg{)}+\frac{l_{w}}{x_{5}}(\dot{e_{1}}) \tag{51}\]  
\[u_{2}\dot{=}\frac{C_{pv}}{x_{3}}(-\dot{e_{3}}+\frac{I_{pv}}{C_{pv}}-V_{PVref} \ ) \tag{52}\]  
\[u_{34}=\frac{L_{bat}}{x_{5}}(\frac{V_{bat}}{L_{bat}}-\frac{R_{bat}}{L_{bat}}x_{4 }-I_{butref}\dot{-}\dot{e_{3}}\ ) \tag{53}\]  
For the error convergence towards zero, barrier functions for \(\dot{e_{1}},\dot{e_{2}},\dot{e_{3}}\) and \(\dot{e_{4}}\) are illustrated below considering the Equation (43) as:  
\[\dot{e_{1}}=-K_{1}|e_{1}|\ sgn\ (e_{1}) \tag{54}\]  
\[\dot{e_{2}}=-K_{2}|e_{2}|\ sgn\ (e_{2}) \tag{55}\]  
\[\dot{e_{3}}=-K_{3}|e_{3}|\ sgn\ (e_{3}) \tag{56}\]  
\[\dot{e_{4}}=-K_{4}|e_{4}|\ sgn\ (e_{4}) \tag{57}\]  
where \(K_{1},K_{2},K_{3}\) and \(K_{4}\) are the adaptive gains, whose values can be determined by using the Equations (44) and (45) as:  
\[K_{i}(t)=\left\{\begin{array}{l}K_{PB}(t),K_{PB}^{\ \ \ \ \ \ \ }(t)=\bar{F}|\dot{e_{i}}(t)|,\ \ \ \ \ \ \ if\ (0<t<\bar{t})\\ K_{PSB}|\dot{e_{i}}(t)|,\\[\mu_{2}=\frac{C_{pv}}{x_{3}}\bigg{(}K_{2}|e_{2}|\;sgn\;(e_{2})+\frac{I_{pv}}{C_{pv} }-\dot{V_{PVref}}\;\bigg{)} \tag{60}\]  
\[u_{34}=\frac{L_{bat}}{x_{5}}(\frac{V_{bat}}{L_{bat}}-\frac{R_{bat}}{L_{bat}}x_{4}- \dot{I_{batref}}+\;K_{3}|e_{3}|\;sgn\;(e_{3})\;) \tag{61}\]