Installing and using LTspice IV (now including LTXVII), From beginner to advanced

Joined 2007
Paid Member

Recent months have seen Linear Technology become absorbed into Analog Devices. The good news is that LTIV remains available (although unsupported) for legacy systems running older operating systems.

The successor to LTIV is LTXVII which is under constant development, just as LTIV used to be. Both these simulators are now hosted on the Analog Devices site.

Users just starting out with LTspice and running modern hardware should consider using LTXVII over the older unsupported version. Much of what is written here is applicable although subtle differences in operation will become apparent as you dig deeper.

1/ Installation. Post #1 (you are here)

2/ Running a simple DC simulation. Post #2 and #3 HERE

3/ Running a simple AC simulation. Post #7 HERE

4/ Simulating a one transistor Amplifier. Post #14 and 16. HERE

5/ Distortion and FFT's. Post #19 and 20 HERE

6/ Squarewave Testing. Post #31 Here

7/ Measuring AC voltages. Post #35 Here

8/ Setting up multiple signal sources and running two simulations in parallel. Post #39 Here

9/ Adding ripple to the PSU. Post #51 Here

10/ Simulating a simple PSU. Post #59 Here

11/ Adding and simulating a voltage doubler and regulator. Post #67 Here

12/ Testing under load and dynamically. Post #71 Here

13/ Adding models to use in a simulation. Post #85 Here

14/ Adding a PSpice 3rd party model to a simulation. Post #146 Here

15/ Measuring amplifier output impedance. Post #214 Here

16/ Stepping a component value. Post #222 Here

17/ Stepping the bias of an amplifier. Post #225 Here

18/ Adding your own Subcircuit Model to LTXV11. Post #2272 Here

Subsection... Ideas and Tutorials submitted by diyAudio members

A/ Using LTSpice simulation command for a DC sweep for resistors. For a worked example see post # 560 Here
(submitted by pr)

B/ Functional LF198/LF298/LF398 Sample and Hold, post #754 here (submitted by FdW)

C/ Limit the length of figures to a set length independent of the exponent while at the same time rounding the number,
post #1915 Here
(submitted by FdW)


