LTSpice Tutorial
LTSpice Tutorial
ca/ltspice/
Pages created and updated by Terry Sturtevant Date Posted: February 7, 2012
LTspice Tutorial
While LTspice is a Windows program, it runs on Linux under Wine as well. (LTspice is also called SwitcherCAD by its
manufacturer, since they use it primarily for the design of switch mode power supplies (SMPS).)
Note: Some of this was written using SwitcherCad III, and some was written using LTspice IV. The
instructions should be the same.
I. Opening LTspice
III. Simulation
A. Before you do the simulation
B. Choosing a simulation
C. Graphing
D. Adding/Deleting Traces
E. Doing Math
F. Labeling
G. Finding Points (aka Using Cursors)
H. Saving
I. Printing
V. Types of Sources
A. Voltage Sources
1. DC
2. PULSE
3. SINE
4. EXP
5. SFFM
6. PWL
7. PWL File
B. Current Sources
1 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
I. Opening LTspice:
Find LTspice on the C-Drive. Open LTspice IV (or SWCad III). The opening screen will look
like this:
.
Begin a new circuit
from the file menu, or
2 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
3 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
rectangle works well for simple circuits). To move parts, click on the 'move' icon,
and then you may select parts and drag them where you want them.
(When you have a part selected for a move, you can rotate or reflect it as well.)
If you have any parts left over, just select them and press "Delete".
D. Connecting the Circuit:
Now that your parts are arranged well, you'll have to attach them with wires.
4 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
5 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
Please note that if you double click on the part or its value, no box will appear.
F. Changing the Value of the Part:
If you only want to change the value of the part (if you don't want all your resistors to
be 1K ohms), you can right click on the part, (not the name), and a box title by the
part name (such as "Resistor") will appear. The number of fields in the box will depend
on the type of part it is. Type in the new value and press OK. Use u for micro as in uF
= microFarad.
6 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
This method makes sense if you are working on your own computer, where you can update
your own libraries and use them again.
1. Look under C:\Program Files\LTC\LTspiceIV
(or C:\Program Files\LTC\SwCADIII )
2. Go to the directory lib\cmp
3. Look at the list of standard devices to figure out which kind you want, such as:
7 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
standard.bjt
standard.dio
standard.jft
...etc...
Each line in each of these files has a model for one device.
4. Add a line with the .model line for your device to the end of the appropriate file using
a text editor.
Note you may have to adapt the model line to match the pattern in the file. It
should be pretty easy to figure out.
Now when you open LTSpice, you should be able to pick the device you've added as though
it was one of the existing models.
This will work well if you are using a computer where you can't edit the built-in library files,
or where edits will not be saved, but where you may have several models in one file which
you would like to be able to use in the future.
1. Save the file which contains the model you want to use in a directory where you have
write access. (For example, I use c:\windows\temp.)
2. Insert a SPICE directive from the edit menu,
This will work well if you are using a computer where you can't edit the built-in library files,
or where edits will not be saved, and that there is only a single model you want to use.
8 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
1. Open file which contains the model you want to use, and copy the model into the
clipboard.
2. Insert a SPICE directive from the edit menu, by using the icon, or by typing 'S'.
In the text box, paste the model from the clipboard.
3. Change the name of the component in your schematic to match the exact name of the
model in the model line.
Now when you simulate, your new device model should be used.
Note: Because you now have the model saved as part of your schematic, this is completely
portable between computers.
This method makes sense if you are working on your own computer, where you can update
your own libraries and use them again.
1. Look under C:\Program Files\LTC\LTspiceIV
(or C:\Program Files\LTC\SwCADIII )
2. Put the file 1N5338B.LIB in the subdirectory lib\sub .
3. Go to the directory lib\sym
4. Find a component similar to what you want. That way you won't have to draw the
symbol from scratch. For instance, if I were adding a new zener diode, I see there's a
component zener.asy.
5. Copy zener.asy to 1N5338B.asy. (1N5338B will be the name of the new zener diode
model I want to use.)
6. Open 1N5338B.asy in a text editor, and make the following changes:
change SYMATTR Prefix D to SYMATTR Prefix X
(This says that the model we're using is a .subckt.)
change SYMATTR Value D to SYMATTR Value 1N5338B
(This says that the name that will show up on the schematic is 1N5338B.)
add a line SYMATTR ModelFile 1N5338B.LIB
(This says that the name of the file containing the subcircuit we're using is
1N5338B.LIB.)
add a line SYMATTR SpiceModel 1N5338B
(This says that the name of the subcircuit we're using is 1N5338B. You can see
this by looking at the first line of the file:
.SUBCKT 1n5338b 2 1
This tells the name of the subcircuit and that it has two pins.)
Now when you open LTSpice, you should be able to find the component you have added,
and use it like any of the ones that are built-in .
This same procedure applies to both methods. These methods will be useful where you
can't edit the library files. This might happen if you are working on computers in public labs,
for instance.
1. Hold down CTRL-M while right-clicking on the component to bring up the dialog.
9 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
2. Change the prefix of the device to "X" to indicate you are using a subcircuit, and edit
the value of the device to match the subcircuit name exactly.
This will work well if you are using a computer where you can't edit the built-in library files,
or where edits will not be saved, but where you may have several models in one file which
you would like to be able to use in the future.
1. Save the file which contains the subcircuit you want to use in a directory where you
have write access. (For example, I use c:\windows\temp.)
2. Insert a SPICE directive from the edit menu,
10 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
This will work well if you are using a computer where you can't edit the built-in library files,
or where edits will not be saved, and that there is only a single model you want to use.
1. Open file which contains the subcircuit you want to use, and copy the subcircuit into
the clipboard.
2. Insert a SPICE directive from the edit menu, by using the icon, or by typing 'S'.
In the text box, paste the subcircuit from the clipboard.
11 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
The subbcircuit itself may include model definitions, so you may have to include
several lines when you copy. If the library file is only for that one device, then you'll
want to copy and paste the entire file contents.
I. Saving:
To save the circuit, use the save button on the tool bar or any other method you
would normally use to save files.
J. Printing:
To print, you may use the menu or the print icon as usual.
III. Simulation:
A. Before you do the simulation:
You have to have your circuit properly drawn and saved.
There must not be any floating parts on your page (i.e. unattached devices).
You should make sure that all parts have the values that you want.
There are no extra wires.
It is essential that you have a ground in your circuit.
B. Choosing a simulation:
Click on the Simulate button on the tool bar or use the "Simulate/Edit Simulation
Cmd" command.
12 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
Enable whatever type(s) of analysis you want using the Edit Simulation Command
window. The last one you choose is the one which will be done when you simulate.
Click on the Simulate button on the tool bar or use the "Simulate/Run" command.
It will check to make sure you don't have any errors. If you do have errors, correct
them.
C. Graphing:
Go to the "View" menu:
D. Adding/Deleting Traces:
Use "Visible Traces" or on the toolbar to select all the traces you want.
The add traces window allows you to choose various signals from the circuit, or to
create mathematical expressions involving them.
13 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
To delete a trace, select its title on the graph and press "Delete".
E. Doing Math:
In Visible Traces, there are functions that can be performed, these will add/subtract
(or whatever you chose) the lines together.
14 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
.
Note that if you right click on the trace name, you can choose to show two cursors.
This then allows automatic math to be done, such as to give the difference between
them in both dimensions.
You can use the cursor keys to move back and forth through the data points.
H. Saving:
To save your probe you need to go into the tools menu and click display, this will open
up a menu which will allow you to name the probe file and choose where to save it.
You can also open previously saved plots from here as well.
I. Printing:
This is a simple, but incredibly useful analysis. It will not give you anything to plot, but
it will indicate the DC voltages at all nodes and DC currents through all devices in the
circuit.
15 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
After a simulation has been performed, mousing over any wire in the circuit will show
what node it belongs to in the status bar. (See the lower left corner of the screen.)
16 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
After a simulation has been performed, mousing over a component shows parameters
like current and power in the status bar.
Note the sign of the current and power from the source.
17 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
The netlist allows you to see the node numbers for each device, among other things.
18 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
B. Transient
When doing a transient analysis of a source, the sections highlighted below in the source
configuration window are relevant.
19 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
The transient analysis is probably the most important analysis you can run in LTspice,
and it computes various values of your circuit over time. Two very important
parameters in the transient analysis are:
Stop Time.
Time to Start Saving Data
Maximum Timestep
(various checkboxes....later)
The ratio of Stop Time: Maximum Timestep determines how many calculations
LTspice must make to plot a wave form. LTspice always defaults the start time to zero
seconds and going until it reaches the user defined final time. It is incredibly important
that you think about what timestep you should use before running the simulation, if
you make the timestep too small the probe screen will be cluttered with unnecessary
points making it hard to read, and taking extreme amounts of time for LTspice to
calculate. However, at the opposite side of that coin is the problem that if you set the
timestep too high you might miss important phenomenon that are occurring over very
short periods of time in the circuit. Therefore play with step time to see what works
best for your circuit.
You can set a step ceiling which will limit the size of each interval, thus increasing
calculation speed. Another handy feature is the Fourier analysis, which allows you to
specify your fundamental frequency and the number of harmonics you wish to see on
the plot. LTspice defaults to the 9th harmonic unless you specify otherwise, but this
still will allow you to decompose a square wave to see it's components with sufficient
detail.
20 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
21 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
22 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
23 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
24 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
You can also look at the current through any wire. Remember you get the voltage by
mousing over any point in a node, (such as along a wire).
Now, if while mousing over it you hold down the ALT key, you'll see the current
pointer and the status bar indicates you can click to plot the wire current.
You can also look at the power dissipation in any device. Remember you get the
current by mousing over any device.
25 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
Now, if while mousing over it you hold down the ALT key, you'll see the power
pointer, (a thermometer), and the status bar will show you can plot the device power
dissipation.
C. AC Analysis
When doing an AC sweep of a source, the sections highlighted below in the source
configuration window are relevant.
Note: In an AC sweep, all AC sources are treated as sine waves.
26 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
The AC analysis allows you to plot magnitude and/or phase versus frequency for different
inputs in your circuit.
Type of Sweep
In the AC analysis menu you have the choice of three types of analysis:
Linear,
Octave and
Decade.
These three choices describe the X-axis scaling which will be produced in probe. For
example, if you choose decade then a sample of your X-axis might be 10Hz, 1kHz,
100kHz, 10MHz, etc.... Therefore if you want to see how your circuit reacts over a
very large range of frequencies choose the decade option.
27 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
You now have to specify at how many points you want LTspice to calculate
frequencies, and what the start and end frequency will be. That is, over what range of
frequencies do you want to simulate your circuit.
Number of points
Start Frequency
Stop Frequency
D. DC Sweep
The DC sweep allows you to do various different sweeps of your circuit to see how it
responds to various conditions.
For all the possible sweeps,
voltage,
current
you need to specify a start value, an end value, and the number of points you wish to
calculate.
For example you can sweep your circuit over a voltage range from 0 to 12 volts. The
main two sweeps that will be most important to us at this stage are the voltage sweep
and the current sweep. For these two, you need to indicate to LTspice what
component you wish to sweep, for example V1 or V2.
28 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
LTspice will simulate noise for you either on the output or the input of the circuit.
These noise calculations are performed at each frequency step and can be plotted in
probe.
The two types of noise are:
Output for noise on the outputs and
Input for noise on the input source.
Type of Sweep (same as for AC analysis)
Number of points... (same as for AC analysis)
Start Frequency (same as for AC analysis)
Stop Frequency (same as for AC analysis)
To use input noise you need to tell LTspice where you consider the 'input' in your
circuit to be, for example, if your voltage source is labeled 'V1'.
F. DC Transfer
G. Parametric
Parametric analysis allows you to run another type of analysis (DC operating point,
transient, sweeps) while using a range of component values. The best way to
demonstrate this is with an example, we will use a resistor, but any other standard
part would work just as well (capacitor, inductor).
29 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
First, right click the value resistor that is to be varied. This will open a dialog box
allowing you to set "Resistor Properties". Enter the name {R} (including the curly
braces) in place of the component value.
This indicates to LTspice that the value of the resistor is a global parameter called R.
Now add a spice directive to the page, by pressing the 's' key, using the icon
30 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
use the command to "Select Steps" from the trace menu. This brings up a dialog
31 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
fourier
V. Types of Sources
A. Voltage Sources A voltage source can be configured in many possible ways. Right clicking
on one will bring up the "Independent Voltage Source" window. The options which show up
in the window will change as the function selected changes.
1. (none)
This is your basic direct current voltage source that simulates a simple battery
and allows you to specify the DC voltage value.
2. PULSE
32 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
PULSE is often used for a transient simulation of a circuit where we want to make
it act like a square wave source. It should never be used in a frequency response
study because LTspice assumes it is in the time domain, and therefore your
probe plot will give you inaccurate results.
V is the value when the pulse is not "on." So for a square wave, the
initial
value when the wave is 'low'. This can be zero or negative as required. For
a pulsed current source, the units would be "amps" instead of "volts."
V is the value when the pulse is fully turned 'on'. This can also be zero or
on
negative. (Obviously, V and V should not be equal.) Again, the units
1 2
would be "amps" if this were a current pulse.
T is the time delay. The default units are seconds. The time delay may
delay
be zero, but not negative.
T is the rise time of the pulse. LTspice allows this value to be zero, but
rise
zero rise time may cause convergence problems in some transient analysis
simulations. The default units are seconds.
T is the fall time in seconds of the pulse.
fall
T is the pulse width. This is the time in seconds that the pulse is fully on.
on
T is the period and is the total time in seconds of the pulse.
period
N is the number of cycles of the pulse that should happen. Leave it as
cycles
zero if you want ongoing pulses.
This is a very important source for us because we do a lot of work with the
square wave on the wave generator to see how various components and circuits
respond to it.
3. SINE
33 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
A few things to note about the alternating current source. First, there are two
possible analyses which can be done and so there are two sets of parameters.
For an ac analysis, the parameters are:
AC Amplitude which is the peak value of the voltage.
AC Phase which is the phase angle of the voltage
For a transient analysis, the parameters are:
DC offset is the DC offset voltage. It should be set to zero if you need a
pure sinusoid.
Amplitude is the undamped amplitude of the sinusoid; i.e., the peak value
measured from zero no DC offset value.
Freq is the frequency in Hz of the sinusoid.
T is the time delay in seconds. Set this to zero for the normal sinusoid.
delay
Theta is the damping factor. (Not the phase angle!) Also set this to zero
for the normal sinusoid.
This is used to apply an exponential decay to the sinusoid; theta is the
decay constant in 1/seconds.
PHI is the phase advance in degrees. Set this to 90 if you need a cosine
wave form.
N is the number of cycles of the pulse that should happen. Leave it as
cycles
zero if you want ongoing pulses.
For this analysis, LTspice takes it to be a sine source, so if you want to simulate
a cosine wave you need to add (or subtract) a 90° phase shift. Note that the
phase angle if left unspecified will be set by default to 0°
4. EXP
34 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
35 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
5. SFFM
The SFFM (Single Frequency FM) type of source has these parameters:
DC offset the DC component of the sine wave
Amplitude the AC value of the sine wave
Carrier Freq is the carrier frequency.
Modulation Index is the modulation index.
Signal Freq is the signal frequency.
36 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
The PWL source is a Piece Wise Linear function that you can use to create a wave
form consisting of straight line segments drawn by linear interpolation between
points that you define. Since you can use as many points as you want, you can
create a very complex wave form This source type can be a voltage source or a
current source.
The syntax for this source type is flexible and has several optional parameters.
The required parameters are two-dimensional points consisting of a time value
and a voltage (or current) value. There can be many of these data pairs, but the
time values must be in ascending order, and the intervals between time values
need not be regular.
7. PWL File
37 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
The PWL File source reads a file for Piece Wise Linear function parameters.
B. Current Sources
For each of the previous discussed voltage sources, there exists the exact same
source except that it produces current. There is one thing that should be mentioned;
current sources in LTspice get a little confusing. For those current sources whose
circuit symbol has an arrow, you have to point the arrow in the direction of
conventionally flowing current. This applies to all current sources, including AC and
DC. Therefore placing the current source in the circuit backwards with seemingly
incorrect polarities will give the correct results.
An interesting little feature under the markers menu is the ability to add markers to
your circuit so you can see where the current and voltage have imaginary values in
the circuit, and the phase of your source at any point in the circuit.
38 de 39 19/01/2013 19:53
LTspice Tutorial http://denethor.wlu.ca/ltspice/
**Most of the pictures and screen shots came from Linear Technology© LTspice version 4.08o
Not related to LTspice specifically, but there is a tutorial on using LaTeX to typeset technical documents at
http://denethor.wlu.ca/latex
If you need to download Adobe Acrobat Reader go here If you need to update a browser, you might try Firefox
which is
free
open source
available for several platforms
Since this page uses cascading style sheets for its layout, it will look best with a browser which supports the
specifications as fully as possible.
Disclaimer
contact WLU site index disclaimer privacy office © 2012 Wilfrid Laurier University
Wilfrid Laurier University 75 University Avenue West, Waterloo, Ontario, Canada N2L 3C5 Laurier Brantford
39 de 39 19/01/2013 19:53