0% found this document useful (0 votes)
364 views10 pages

LTSpice Tutorial New PDF

LT Spice is a free, robust SPICE simulator that can be used to simulate circuits similarly to OrCad PSPICE. It includes models for switching regulators and op amps. Users can build and simulate circuits by opening a new schematic, adding components from the library, and connecting them. Custom models can be created by editing existing models or adding new .sp3 files. The document provides guidance on using various tools and features in LT Spice to build, simulate, and analyze circuits.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
364 views10 pages

LTSpice Tutorial New PDF

LT Spice is a free, robust SPICE simulator that can be used to simulate circuits similarly to OrCad PSPICE. It includes models for switching regulators and op amps. Users can build and simulate circuits by opening a new schematic, adding components from the library, and connecting them. Custom models can be created by editing existing models or adding new .sp3 files. The document provides guidance on using various tools and features in LT Spice to build, simulate, and analyze circuits.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

LT SPICE TUTORIAL

(compiled by Andrew Szeto using internet sources plus helpful hints from students)

LT Spice IV is a high performance SPICE simulator, schematic capture and waveform viewer with enhancements and
models for easing the simulation of switching regulators. Included in this download are LT Spice IV, Macro Models
for 80% of Linear Technology's switching regulators, over 200 op amp models, as well as resistors, transistors and
MOSFET models. LT Spice is just as robust and useful as OrCad except that it is free (no licensure issues), minimal
circuit size limitations, and works readily on your laptops. There are a few differences between OrCad and LT Spice
(noted below). Once these are learned, any simulation that could be done using OrCad’s PSPICE also can be done
using LT Spice.

Downloading LT Spice: visit http://www.linear.com/solutions/ltspice?type=video

The windows version of LT Spice can be used on all versions of Windows from XP through 10. There’s also a version
of LT Spice that will work on Mac OS 10.7 and above.

Building and Simulating a Circuit:

After LT Spice has been


successfully installed, open LT
Spice and select File → New
Schematic. You should see a
schematic capture window
show at right.

To Save the files, go to File → Save and give it a descriptive name. Suggestion: Create a new folder for each new
project because every schematic produces several ancillary files that get placed in the same folder as the schematic.

Functions of most buttons in the title bar above should be pretty


self-explanatory. For example, the “scissor” button deletes
whatever you highlight (left click).

Just like OrCad, LT Spice has hotkeys for each of the functions in
the tool bar. The default hotkeys for them are different from
OrCad, but they are reconfigurable by selecting: Tools → Control
Panel → Drafting Options Tab → Hotkeys Button

Suggestion: If your schematic does not show grid points and you
wish to show them. Go to Tools>Control Panel and check the
“Show schematic grid points (*)” box. You can also change the
colors of your schematic by clicking the “Color Scheme(*)”
button.

p. 1
Move and Drag Commands:

Unlike OrCad, where you can just click and drag a part or a net to move it, in LT Spice you first must select the option
to “move” or “drag” a part and then clicking on it to move it.

- move button – this command disconnects the selected wire segment or part from all its associated nodes and
allows you the place it disconnected anywhere on the schematic

- drag button – all of the associated nodes remain connected


to the selected part or wire segment as it is moved to a new
location

Component Library & Component Placement:

- component button -- Left clicking on the Component symbol


in the Schematic Editor Toolbar will bring up a directory of library
parts window from which you can select the desired part, i.e.,
BJTs, Op Amps, MOSFETS, independent voltage and current
sources, voltage dependent voltage source (a voltage amp),
current dependent current source (a current amp), voltage
dependent current source (a transconductance amp), a current
dependent voltage source (a transresistance amp), and a voltage
controlled switch.

** Right click on the part’s name to change it

** Right click on the part symbol itself to


change its value

Independent Voltage or Current Sources:

Unlike OrCad, there are not separate voltage or current sources for AC, DC, Pulse, etc. One signal source can be
programmed to perform all these functions. After selecting, placing, and connecting a voltage or current source on
your schematic, right click on the source to open the window at right:

Clicking the “Advanced” button will take you to the window shown below. From this window, you can select any of
the useful functions on the left and specify the DC and AC voltages and phase on the right. When assigning
magnitudes of voltages, standard postfixes apply:

p. 2
f = F =femto = 10-15 p = P = pico = 10-12
n = N = nano = 10-9 u = U = micro = 10-6
m = M = milli = 10-3 k = K = kilo = 103
MEG = mega = 106 g = G = giga =109

Note: m or M ≠ Mega

Editing Libraries or Creating Custom Parts:

OrCAD stores its library of parts using xxx.lib


files and you add to them from within the
“Edit Simulation” window.

