Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Principles & Applications

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 85

Electronics

Principles & Applications


Seventh Edition

Charles A. Schuler

LTspice/SwitcherCad III
(revised 1/30/2008)

©2008 The McGraw-Hill Companies, Inc. All rights reserved.


LTspice/SwitcherCad III
• A freeware SPICE III circuit simulator written by Mike Engelhardt
at Linear Technologies http://www.linear.com/
– SPICE I and SPICE II were written using the FORTRAN
programming language. SPICE III was written using the C
programming language (U.C. Berkeley, 1985).
http://bwrc.eecs.berkeley.edu/Classes/IcBook/SPICE/)
• LTspice was written to support circuit designers who evaluate or
use Linear Technology products.
– It includes an extensive library of Linear Technology devices.
• It has schematic capture and is much easier to use than
traditional text-based SPICE.
– Traditional SPICE requires a text file called a netlist that
describes the circuit to be simulated.
– With schematic capture, the user can enter a circuit using
schematic symbols and wires via a graphical user interface.
LTspice/SwitcherCad III
• Is powerful and fast, but is not as intuitive for
beginners as simulators such as Multisim
– Requires more knowledge about SPICE directives
and terminology
– Has a limited (mostly proprietary) device library
– LTspice has only basic behavioral gates for digital
circuits. It is expandable, but this requires knowledge
about SPICE and device behavior.
• Is worth learning about
– Since it is free, fast, and powerful, it is one of the
most widely used circuit simulators at this time.
– Many professionals consider it to be superior to some
commercial simulators.
LTspice/SwitcherCad III is a free download and can be found
on the Linear Technology website:
http://www.linear.com/designtools/software/switchercad.jsp
It’s easy to “draw” a circuit.

Get started by clicking File and then New Schematic, or hold


down the Control key and then press the “N” key (Ctrl+N).
Drawing a circuit …

is easier if the grid is active. Click


on View and then Show Grid. Or,
you can type Ctrl+G.
Delete tool

It is easy to place grounds and basic components. Click on


the desired component and then move the mouse to position
it and then left click to place it. You will find that the
connectors (square blue boxes above) snap to the nearest
grid points. To place another component of the same type,
move to the next location and click the left mouse button
again. To cancel or quit a component type, click the right
mouse button. It is often more time efficient to place all of the
resistors, then the capacitors, and so on. Use the scissors
(delete tool) to remove components and wires.
After a component has been selected, it can be rotated
by holding down the Control key and then pressing
the R key. Here, D1 was placed first (by left-clicking in
the desired location on the schematic) followed by
Control+R and then D2 was placed followed by
Control+R again and so on.
Rotated components

Mirrored components

Control+E was used here before placing Q2 on the


above schematic. Note that Q2 is the mirror image of
Q1. Control+E is the mirror command. Control+R and
Control+E are keyboard shortcuts.

Rotated and mirrored


The menu command Tools→Control
Panel→Drafting Options→Hot Keys allows
you to define your own keyboard shortcuts.
Additional components are
available by clicking on the or
gate symbol or by pressing
the F2 key. Suppose you
need a voltage source.
Choose “voltage” from the
component symbol list and
then place the source on
the drawing area with a left
click. Right click the
source to specify the
voltage. To specify a
sinusoidal voltage source,
select Advanced after right
clicking.
Specifying a SINE ac voltage source

Amplitude and Frequency


(V1, as shown
here, is a 44-V
dc source.)
Use the pencil tool to connect the components. Left click a
terminal (blue box) and then move the mouse to the
connecting terminal and left click again. The crosshairs
below are positioned to connect R4 to R5.

The blue boxes disappear after they are connected.

Unconnected nodes can cause Netlist errors.


Place Diode
Place Inductor
Tool Bar
Place Capacitor Summary
Place Resistor
Label Node Place Circuit Element
Place Ground
Draw Wire

Simulate
Move
Zoom In
Drag
Pan
Undo
Zoom Out Find
Auto Scale Redo
Delete Rotate
Copy Mirror
Paste Place Comment
Place SPICE Directive
Place a resistor
and right click it
to enter its values.
Or, click Select Resistor
to view a Standard list.

You must specify component values.


