## 3 Two-Level Control Design
### Higher-Level Inverse Dynamic Control  
The higher-level control is based on an inverse dynamic approach and relies on maintaining power balances to control internal and external voltages. For the sake of clarity, consider, with no loss of generality, an example case comprising \(N=6\) ports, as shown in Figure 3, where port 1 is connected to an AC grid, which acts as an external power source; port 2 is connected to storage devices, which allows for high dynamic performance to be maintained regardless of grid dynamics, and realizes UPS functionality; port 3 is connected to an AC load; port 4 is connected to a PV source; ports 5 and 6 are connected to DC loads. Control-wise, the PV port is treated as a load since it requires a predetermined voltage obtained from an MPPT algorithm. Note that, due to the modular topology and control design concept, developing the control design for the present case study is a non-restrictive assumption, and it can be easily generalized to any number of ports. In particular, the control equations presented in the following enable the realization of voltage-controlled ports, power-controlled ports or current-controlled ports, covering all the functionalities usually required for distribution system applications and realizing a fully modular control layer where all ports performing the same functionality are controlled by the same control equation, while the centralized control is only required to manage the different power sources. Figure 3: Three\(-\)wire, capacitive\(-\)coupled MC case study. Let us consider voltage control first. Since the proposed MC is required to maintain the power balance among AC and DC ports, which may each have a different voltage level, the control is formulated in terms of port powers. Current references for the modulation algorithm are successively obtained as functions of reference powers and measured port voltages. Note that, as far as three-phase ports are concerned, the control equations are formulated in terms of a space vector for clarity and compactness; furthermore, in the following, the zero component is neglected, which implies that the converter produces balanced voltages. However, zero-component control can be realized with the same approach, if necessary. According to the inverse dynamic control principles [63], let us define the voltage tracking error \(\varepsilon_{i}\) at the \(i\)-th port as:  
\[ \begin{array}{ll}\varepsilon_{i}=\mathbf{v}_{i}^{*}-\mathbf{v}_{i}&i=3,\\ e_{i}^{+}={v_{i}^{+}}^{-}-{v_{i}^{+}}\\ \varepsilon_{i}^{-}={v_{i}^{-}}^{*}-{v_{i}^{-}}\end{array} \Bigg{\}}&i\in[4;6], \end{array} \tag{12}\]  
and the dynamic voltage error equation as:  
\[\eta_{i}=f\bigg{(}\varepsilon_{i},\int{(\varepsilon_{i})dt},\frac{d\varepsilon _{i}}{dt},\ \ldots\,\frac{d^{n}\varepsilon_{i}}{dt^{n}}\bigg{)}. \tag{13}\]  
For each port, at capacitor terminals, the power balance can be formulated as:  
\[ \begin{array}{ll}\mathbf{S}_{i}=\frac{d}{dt}\bigg{[}\frac{1}{2}\mathbf{C}_{ i}\bigg{(}\sqrt{\frac{2}{3}}|\mathbf{v}_{i}|\bigg{)}^{2}\bigg{]}+\frac{3}{2} \mathbf{v}_{i}\cdot\overset{-*}{\mathbf{i}}_{load\ i}&i=3,\\ P_{i}^{+}=\frac{d}{dt}\bigg{[}\frac{1}{2}\mathbf{C}_{i}\big{(}{v_{i}^{+}}^{2} \big{)}^{2}+{v_{i}^{+}}\cdot\overset{+}{\mathbf{i}}_{load\ i}\\ P_{i}^{-}=\frac{d}{dt}\bigg{[}\frac{1}{2}\mathbf{C}_{i}\big{(}{v_{i}^{+}}^{2} \big{)}^{2}+{v_{i}^{-}}\cdot\overset{-}{\mathbf{i}}_{load\ i}\end{array}  \Bigg{\}}&i\in[4;6],\end{array} \tag{14}\]  
being \(i_{load\ i}\) the current absorbed by the load connected to the \(i\)-th port. Considering (14), by tedious yet simple calculus, the derivatives of the tracking error are obtained as:  
\[