LT Spice stores its library of parts using


xxx.sp3 files. To add or edit models for
custom transistors, you must create a xxx.sp3 file using your favorite text editor (not a word processor) and then
save it in the same folder location as your simulation project.

Example: Creating and Using a Custom BJT

Open the schematic capture window and create the schematic. Using any
text editor (e.g., Notepad), create a custom component file with the
extension “.sp3”, and saved it in the same folder location as this schematic.

Manufacturers often provide SPICE parameters for their


parts. As an example, the BJT model parameters shown
were found on the internet and copied into a text editor
and then saved as “NPNTutorial.sp3” in the
subdirectory containing this simulation project.

Using the text editor, selective parameters now can be


changed as desired and then saved under a custom
parts name.

p. 3
To use this custom part in your project, you must click the “add spice directive button”:

This will bring up the following window:

Click on the “SPICE directive” option and insert the following


into the text box:

.lib <<Location of .sp3 file>>/<<sp3filename.sp3>>

To link a particular transistor model to a transistor on your schematic, right click on the transistor’s name on your
schematic and input the model name from the library. For the Q1 BJT in the circuit example above, you would right-
click on “NPN” and change it to “NPNtutorial.” For the above example, the text box would look like this:
.lib C:\Users\szeto\Documents\PSPICE\tutorial\NPNtutorial.sp3

Clicking “OK” will return you to the main schematic screen with a box containing the tag for the new spice directive.
Click anywhere in the schematic to place the resulting tag and thus add this spice directive to the simulation.

Creating EE530/430 models in LT Spice’s


Parts Library:

Another method for creating customized


transistors involves editing the standard
models already in LT Spice. These models
exist in the folder (shown at right) where
LT Spice is installed. In Windows 7, the
path to these libraries might look like:

C:\Program Files
(x86)\LTC\LTspiceIV\lib\cmp

Among these files, standard.BJT (BJT


Models) and standard.MOS (CMOS
Models) are probably the most relevant to
EE530/430 course work. The content of the other files can be deduced from their file extensions.

To place an NPN BJT transistor into your


schematic, press F2 or click the “Component”
button on the toolbar. Then → place a
transistor (any) → shift + right click, choose
"pick new transistor" in box that opens →
choose from the expanded parts list. Then
right click on the part and “Pick New
Transistor.” If the transistor that you want is
NOT shown and you wish to create a custom
NPN transistor, pick an existing part, e.g.,
p. 4
2N2222, that comes closest to what’s required. Then right click on the “2N2222” BJT to bring up its SPICE parameters
to modify them and then save it under a new model name.

IMPORTANT NOTE: If (for some reason) your computer does not allow you to edit the parts file, e.g., “standard.BJT”
or “2N2222,” save your work and exit LT Spice. Using windows explorer, search for the library file that contains the
components for LT Spice (see probable path name above). Then click on the file’s “Properties” and “Security” to
change its property so that this file can be edited (you need to be logged on with “administrator” level privileges).
Then save the changes by clicking “Apply.”

Now that you have permission to edit the library parts file, open it using a text editor. Then you’ll see a list of parts
with their various parameters. Locate and edit the part that needs to be customized -- usually by copying pasting the
part to be modified, make the changes to it -- and giving it a NEW MODEL name. For example, the BJT named
“2N2222-Spice 1” shown below has new parameters for BF and VAF. Suggestion: Keep your custom parts at the top
of your parts list for easier identification, but the order of your parts list does not matter. Now save the modified
component library file and exit your text editor. Restart LT Spice to have your modified library file take effect.

After doing the above, the new part


(“2N2222-Spice 1”) should be
available to use in LT Spice. To have
an existing NPN transistor on the
schematic take on the new model
parameters, right click the part and
“Pick New Transistor” and pick the
new part from the pop-up window.

Highlight, copy and paste your


custom part to put another identical
transistor into your schematic.

p. 5
Inserting a “custom” model directly into the schematic drawing:

This method works well if you are using a computer that will not allow you to edit the built-in library files or will not
allow you to save your edits and you have only one or two custom models that you want to use.

 Open file which contains the model you want to use, and copy the model into the clipboard.
 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 onto your schematic and then change its model name and
model parameters as desired.
 Change the name of the component in your schematic to exactly match the name of your customized model.
The model name appears immediately after the word “.model” in the model definition syntax.

Now when you simulate, your new model will be used. Note: Because you have now made the custom model a part
of your schematic, your simulation circuit is self-contained and should work on another computer running LT SPICE.

Editing passive components:

All passive components can be edited by right


clicking on the component itself and inserting
the change. Be sure to include the CORRECT
pre-fixes as given earlier.