Right click the resistor label to enter a new
reference designator. You can specify
vertical text.
Models are required.
• Missing models will generate error
messages.
– The next slide shows an example.
– LTspice does not have a model for the
1N4001 diode.
• There are several ways to add models.
You can expand the component
data base (add models).
• For example, suppose that you want to simulate a circuit
using a BFR540 transistor and that you have the SPICE
model saved in text format via Windows Notepad (go to
Start, Programs, Accessories to launch this basic text editor).
– Load the SPICE model into Windows Notepad and then Copy it to the
clipboard using Control+A followed by Control+C.
– Use Windows Notepad with File Type set to All Files to open the file
C:\Program Files\LTC\SWCADIII\lib\cmp\standard.bjt, scroll to the
end of that file, and then paste the model from the clipboard
(Control+V) and then Save the file.
– The next time that you run LTspice, the BFR540 will be available as a
choice when selecting an NPN BJT transistor as shown on the next
slide.
CMRR

Here it is!
A SPICE model for the BFR540
.MODEL BFR540 NPN + RBM = 5.00000E+000
+ IS = 1.04516E-015 + RE = 3.53552E-001
+ BF = 1.84359E+002 + RC = 1.34000E+000
+ NF = 9.81774E-001 + EG = 1.11000E+000
+ VAF = 4.16981E+001 + XTI = 3.00000E+000
+ IKF = 1.00000E+001 + CJE = 1.97895E-012
+ ISE = 2.32436E-013 + VJE = 6.00000E-001
+ NE = 2.02825E+000 + MJE = 3.32695E-001
+ BR = 4.39917E+001 + TF = 7.45719E-012
+ NR = 9.92532E-001 + XTF = 1.14072E+001
+ VAR = 2.09773E+000 + VTF = 3.15854E+000
+ IKR = 1.66296E-001 + ITF = 1.56917E-001
+ ISC = 1.29849E-016 + CJC = 7.93745E-013
+ NC = 1.06486E+000 + VJC = 1.85522E-001
+ RB = 5.00000E+000 + MJC = 8.41656E-002
+ IRB = 1.00000E-006 .ENDS
Also, a SPICE model can be added
directly to the schematic.
Adding a model to a schematic
• Copy the model to the clipboard.
– Left click and hold and drag over the model and then capture it
with Control+C. e.g. .MODEL 1N4001 D IS=29.5E-9 RS=73.5E-
3 N=1.96 CJO=34.6P VJ=0.627 +M=0.461 BV=60 IBV=10U
• Click on .op on the toolbar
• Paste the model into the window.
– Control+V.
• Click OK.
• Place the model on your schematic with a left click.
• This method is often preferred when sharing circuits with
others.
– The necessary model or models are imbedded in the circuit
file.
Where does one obtain SPICE
models?
• Search the Internet … many are available as
free downloads or can be copied to the clipboard
and then pasted into Windows Notepad (or onto
your schematic via .op on the toolbar). Some
links are provided at the end of this presentation.
• Search device manufacturers’ websites.
• Modify an existing model.
• Create your own.
– Software is available. http://
www.intusoft.com/spicemod.htm
• Or, you can use a subcircuit.
Subcircuits (.SBCKT)
• Are often used when repetition occurs.
– Better than cluttering the schematic with redundant
information
• Also can be used to replace a complicated
device such as an OP-AMP, a DIAC or a TRIAC.
• The next slide shows a common dimmer circuit
where the DIAC and TRIAC functions are
defined by subcircuits.
– LTspice has pre-defined schematic symbols for
DIACS and TRIACS, but no corresponding models.
More about models and subcircuits
Models given as .MODEL statements are for intrinsic SPICE
devices such as diodes and transistors. The .MODEL
statement gives the parameters for the specific component.
The general behavior of the device is already known by
SPICE … only the parameters need to be given to finish
specifying the component's electrical characteristics.
 
