2

I have a very simple simulation. Just a voltage source set to an 80v DC offset with an amplitude of 2 volts and frequency of 1500Hz. Unfortunately, LTSpice doesn't seem to be capable of simulating a sine wave. Am I doing something wrong here?

I have seen other people produce sine waves using LTSpice, so I'm pretty sure it's possible. What's going on here?

I tried putting a resistor across it, but no change.

Sine wave on LTSpice

enter image description here I even tried lowering the frequency, but now the results are much worse. There are even some major glitches

I have tried restarting the program, but that didn't fix it.

Null
  • 7,448
  • 17
  • 36
  • 48
griffin175
  • 431
  • 1
  • 4
  • 15

3 Answers3

8

Try .option plotwinsize=0

Always good to try when you get weird waveforms like that.

Likely compression/sampling issue. enter image description here

pat
  • 2,075
  • 12
  • 11
  • That worked! How does this work to fix compression issues? – griffin175 Oct 22 '21 at 07:49
  • LTspice uses compression and downsampling to minimize memory file sizes and processing time by default. As you've seen, it can result in bad waveforms, similar to aliasing. This option disables it. – pat Oct 22 '21 at 08:04
  • @griffin175 Don't forget that disabling compression means the `.raw` file will grow and can reach GB, or more, depending on the case. In that case, the `.SAVE` can help, because with many variables to write the disk write bandwidth can be reached or exceeded, which means the simulation will go slow. – a concerned citizen Oct 22 '21 at 08:46
3

To illustrate the difference between OP and @pat 's solution, I exported the waveforms as text. Here are the first fifty points. Without the plotwinsize=0 option, these points span several cycles as shown in the red with a jagged appearance.

EDIT

enter image description here

File details:

  • Without the option, 20154 lines
  • With the option, 44360 lines
Syed
  • 1,149
  • 1
  • 4
  • 11
0

If you need a user-defined source (i.e. not a normal sine source) in the future, you can also insert a VPWL_FILE from the library and have it point to the text file. You can write a program that creates a text file and writes a few values into it (English notation, 2 columns: Time TAB a Value).

Daniel
  • 333
  • 1
  • 8