The purpose of this thread is to show how to both install and to use LTspice, hereafter just referred to as LT, the free circuit simulation program from Linear Technology (now I consider myself very much at the beginner end of the spectrum, but I'm hoping that as the thread develops we can gather input from those more seasoned users amongst you all...

A picture... or two or three... are worth a thousand words.

Can you believe it took me many days to figure out how to include a simple model for a device into a simulation. For a newbie it needs to be a click by click instruction with pictures.

Credits... firstly to Bob Cordell and his excellent book "Audio Power Amplifiers". I can say with certainty that I would still be staring at the blank grey workspace of LT had it not been for Bobs excellent introduction to this fantastic program. I would urge anyone with an interest in simulating amplifiers to "go buy the book". You won't regret it.

Thanks also to Keantoken who has a prety comprehensive WIKI on the site. Take a wander over when you've a few minutes spare and have a read.

So lets get started.

LT is best downloaded from Be sure to download LT IV (for the purposes of this tutorial), or you may wish to install both versions (LT IV and LTXVII) and retain LT IV as a legacy program.

Old URL which currently redirects correctly to Analog Devices.
Linear Technology - Design Simulation and Device Models

Direct URL
LTspice from

The version marked for Windows XP is LTIV. All other options are for LTXVII. There is also a Windows and Mac version with this thread being based on the Windows version.

Install LT as you would any other program. On Windows the installer will probably say you have UAC (user account control) enabled and that it may cause issues with file paths. I have used LT on Vista, W7 and W8.1 with no unresolvable issues by leaving UAC on.

When you have installed LT you should find you have a desktop icon to open it... the usual stuff. What you should now is change the icon (or whatever means you yourself use to open programs) to run as administrator. This is important because LT will not run and update correctly if this is not done.

To do this, right click the icon and using the <properties> tab, change the shortcut to "Run as administrator". This picture show it for Windows 8.1, W7 and Vista are similar.

Next thing we do is open LT and set a few basic options. Setting these options as shown ensures that LT doesn't accumulate a lot of temporary files... even then its not foolproof... we'll cover that later.

Nearly there, but first lets get to know where LT lives on your PC and how it handles files and folders. This is important in order to keep your system tidy and to make it easy to keep track of things.

Depending on your operating system, go to the run box and type C:\Program Files.

You should see something like this with LTC being the folder of interest. Click your way through the folder to open it. You will see this.

The <scad3> line is the program shortcut. If you are using W8.1 then this is probably the best place to alter the settings mentioned above to "run as admin". There is a folder of examples in there too, as well as all the models and files LT needs to run.

I recommend that you DONT add to, or change anything in those folders at this stage.

Lets just jump ahead of ourselves at this point because there is something worth mentioning. If you run a simulation (such as from one of the examples), or you create one of your own, then LT by default wants to save it back in the LTC folder in program files when your done or when you close it. My advice... dont let it. Save all your work in a normal folder in your documents. This then leaves all the program files untouched. If you want to use an example as a starting point then I recommend the first thing you do is save the simulation again under a different name and as suggested, save it to documents or some dedicated area away from the LT folder in program files. Doing that preserves the original installation and leaves all the files and examples untouched.

So if you are creating your own simulation and design then I suggest just opening LT first and then click <file> followed by <new schematic> followed by <file> once again and then <save as> giving your intended design both a name and then saving the blank workspace somewhere such as your documents folder.

So we now have LT installed, we can move on to actually using it to do something useful. This will be your first simulation.

Note on updating LTspice. Updates to the library files are frequent. By default LT seems to warn you after 60 days have elapsed that you have not updated the installation. These updates are mainly for database of models adding new ones as they become available. The updates are incremental and simply add new items to the already installed files. The update typically takes around 3 minutes to complete, however you must be logged on as an administrator (in Windows) for the update to run correctly.

To manually check for and install updates

1/ Open LT with elevated privileges. In Windows this means right clicking the icon you use to launch the program and selecting the 'run as admin' option.

2/ Under 'Tools' there is a dropdown menu. Select 'Sync release to allow LT to check for and install updates.

When the update is complete the program automatically closes with a message saying the update was successful.

(note... this thread isn't something that can be completed quickly. I shall add things to it as and when I have the time)


  • Run as admin.PNG
    Run as admin.PNG
    33.2 KB · Views: 2,343
  • Settings.PNG
    56.1 KB · Views: 850
  • Program Files.PNG
    Program Files.PNG
    126.7 KB · Views: 818
  • Folder Contents.PNG
    Folder Contents.PNG
    82.8 KB · Views: 705
  • Updating LTspice.png
    Updating LTspice.png
    122.9 KB · Views: 656
  • Like
Reactions: 1 user
Joined 2007
Paid Member
Running a simple DC simulation.

Our first simulation will be a simple DC circuit. Something like this will help familiarise you with LT's basic component handing properties and show how you place items on the workspace.

So this is what we do... and I would recommend that you now create a folder in your documents called LTspice.

1) Open LTspice.
2) Goto <file> at the top left and then click <new schematic>
3) Now click <file> again and this time click <save as>. A window will open. At the top is a drop down that allows you to browse for a location to save your simulation. I suggest you name it "DC Simulation" and save it in documents within the new folder (LTspice) that we have just created.

Depending on your PC, it may complain when you open a simulation file so lets see what happens on your own set up. Close LT and browse to the newly created file in the above folder. You should see a symbol like this,

Click it and check that it opens LT correctly. W7 and W8.1 may give a brief warning warning message but complete the operation anyway.

Thats one way to open a file. The other is to open LT from its icon and then either use <file> and <open> or you can right click the blank workspace and your last 10 simulation files are displayed.

So open our blank DC simulation file and lets create the first sim. This is the circuit... simple isn't it.

What we have to do now is recreate that as a working simulation. Click the component symbol on the top line,

and have a good browse and see what is on offer. We are going to start with the voltage source, which will become our 10 volt supply. So click <voltage> and then <OK> and you will be returned to the workspace with a symbol that you can seemingly drop anywhere. Move it to the left and left click to drop it. Then right click to clear the symbol which is still attached to the cursor. Now we need two resistors. Wwe can get these either from the component library again or, as these are common parts, straight from the top line of LT. Do you see the resistor symbol. Just click it and drop two resistors onto the workspace. It should look something like this.

Now we wire it up using the <wire> symbol from the top line. This looks like a pencil. Click it and you have a crosshair cursor appear. Move that over a component node and left click. Then drag the wire up/down/left/right etc left clicking each time you want to change direction.

