Skip to content

Proportionnal Resonant Controller

Introduction.

The Proportionnal Resonant Controller is dedicated to follow a sinusoidal reference.

It is design to minimized phase shift and amplitude error.

prop_res block diagram
Block diagram of Proportionnal Resonant controller

The \(\phi'\) variable is dedicated to reduce delay generated by the calculation and the PWM.

prop_res block diagram
Block diagram of Proportionnal Resonant controller including delay compensation

Parameters:

Here the continuous transfer function representation of the Proportionnal resonant.

\[Pr(s)=K_p + K_r \dfrac{s \cos(\phi')-\omega_0.\sin(\phi')}{s^2+w_0^2}\]

Where:

  • \(\omega_0\) is the pulsation in [rad/s]
  • \(\phi'\) is the compensation delay in [rad]

controller are sampled

We show here the continuous form of the function we want to implement. But calculation are sampled. Relationship to Laplace transform

Discretization:

Using the \(z\)-transform we get the following form:

\[ \begin{align} Pr(z^{-1}) = \left(K_p + K_r . \dfrac{b_0 + b_1.z^{-1}}{a_0+a_1.z^{-1}+ a_2.z^{-2}}\right) \\ \\ Pr(z) = \left(K_p + K_r . \dfrac{b_0 .z^2 + b_1.z^1}{a_0.z^{2}+a_1.z^{1}+ a_2}\right) \end{align} \]

As there's a direct relation between \(z^{-1}\) and \(q^{-1}\) the delay operator, we can write the reccuring equations we will use in the code.

\[ \begin{align} res_k &= b_0.\epsilon_k + b_1.\epsilon_{k-1} - a_1.res_{k-1} - a_2.res_{k-2} \\ \\ u_k &= K_p . \epsilon_k + K_r .res_k \end{align} \]

With:

\[ \begin{align} a_1 &= -2.\cos(T_s . \omega_0)\\ a_2 &= 1.0\\ b_0 &= T_s . \cos(\phi')\\ b_1 &= -T_s . \cos(\phi' - T_s . \omega_0)\\ \end{align} \]

Use of the Proportionnal Resonant Controller.

The use of the Pr is based on 3 steps.

  1. Object instanciation (declaration).
  2. Initialisation.
  3. Execution.

Example

For each Controller like (Pid, Rst, Pr) we have to define a parameter structure.

We define constants used to initialize the parameter structure.

#include "pr.h"

static float32_t Kp = 0.001F;
static float32_t Kr = 300.0F;
static float32_t w0 = 2 * PI * 50.0F;
static float32_t phase_shift = 0.0F;
static float32_t upper_bound = 1.0F;
static float32_t lower_bound = -1.0F;
static float32_t Ts = 100.0e-6F;

We define the parameter structure. Each parameter is defined here.

static  PrParams params = PrParams(Ts, Kp, Kr, w0, phase_shift, lower_bound, upper_bound);

We define the variable prop_res which is a Pr object.

static Pr prop_res;

In the setup_routine() of the OwnTech Power API, you must initialize the Pr with its parameters.

prop_res.init(params);

In the loop_critical_task() you can call the method calculateWithReturn() which have two arguments:

  1. the reference
  2. the measure.

Remind that the loop_critical_task() is called every 100µs.

new_command = prop_res.calculateWithReturn(reference, measurement);

new_command is the result of the pr calculation for one step.

Example

You can find the use with a grid forming example which generate an AC voltage source.