In this example you need to have a first Twist with the Grid Forming example.
The parameters are:
$U_{DC} = 40 V$ -
$R_{LOAD} = 15 \Omega$ .
In the second Twist we use a software phase locked loop ( "PLL" ). By this way we are synchronised with the grid voltage and we can then inject current with a power factor of one. The current is regulated using a proportional resonant ("PR") regulator.
the "pll" and "pr" are provided by the OwnTech control library which must be included
in the file platfomio.ini
.
lib_deps=
control_lib = https://github.com/owntech-foundation/control_library.git
The Proportional Resonant regulator is initialized with the lines above:
PrParams params = PrParams(Ts, Kp, Kr, w0, 0.0F, -Udc, Udc);
prop_res.init(params);
The parameters are defined with these values:
static Pr prop_res; // controller instanciation.
static float32_t Kp = 0.2F;
static float32_t Kr = 3000.0F;
static float32_t Ts = control_task_period * 1.0e-6F;
static float32_t w0 = 2.0 * PI * 50.0; // pulsation
You have to define a PLL:
static PllSinus pll;
static PllDatas pll_datas;
Then initialize it:
float32_t rise_time = 50e-3;
pll.init(Ts, Vgrid_amplitude, f0, rise_time);
and use it:
pll_datas = pll.calculateWithReturn(V1_low_value - V2_low_value);
The calculation return a structure with 3 fields:
- the pulsation
w
in [rad/s] - the angle
angle
in [rad] - the angle error
error
in [rad/s]
The voltage source is defined by the voltage difference:
Link with the duty cycle:
- The leg1 is fixed in buck mode then:
$V_{1low} = \alpha_1 . U_{DC}$ - The leg2 is fixed in boost mode then:
$V_{2low} = (1-\alpha_2) . U_{DC}$
We change at the same time
And then:
After stop i.e. in IDLE mode you can retrieve some data by pressing 'r'. It calls a
function dump_scope_datas()
which send to the console variables recorded during
the power flow phase.
But before running, you have to add one line in the file platfomio.ini
monitor_filters = recorded_datas
And you have to put the python script filter_datas_recorded.py
in a monitor
directory
which must be in you parent project directory. Then the script should capture the
console stream to put it in a txt file named year-month-day_hour_minutes_secondes_record.txt
.
These files can be plotted using the plot_data.py
python script if you have the
matplotlib
and numpy
modules installed.