Fastest simulation method for variable frequency regulator

Hi,

I want to simulate a resonant DCDC converter (LLC) which uses frequency modulation as a way to regulate the output voltage.

I have a module in C which calculates the desired switching frequency fsw. Can you propose implementation methods for the variable frequency?

I have seen an approach using the C block where the simulation time variable is used but I wonder whether there’s a lighter implementation, maybe one that does not use the time variable.

TSW = 1 / fsw; //Switching period
t_var = t/TSW - floor(t/TSW); //this is a sawtooth with frequency = fsw
if ((t_var) < 0.5) output = 1
else output = 0;

The if part can be easily substituted by a behavioral voltage source although I don’t know what is lighter for the simulation.

Before, I was using a pulse voltage source and the simulation got more than 10 times slower.

After some optimization the code got as simple as:
product = t * fsw_ref;
VM = product - (int)product;
and this VM is the sawtooth which I compare externally with bv, but still is excessively slow.

Thanks and regards

Hi, mosfet.

There are lots of ways to unintentionally make QSpice simulate slowly. You might want to post the *.qsch & *.cpp.

–robert

Hi,

I think there might have been something else in the simulation, which I inadvertently solved.

Anyway, for generating a variable frequency squarewave the logic that worked best for me was:

product = t * fsw_ref;
VM = product - (int)product;

and the generated sawtooth is compared against a fixed threhsold, 0.5 for me for a 50% duty cycle, with a bv element.

Regards