On the other hand, models given by .SUBCKT statements
define the modeled component by a collection of intrinsic
SPICE devices. For example, the SPICE model of an opamp
would be given as a subcircuit. In the previous slide, the
SPICE models of a DIAC and a TRIAC were specified as
subcircuits.
LTspice is useful for analyzing
circuits designed by others.
• It is sometimes only necessary to use it to
review and experiment with circuit files
that have already been created.
– Many can be found in the LTspice
subdirectories.
– Some examples are available for download.
This is an outstanding example:
http://cmosedu.com/cmos1/book.htm
How to run an existing circuit file
• From the File menu, select Open. Make sure the file type is
set to Schematics.
• Some good examples are available in
C:\ProgramFiles\LTC\SwCADIII\examples\Educational
(created on your hard drive when you install LTspice).
• Some appropriate examples for the McGraw-Hill basic skills
series are available on the website: http://highered.mcgraw-
hill.com/sites/0073106941/student_view0/lt_spice_instructio
ns_and_support_files.html (You probably have these files if
you obtained this presentation from the McGraw-Hill site.)
• The next slide shows a circuit from Schuler’s book. To view
the dc voltages and currents, a dc analysis is selected by
first clicking on Simulate, then Edit Simulation Cmd.
– The SPICE directive is .op.
CMRR

SPICE directive
for dc analysis
The DC operating point
selection provides all
node voltages and device
currents.

When you click OK, the


SPICE directive .op is
placed on the schematic.
A ground is required for simulation.
After a DC operating point analysis, moving the cursor over the schematic reveals the
various node voltages, currents, and the dissipations in each component. These values
are displayed in the lower left portion of the screen.
Summing the dissipations in this
-24V circuit produces zero. The negative
40W signs at V1 and V2 indicate that
they are power sources.

Placing the
9.6W
cursor here
shows the
-12V current and the
-88W dissipation in R5,
28.8W 1.2W
as shown below.

12W -3.6W

