Problem plotting postprocess data

I am trying to compare the dynamic response of two buck converters. Everything goes well but when I try to represent the post process data of the two responses the representation is not correct. It does not show the magnitude and phase separately.
What can be the issue?
The library file for the components is available here:
4.- Buck-closed-loop-bode-FRA - Comparison.qsch (29.0 KB)

Missing subckt of opamp
MyLibrary.lib from the Library path you share only contains .subckt for comparator but without opamp.

A suggestion for symbol library file. As consider for sharing purpose, symbol should prevent using absolute path. Just put MyLibrary.lib in Library File of symbol, and you have two method to link to that library

  1. Add directive .libpath C:\Users\[*username*]\Documents\QSPICE\MyLibrary\ in schematic
  2. View → Symbol & IP Browser, Add "C:\Users\[*username*]\Documents\QSPICE\MyLibrary\" to your symbol directory
    The second method do the same thing as first method, just QUX.exe automatically do it for you when converting schematic into netlist

The benefit is that, when you share your schematic and library file, what we do is just to put your schematic and library file in same folder and can run the simulation. If not, we have to go to each symbol and delete the absolute path.

I put my ideal opamp to run your simulation, and your question is how to plot magnitude and phase from .meas results.

I think waveform viewer may not handle fra measurement results yet (i.e. in format 17.0598dB -98.9782°). An alternative way is to setup extra .meas parameter which convert this format into dB and phase only.
** remark, I don’t know why result is 0 17.0598 0.0085 in magnitude and 0 -98.9782 0.0085 in phase, definitely no idea what 0.0085 come from. But it seems that extra number not affecting what to look for.

.meas GaindB dB(abs(Gain))
.meas GainPhase Phase(Gain)
.meas GaindB_i dB(abs(Gain_i))
.meas GainPhase_i Phase(Gain_i)
.meas plot GaindB GaindB_i
.meas plot GainPhase GainPhase_i

Just for your reference, you can do what you are trying to do with .bode simulation directive.
It needs some learning before your can master it. You can get more information from Qspice HELP or from Qspice - Bode Frequency Response Analysis (.bode).pdf in my Github. Here is an example using .bode from your schematic. I changed the comparator to a comparator with TTOL as it normally work better in .bode simulation as simulation come across different perturbution frequency and need a smarter timestep control through simulation.

Buck-closed-loop-bode (.bode).qsch (15.7 KB)

Thanks for the information on the library. This is very useful information. I will do so in the future.
Thanks for the solution to do the representation. This solves the issue. It is very useful information to know how to process the data after simulation.
I know that we can use .bode. I have tried it but I think we have more control using .meas fra because we can see the waveforms and know what is happening. For example, I have seen that it is better to wait a few periods after injecting the perturbation before calculating the gain because there is a small transient, especially at high frequencies. That is why I do the .tran up to t0+8/freq and process from t0+4/freq. What do you think?

And if the perturb amplitude is changing what is the effect for this? What is the benefit of using a perturb amplitude that is changing vs using a perturb amplitude that is not changing?

Yes, I agree with it. Currently, .bode doesn’t offer .tran data and user may enter a mist when thing goes wrong. I also thought about if it is because you are working on tutorial and prefer to use FRA instead of .bode before I sent above example.

1 Like

At high frequency the gain of the system is very small. It is better to use a higher amplitude of the input perturbation so the perturbation at the output is higher too. Otherwise the output perturbation is too small and the error in the measurement is higher. It is the same thing as when doing the measurement at the laboratory.
At low frequency the gain of the system is high enough and we do not want to introduce a too high perturbation because we can go to far from the steady-state operating point and get into non-linear region. This would distort the measurement too.
This kind of behavior is what you can investigate using .meas fra statement but not if you use .bode.

1 Like