Editing BJTs (specifying BF, VAF, or AREA):

 Place the desired BJT symbol on the schematic


 Right-right-click on the BJT symbol, then either “Pick New Transistor”
 When the list of BJTs opens, highlight the entire line for 2N2222 and copy the model definition onto the
clipboard using ctrl-c and ctrl-v. Note: SPICE transistor model definition can be copied from any source so
long as it is a text file and has the correct format
 Close the “models” window and the “Pick New Transistor” window.
 Click on the .op icon on the tool bar to insert a “SPICE directive”
 Paste the model definition into the .op window and change the model parameter as desired (e.g., BF = ? or
VAF = ?). Be sure to also give the revised model definition a new name, e.g., 2N2222_new.
 Click OK to close the SPICE directive window and to insert the model definition in the schematic.
 Change the name of the transistor (right click on the circuit symbol) to match the new name of the model
just created.
 To specify the transistor area of any BJT, ctrl-right click on the symbol and enter the desired area under
VALUE2 in the pop-up window.
 To check the area for each BJT, hit VIEW  SPICE netlist. The transistor’s area is the numerical entry that
follows the transistor’s model name (blank if transistor area was unspecified with default value = 1).

Editing MOSFETs (specifying W/L ratios):

 Place the desired MOSFET symbol on the schematic. Must use 4 terminal MOSFETs (“NMOS4” or “PMOS4”)
 Right-click on the MOSFET symbol and then specify W and L as desired (must be in microns)
 To check the W/L ratio for each MOSFET, hit VIEW  SPICE netlist. The transistor’s length and width are
given by L = ? and W = ? respectively.

p. 6
Running Simulations:

Unlike OrCad’s PSPICE where you must go into the ‘Edit


Simulation’ Window to specify or change the type of
simulation, LT Spice allows you to add or remove
simulation commands by directly adding and editing the
SPICE directives that are on your schematic. If no
simulation directives have been specified either on the
schematic or in the Simulation window, clicking on the
“run” button will cause LT Spice to ask you to pick some
available simulation options (shown at right).

Various simulations can be chosen by inserting SPICE


directives (using the syntax below):
 AC Sweep = .ac <oct, dec, lin> <Npoints>
<StartFreq> <StopFreq>
 Transient Analysis = .tran <Tstop> [<option> [<option] … ]
 DC Sweep = .dc [<oct,dec,lin>] <Source1> <Start> <Stop>
 DC Transfer Function = .tf V(output node name) [,<ref node name>]) Vinput source {or V(input node name)}
 Operating Point Simulation = .op
 Fourier Harmonic Analysis = .four <fundamental freq> [number of harmonics to be calculated, default = 9]
[number of periods to analyze] <V(node_name) voltage to analyze with respect to the fundamental freq.>

In the commands above, you must use <...> to designate one of the simulation options or else the default option will
be used. Choosing among the available options by using [....] is optional, however. Here are some USEFUL options:

.op (detailed DC operating point information) can be run in conjunction with other simulations. Otherwise
only one simulation type can be run at a time. This is a simple, but incredibly useful DC analysis (all caps =
open circuits and all inductors = short circuits). 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. To have node voltages appear on the
schematic, .op must be selected together with any other simulation type.

When .op is run by itself, Node voltages, drain/collector currents, transistors’ operating point parameters,
and junction voltages & capacitances all can be viewed within the Error Log (i.e., the Spice output text file).
Open the Error Log (a text file) as follows: View → Spice Error Log or by pressing the hotkey “Ctrl+L.” This
file can now be printed also.

.tf (small-signal transfer function) When the small-signal transfer function (.tf) is selected, a pop up
window will appear after the simulation and display the values based on the input and output terminals that
was specified earlier.