DC operating point (I(R5) = 200 mA Dissipation = 1.2 W


Waveforms
• Waveforms are what one sees on an
oscilloscope (graphs of instantaneous
voltages versus time).
• Waveforms can be viewed via the
transient analysis option. Click on
Simulate, Edit Sim Command, and then
select the Transient tab.
• The next three slides show the procedure.
Reference: Schuler, 7th edition, page 247 … the stiff
current source has been replaced with a resistor. Probe
both the base and the collector of Q2. Without the stiff
current source, the CMRR is notably poorer.

Load the circuit from the file menu.

Then, click run.


A small differential signal plus a
large common-mode signal

Move the cursor to the desired node. When the cursor changes
to a probe, click the left mouse button to view the waveform.
Can you see the 60 Hz common-mode component at the collector of Q2?

Move the cursor to the collector. Left click and now two waveforms are shown.
The next slide demonstrates the
value of simulation when evaluating
circuit performance.
• The differential amplifier circuit is much
improved with a stiff current source.
• The common-mode rejection ratio (CMRR)
is remarkably better.
– The common mode signal cannot be seen in
the output.
• Circuit simulators make it easy and fun to
investigate issues such as this.
The 60 Hz common-mode signal is too small to be seen here.

Stiff current source


Remember, waveforms are
available via transient analysis.
• You must specify the time duration of a transient
analysis by specifying a Stop Time.
– Often, this is all that is required.
• You can also specify the Time to Start Saving
Data.
– Useful in circuits where the start-up period is not
important.
• You can also specify the Maximum Timestep.
CMRR

Go to Simulate and then click on Edit


Simulation Cmd.
The time duration of a transient analysis is
like choosing the time base setting on an
oscilloscope.
For a basic
analysis, this is
often all that
needs to be
specified.
In this circuit, the common-mode signal is 60 Hz. A 60 Hz
signal has a period of roughly 17 milliseconds. Thus, a
Stop Time of 20 milliseconds is a reasonable choice.
Box

Expanded waveform measurements are easy. Hold the left


mouse button down and drag a box around the area of
interest. Before you release the button, the measurements are
available here: dx = 500 us (2 kHz) dy = 4.7 V
When you release the mouse
button, the area inside the box will
be zoomed to fill the waveform
display. Restore the original
waveform by right-clicking in the
waveform area and then selecting
Zoom to Fit or simply press Ctrl+E.
To obtain an accurate frequency measurement,
draw a box around several cycles and then draw a
second box to capture one cycle.
This box captures one cycle.
(The peaks are easier to
identify than the zero
crossings.)

The output frequency


of this Wien bridge
oscillator is predicted
by 1/(2πRC), thus we
1.572 kHz can expect an output
at 1.59 kHz.
To obtain the voltage difference across two nodes, move the cursor to the first
node and left click when it changes to a red voltage probe and then without
releasing the mouse button, move to the second node and when the cursor
changes to a black voltage probe, release the mouse button.
Ctrl+Left Click here

To determine the Average and


RMS values of a waveform,
hold down the Control key and
left click the waveform’s label.
The Fourier transform
• Converts from the time domain to the frequency
domain (the signal spectrum)
– Schuler, 7th edition, page 500
• The FFT (fast Fourier transform) is available in
LTspice.
– After a waveform is plotted, right click in the
waveform window and select FFT. Choose the
node of interest and then click OK. Left click the
node label in the FFT window and then use the
keyboard arrow keys to make accurate
measurements of frequency and amplitude for the
various spectral components. Left click and hold to
draw a box around a part of the graph to expand it.
FFT (frequency domain) display

Time domain display


Expanded FFT display

Note: you can increase


the simulation time for
better frequency
resolution.
Resolution = 1/Time
Simulation time = 0.001 seconds
Resolution = 1 kHz

Simulation time = 0.01 seconds


Resolution = 100 Hz
In addition to increasing the simulation time, you can turn
off data compression for better resolution (Tools 
Control Panel  Compression). The next slide shows a
significant improvement in dynamic range with data
compression turned off.

Default data compression No data compression


FFT with no data compression (approaching a 120 dB range)

FFT with default data compression (90 dB range)


The option plotwinsize determines the number of data points to compress in
one window. Set plotwinsize to zero to disable compression. Data
compression will always be turned off, regardless of the control panel settings
(an advantage when sharing circuits with others).
Individual waveforms can be placed
onto different plot panes.
• Right click in the waveform pane and then
select Add Plot Pane.
• The next slide shows the usefulness of
this feature.
– With all five waveforms on one plot pane, the
display is confusing.
– Separate plot panes make it easy to see the
divide-by-two action of each flip-flop.
Input (TRIG)

Threshold waveform

Output

555 one-shot
There are
three Three plot
important panes add
waveforms clarity.
here.
A dc offset is also available.
• The next slide shows a D/A converter.
• The input waveforms were separated by right-
clicking on the node name, e.g. V(b1), as shown
below, and adding a dc offset of +2 volts.
• It also shows how colors can be chosen by using
Tools→Color→Preferences→Selected
Item→Waveform→Background→Grid→Axis

V(b1)+2 dc offset
+6 dc offset

+4 dc offset
Separate plot plane

+2 dc offset

0 dc offset
Current waveforms
• Moving the cursor to the inside area of a
component, after a transient analysis has
been run, displays the current waveform in
that component.
• When the cursor morphs to a current
probe:
– left click to see the current waveform.
• This is illustrated in the next slide.
The current probe, like the voltage probe, shows time variations after
a transient analysis. Here, the current in R1 averages 2 mA (which
was measured earlier in a dc analysis) and the current fluctuations in
R1 are easy to see.

Current waveforms can be obtained after a transient


analysis by moving the cursor to the inside of a device.
When the cursor changes to a current probe, left click the
mouse to obtain the current waveform. To display the
current in a wire, Alt-left click the wire.
Current probe icon
The current in Q1 is constant.

The constant current source is doing its job!


e.g., Alt+click here.

To display a power waveform (instantaneous power), hold down


the Alt key and left click on the component of interest (after the
cursor has changed to a thermometer).
Ctrl+left-click

To determine the average power


dissipation, Control+left-click on
the label.
AC Analysis
• Provides the frequency response of a circuit
– Both the amplitude and the phase angle are graphed
as a function of frequency (Bode plot).
• Go to Simulate, Edit Simulation CMD, and then
click on the AC Analysis tab.
– You must enter the Number of points per sweep
interval, the Start Frequency and a Stop Frequency.
– You can also choose various sweep intervals.
• Octave, Decade, or Linear
Amplitude

AC Analysis provides the frequency response of a


circuit. One of the signal sources must be designated
as the input by specifying an AC Amplitude for Small
signal AC analysis. Run the simulation and then probe
the output for the Bode plot.
Phase

Output

Input Spice
directive
Ctrl+left-click the label
to measure bandwidth.
Here, the only change is the transistors. This
illustrates the need for proper SPICE models
when investigating issues such as bandwidth.
The BFR540 is a high-frequency transistor.

2N3904 BFR540
The .measure directive
• Is useful to find instantaneous values and values over
intervals

Keyword Operation performed over interval


AVG Compute the average value of <expr>
MAX Find the maximum value of <expr>
MIN Find the minimum value of <expr>
PP Find the peak-to-peak value of <expr>
RMS Compute the root mean square value of <expr>
INTEG Integrate <expr>

• The next slide shows an example of an instantaneous


measurement.
Run->View->View SPICE Error Log will show the instantaneous value at 1 ms.

vi: v(exponential_a)=0.632013 at 0.001


Here,
bandwidth is
measured.
(8.5 Hz to 2.8
MHz)
Configuring LTspice
• There are many user options.
– SPICE options (e.g. integration method)
– Drafting options including font properties
– Data saving defaults
– Compression
• Hint: turn compression off for the least distortion for analog
circuit simulations.
– Most options are available via the control panel.
• The next two slides illustrate some configuration
choices.
Tools  Control Panel  Operation

LTspice generates
several kinds of files.
To save disk space
and avoid clutter, these
files can be deleted
automatically.
Tools  Color Preferences

LTspice allows color


choices for waveform
plots and the
background on which
they are plotted. Also,
the axes and grid
colors are selectable
Support for LTspice
• The next slide shows an example of the
built-in help system.
• The help file is a downloadable and
printable document:
http://ltspice.linear.com/software/scad3.pdf
• There are numerous other resources.
Check the Links slide at the end of this
presentation.
Press F1 for the
Help System. You
can download the
User’s Manual
from:
http://ltspice.linear.
com/software/scad
3.pdf
The help files explain many things: for example, how to model transformers.
Some “gotchas” and hints
• “M” and “m” are interpreted the same by SPICE. Thus, a
resistor value of 10M is the same as 10m (ten milliohms
or 10-3).
– Use 10MEG (or 10E6) to specify ten megohms.
• Do not enter “1F” or “1f” as the capacitance for a one-
farad capacitor (enter “1”). “F” and “f” designate the
prefix femto (10-15).
• SPICE will not allow voltage sources in parallel, even
when of the same value.
– Add series resistances.
• SPICE will not allow current sources in series, even
when of the same value.
– Add parallel resistances.
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
LTspice leading characters
• A special functions device • L inductor
• B arbitrary behavioral source • M MOSFET transistor
• C capacitor • O lossy transmission line
• D diode • Q bipolar transistor
• E voltage dependent voltage • R resistor
source • S voltage controlled switch
• F current dependent current • T lossless transmission line
source • U uniform RC-line
• G voltage dependent current •
source V independent voltage source
• • W current controlled switch
H current dependent voltage
source • X subcircuit invocation
• I independent current source • Z MESFET transistor
• J JFET transistor • * comment
• K mutual inductance • + continuation of prior line
• . simulation directive
LTspice/SwitcherCad III final
notes
• Like many modern software tools
– it is relatively easy to begin using but one must spend
some time to discover and then master the most
powerful features.
• As freeware goes, it is outstanding!
– It is relatively bug-free.
– It is compact and very fast.
– It is regularly updated.
• A tip for students:
– Knowing how to use a professional level circuit
simulator looks great on your resume!
Links
http://www.intusoft.com/models.htm#freemodels
http://www.penzar.com/links.htm
http://ee.cleversoul.com/simulation.html
http://www.cadence.com/orcad/index.html
http://cmosedu.com/videos/videos.htm
http://cmosedu.com/cmos1/book.htm
http://www.anasoft.co.uk/Spice3F5Manual.html
http://www.onsemi.com/site/support/models
http://www.coilcraft.com/modelsswcad.cfm
http://tech.groups.yahoo.com/group/LTspice/
http://ltspice.linear.com/software/scad3.pdf
I would like to acknowledge
• Helmut Sennewald for making many
helpful suggestions that have significantly
improved this presentation.

You might also like