Next up is our Ground. This is important. LT can not run without a ground. So click the ground symbol (top line) and drop the ground symbol onto the correct point of the circuit, the zero volt line. You can drop the ground below this and attach it with a wire which looks better.

Next we right click the voltage source and set it to 10 volts and click OK.

Your circuit should like the above although the placement of the parts doesn't matter but we can tidy it up. Look on the top line. There is a small and a big hand. Click the small one and drag it over components. Click the part with the hand and drag them to where you want.

Do the same for the wires.

Now use the scissors symbol to tidy those loose ends. It takes practice.

For information... if you make a mistake you can use the <edit> tab at the tob left where there is an <undo> and a <redo> option.

And we need to assign values for the resistors. Right click each in turn and type the value as shown. Click OK.

At this point we should have a complete simulation ready to run... but how ? That comes next.


  • Final.PNG
    23.4 KB · Views: 543
  • Scissors.PNG
    23.5 KB · Views: 492
  • Wires.PNG
    23.7 KB · Views: 494
  • Hand.PNG
    23.8 KB · Views: 495
  • DCsim3.PNG
    28.1 KB · Views: 482
  • DCsim2.PNG
    21.2 KB · Views: 483
  • DCsim1.PNG
    20.9 KB · Views: 515
  • Component.PNG
    31.4 KB · Views: 521
  • DC Simulation.png
    DC Simulation.png
    7.6 KB · Views: 498
  • asc file.PNG
    asc file.PNG
    27.5 KB · Views: 533
Joined 2007
Paid Member
Running the simulation.

Open the completed simulation file and right click a blank area of the workspace. Click the <edit simulation CMD> line and a new window opens. Select the <DC op pnt> tab and click OK. You now have a little box attached to the cursor which when you drop it onto the circuit will display as .op

You can move the text by using the hand symbol as we did before so put it somewhere neat on the diagram.

Now right click the workspace again and select <run>. A window opens with all the circuit nodes together with their currents and voltages but tbh, its not very intuitive, certainly not on a complex diagram. Note... you can also run the simulation by clicking the running man on the top line.

Now close that window and move your cursor over various points on the diagram. As you move over wires you will read the voltages (displayed at bottom left). Move over the resistor and you will see both the current and the power dissipated in that resistor.

That covers a very basic DC simulation. We will build on this to look at other aspects of LT.


  • DC op pnt.PNG
    DC op pnt.PNG
    30.5 KB · Views: 661
  • Run.PNG
    34.4 KB · Views: 637
  • Like
Reactions: 1 user
Joined 2007
Paid Member
Running a simple AC simulation.

Next up and we can try a simple AC simulation. What we are going to do first is rename the original DC simulation file so that we can retain both files.

Firstly, open the DC simulation file and go to <file> at the top left and using <save as> resave the file under a new name (such as AC simulation). Check the location is correct and that it is saved in the folder you decided on at the start of the tutorial.

So, starting with the AC simulation file open in LTspice we are now going to change the supply voltage source to an AC source. To do this we right click the voltage source and select <Advanced>

Select <Sine> and fill in the following settings. Be sure to click OK at the bottom. The word Sine an a lot of numbers will sprawl across the diagram. Use the hand symbol (covered in part 1) to move the text somewhere out of the way.

For information... the scroll wheel of the mouse zooms the diagram in and out. If you right click the blank workspace there is a ZOOM TO FIT option which will automatically best fit the image to your screen.

You can right click the voltage source at any time to review and alter the settings.

So what have we actually done here.

The DC offset value (entered as zero) ensures the sine wave is centred around the zero point.

The amplitude sets the PEAK value. This means the waveform will go 1 volts ABOVE and 1 volts BELOW ground as we shall see in a moment.
Frequency is self explanatory.
Time delay (which we set at zero) would be a time you want to wait before the sine wave starts.
Theta... I have never researched so I don't know ;)
Phi or phase angle is the number of degrees into the cycle that you want it to start. 360 degrees to one full cycle remember.
Cycles is the number of complete cycles the voltage source will generate.

So now you should have something that looks like this,

Maths we keep to a minimum but you need to know a couple of basics. To view the waveforms on LT's oscilloscope means you need to know how to set the scope settings in the first place. This is something you have to understand and be confident in calculating... but its easy...even I can do it.

