PWMSim

LTspicePowerSim

Flyback — peak current mode with PI loop

LTspicePowerSim's 24 V to 5 V flyback, its boundary-mode latch and compensator replaced by a clocked current-mode switch.

Open and simulate
Press Run: the example simulates in your browser. Open and simulate takes it to the full app, where you can change it.

Try this

Halve the load resistance: the peak primary current rises from 1.08 A to 1.71 A and the output stays at 5 V. Then press Run again.