# Software resources

# Operating principles

In DC applications, conventional PI controllers provide excellent performance, notably a minimal steady state error, thanks to the (almost) infinite DC gain provided by the integral control action. However, in AC applications, PI controllers inevitably present a delayed tracking response, because their gains cannot be set high enough to avoid a steady-state error.

A well-known countermeasure to this shortcoming is the implementation of the PI controller(s) within a rotating reference frame (dq), which allows to re-locate the (almost) infinite DC gain at the desired frequency. More information is given in:

TN106: Vector current control regarding current control in rotating reference frame.

TN124: Fictive Axis Emulation (FAE) regarding the particularity of single-phase applications.

Alternatively, proportional resonant controllers (PR) have attracted significant interest for AC current/voltage control applications due to the simplicity of their implementation, notably for single-phase systems.

In essence, proportional resonant (PR) controllers are usually designed such that the controller transfer function is similar to:

\begin{array}{l}\displaystyle G_{C}(s)=K_{p}+\displaystyle\frac{2K_{i}s}{s^{2}+\omega_{0}^{2}}\end{array} |

where \begin{array}{l}\omega_0\end{array} designates the target reference current frequency. In this expression, the denominator term \begin{array}{l}s^{2}+\omega_{0}^{2}\end{array} creates infinite control gain at \begin{array}{l}\omega_{0}\end{array}.

Practically, this expression may be difficult to implement into a digital controller, which is why a more practical alternative is to introduce some damping around the resonant frequency, resulting in:

\begin{array}{l}\displaystyle G_{C}(s)=G_{Cp}(s)+G_{Cr}(s)=K_{p}+\displaystyle\frac{2K_{i}\omega_{c}s}{s^{2}+2\omega_{c}s+\omega_{0}^{2}}\end{array} |

were \begin{array}{l}\omega_{c}\end{array} designates the resonant cut-off frequency (i.e. width of the resonant filter). In this second expression, the gain at \begin{array}{l}\omega_{0}\end{array} is now finite, but still high enough for enforcing a sufficiently small steady-state error. Interestingly, the widening of the bandwidth around \begin{array}{l}\omega_{0}\end{array} also offer increased tolerance towards slight frequency deviations, such as in most practical grid-tied applications.

## Digital implementation

A practical implementation can be easily derived using the bilinear (Tustin) transform. The resulting discrete transfer function for the resonant term, discretized with a period \begin{array}{l}T_s\end{array}, yields:

\begin{array}{l}G_{Cr}(z)=\displaystyle\frac{Y(z)}{E(z)}=\displaystyle\frac{a_{1}(1-z^{-2})}{b_{0}+b_{1}z^{-1}+b_{2}z^{-2}}} \text{ with } \begin{cases} a_1=4K_{i}T_{s}\omega_{c}\\ b_0=T_{s}^2(\omega_{0}^2+2\omega_{c})+4\\ b_1=2T_{s}^2(\omega_{0}^2+2\omega_{c})-8\\ b_2=b_0 \end{cases}\right.\end{array} |

Once transformed into a difference equation, the resonant part yields:

\begin{array}{l}\displaystyle y(k)=\displaystyle\frac{1}{b_0}[a_{1}\cdot e(k)-a_{1}\cdot e(k-2)-b_{1}\cdot y(k-1)-b_{2}\cdot y(k-2)]\end{array} |

This difference equation can be easily used for generating run-time code. Notably, a possible implementation on Simulink is given below. A similar implementation is given in [1].

Implementation example

#include "../API/controllers.h" PrController mycontroller; float Kp = 10.0; float Kr = 500.0; float w0 = TWO_PI*50.0; float wc = 10.0; tUserSafe UserInit(void) { ConfigPrController(&mycontroller, Kp, Kr, w0, wc, SAMPLING_PERIOD); return SAFE; }

tUserSafe UserInterrupt(void) { //... some code Evsi = Vgrid + RunPrController(&mycontroller, Igrid_ref - Igrid); //... some code return SAFE; }

## Simulink

The included file provides a Simulink block that uses the above-presented implementation. This block can then easily be integrated with run-time configurable parameters:

The configuration mask is shown below. Typical parameters are also indicated:

Results

The first graphs show the grid voltage and the stabilized value of the grid pulsation:

The small remaining oscillations on the grid pulsation (<0.4% of the nominal value) are an expected consequence of the finite loop gain of the SOGI block at the fundamental frequency.

The measured grid current matches perfectly the given reference:

A jump of current reference has been performed in both simulation and experimental modes. The following graphs show a comparison between both results:

In simulation, a small overshoot can be observed on the current. This can be explained by the fact that the isolation transformer is not taken into account (modeled) in simulation. Indeed, the transformer increases the total inductance between the converter and the grid, which in turn increases the inertia of the system.