So we have 1000Hz as voltage source that is set to generate 10 cycles of the signal. The time period of this is found by taking the reciprocal. So all you do is divide 1000 into 1. That gives 0.001 That quantity is time. One cycle of 1Khz lasts for 1 millisecond. Now we decide how many cycles we would like to see on the screen. Well we set the voltage source for 10 cycles so let us display all those. Ten cycles of 1ms (milliseconds) each is 10ms in total.

To set LT to do this, first right click the workspace and select <Edit simulation>. A new window opens. Select the <Transient> tab and enter a stop time of 10ms. Click OK. You now have a new command attached to the cursor to drop neatly on the diagram. As before, use the hand symbol to tidy things up.

However you arrange things, it should have all these ingredients.

Now right click the workspace and select run.

You should hopefully see something like this. A red probe appears. Move over the top of the voltage source with the probe and click anywhere on connection to R1. You see the input voltage as it would be on a scope. Click the junction of the two resistors and a second trace is overlaid... you get the idea. What about current ? Mouse over a resistor and left click. The current is displayed. Notice the scale changes automatically. Double clicking anywhere you want to measure brings just that one value into focus with just that trace displaying.

What about RMS voltages ? We know we have 1 volt peak which equates to 0.707 volts RMS (1 divided by root 2). We can get LT to display that. Run the sim and display the voltage source output. Hold the CTRL key and left click V(n001)which is the name of the current trace displayed.



    51.8 KB · Views: 623
  • Transient Ready.PNG
    Transient Ready.PNG
    28.1 KB · Views: 606
  • Transient.PNG
    21.2 KB · Views: 599
  • AC Simulation.PNG
    AC Simulation.PNG
    25.3 KB · Views: 614
  • Settings.PNG
    53.2 KB · Views: 614
  • Advanced.PNG
    32.3 KB · Views: 690
Please explain the sine(0 1 1000 0 0 0 10) and similarly for pulse and others.
How do we supply two signals?
Can we change from one signal type to another and back again?
Can we gate a sine ON and OFF? and start at different parts of the waveform eg max +ve voltage, max -ve voltage, or zero voltage or some other?
same for a stream of pulses that needs repeating?

And a big Thank You !!!!
Joined 2007
Paid Member
Please explain the sine(0 1 1000 0 0 0 10) and similarly for pulse and others.
How do we supply two signals?
Can we change from one signal type to another and back again?
Can we gate a sine ON and OFF? and start at different parts of the waveform eg max +ve voltage, max -ve voltage, or zero voltage or some other?
same for a stream of pulses that needs repeating?

And a big Thank You !!!!

Thanks Andrew.

I know I haven't got all the answers hopefully we can figure things out and ask as we go along.

The (0 1 1000 0 0 0 10) is non intuitive but is in fact a group of seven numbers corresponding to the seven options available while setting the sine waveform.

Changing from waveform type to another can be done (and there might be easier ways than this) by either setting up two (or more) voltage sources on your diagram and manually connecting each as required or by using the time delay line in the settings box to start waveforms in sequence. They would then have to be mixed (as you would in a real circuit perhaps with a resistive divider) and fed to your circuit under test.

Gating a sine can be done with simple circuitry (say a FET) and applying a pulse of the required timings to turn it on and off.

We can come to all that though... and if anyone has any better methods then please join in.

Edit... I noticed the DC offset in the last two pictures was showing 0.1 That was me trying something. Set it to 0 for your sim.


  • Code.PNG
    27.6 KB · Views: 509
I wouldn't be fussed about dividing users into a range, from beginner to that impressive sounding, "advanced" category, ;) - LTspice is a tool, and one just learns to use it well enough to get what you want out of it; that's the way I approach everything, keep banging away at the thing until it does the job you want it to do.

I could be reasonably sharp in some areas of the program's use, and really dumb in my approach doing other bits - so long as a means of getting meaningful results is possible, that's the important thing ...
I taught woodwork at school.
I found that about 20% knew how to use a hammer to knock in a panel pin.
The other 80% had to be taught how to hammer that pin in.

What did surprise me (and maybe shows I am a little bit sexist) was seeing one girl (only ever this one) know how you get that pin in straight and without bending it and NO TEACHING required.

I don't need to imagine, I know the same learning and teaching is required for all skills, even using simulators.
Last edited:
Joined 2007
Paid Member
Simulating a one transistor Amplifier.

To put what we learned so far into practice our next simple simulation will be a simple one transistor amplifier. We will explore and build on this to put into practice some of LT's more useful features.

