Bidirectional Buck and Boost Converter

Below is the Circuit Diagram, Equations and Calculator for Calculating different aspects like Power, Current and Voltage average, Inductance, Switch On and off time etc in a Bidirectional Buck and Boost DC to DC converter. I will write an article separately explaining the workings of DC to DC converter.

Assuming Duty Cycle Ds1 and Voltage Source Vin = VHVbus, Vout = Vbattery is constant. V12average = DS1*VHVbus.
Then
No Power Flow Vout (battery) = V12 average
Buck Operation Vout (battery) < V12 average
Boost Operation Vout (battery) > V12 average
Equations:
Ds1 = Ton/Toff
T = Ton + Toff
Ds2 = ( 1 – Ds1)
T = 1 / f
V12 = Ds1 * VHVbus
I av = (V12 – Vbatt) / R
P0 = I av * Vbatt
VL (on) = VHVbus -Vbatt-Iav*R
ΔI = ( VL (on) * Ton ) / L
VL (off) = ( – Vbatt) – (I av * R)
ΔI = ( VL (off) * Toff ) / L
Where
Vout is the output Voltage
V12 is the average voltage across Switch 2
Vin is the input voltage
Ds1 is the duty cycle of the Switch S1
Ds2 is the duty cycle of the Switch S2
f is the switching frequency of the semiconductor Switch
T is the time period of the semiconductor Switch
Ton is the ON time of the semiconductor Switch
Toff is the OFF time of the semiconductor Switch
I av is the average current through the Inductor the sign of I av determines the direction of Power Flow
R is the Resistance of the Inductor
P0 is the power Delivered to the output Voltage V out
Interactive animation from TU Delft University
Below is Individual Buck Converter and Boost Converter Circuit Diagram and equations. Calculator to be added later for this one.
Buck Converter:

Vout = DVin
T = 1/f
D = Ton / (T )
T = Ton + Toff
Where
Vout is the output Voltage
D is the duty cycle of the Switch
Vin is the input voltage
f is the switching frequency of the semiconductor Switch
T is the time period of the semiconductor Switch
Ton is the ON time of the semiconductor Switch
Toff is the OFF time of the semiconductor Switch
Boost Converter:

Vout =Vin / ( 1 – D )
T = 1/f
D = Ton / (T )
T = Ton + Toff
Where
Vout is the output Voltage
D is the duty cycle of the Switch
Vin is the input voltage
f is the switching frequency of the semiconductor Switch
T is the time period of the semiconductor Switch
Ton is the ON time of the semiconductor Switch
Toff is the OFF time of the semiconductor Switch