This examples demonstrates bidirectional coupling of two
batteries with different voltages as used in automotive. For
idleDutyCycle = 1 - (VLV/VHV), no current is
exchanged.
Starting with dutyCycle < idleDutyCycle, the
high voltage battery feeds the low voltage battery. Changing the
dutyCycle > idleDutyCycle, the low voltage battery
feeds the high voltage battery.
The capacitors are precharged to the battery voltages, but the inductor leads zero current. The current sensor may be used to implement current control.
For hints implementing control, see: Stefan Norbert Matlok, Digitale Regelung bidirektionaler Gleichspannungswandler (German, Digital control of bidirectional DC/DC converters), PhD thesis University Erlangen-Nuremberg 2020.