This is the circuit we will attempt to simulate. Its the kind of thing you might draw on a scrap of paper and wonder how it might all work in practice.

Using what we have learnt, open LT and create and save a new blank file called "One transistor amp" Using the "component" symbol on the top line select and NPN transistor, click OK, and drop it onto the workspace.

Now do the same for a resistor. We need five resistors so having selected the resistor, drop it onto the workspace and then while the "resistor" is still attached to the cursor drop another four onto the workspace. Now do the same for the caps. We need two.

Information... for caps and resistors we can use the R and C symbols on the top line for ease. Also when dropping the caps first drag the attached cap to the "Rotate" symbol on the top line and click it.

It should look something like this.

Now using the scroll wheel zoom it all out a little and using the "hand" symbol, the "wire" symbol and "scissors" try and connect it all up. Remember you can use the <Edit> button to undo anything. Remember to add a ground symbol. Also you need to add a voltage supply as we have covered in the first part. You can either wire the ground line to the voltage source or do as I have done here an added a second ground directly on the voltage source. Finally we need an input source added in exactly the same way.

It should look something like this.

Now add the component values to match my final circuit diagram below.

Set the supply to 12 volts DC. Set the input source to be a 1kHz sine of 0.1 volt amplitude. For the transistor we will use one of LT's models. Hover over the transistor (a hand symbol appears) and right click the transistor. A new window appears that has a "pick new transistor" option. Click it and select the 2N2222 which is top of the list.

And you should end up with something like this.

We are now going to set some simulation options for LT because at the moment it doesn't know what to do with the circuit.

So do you remember how we right clicked the blanked workspace and selected the "edit simulation" window to appear. We do that now, and firstly select "transient" and enter a stop time of 10ms. Click OK. PLace the now attached command on the workspace. Again select edit simulation and this time select "AC Analysis" Set the options as follows, click OK and drop the new command onto the workspace.

The final simulation diagram should have all these ingredients.

Information... when you enter the edit simulation window and click an option... DC op pnt, AC Analysis etc, that option becomes the point of focus that the simulation will run. If you look at the options as they appear on the diagram you will see that the prefix is a semicolon for all inactive options and the active option changes that to a decimal point.

At this point we are ready to investigate the behaviour of the circuit under simulation and that comes next. And we are going to do some neat tricks with it......


  • Complete sim.PNG
    Complete sim.PNG
    34 KB · Views: 688
  • AC Analysis.PNG
    AC Analysis.PNG
    18.5 KB · Views: 647
  • Final.PNG
    32.5 KB · Views: 599
  • Pick Transistor.PNG
    Pick Transistor.PNG
    37.7 KB · Views: 589
  • Parts.PNG
    29.3 KB · Views: 568
  • Rotate.png
    147.6 KB · Views: 603
  • Transistor.PNG
    33.7 KB · Views: 621
  • One transistor amplifier.asc
    1.5 KB · Views: 525
Joined 2007
Paid Member
So lets begin and see what we can do with LT and see how the simulation compares with traditional circuit calculation methods.

Open the "One transistor amplifier" simulation file and right click the workspace. Select the <DC op pnt> tab and click OK. That has brought that command into focus such that when we run the simulation it will be running the DC conditions sim. So go ahead and run the simulation. As before, a window with all the circuit nodes and voltages and currents appears. We just close that as before as we are moving beyond that.

And just as in the first sims, hovering over circuit lines and nodes shows the DC conditions. We will elaborate on that and actually "click and attach" voltages to the diagram.

Notice how the emitter voltage is untidy. Because it is attached to a node we can't physically move it or rotate it with the hand symbols etc... well we can but it won't do as you want. So what we do is add a spur to the point of interest and attach the voltage to that. First though, use the scissors and cut that voltage from the diagram. Now add a spur using the "wire" tool. Drag the spur a suitable distance and left click to show where it finishes. Now right click to attach the spur and right click again to exit the "wire" tool. First few attempts take practice. Try it on various parts of the diagram. You can always undo with <edit> Now run the sim again and attach the emitter voltage to the spur.

If you alter any value and run the sim again you will see all the attached voltages change to the new values.

How do those voltages compare with basic theory. Lets see.

We have a voltage divider of 270k and 39k across 12 volts. That gives 1.51 volts at the junction of the divider. LT says nearer 1.4. Why is that ? Well the base current of our transistor is being taken from that divider and so it actually pulls the voltage down a little. We'll carry on though...

