Distortion measurements with LTSPICE

LTSPICE is offering good capabilities for distortion analysis and simulations. All you have to do is to run transient analysis and then right click on the signal plot and use FFT command from view section of submenu. Or use .FOUR command and look for results in SPICE error LOG file from View menu. Though, you have to change a couple of default settings to be able to simulate and analyze harmonics, lower than – 60dB.

I was really surprised, when tried to use FFT analysis to evaluate nonlinear distortions of one of my circuits. The circuit showed unexpectedly low performance. It just could not be that bad. So, I decided to check distortions of voltage source itself. I put voltage source in the schematic and tried to measure it’s harmonics by using both FFT command and dot FOUR. Here is what I got:

Schematic of distortions simulation, used in LTSPICE

Schematic of distortions simulation

I used Maximum Timestep of 1uS to get predictable time resolution, not overridden by nobody knows what autotimestep.

FFT analysis, 131072 data points, no Windowing function (because 10mS corresponds to integer numbers of 1KHz periods)

FFT analysis, 131072 data points, no Windowing function

No Windowing function was used because 10mS corresponds to integer numbers of 1KHz periods.

Log file content after .FOUR command

Log file content after .FOUR command

Quite discouraging results, taking into account that it is just signal source and I was looking for distortions simulations, capable of analyzing at least -130dB.

I started to look for solution. First thought was to increase time resolution by decreasing Maximum Timestep to 10nS.

FFT with increased time resolution

FFT with increased time resolution, Maximum Timestep is set to 10nS

 

.FOUR with increased time resolution, Maximum Timestep is set to 10nS

.FOUR log file with increased time resolution

Well, this is much better, but that small number of Maximum Timestep could cause very long simulation time of complex circuits.

Let’s see what else could be done to improve resolution while, may be, using bigger timestep to speedup simulation.

LTSPICE control panel has a special section, dedicated to data compression. Intuitively, I felt that this may be related to resolution of FFT, because we are speaking about big range of data representation. 200dB represents data ratio of 10000000000 and this is very demanding requirement. Help describes this compression as: “LTspice compresses the raw data files as they are generated. A compressed file can be 50 times smaller than the un-compressed one. This is a lossy compression.”

After disabling compression and restoring max timestep to original 1uS the simulation looks like:

FFT with disabled compression and max timestep 1uS

FFT with disabled compression and max timestep 1uS

 

.FOUR log file with disabled compression and max timestep 1uS

.FOUR log file with disabled compression and max timestep 1uS

The main drawback of disabling compression through control panel is that you have to do this every time you are restarting LTSPICE.

More convenient way is to add  .OPTIONS plotwinsize=0 to your LTSPICE schematic. In fact, I used this option to generate previous results.

So, results look very promising and are good enough for most kinds of applications. It is hard to imagine any practical and physically realizable circuit, that will have harmonics better than -160dB.
However, it is possible to improve resolution even better by switching to double precision calculations by using .OPTIONS numdgt=7. Any number more than 6 will force LTSPICE to switch to double precision math on dependent variables.

 

FFT with disabled compression, double precision math and max timestep 1uS

FFT with disabled compression, double precision math and max timestep 1uS

 

.FOUR log file with disabled compression, double precision math and max timestep 1uS

.FOUR log file with disabled compression, double precision math and max timestep 1uS

Quite impressive.

You can get even more by decreasing Maximum Timestep to 10nS, but this will significantly increase your simulation time in any practical case.

 

FFT with disabled compression, double presigion math and max timestep 10nS

FFT with disabled compression, double precision math and max timestep 10nS

 

.FOUR log file with disabled compression, double precision math and max timestep 10nS

.FOUR log file with disabled compression, double precision math and max timestep 10nS

You can download LTSPICE schematic and play with this options by yourself.

Comments

23 Responses to Distortion measurements with LTSPICE