# Proportional resonant control

Table of Contents

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 proportional resonant control. This means that PI controller(s) a implemented 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:

- Vector current control (TN106) regarding current control in rotating reference frame.
- Fictive Axis Emulation (FAE) (TN124) 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.

## Operating principles of proportional resonant control

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

$$ G_{C}(s)=K_{p}+\displaystyle\frac{2K_{i}s}{s^{2}+\omega_{0}^{2}} $$

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

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:

$$ 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}} $$

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

### Digital implementation of PR control

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 \(T_s\), yields:

$$ 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{array}

a 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{array} $$

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

$$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)]$$

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].

### Tuning and performance evaluation

Proportional resonant controllers can be relatively easily tuned using the controller gains as well as the width of the resonant filter \(\omega_c\). The side figure illustrates the tuning of the proposed PR controller with various values of the resonant gain, with \(K_p=15\). Further details regarding the tuning can notably be found in [2].

### Academic references

[1] R. Teodorescu, F. Blaabjerg, M. Liserre and P. C. Loh, āProportional resonant controllers and filters for grid-connected voltage-source converters,ā in IEE Proc. on Electr. Power Appl., Vol. 153, NĀ°. 5, Sep. 2006.

[2] D. G. Holmes, T. A. Lipo, B. P. McGrath and W. Y. Kong, āOptimized Design of Stationary Frame Three Phase AC Current Regulators,ā in IEEE Trans. on Pow. Elec., Nov. 2009.

## B-Box / B-Board implementation

### C/C++ code

The imperix IDE provides numerous pre-written and pre-optimized functions. Controllers such as P, PI, PID and PR are already available and can be found in the `controllers.h/.cpp`

files.

As for all controllers, PR controllers are based on:

- A pseudo-object
`PRcontroller`

, which contains pre-computed parameters as well as state variables. - A configuration function, meant to be called during
`UserInit()`

, named`ConfigPrController()`

. - A run-time function, meant to be called during the user-level ISR, such as
`UserInterrupt()`

, named`RunPrController()`

.

The necessary parameters are documented within the controller.h header file. They are namely:

`Kp`

and`Ki`

, proportional and integral gain, respectively.`wres`

, which is the nominal frequency (center of the resonant term, in rad/s.), as well as`wdamp`

, the “width” of the resonant term (limits the quality factor of the resonant term).`tsample`

, corresponding to the sampling (interrupt) period.

#### 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;
}
```

Code language: C++ (cpp)

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

Code language: C++ (cpp)

## 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:

### 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.