fs = 20e3; % Sampling, interrupt and switching frequency [Hz]
Ts = 1/fs; % sampling and switching period [s]
Vg = 230; % RMS Grid voltage [V]
fg = 50; % Grid frequwncy [Hz]
Lg = 2.5e-3; % Inductance used for the grid [H]
Rg = 22e-3; % Resistance of the inductor used for the grd [Ohm]
Vg_dc_0 = 700; % Initial grid-side DC bus voltage [V]
% GRID CURRENT CONTROL
K1 = 1/Rg;
T1 = Lg/Rg;
Td1 = (1/2 + 1 + 1/3)*Ts; % 1/2Ts of sampling, Ts of computation, 1/3 for the triangle carrier
Tn1 = T1;
Ti1 = 2*K1*Td1;
Kp1 = Tn1/Ti1;
Ki1 = 1/Ti1;