I'm trying to simulate a buck converter IC in LTSpice (MP4569) based on the functional block diagram from the datasheet using behavioral voltage sources to represent the logic from the block diagram.
I have 2 switches in place of the high and low side mosfets and the switches are driven by behavioral voltage sources.
I'm trying to implement the zero current detection block (ZCD block on the diagram) with a behavioral voltage source with the condition comparing the current to a threshold (
V=(I(L1)>1m), the number is arbitrary, just a small near-zero value, could be zero.
The LTSpice model is available here.
I end up having the output of the ZCD voltage source in the simulation to be always 0 (after the initial 1 in the very beginning), BUT the current in the inductance is oscillating (very small amplitude) just above the limit in the ZCD voltage source (whatever I set it to). Also the simulation slows down to a crawl at this point and never completes, I have to stop it.
It appears that it does trigger the voltage source, but very briefly and it's not visible on the output when plotted in the simulation, but it does affect the behavior of the switch.
Maybe some kind of hysteresis is needed around the zero current for this ZCD voltage source, but I cannot figure out how to add it. I tried adding a flip-flop with 2 behavioral voltage sources connected to Set and Reset but it didn't help and I'm still getting similar behavior