Sie sind auf Seite 1von 37

ECE 326

LTSpice Tutorial

By Wei Wu

Contents

Introduction to spice model


Introduction to LTSpice
Add components
Simulation types
Measurement & Math
Initial Condition
Parameter set up
Include SPICE model
Transformer
2

SPICE

Simulation Program with Integrated Circuit Emphasis


Open source analog electronic circuit simulator
Originally developed at UC Berkeley by Laurence Nagel
Uses mathematical models to describe circuit elements
Hspice (Synopsys), Pspice (Cadence), Xspice (Ge Tech),
Adice (analog device), Ltspice (Linear Technology) etc.

Netlist
SPICE Netlist text file containing circuit description
INPUT

OUTPUT

Netlist
Circuit description
* Demo of a simple AC circ.
v1 1 0 ac 12 sin ; v1 is an AC source of 12V amp.
r1 1 2 30 ; r1 is 30 Ohm between nodes 1 and 2
c1 2 0 100u ; c1 is 100uF between nodes 2 and 0
.ac lin 1 60 60 ; directive to perform AC analysis
.print ac v(2) ; print out the voltage from node 2
.end ; anything after .end will be ignored
SPICE directives
Commands starting with dot (.ac, .end, etc.) are known as
SPICE directives

http://www.linear.com/designtools/software/#LTspice

w
o
D

a
o
nl

e
c
i
p
s
T
L
d

To begin drawing the circuit, click New


Schematic, or Ctrl+N
Enable grid if not shown by clicking Ctrl+G

Place Diode / D
Place Inductor /L

Toolbar Summary

Place Capacitor /C
Place Resistor /R
Label Node /F4

Place Circuit Element/ F2

Place Ground /G
Draw Wire /F3

Simulate
Zoom In/
Ctrl +Z

Move/F7

Pan
Zoom Out/Ctrl +B

Find

Auto Scale/ Space


Delete/F5
Mouse Wheel
can be used to
zoom in /out

Copy/F6

Paste

Drag/F8
Undo/ F9
Redo/ Shift+F9
Rotate/ Ctrl +R
Mirror/Ctrl+E
Place Comment /T
8

Place SPICE Directive /S

Color
Press Tools-> Color Preference
To change background color or wire
color
Change both Schematic & Waveform
background color to White for your
report. Save printer ink!!

Rotation

To rotate the component


prior to placing press Ctrl-R

To mirror the component


prior to placing press Ctrl-E
Click F2 or Component to
add components.

10

Add Component
Click R add resistor

Right-click component to
enter component value

Or Click
Or Click F2 or Component
to add components.

Or Right-click R to
enter component value

Right-click R1 to
change designator

11

Add Source
Right-click component to
enter DC value

Click F2 or Component select


Voltage to add voltage source.
Click Advance to have
more source option.

12

Prefixes are case insensitive: T = t, G


= g, and so on

T = terra = 1012
G = giga = 109
MEG = meg = 106
K = kilo = 103
M = milli = 10-3
U = micro = 10-6
N = nano = 10-9
P = pico = 10-12
F = femto = 10-15
No need to enter units, they are assumed (e.g. 1M is
1mV if entered for voltage, 1ms if entered for time, etc.)
13

A Simple Example

Place components and source.


Change value and reference
designator.
Dont forget GND!

Use F3 to connect components.

14

SPICE analysis
After finishing your circuit, select Simulate Edit
Simulation Cmd
Your choices:
Transient analysis
AC small signal anlysis
DC sweep
Noise analysis
DC transfer function
DC operating point (Q-pt)

15

Adding SPICE directives


For example, use Transient with 1us Stop time
After setting up the simulation command, you are set to go.
Simply click Run button
Run command is a SPICE directive itself
You can add other SPICE commands directive by clicking
on Spice Directive button

16

Simulation Results
After run the simulation, a
new window will show up.
Its the waveform viewer
with .raw extension.
Left click on any wire in the
schematic file to plot the voltage
of that point on the waveform
viewer.

Left click on the body of the


component in the schematic file to
plot the current flow in that
component on the waveform
viewer.

Press Alt and move mouse to the


component, then left click . It will
give apparent power (V*I)
17

Simulation Results
Voltage at node n001

Current across Rx

Voltage Value

Time

Current Value

Apparent Power

18

Add Labels
Add Labels to signals/ netlist

Re-run the simulation and use voltage


probe to measure voltage at Vin point

19

19

Simulation Types
Recall, there are many simulation options such
as:
Transient analysis
AC small signal anlysis
DC sweep
Noise analysis
DC transfer function
DC operating point (Q-pt)

20

