function [q1, q2, q3, q4, duty_cycle] = buckBoostController(vin)
q1 = 0;
q2 = 0;
q3 = 0;
q4 = 0;
duty_cycle = 0;
delay = 0;
% Define the duty cycle and delay values for each case of input voltage
if vin == 0.6
duty_cycle = 0.6667;
delay = 5e-7*(240.012)/360;
elseif vin == 0.77
duty_cycle = 0.7004;
delay = 5e-7*(252.144)/360;
elseif vin == 1.2
duty_cycle = 0.6000;
delay = 5e-7*(216)/360;
elseif vin == 2
duty_cycle = 0.4737;
delay = 5e-7*(170.532)/360;
end
% Calculate the duty cycles for q1, q2, q3, and q4 based on the input voltage and duty cycle
if vin == 2
% Operate in Buck Mode
q1 = duty_cycle;
q2 = 0;
q3 =1-duty_cycle;
q4 = 1.8;
elseif vin == 1.8
% Operate in Battery Voltage Mode
q1 = 1.8;
q2 = 0;
q3 = 0;
q4 = 0;
else
% Operate in Boost Mode or Battery Voltage Mode
q1 = 1.8;
q2 = duty_cycle;
q3 = 0;
q4 = 1-duty_cycle;
end
end