So 1.51 volts on the base. What would be on the emitter ? Well it will be 1.51 volts less the base/emitter drop of around 0.7 volts. So the emitter would be at 0.81 volts give or take. LT says 0.74 Again that is because the transistor base voltage was a little lower due to the base current of the transistor. LT has accounted for that, I haven't in the simple calculation. What about the collector voltage. Well with a calculated 0.81 volts across 1k we have a current of 0.81ma flowing.

Remember these from text book days. The current relationships in the base, emitter and collector.

Ie = Ic + Ib
Ic = Ie - Ib
Ib = Ie - Ic

Because Ib is small we can "ignore" it for this calculation and say that the voltage across the 10k collector resistor Ie * 10,000 which is 8.1 volts. If we have a 12 volt supply then the collector voltage is 12 - 8.1 which is 3.9 volts. LT says 4.58. Its in the ballpark... just.

That calculation was at the most basic level. The unknown is the transistor base current which depends on the device selected. If you tried that calculation again but this time reduced the two bias resistors by a factor of ten, then I suspect it would be a lot closer because the bias current would (relatively speaking) be a much smaller percentage of what is flowing in the bias network.

For interest you can right click the transistor and select a different device. Try a 2N3055 which is in the list of models. Just scroll down to find it. Now run the sim again and look at the voltages. The old low gain device is taking lots of base current and that is relected in the final voltages.

What is the base current ? hover over the base of the transistor and read the value off at the bottom left of the screen. Its 11.5ua for the 2N3055 vs 3.6ua for the 2N2222.

How about frequency response ? Thats interesting to look at. Again, we right click the workspace and this time select the <AC Analysis> tab to bring that into focus. (Remember to set the sim back to the 2N2222 and correct anything you altered earlier)

Run the sim and then use the probe to look at voltage on the top of R5 which is the load. You should see this.

We can see the response falls away at both top and bottom end. The lower end is caused by the coupling caps, the top end by circuit limitation.

At this point we are going to make the circuit and displayed waveforms a bit easier to use and interpret. Look on the top line and click

the <label net> symbol.

