¿ªÔÆÌåÓý

Looking for advice on TRAN timing #FFT


 

I'm looking for help concerning the timing parameters of a TRAN simulation
to evaluate the distortion of an amplified sine wave.
?
I've been reading through lots of messages of this group concerning "distortion" and "tran timing"
recently but could not find an answer to what I was looking for.
[I came across the audio distortion analyser contributed by Tony Casey,
for which I am thankful and it is indeed a fine tool.]
?
Hitherto I've used 1 or 2 per mille of the sine wave period, so the time step would be 1 usec or 2 usec
when testing with 1 kHz. From my tests I decided for myself that values exceeding 1% of the period
should best be avoided.
I also tested time steps adjusted to the power of 2, e.g. 2**14 (interval / 16384).?
?
For the interval (t_stop - t_start) I usually take 16msec when testing with 1kHz
but I have also used values from 10msec to 48msec.
It is this parameter which I personally find most difficult to decide upon.
?
So, to sum it all up, I wonder if there is a guideline which values to use for the time step
and the interval for a certain test frequency when testing audio related circuits with sine waves.
(I'm still using LTspice XVII.)
?
Ryu


 

¿ªÔÆÌåÓý

Time step: Set to half (or less) the period of the highest harmonic you are interested in.

Interval: The longer you make it, the lower is the frequency that appears as the fundamental, and the narrower the bandwidth of the peaks in the spectrum display. For example, if you simulate for 100ms, the lowest frequency you can see is 10 Hz, and the spectral 'lines' are 10Hz wide.


On 2025-02-21 12:34, Ryu via groups.io wrote:
I'm looking for help concerning the timing parameters of a TRAN simulation
to evaluate the distortion of an amplified sine wave.
?
I've been reading through lots of messages of this group concerning "distortion" and "tran timing"
recently but could not find an answer to what I was looking for.
[I came across the audio distortion analyser contributed by Tony Casey,
for which I am thankful and it is indeed a fine tool.]
?
Hitherto I've used 1 or 2 per mille of the sine wave period, so the time step would be 1 usec or 2 usec
when testing with 1 kHz. From my tests I decided for myself that values exceeding 1% of the period
should best be avoided.
I also tested time steps adjusted to the power of 2, e.g. 2**14 (interval / 16384).?
?
For the interval (t_stop - t_start) I usually take 16msec when testing with 1kHz
but I have also used values from 10msec to 48msec.
It is this parameter which I personally find most difficult to decide upon.
?
So, to sum it all up, I wonder if there is a guideline which values to use for the time step
and the interval for a certain test frequency when testing audio related circuits with sine waves.
(I'm still using LTspice XVII.)
?
Ryu
--
OOO - Own Opinions only If something is true: * as far as we know - it's science *for certain - it's mathematics *unquestionably - it's religion

Virus-free.


 

On Fri, Feb 21, 2025 at 07:34 AM, Ryu wrote:
Hitherto I've used 1 or 2 per mille of the sine wave period, so the time step would be 1 usec or 2 usec
when testing with 1 kHz. From my tests I decided for myself that values exceeding 1% of the period
should best be avoided.
In my opinion, those are good choices.? I prefer to keep the timestep smaller than 1% of the period, and sometimes I make it 0.1% or smaller.? It depends on how low I want the artifacts to be, and how low I can make them.? Eventually, "diminishing returns" sets in and it's pointless to change it further, but each case is different and there are no general rules about that.? 0.1% might be overkill in one case, and insufficient in another.
?
Of course it's assumed that you disabled waveform compression.
?
I also tested time steps adjusted to the power of 2, e.g. 2**14 (interval / 16384).?
That might help, but I am not aware that it actually does.? In my experience, keeping the time steps small is more important.

For the interval (t_stop - t_start) I usually take 16msec when testing with 1kHz
but I have also used values from 10msec to 48msec.
It is this parameter which I personally find most difficult to decide upon.
The one most important thing is that the interval MUST be an exact multiple of the signal's period.
?
If you don't make Tstop-Tstart equal to an exact multiple, then make sure that your FFT's time interval is set to an exact multiple.? You do not need to find the FFT over the whole simulated interval.
?
Whether it is 1 period or 100 periods, that might not make much difference when checking harmonics (via FFT or something similar).? But it does make a difference in the display of harmonics in LTspice's View > FFT, but I don't think it affects the numerical results that much.
?
Now this is assuming that each of your cycles looks like the next one.? If, for some reason, they are not, then you may want to re-consider this.
?
Also be aware of the interaction with the "Number of data point samples in time" in the FFT menu.? You have interaction between that number and the number of audio cycles you captured.
?
So, to sum it all up, I wonder if there is a guideline which values to use for the time step
and the interval for a certain test frequency when testing audio related circuits with sine waves.
Experiment!? Other than what I stated above and has been stated and re-stated several times already, my advice is to experiment.? Don't be satisfied with one technique and the same settings every time.? Try things.? See what matters to your simulations.? It won't be the same every time.? Once you find what seems to work best in your situation, then it's OK to stick with that.? But in another simulation, the choices might not be the same.
?
Andy
?


 

Time step: Set to half (or less) the period of the highest harmonic you are interested in.

Hmm.? That is a necessary requirement to get anything resembling the right frequency in the simulated waveforms.? But it does not get you a good spectrum from which you can estimate distortion.? For that, time step needs to be MUCH smaller.
?
Andy
?


 

¿ªÔÆÌåÓý

If you're interested, I have a new tool, which is somewhat faster than the Analyser you mentioned and just as accurate.

I don't know for sure whether using (maximum) timesteps of binary fractions of the period are better, or not, but it is convenient. You might also find THD_Measurement_Test_Results.pdf useful. It shows the THD measurement floor as you increment the exponent, "n", in the expression Tmax = Period/2**n. There's no point in making Tmax shorter than necessary as it just makes the simulation slower for no benefit.

--
Regards,
Tony


On 21/02/2025 13:34, Ryu via groups.io wrote:

I'm looking for help concerning the timing parameters of a TRAN simulation
to evaluate the distortion of an amplified sine wave.
?
I've been reading through lots of messages of this group concerning "distortion" and "tran timing"
recently but could not find an answer to what I was looking for.
[I came across the audio distortion analyser contributed by Tony Casey,
for which I am thankful and it is indeed a fine tool.]
?
Hitherto I've used 1 or 2 per mille of the sine wave period, so the time step would be 1 usec or 2 usec
when testing with 1 kHz. From my tests I decided for myself that values exceeding 1% of the period
should best be avoided.
I also tested time steps adjusted to the power of 2, e.g. 2**14 (interval / 16384).?
?
For the interval (t_stop - t_start) I usually take 16msec when testing with 1kHz
but I have also used values from 10msec to 48msec.
It is this parameter which I personally find most difficult to decide upon.
?
So, to sum it all up, I wonder if there is a guideline which values to use for the time step
and the interval for a certain test frequency when testing audio related circuits with sine waves.
(I'm still using LTspice XVII.)


 

To all who replied so far a hearty thanks! I will do some more experimenting as supposed by Andy.
?
One more thing that troubles me is: when I step Tstop from let's say 12m to 18m in (1m or whatever) steps and thereafter do an FFT on v(out), only the very last step is displayed as an FFT as I expect it to be . . . :-(
As a reference I've uploaded two screenshots to the Photos directory. They are in the album "TRAN param query (Ryu)"
?
--
Regards,
Ryu


 

Maybe I should have mentioned that the D.U.T is nothing extraordinary, it is a Bryston DOA33 replacement (discrete opamp)?
and? a mere 10dB amplification.
?
--
Ryu


 

On Sat, Feb 22, 2025 at 12:02 AM, Ryu wrote:
One more thing that troubles me is: when I step Tstop from let's say 12m to 18m in (1m or whatever) steps and thereafter do an FFT on v(out), only the very last step is displayed as an FFT as I expect it to be . . . :-(
I am a little confused whether it works as you expected, or not as you thought and this troubles you.
?
I suspect there could be a problem doing an FFT when .STEPping Tstop, if the requested time interval is not the same in all of them.? I think the FFT is performed all at once, and that would not work unless the time interval is correct.? I think you can compensate for that by specifying a time range for the FFT that is smaller than that of the shortest .STEP, and is appropriate for the waveform's frequency.? Thus it would apply the FFT over only a portion of the saved waveforms, which is hopefully the same time interval regardless of the .STEP.
?
It looks like some of your FFT spectra in your uploaded screenshots are corrupted.? Maybe that happened because of the time interval problem described above.? The "Run: 1/2" plot in your "FFT-step Tstop 10m + 12m.png" looks particularly bad.? "Run: 1/2" in "FFT-step Tstop 12m + 18m.png" looks bad too.
?
Note it might help to turn on View > Mark Data Points, to see where the "real" spectral data is.
?
Andy
?


 

@Tony
Thank you for your answer, Tony. Is the new version available in the Files section?
I also had a look at the PDF file you mentioned.
I presume Tswp stands for sweep time, Tdel for the time you delete from the beginning,?
and Mcycles for the amount of cycles that you actually use for measuring, is that right?
?
Ryu


 

Ryu,
?
See the file STEP_Sine_FFT.zip that I uploaded to the Temp folder.? It shows what happens to your waveform when you .STEP the .TRAN simulation's stop time.? When the waveforms are separated into different plot panes, you can see that part of some waveforms are missing.? That causes the FFT to process a modulated signal, unless you restrict the time interval that is passed to the FFT.? Without that step, the FFT processes the waveform over the full extent of the simulated data, which includes time where some of the .STEPs were not simulated.
?
Andy
?


 

Thank you for your reply and the test file, Andy.
Indeed, splitting v(out) into v(out)@1 and v(out)@2 clearly revealed the missing part at the end,
and so the crazy fft plot makes perfect sense. Specifying a time range solved the fft problem.
?
--
Ryu