Transient Analysis
Transient Analysis:
It computes the time response of all
components in any circuit. Isa a non-linear,
time domain analysis. X-axis is the timed in
seconds and y-axis will be any electrical
variables.
You can specify several parameters such as:
*Stop Time (duration of simulation)
*Time to start saving data (set up starting
time other than 0)
*Maximum Time step: smallest interval of
time step

21

Small signal AC & Bode plot


AC Analysis
AC analysis is used to see frequency
response (gain and phase info) of a passive or
active filter. It also can be used to check the
bandwidth of an amplifier.
AC analysis will find the DC operation
point of the circuit first, then find the small
signal response under that DC bias condition
You can plot results using octal, decade or
linear frequency ranges. Start/Stop frequency
let you set the sweep frequency range.
Usually set AC source to 1 so that every
point in the schematic will be the transfer
function.
Hint. Decibel plot will be the bode plot
22

DC sweep
DC Sweep
It will show the transfer function of an
amplifier, DC characteristic curves of a
transistor.

23

Noise
Noise
Test the response of an audio amplifier
under noise conditions.
Specify input and output nodes.
Noted, click on resistor R1 and R2, it will show
the noise contribution of these resistors. If we
would like to ignore the noise caused by R1,
just add noiseless note behind the resistor
value.
It also can provide gain plot. When use Add
Trace command

24

DC Transfer Function
DC Transfer Function
This is an analysis mode that finds the dc
small signal transfer function of a node voltage
or branch current due to small variations of an
independent source.

25

DC operating point
DC Operating Point:
It determines the DC conditions of a biased
transistor. ( operation region of BJT/ MOSFET)
Computes DC node voltages and loop currents
of an electric network. AC sources are
disconnected

26

Average, RMS & Cursor


Average Power:
Ctrl + Left click on monitored signals (V(out) in this case). A small window will
pop out provides average and RMS value.

Cursor:
For accurate measurement / data reading, apply just left click
on V(out) , a cursor will show up(#1). Hold left click and drag
the cursor to any point you want to measure. Left click once
again will give you another cursor (#2). A small windows will
show up on the most right corner of your desktop that provides
extra information.

27

Math
Math function
Right click on monitored signals
(V(out)). A expression editor will
show up that allows you to apply
some simple math function on this
signal.
for example abs(V(out)) will
give the absolute value of V(out)
signal.

28

FFT
FFT
Select waveform viewer , go to
View -> FFT
Select signals, for example V(out),
you can change the time range and
other parameters.
Click ok, the FFT result window
will provide you the result.

29

Initial Condition
Initial Condition
In some cases, especially for transient analysis, set up a starting voltage for certain component
(capacitor/ inductor) will be very helpful. Ltspice has a spice directive .IC that allows to set
initial condition.
Use

command to add spice directive.

Type .IC [V(<signal>)=<voltage>] [I(<signal)=<current>]

30

Parameter
Parameters:
If there are lots of same components in the schematic that may subject to change
occasionally. It will be very convenience to use parameter definition. Its a spice directive.
First, right click on the component, instead of adding a real value, use {parameter name}.
For example,

use
command to insert a spice directive: .param Rpa = 1k and add this directive
into the schematic. The resistor value of RL is equal to 1k in this case.

31

Step
Set up step:
LTSpice can do much more stuff, for example, sweep parameters. For example, if we
would like to check the circuit performance with various load conditions and compare the
result. Set up a load parameters will be the easiest way.
Use
command to add spice directive. Type: .Step param Rpa 100 1k 100 dont
forget to replace the real value of load with {Rpa}

32

Add Real Components


For non-ideal components simulation, LTSpice provides many commonly used device models.
For example
Right Click on the resistor and click select resistor, the resistor models will pop up. These
model database can be modified too.

33

Include SPICE Model


Too add a third party spice model:
.model parts: simple components such as transistors and diodes
.subckt parts : more complex parts made up of simpler spice parts
Procedure:
*Place a generic component to the schematic such as ideal diode / op-amp
*Download the SPICE model to the same directory
*Change filename to the SPICE model
*Add a .include SPICE directive to the schematic
*Press Ctrl then right click over the generic component, change the value field to the
SPICE model name. For subcircuit, make sure the Prefix attribute is marked as X

34

Example

35

Example

36

Transformer
There is no transformer model exists in LTSpice software, however, we can simulate it by
using inductors.
*Draft an inductor for each transformer winding
*Couple them using a single mutual inductance (K) statement via a SPICE directive
K [inductor 1] [inductor 2] [coupling coefficient]
*Add the K statement will displays the dot on the inductors, adjust the transformer
polarity position
*Give values to two inductors, notice the relationship between inductor value and turns
ratio:
*Ideal transformer, very large inductance and coupling
coefficient =1.
Note: A series resistance in primary side is required for
computation, say 0.1 ohm (make it small); The
inductance should be much larger than the series
resistance ;
37

Das könnte Ihnen auch gefallen