Cycle by Cycle Average or RMS

Hi
Is there any way i can get RMS or AVERAGE of the switching waveform in Qpsice. Cycle by Cycle averaging of the waveform, like moving periodic average in other softwares? For example i want to see the averaged and switching waveforms of the buck converter in transient simulation.
Any help is appreciated.


Mike

You can refer to this post for a real time statistic block to calculate RMS and Mean continuously. The idea was originated from @bordodynov and I modify it a bit and built into a subckt symbol.
https://forum.qorvo.com/t/behavioral-true-rms-to-dc-converter/21726/3

This symbol can be download from my Github (Github : Stat-RealTime.qsym)
and this is an example schematic to demonstrate its performance. With this, you should have all information to study how this math works… it rely on delay() function, so, a bit tricky approach and can be heavy computational.
example2.Stat-RealTime.qsch (4.2 KB)

HOWEVER, your question is Cycle by Cycle results… this requires math to sync with your switching signal, and I think the only way to do it is to write a DLL block for such purpose. The statistic information should calculate during each switching period, and update the output at end of each switching period, and then next. I think it possible but I expect you have to be good at DLL block (C++ block) in order to do it.

OR, if Cycle by Cycle in your text only mean a Window for calculation, possibly above native devices approach is good enough. I didn’t do this with a DLL block, as DLL symbol needs share a .qsym and a .cpp / .dll… if something can be done with a .subckt only with native devices, I prefer to do it in this way.

But I mention this, as this math rely on delay() function, if not taking care of simulation step, delay() function can introduce error in math. But to limit maxstep also somehow limit simulation speed. So, this is where I hesitate if real-time statistic should implement with a DLL block, and for example, max, min, etc… can be implement more easy with DLL.