2
\$\begingroup\$

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.

\$\endgroup\$
3
  • \$\begingroup\$ Your parameters are in the wrong order. It should be... Sine(2 80 1500) V(Offset) = 2 V = 80 Freq = 1500 \$\endgroup\$ Oct 22, 2021 at 5:22
  • \$\begingroup\$ @GTElectronics As I commented before you deleted your answer and changed it to a comment, my parameters are not in the wrong order. \$\endgroup\$
    – griffin175
    Oct 22, 2021 at 6:24
  • \$\begingroup\$ Did you change the integration settings etc. ? \$\endgroup\$
    – DamienD
    Oct 22, 2021 at 7:42

3 Answers 3

8
\$\begingroup\$

Try .option plotwinsize=0

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

Likely compression/sampling issue. enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ That worked! How does this work to fix compression issues? \$\endgroup\$
    – griffin175
    Oct 22, 2021 at 7:49
  • \$\begingroup\$ 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. \$\endgroup\$
    – pat
    Oct 22, 2021 at 8:04
  • \$\begingroup\$ @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. \$\endgroup\$ Oct 22, 2021 at 8:46
3
\$\begingroup\$

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
\$\endgroup\$
0
\$\begingroup\$

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).

\$\endgroup\$

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