13
\$\begingroup\$

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

\$\endgroup\$
  • 2
    \$\begingroup\$ I got a somewhat similar result. Waveform is more uniform, but not a sine wave. Disabling compression fixed it for me. (as per Lorenzo's answer below). \$\endgroup\$ – mkeith Nov 6 '17 at 7:01
20
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ been using LTSpice for years, and never been bitten by that one (yet), thx for the gotcha alert. \$\endgroup\$ – Neil_UK Nov 6 '17 at 7:18
  • \$\begingroup\$ @Neil_UK You're welcome! I'm one of those refman freaks that like to read the whole manual (the problem is remembering where I saw something!) ;-) \$\endgroup\$ – Lorenzo Donati Nov 6 '17 at 7:22
  • \$\begingroup\$ @LorenzoDonati Thanks for the quick response! I was loosing my mind. You are a scholar and a gentleman :) \$\endgroup\$ – EasyOhm Nov 6 '17 at 7:30
  • \$\begingroup\$ @Gonzik007 You're Welcome! :-) \$\endgroup\$ – Lorenzo Donati Nov 6 '17 at 7:34
  • 1
    \$\begingroup\$ Word of warning: reducing the tolerance will make your simulations go slower. It won't be felt for smaller schematics, but for larger... As long as the dynamic range is not that great (e.g. 1mV sine on top of 1kV DC, or similar/lower), you're better using opt plotwinsize=0 than reducing tolerances. In general, dynamic range is a problem since everything is mathematically calculated using machine precision. \$\endgroup\$ – a concerned citizen Nov 6 '17 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.