.trans (or 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 size

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

p. 7
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 do the simulation. 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 and will give you smooth and accurate waveforms. You can set a step ceiling which
will limit the size of each interval, thus increasing calculation speed.

.Fourier (Fourier analysis) is another handy feature that allows you to specify the fundamental frequency and the
number of harmonics desired in analyzing the signal at any node. LT Spice defaults to calculating the nine lowest
harmonics unless you specify
otherwise. Nine harmonics will
allow you to decompose a square
wave to see it's components and to
find the total harmonic distortion by
summing the harmonics.

Naming Nets/Nodes:

Suggestion: give descriptive names to key nodes or nets such as Vout or Vin. Use the following procedure to name a
node or net in LT Spice.

Selecting Name Nets button : to bring up the window at right:

The top choice is for grounds; the middle choice is for assigning power rails
like VCC and VDD ; and the bottom choice is for specifying custom node/net
names, e.g., Vout or Vin.

Once a choice is selected and, in the case of custom names, a descriptive


name is written, click “OK.” This will close the “Net Name” window and
return you to the schematic with a tag attached to the cursor. Move the
cursor to the node to be named and left-click on it to attach the node
name.

Alternatively, you can simply right-click on the desired node and select “Label Net.” This will bring up the above pop-
up window. Then follow same procedure as above.

.OP & ERROR LOG: Displaying Node Voltages in the Schematic and the Transistor’s Operating Point Parameters

Valuable diagnostic information can be found in the .OP and Error-Log files. In order to know the node voltages in
your schematic, the “.op” simulation must be performed. Then left click on the desired net or node to bring up a box
above the cursor. This box is the node voltage tag. Simply place this tag on the node to display its voltage.

Unlike OrCad’s PSPICE, LT Spice does not show branch currents on the schematic itself. To view the node voltages,
branch currents or the transistors’ operating point parameters, the simulation option .op must be activated. To view
the node voltages and branch currents after your simulation, do the following: Toolbar → View → .op

p. 8
The transistor currents and key parameters can then be viewed in the .OP output file as follows: Toolbar → View →
Spice Error Log. Using the hot key “Ctrl+L” also will bring up the error log (i.e., the Spice output text file). To print the
Error Log, copy and paste it into a text editor such as Notepad.

Simulating a Net List Created or Borrowed from Another SPICE Program:

How do I run a netlist? LTspice IV will recognize the file as a netlist if it has file extension of ".cir” Just open the text
file first and then run it.

Start LTSpice  open the *.cir file from the "file" menu  click anywhere in the file to be sure its active  click
the Run button (Running Man symbol).

Obtaining the Complete SPICE Simulation (results) File:

As part of your SPICE documentation, submitting a complete record of the simulation results is often required. Such
a file would include the net list; simulation commands; circuit errors; name, time, and date of the simulation; default
transistor parameters; characteristics of each transistor at its operating point; node voltages (if the .op option was
picked); output currents of the voltage sources; power dissipation; small signal input resistance, small signal output
resistance, and transfer gain; and harmonic distortion.

In OrCad’s PSPICE, all this information would be found in one large text file having the “__.out” extension. Search for
the location of this file and then copy and paste it into a text editor or your word processor program.

In LT Spice, such valuable information would be found in the Net List, .OP file, and the Error Log. To view the “SPICE
Error log.” Click tool bar  View  SPICE Error Log (or press CTRL-L shortcut). Copy and paste the desired
portions of the simulation results into a text editor (e.g., WordPad) or a word processing program. A similar
procedure would be used for the Net List and .OP files.

Average and Instantaneous Power Dissipation (PD) in LT Spice:

 Average power dissipation (PD) at circuit’s operating point for any given component will be shown at the
screen’s bottom by placing your cursor over that component. To obtain PD for your entire circuit, place your
cursor over +VCC and sum. Note: you must first simulate your circuit with the .OP option activated.

 Instantaneous power dissipation for each circuit component can be viewed by holding down the ALT key and
left clicking on the component of interest. The pointer will change to a thermometer and a plot of the
instantaneous PD will be shown. Note: you must first perform a transient simulation of your circuit.

Displaying and Printing Plots in LT Spice:

Once a simulation that yields a waveform or bode plot is run, an empty window will pop up to allow you to insert
plots. For bode plots, magnitude will be automatically expressed in dB and phase in degrees. The transient plots and
DC sweeps are plotted in volts. Right clicking on a trace allows you to edit its line color, thickness, and other
parameters.

p. 9
To mark key points on a plot or to more closely investigate them, left click on the name of the trace name at the top
of the graph to bring up a movable cursor. The exact value of the magnitude, phase, and frequency at the cursors’
location will be shown in a nearby pop up window. To investigate additional points, clicking on the trace name again
to bring up a second cursor and repeat.

Hit “CTRL-P” to print the plot using black lines on a white background. You also can export as a pdf file your SPICE
plots for later printing. Avoid using “Print Screen” or screen shot if you do NOT want to print your waveform using
light colored lines on a very dark background. Such plots are not very readable and very wasteful of ink. Also make
sure that your plots are sized for easy readability.

Labeling Key Points on a Trace:

Select from your command bar Plot Settings  Notes & Annotations  Label Cursor Position. This places a label
(frequency and either the magnitude or phase) at the active cursor’s last location. To select which label, choose
between magnitude and phase in the pop-up window when a cursor is activated.

Labeling Your Plots or Adding Explanatory Text:

 Click on Text Label text label icon on top tool bar.


 Type in what you want to write.
 Click OK
 You can move this around by single clicking and dragging.

p. 10

You might also like