Skip to content
Snippets Groups Projects
config_script.m 2.08 KiB
Newer Older
% script to launch before everything! 
clear all;
%% add the path of this file to the matlabpath.
[dirName, fileName, ext] = fileparts(mfilename('fullpath'));
addpath(dirName);

%% Initializes the simulation

sim_time = 0.05;  %overall simulation time

%% Initialize the source parameters

source_R = 0.1; %source internal resistance [Ohm]
source_V = 40;  %source voltage [V]


%% Initialize the load parameters

load_Vout = 24; %load voltage [V]
load_freq = 1;  %load frequency [Hz] - near DC
load_Power = 200; %load power [W]

load_pulse1_on_time = sim_time*0.2; %disturbance starts at 20% of simulation
load_pulse1_off_time = sim_time*0.4; %disturbance ends at 40% of simulation

load_C = 240e-6;  %load capacitance [F]
load_C_init_V = load_Vout ; %load capacitor initial voltage [V]
load_Rline1 = 1;  %load line 1 resistance [Ohm]
load_Rline2 = 1;  %load line 2 resistance [Ohm]


%% Initilalizes twist parameters

isInterleaved = 1; %defines if the legs are interleaved

twist_low_side_L = 33e-6;
twist_low_side_rL = 20e-3;
twist_low_side_C = 47e-6 + 0*3*4.7e-6;
twist_low_side_rC = 0.4;

twist_high_side_rC = 0.1;
twist_high_side_C = 120e-6;
twist_high_side_C_init_V = source_V;


twist_FET_Ron = 0.02;
twist_FET_Rd = 0.01;
twist_FET_Vf = 1.5;
twist_FET_Rs = 1e5;
twist_FET_Cs = inf;



twist_freq_switching = 200e3;
twist_period_switching = 1/twist_freq_switching;
twist_freq_control=1000;  %control frequency

twist_freq_sampling=10000; %sampling frequency
twist_period_sampling = 1/twist_freq_sampling;

twist_duty_cycle_max = 0.9; %Maximum duty cycle
twist_duty_cycle_min = 0.1; %Minimum duty cycle

twist_pwm_resolution = 100e-9; %resolution of the PWM generator

twist_meas_delay = 200e-9; %delay of the measurement chain
twist_data_sampling_period = 1/twist_freq_sampling;

twist_phase_shift_leg_1_deg = 180;
twist_phase_shift_leg_1_sec = (twist_phase_shift_leg_1_deg/360)*(twist_period_switching);




%% Initialize control parameteres

control_v_low_ref = 24;  %voltage reference for the ++/-- control
control_d_step = 0.01; %step for the ++/-- control
control_droop_R = 1;     %resistance of the droop control