# Inner-Loop Controllers for Grid-Forming Converters
## 2 Materials and Methods
### Proposed Inner-Loop Voltage Controller with Current Limiter
#### 2.1.1 Current Limiter Design  
For the current limiter design, the current condition is represented by a load resistance \(R_{L}\). The discrete-time model presented in (1) and (2) is then rewritten in (3) and (4), with the block diagram of the current loop controller shown in Figure 7.  
\[\left[\begin{array}{c}i_{Lk+1}\\ v_{ck+1}\\ u_{dk+1}\end{array}\right]=\left[\begin{array}{ccc}1&-\frac{T_{s}}{L}&\frac {T_{s}}{L}\\ \frac{T_{s}}{C}&1-\frac{T_{s}}{R_{L}C}&0\\ 0&0&0\end{array}\right]\left[\begin{array}{c}i_{Lk}\\ v_{ck}\\ u_{dk}\end{array}\right]+\left[\begin{array}{c}0\\ 0\\ 1\end{array}\right]u_{k} \tag{3}\]  
\[\mathbf{x}_{k+1}=\mathbf{G}_{i}\mathbf{x}_{k}+\mathbf{h}_{i}u_{k} \tag{4}\]  
Under short-circuit conditions, the plant model order is reduced since the capacitor voltage \(v_{c}\) in parallel with the resistance \(R_{L}\) approaches zero. This simplified discrete-time model is presented in (5) and is rewritten in the compact form in (6).  
\[\left[\begin{array}{c}i_{Lk+1}\\ u_{dk+1}\end{array}\right]=\left[\begin{array}{ccc}1&\frac{T_{s}}{L}\\ 0&0\end{array}\right]\left[\begin{array}{c}i_{Lk}\\ u_{dk}\end{array}\right]+\left[\begin{array}{c}0\\ 1\end{array}\right]u_{k} \tag{5}\]  
\[\mathbf{x}_{sck+1}=\mathbf{G}_{isc}\mathbf{x}_{sck}+\mathbf{h}_{isc}u_{k} \tag{6}\]  
To implement a state feedback controller, the state feedback gain \(\mathbf{k}_{i}\) must be determined. This can be achieved using the Discrete Linear Quadratic Regulator (DLQR). The DLQR is an optimal control design method that minimizes the cost function \(J\). The optimal gains are obtained by recursively solving the Algebraic Riccati Equation, which guarantees system stability under nominal conditions, provided the matrices \(\mathbf{Q}\) and \(\mathbf{R}\) are positive and the system is controllable. Increasing \(\mathbf{Q}\) results in a faster response, while increasing \(\mathbf{R}\) reduces the control effort. The cost function is minimized as shown in (7).  
\[u_{k}=-\mathbf{k}_{i}\mathbf{x}_{sck}+k_{f}i_{refk} \tag{7}\]  
Figure 7: Block diagram of the inverter current loop controller.  
The cost function is minimized with the gains given by (8), which are obtained from the solution of the discrete Riccati equation in (9).  
\[\mathbf{k}=\left(r+\mathbf{B}^{T}\mathbf{P}\mathbf{B}\right)^{-1}\mathbf{B}^{T} \mathbf{P}\mathbf{A} \tag{8}\]  
\[\mathbf{P}_{k+1}=\mathbf{Q}+\mathbf{A}^{T}\mathbf{P}\mathbf{A}-\mathbf{A}^{T} \mathbf{P}_{k}\mathbf{B}\Big{(}r+\mathbf{B}^{T}\mathbf{P}_{k}\mathbf{B}^{T} \Big{)}^{-1}\mathbf{B}^{T}\mathbf{P}_{k}\mathbf{A} \tag{9}\]  
where \(\mathbf{P}_{0}=0\) and \(\mathbf{A}\) and \(\mathbf{B}\) are the matrices of the state-space model of the plant with a resonant controller. Specialized routines, such as the DLQR function in Matlab, can provide the gain \(\mathbf{k}_{i}\) based on the knowledge of the matrices \(\mathbf{G}_{\mathbf{i}\mathbf{c}}\) and \(\mathbf{h}_{\mathbf{i}\mathbf{c}}\) (6), as well as the choice of the weighting matrices \(\mathbf{Q}\) and \(\mathbf{R}\).  
Considering the parameters of the project presented in Table 1, \(\mathbf{Q}=\text{diag}([\begin{array}{cc}1000&1\end{array}])\) and \(\mathbf{R}=1\) as the weighting matrices of the DLQR, it is observed that the current gain converges to 5, while the one-sample delay gain converges to 1 (\(\mathbf{k}_{i}=[\begin{array}{cc}5&1\end{array}]^{T}\)).  
When the model that includes the capacitor, represented by the matrices \(\mathbf{G}_{\mathbf{i}\mathbf{c}}\) and \(\mathbf{h}_{\mathbf{i}}\) (4), is used, and instead of a short circuit, a resistor representing three times the rated power of the inverter is considered, the current and one-sample delay gains remain close to those obtained previously. Finally, the gain \(k_{r}\) is adjusted such that the rated current error becomes zero under rated power conditions of the inverter (\(k_{r}=8\)).