Hello forum,
since some time I have a problem with the fft analyse which can be accessed through the plot window in LTSpice XVII. When i start a new schematic everything is fine for some time but then the end time in the option window starts to variate. For example 10ms of simulation time can lead to an end time of 10.00033ms in the fft analyse. This small difference destroys the analyse and I have to adjust the end time manually every time a do a fft analyse. Is there any way to avoid this?
Best greetings
Joel
since some time I have a problem with the fft analyse which can be accessed through the plot window in LTSpice XVII. When i start a new schematic everything is fine for some time but then the end time in the option window starts to variate. For example 10ms of simulation time can lead to an end time of 10.00033ms in the fft analyse. This small difference destroys the analyse and I have to adjust the end time manually every time a do a fft analyse. Is there any way to avoid this?
Best greetings
Joel
Joel
Do you specify a Maximum Timestep in your transient analysis?
The FFT analysis needs a specific number of data points. The default is 262144 points, but this can be changed from 256 to 16777216 points in the FFT dialogue.
What is noticeable is that these numbers are all 2 to the power of an integer. For example, the default 262144 is 2^18. So in order to get the FFT accurately to analyse a set number of cycles, you need to set the Maximum Timestep so that, at the default setting, 2^18 timesteps cover exactly the needed total time.
This is a bit of a nightmare to set up for every different analysis, but there are ways to simplify things. I do it as follows – this runs the transient analysis for 10 cycles, but drops the first 2, so that the last 8 cycles are displayed in the waveform window.
Suppose your source signal is a voltage source set to output a sinewave. In the source’s dialogue box, set the field for Freq[Hz] to “{Frequency}” (without the quotation marks but with the curly brackets).
Put the following directives on the schematic:
.param Frequency=1k
.param StartTime=(1/Frequency)/2
.param StopTime=(1/Frequency)/10
.param MaxTimestep=(StopTime-StartTime)/fft
.param fft=2**18
.tran 0 {StopTime} {StartTime} {MaxTimestep}
(Note that ** is equivalent to ^ in LTspice, and the .tran command would normally be set up in the Edit Simulation Command/Transient dialogue box)
Now, to run any transient analysis, all one has to do is to set the parameter Frequency to the desired value, and LTspice will automatically display the last 8 of 10 cycles in the waveform window. Moreover, the number of timesteps will be exactly right for the FFT analysis to analyse exactly those 8 cycles.
Assuming the default “Use Extent of Simulation Data” is chosen in the FFT dialogue, you will find that Start Time=0, and End Time=8ms (which is 8 cycles at 1kHz – the value will change automatically to 8 cycles of your chosen frequency).
Incidentally, it’s LTspice, not LTSpice (small letter s). The best place to get help with the nuts and bolts of LTspice is the Yahoo users’ group; they are a very knowledgeable, friendly and helpful bunch over there.
I hope this helps
Stephen
Do you specify a Maximum Timestep in your transient analysis?
The FFT analysis needs a specific number of data points. The default is 262144 points, but this can be changed from 256 to 16777216 points in the FFT dialogue.
What is noticeable is that these numbers are all 2 to the power of an integer. For example, the default 262144 is 2^18. So in order to get the FFT accurately to analyse a set number of cycles, you need to set the Maximum Timestep so that, at the default setting, 2^18 timesteps cover exactly the needed total time.
This is a bit of a nightmare to set up for every different analysis, but there are ways to simplify things. I do it as follows – this runs the transient analysis for 10 cycles, but drops the first 2, so that the last 8 cycles are displayed in the waveform window.
Suppose your source signal is a voltage source set to output a sinewave. In the source’s dialogue box, set the field for Freq[Hz] to “{Frequency}” (without the quotation marks but with the curly brackets).
Put the following directives on the schematic:
.param Frequency=1k
.param StartTime=(1/Frequency)/2
.param StopTime=(1/Frequency)/10
.param MaxTimestep=(StopTime-StartTime)/fft
.param fft=2**18
.tran 0 {StopTime} {StartTime} {MaxTimestep}
(Note that ** is equivalent to ^ in LTspice, and the .tran command would normally be set up in the Edit Simulation Command/Transient dialogue box)
Now, to run any transient analysis, all one has to do is to set the parameter Frequency to the desired value, and LTspice will automatically display the last 8 of 10 cycles in the waveform window. Moreover, the number of timesteps will be exactly right for the FFT analysis to analyse exactly those 8 cycles.
Assuming the default “Use Extent of Simulation Data” is chosen in the FFT dialogue, you will find that Start Time=0, and End Time=8ms (which is 8 cycles at 1kHz – the value will change automatically to 8 cycles of your chosen frequency).
Incidentally, it’s LTspice, not LTSpice (small letter s). The best place to get help with the nuts and bolts of LTspice is the Yahoo users’ group; they are a very knowledgeable, friendly and helpful bunch over there.
I hope this helps
Stephen
Hello Stephen,
Yes I specified a max. timestep but I tried your settings cause i like the way to set the resolution by fft=2**18. I had to change the division of the wave length to a multiplication to get right parameters. Now everything looks good in the transient analyse and all parameters are adjusted correctly to my frequency setting.
But I still have the problem with the fft analyse. When I open the fft settings through the plot window, the end time is set to 7.9999695ms. The frequency is 1kHz which should result in 8ms since the first 2 waves ar dropped. When I put 8ms as end time the noise floor of the fft analyse goes down to -270dB which ist great. Without adjusting it the small pulse at 1kHz is much wider and the noise floor moves up to -100dB which makes all harmonics just invisible.
EDIT: I just tried some changes on StopTime and the problem seem to appear for some values of StopTime. It does not really depend on the frequency but when I use the following settings I don't get the problem anymore. So maybe I can work around by fixing the StopTime or actually the difference between Start and StopTime to a working value.
.param Frequency=1k
.param StartTime=(1/Frequency)*2
.param StopTime=(1/Frequency)*20
.param MaxTimestep=(StopTime-StartTime)/fft
.param fft=2**18
.tran 0 {StopTime} {StartTime} {MaxTimestep}
Best regards and thanks for your help
Joel
Yes I specified a max. timestep but I tried your settings cause i like the way to set the resolution by fft=2**18. I had to change the division of the wave length to a multiplication to get right parameters. Now everything looks good in the transient analyse and all parameters are adjusted correctly to my frequency setting.
But I still have the problem with the fft analyse. When I open the fft settings through the plot window, the end time is set to 7.9999695ms. The frequency is 1kHz which should result in 8ms since the first 2 waves ar dropped. When I put 8ms as end time the noise floor of the fft analyse goes down to -270dB which ist great. Without adjusting it the small pulse at 1kHz is much wider and the noise floor moves up to -100dB which makes all harmonics just invisible.
EDIT: I just tried some changes on StopTime and the problem seem to appear for some values of StopTime. It does not really depend on the frequency but when I use the following settings I don't get the problem anymore. So maybe I can work around by fixing the StopTime or actually the difference between Start and StopTime to a working value.
.param Frequency=1k
.param StartTime=(1/Frequency)*2
.param StopTime=(1/Frequency)*20
.param MaxTimestep=(StopTime-StartTime)/fft
.param fft=2**18
.tran 0 {StopTime} {StartTime} {MaxTimestep}
Best regards and thanks for your help
Joel
This looks like a rounding error within LTspice to me.
If you don't already do this, add:
.option plotwinsize=0
.option numdgt=7
to your schematic. This will increase the precision of the internal maths by disabling compression of the waveform data, and by forcing double precision for variable data.
I must say that the method I showed works well for me (with the two .options shown above) - the End Time shows as exactly 8mS with a 1kHz i/p. But I'm glad at least that it showed you a way forward.
Stephen
If you don't already do this, add:
.option plotwinsize=0
.option numdgt=7
to your schematic. This will increase the precision of the internal maths by disabling compression of the waveform data, and by forcing double precision for variable data.
I must say that the method I showed works well for me (with the two .options shown above) - the End Time shows as exactly 8mS with a 1kHz i/p. But I'm glad at least that it showed you a way forward.
Stephen
- Status
- Not open for further replies.