% This file is used to compute the values of Kp and Ki for the current regulator.
% Place this file in the same folder than the Simulink file.


% PARAMETERS
fs = 20e3;              % Sampling, interrupt and switching frequency [Hz]
Ts = 1/fs;              % Sampling period [s]

Lb = 2.5e-3;            % Inductance used for the boost [H]
Rb = 22e-3;             % Resistance of the inductor used for the boost [Ohm]


C = 260e-6;             % Capacitance of the DC bus [F]
Vb = 100;               % Battery voltage [V]
Rload = 87;             % Load resistance [Ohm]

Vdc0 = 202;             % Inital DC bus voltage [V]
Ib0 = 5;                % Inital boost current [A]


% BOOST CURRENT REGULATOR -------------------------------------------------

K1 = 1/Rb;
T1 = Lb/Rb;

Td = (1/2 + 1/2 + 1/3)*Ts; % 1/2Ts of sampling, 1/2Ts of computation, 1/3 for the triangle carrier

Tn1 = T1;
Ti1 = 2*K1*Td;

Kp1 = Tn1/Ti1;
Ki1 = 1/Ti1;

