Electronic – LTspice sinusoidal voltage source with offset much larger than amplitude broken

ltspicespice

I've been troubleshooting an analog circuit and have just come to the realization that Sine Voltage sources at mV are broken.

Here is one that is supposed to provide a 1mV 1Hz sine wave on top of a 300mV DC signal. Instead I get complete garbage.

Running LTSpice version 4.22. Anyone else seen this issue or can advise what is the problem?

enter image description here

Best Answer

Most probably you have waveform compression enabled and the compression algorithm has too high a relative tolerance to process such a signal correctly, since the AC component is so small compared to the DC offset.

Open the control panel and decrease the relative tolerance:

enter image description here

LTspice usually performs waveform compression to avoid generating huge data files for waveforms. The compression algorithm is lossy, so you might lose details and have artifacts like those you see on your simulation.

LTspice online help excerpt:

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. This pane of the control panel allows you to control how lossy the compression runs.

Sometimes it is useful to disable compression entirely, for complex waveforms, but expect GB size .raw files (these are the files where LTspice saves waveform data). Neverthelss, usually it is sufficient to play around with compression settings, but only when you reasonably know what to expect from a simulation.

EDIT (to address some relevant comments)

Some commenters have pointed out that increasing tolerances, or specifically, reltol SPICE parameter will increase simulation time. This is true, but compression relative tolerance has nothing to do with the reltol SPICE parameter, which is found in another tab of the control panel:

enter image description here

To further reinforce my point, I'll cite the whole section of LTspice's help concerning the compression tab of the control panel (emphasis mine):

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. This pane of the control panel allows you to control how lossy the compression runs.

Window Size(No. of Points): Maximum number of points that can be compressed into two end points.

Relative Tolerance: The relative error allowed between the compressed data and the uncompressed data.

Absolute Voltage tolerance[V]: The voltage error allowed by the compression algorithm.

Absolute Current tolerance[A]: The current error allowed be the compression algorithm.

These compression settings are not remembered between program invocations to encourage use of the defaults. They are available on the control panel for diagnostic purposes. The tolerances and window size can be specified with option parameters plotreltol, plotvntol, plotabstol and plotwinsize in .option statements placed as SPICE directives on the schematic.

You will probably want to turn of compression when using .four statements or doing FFT's in post analysis of your data with the SPICE directive:

.options plotwinsize=0

Again, the last directive just amounts to disable compression as you would do using the control panel. As I've already said above, this is just what you want to do to avoid artifacts, but huge files will be generated.