A new window opens. Type a name for the input voltage (I've used Vin) and click OK. The label is now attached to the cursor. Move it over the input line and click it to attach.

(The question marks (???) are showing because I haven't run the simulation yet having just reopened it to work on)

Now follow the same procedure and attach another "net label" to the top of R5 which is the load.

We will now run the simulation again, so make sure that AC Analysis is in focus (by opening <edit simulation> and clicking the <AC Analysis> tab). Probe the now labelled input and output of the amplifier. Probe the input first followed by the output. (That just keeps it consistent as to what we all see) and you should see the following.

This should be much easier to follow now and so we can look at what the diagram is actually telling us. Note how the top line of the scope traces now have our labels attached.

Vin is the input. Because that was probed first it has become a kind of reference. You will see it is just a line at zero db level. The voltage source in LT is perfect and so the response starts from DC and goes ever upward......

Vout is our amplifier output. We can see straight away the effect of the two coupling caps in that the response falls away at the lower end. Hover your cursor over the solid trace corresponding to the output voltage and you can read off at the bottom the amplitude as a figure of gain in db. So at midband around 1Khz we have around 18.5db gain. If we wanted the -3db point we simply follow the trace and look for a level of 15.5db. That seems to be around 6.9Hz. (the frequency is also displayed at the lower left)

Phase shift. At the right of the screen is phase angle together with a corresponding dotted line trace on the scope. That dotted line is the phase of the output (the trace is the same colour as the output showing it relates). Hover over midband (1Khz) again and you can see that the phase is showing -180 degrees. Why ? because out simple amplifier is inverting of overall phase. At the higher and lower frequencies the phase shift moves away from that ideal, at the lower end because of the caps and at the higher end because of the hf limitations of the circuit.

If you smartly double click the input voltage line you will get a single trace of 0db. The phase shift is zero from DC to infinity (because LT is perfect). Smartly double click the output and you get just the one trace.

(You can display as many points in a cirsuit as you wish and label as many nodes as you wish to make it easier to follow)


  • Net Label Run.PNG
    Net Label Run.PNG
    44.4 KB · Views: 639
  • Attached.PNG
    36.3 KB · Views: 541
  • Label Net.PNG
    Label Net.PNG
    17.5 KB · Views: 603
  • AC Any.PNG
    AC Any.PNG
    43.8 KB · Views: 611
  • Attached Voltages.PNG
    Attached Voltages.PNG
    40.8 KB · Views: 670
Thank you so much mooly.
Without your greatly appreciated help in other threads i woudn´t have been able accomplish any diy-audio-related project.
For the simulation of the filters i build i still use the ltspice-settings from the data you once sent me.
I´m pretty sure this thread will bring my skills to the next level.
I will follow these instructions very carefully.
Thank you for putting so much effort into helping lousy noobs like me!
Joined 2007
Paid Member
Distortion and FFT's.

We will now look a little further into the AC performance of our little amplifier and check out its distortion. To get you used to manipulating the commands for LT we shall look at the distortion for a frequency of 4khz. This is what we do...

Open the simulation and set the input voltage to be a sinewave of 4kHz. We can keep the amplitude the same as before, so all we need do is right click the input voltage and change the frequncy to 4000 and click OK.

Can you also make sure that you have the output line (R5) with a Vout label attached (as we covered in the previous sections). Ignore the other commands I have added for now.

For distortion measurements the <Transient> tab must be brought into focus. So right click the workspace and select <edit simulation> and click the <transient> tab. You should see the previously entered stop time of 10ms which we now need to alter. If we didn't then this is what happens. Our 10 cycles of 4kHz are over before the 10ms has run its course.

So how long do we need ? Well taking the reciprocal of 4000 gives 0.25ms, the period of one cycle. We would like to display all 10 and so we set the stop time to 2.5ms. So enter 2.5ms as the new stop time and click OK.

If you now run the sim and probe the input and then the output you should see this,

Although it looks good it tells us little of the actual distortion. LT has the wonderful ability to run a Fast Fourier Transform or FFT on any of the displayed waveforms and so that is what we are going to do next... and show the pitfalls along the way.

Setting the options for LT to do this needs care and we need basic information to set this up. One trick we can use though is to make these settings easily available to use again (which we wil cover shortly).

A standard LT command that we haven't used yet is .option plotwinsize=0 which stops LT compressing the calculations. Setting this option will give better results.

To enter a command into LT we use the .op command on the top line. Click this and enter the .option plotwinsize=0 text. (You can copy and paste it) Click OK and drop the command onto the workspace. Make sure you include the DOT. Its .option

Now we need to set the all important "Timestep" and again I must credit Bob Cordell for his excellent explanation of this (Designing Audio Power Amplifiers). The timestep relates the length of time the sample runs for, together with the frequency or period of the signal of interest. So this number needs to be altered for testing at different frequencies. I'm going to start with LT's default number of sample points which is 262144. This will all make more sense as we progress and run the simulation.

So, we take our simulation run time which is 2.5ms and we divide that by 262144. The result, 0.00953674us is the value we enter for our "Maximum Timestep".

To enter this value, open the <edit simulation> window and select the "Transient" tab. Enter the value just calculated.

We can now run our simulation and as before, look at the output voltage waveform. Notice how the sim runs slower because of the plot winsize command.

Now place your cursor into the waveform window (anywhere) and right click and select FFT from the flyout options. Goto <view> at the bottom and then select FFT. A new window opens and now you will see the 262144 number displayed. That is the default setting for current version of LT. You will see that because we probed the Vout line, that this is now automatically selected and all that remains is for us to click OK.

You should now see a new graph appear showing the FFT. (You can maximimse any individual window of course to get a better view)

Remember how I mentioned some "pitfalls" at the start of this section. Well you are looking at them... a lack of detail and resolution. There are two main causes here, firstly the FFT just hasn't run for long enough. 2.5ms doesn't allow things to stabilise. Secondly, the coupling caps are skewing the trace.

So this is what we do...

Close the FFT and scope windows and go back to the basic circuit. Alter the input voltage (right click the input) to provide more cycles. You don't need calculate anything, just make sure there are going to be enough for a longer run. We had 10, so lets make it 1000. That allows the sim to run for 250ms if we wish.

Now let us alter the <transient tab> to stop after 250ms.

We will also look at the last 20 cycles of the complete run (and ignore all up to that point) which should give more accuracy and detail. There are a couple of ways of doing this. First we recalculate the timestep. 20 cycles at 4kHz take 5 ms. (Reciprocal of 4000 times number of cycles). We divide that by 262144 and arrive at a timestep of 0.0190734us. Enter that value into the <transient> settings window.

Make sure the settings look like this.

Now run the simulation again. This time nothing seems to happen but look at the lower part of the screen. The sim is running and its progress is shown. It will take a couple of minutes to complete PC depending... When it gets to a point that would correspond to 230ms (the point we actually want to start looking from), the 'scope window opens. You can now click the output node as before and see the waveform build up as time progresses. You are lookin now at the 20ms of a 250ms run.

Again, we right click the 'scope window and select View and FFT from th flyout menus.

You should see this.

Immediately we can see there is much more resolution available. Look how the harmonic structure of the distortion appears, 2nd marmonic, 3rd and so on. (The scale is a bit unbelievable too, going below -200db)

We still have a major problem though. Although we attended to the issue of a short run time we can see the trace still slopes away hiding detail. This is caused by the time constant of the caps being small. Thats an easy fix. Go back to the asic circuit and right click them and change the value to 800,000uf (an arbitrary figure). Now rerun the sim again and look at the FFT.

I hope some of that all makes sense... its a lot to take in in one go. Importantly, I hope it shows how to set the FFT up to run correctly and how we kept improving the resolution.


  • Final FFT.PNG
    Final FFT.PNG
    29.8 KB · Views: 611
  • FFT Rerun1.PNG
    FFT Rerun1.PNG
    27.1 KB · Views: 649
  • New FFTSettings.PNG
    New FFTSettings.PNG
    19.4 KB · Views: 640
  • FFT Display.PNG
    FFT Display.PNG
    49.7 KB · Views: 587
  • Select FFT.PNG
    Select FFT.PNG
    94.6 KB · Views: 613
  • Maximum Timestep.PNG
    Maximum Timestep.PNG
    19.3 KB · Views: 634
  • Command Options.PNG
    Command Options.PNG
    49.2 KB · Views: 607
  • InOutRun.PNG
    48.3 KB · Views: 528
  • 1VS4.PNG
    45.8 KB · Views: 644
  • Vout Check.PNG
    Vout Check.PNG
    46.4 KB · Views: 689
Joined 2007
Paid Member
Lets now look at getting a figure as a percentage for the distortion. Lets us first of all change the simulation to run a little quicker. In the <transient> tab of the edit simulation window we can change the stop time to 10ms. That will allow just 40 complete cycles to display. The Maximum Timestep is now calculated as 10ms/262144 which is 0.0381469us.

So set the following data.

We now introduce a new command that is entered using the .op button (on the top line at the right) This is a .four command which tells LT to run a distortion calculation on the FFT result. We need to specify this command exactly and so it becomes .four 4khz 10 10 v(vout) The kHz refers to our input source, the 10 means the first 10 harmonics (F, F1, F2 etc) are to be used for the calculation, and the final 10 that the last ten cycles of the run will be used. The v(vout) specifies the tag we attached to the diagram earlier. That is the point that the distortion will be calculated on.

Information... we now encounter a problem due to the timestep size calculated. To see this in action make sure your sim looks like this and then run it. Make absolutely sure the options are correct.

Information 2... if an option needs altering you can also right click the command as it appears on the diagram and that will open the appropriate window for you to alter that parameter.

You will find it almost freezes and runs incredibly slowly. Click the output node and observe the waveform and the progress at the bottom right. Thats no good so right click the circuit diagram workspace (not the traces above) and select <halt>.

So what went wrong ? Well it was the timestep setting. Lets use Windows calculator to get a few more digits.

Lets try that as a timestep. Its 0.03814697265625us Copy and paste that number into the <maximum timestep> box and rerun your sim. It should run much quicker. Now right click a blank area on the 'scope trace workspace and select <view> and then <spice error log>

Hopefully you should see this.

So as you can see, accuracy when calculating the timestep is vitally important. Actually, just adding the next digit in the sequence would have sufficed but when have the resolution... use it.

Put your own numbers in and have a go at simulating at 1kHz or 20kHz and see what you get.


  • Error Log.PNG
    Error Log.PNG
    113.2 KB · Views: 512
  • Accuracy.PNG
    44.7 KB · Views: 505
  • Sim.PNG
    27.2 KB · Views: 531
  • Distortion1.PNG
    16.4 KB · Views: 561
    81.6 KB · Views: 573