Advanced Circuit Simulation Using Multisim 2012
Advanced Circuit Simulation Using Multisim 2012
SeriesISSN:
Series ISSN:1932-3166
ISSN: 1932-3166
1932-3166
CERVANTES-VILLAGÓMEZ
BÁEZ-LÓPEZ
CERVANTES-VILLAGÓMEZ
CERVANTES-VILLAGÓMEZ
BÁEZ-LÓPEZ ••• GUERRERO-CASTRO
BÁEZ-LÓPEZ
SSYNTHESIS
YNTHESISL LECTURES
& C
YNTHESIS ECTURESON
ECTURES ON
ON gan&
D IGITALC
DIGITAL
IGITAL CIRCUITS ANDSSYSTEMS
IRCUITSAND
IRCUITS AND YSTEMS
YSTEMS
Mor
Morgan
Mor gan &Cl
Claypool
Cl aypool Publishers
aypool Publishers
Publishers
GUERRERO-CASTRO
GUERRERO-CASTRO
Advanced Circuit
Series
SeriesEditor:
Series Editor:Mitchell
Editor: MitchellThornton,
Mitchell Thornton,Southern
Thornton, SouthernMethodist
Southern MethodistUniversity
Methodist University
University
Advanced
AdvancedCircuit
CircuitSimulation
SimulationUsing
UsingMultisim
Multisim
Simulation Using
Workbench
Workbench
David
DavidBáez-López,
David Báez-López,Félix
Báez-López, FélixE.
Félix E.Guerrero-Castro,
E. Guerrero-Castro,and
Guerrero-Castro, andOfelia
and OfeliaCervantes-Villagómez
Ofelia Cervantes-Villagómez
Cervantes-Villagómez
ADVANCED
ADVANCED CIRCUIT
Multisim Workbench
Universidad
Universidadde
Universidad delas
de lasAméricas-Puebla,
las Américas-Puebla,México
Américas-Puebla, México
México
Multisim
Multisimisisisnow
Multisim nowthe
now thede
the defacto
de factostandard
facto standardfor
standard forcircuit
for circuitsimulation.
circuit simulation.It
simulation. ItisisisaaaSPICE-based
It SPICE-basedcircuit
SPICE-based circuitsimulator
circuit simulator
simulator
which
which combines
which combines analog,
combines analog, discrete-time,
analog,discrete-time,
discrete-time,andand mixed-mode
and mixed-mode circuits.
mixed-mode circuits.
circuits.InIn addition,
In addition, it is the
addition,itit isis the only
the only simulator
only simulator
simulator
CIRCUIT SIMULATION
which
whichincorporates
which incorporatesmicrocontroller
incorporates microcontrollersimulation
microcontroller simulationin
simulation inthe
in thesame
the sameenvironment.
same environment.It
environment. Italso
It alsoincludes
also includesaaatool
includes toolfor
tool for
for
printed
printedcircuit
printed circuitboard
circuit boarddesign.
board design.
design.
Advanced
AdvancedCircuit
Advanced CircuitSimulation
Circuit SimulationUsing
Simulation UsingMultisim
Using MultisimWorkbench
Multisim Workbenchisisisaaacompanion
Workbench companionbook
companion bookto
book toCircuit
to Circuit
Circuit
SIMULATION USING
Analysis
Analysis Using
Analysis Using Multisim,
Using Multisim, published
Multisim,published by
published by Morgan
by Morgan
Morgan & & Claypool
& Claypool
Claypool inin 2011.
in 2011.
2011.This This new
This new book
new book covers
book covers advanced
covers advanced
advanced
analyses
analysesand
analyses andthe
and thecreation
the creationof
creation ofmodels
of modelsand
models andsubcircuits.
and subcircuits.It
subcircuits. Italso
It alsoincludes
also includescoverage
includes coverageof
coverage oftransmission
of transmissionlines,
transmission lines,
lines,
thethespecial
the specialelements
special elementswhich
elements whichare
which areused
are usedto
used toconnect
to connectcomponents
connect componentsin
components inPCBs
in PCBsand
PCBs andintegrated
and integratedcircuits.
integrated circuits.Finally,
circuits. Finally,
Finally,
itititincludes
includesaaadescription
includes descriptionof
description ofUltiboard,
of Ultiboard,the
Ultiboard, thetool
the toolfor
tool forPCB
for PCBcreation
PCB creationfrom
creation fromaaacircuit
from circuitdescription
circuit descriptionin
description inMultisim.
in Multisim.
Multisim.
David
DavidBáez-López
Báez-López
USING MULTISIM
Both
Both books
Both books completely
books completely cover
completely cover most
cover most of
most of the
of the important
the important features
important features available
features available
available for for a successful
for aa successful circuit
successful circuit simulation
circuit simulation
simulation
with
withMultisim..
with Multisim..
Multisim..
Félix
FélixE.
E.Guerrero-Castro
Guerrero-Castro
MULTISIM WORKBENCH
Ofelia
OfeliaCervantes-Villagómez
Cervantes-Villagómez
WORKBENCH
About
AboutSYNTHESIs
About SYNTHESIs
SYNTHESIs
This
Thisvolume
This volumeisisisaaaprinted
volume printedversion
printed versionof
version ofaaawork
of workthat
work thatappears
that appearsin
appears inthe
in theSynthesis
the Synthesis
Synthesis
Digital
DigitalLibrary
Digital Libraryof
Library ofEngineering
of Engineeringand
Engineering andComputer
and ComputerScience.
Computer Science.Synthesis
Science. SynthesisLectures
Synthesis Lectures
Lectures
MOR
MORGAN&CL
MOR
provide
provideconcise,
provide concise,original
concise, originalpresentations
original presentationsof
presentations ofimportant
of importantresearch
important researchand
research anddevelopment
and development
development
topics,
topics,published
topics, publishedquickly,
published quickly,in
quickly, indigital
in digitaland
digital andprint
and printformats.
print formats.For
formats. Formore
For moreinformation
more information
information
GAN&CLAYPOOL
GAN&CL
visit
visit www.morganclaypool.com
visit www.morganclaypool.com
www.morganclaypool.com
SSYNTHESIS
YNTHESIS L
YNTHESIS LECTURES
ECTURES ON
ECTURES ON
ON
& D IGITAL C
DIGITAL CIRCUITS ANDSSYSTEMS
ISBN:
ISBN: 978-1-60845-804-2
&
&Cl IRCUITSAND
ISBN: 978-1-60845-804-2
978-1-60845-804-2
Mor
Morgan
Mor gan
gan Claypool
Cl aypool Publishers
aypool Publishers
Publishers IGITAL IRCUITS AND YSTEMS
YSTEMS
AYPOOL
AYPOOL
90000
90000
90000
ww
www
www
w...m
mooorrrgggaaannnccclllaaayyypppoooooolll...cccooom
m m
m
Mitchell
MitchellThornton,
Thornton,Series
SeriesEditor
99978
78111608
608458042
Mitchell Thornton, Series Editor
Editor
78 608 458042
458042
Advanced Circuit Simulation
Using Multisim Workbench
Synthesis Lectures on Digital
Circuits and Systems
Editor
Mitchell A. Thornton, Southern Methodist University
The Synthesis Lectures on Digital Circuits and Systems series is comprised of 50- to 100-page
books targeted for audience members with a wide-ranging background. The Lectures include
topics that are of interest to students, professionals, and researchers in the area of design and
analysis of digital circuits and systems. Each Lecture is self-contained and focuses on the
background information required to understand the subject matter and practical case studies that
illustrate applications. The format of a Lecture is structured such that each will be devoted to a
specific topic in digital circuits and systems rather than a larger overview of several topics such as
that found in a comprehensive handbook. The Lectures cover both well-established areas as well as
newly developed or emerging material in digital circuits and systems design and analysis.
Advanced Circuit Simulation Using Multisim Workbench
David Báez-López, Félix E. Guerrero-Castro, and Ofelia Cervantes-Villagómez
2012
Circuit Analysis with Multisim
David Báez-López and Félix E. Guerrero-Castro
2011
Microcontroller Programming and Interfacing Texas Instruments MSP430, Part I
Steven F. Barrett and Daniel J. Pack
2011
Microcontroller Programming and Interfacing Texas Instruments MSP430, Part II
Steven F. Barrett and Daniel J. Pack
2011
Pragmatic Electrical Engineering: Systems and Instruments
William Eccles
2011
Pragmatic Power
William J. Eccles
2008
Pragmatic Logic
William J. Eccles
2007
All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in
any form or by any means—electronic, mechanical, photocopy, recording, or any other except for brief quotations in
printed reviews, without the prior permission of the publisher.
DOI 10.2200/S00399ED1V01Y201112DCS036
Lecture #36
Series Editor: Mitchell A. Thornton, Southern Methodist University
Series ISSN
Synthesis Lectures on Digital Circuits and Systems
Print 1932-3166 Electronic 1932-3174
M
&C Morgan & cLaypool publishers
ABSTRACT
Multisim is now the de facto standard for circuit simulation. It is a SPICE-based circuit simulator
which combines analog, discrete-time, and mixed-mode circuits. In addition, it is the only simulator
which incorporates microcontroller simulation in the same environment. It also includes a tool for
printed circuit board design.
Advanced Circuit Simulation Using Multisim Workbench is a companion book to Circuit
Analysis Using Multisim, published by Morgan & Claypool in 2011. This new book covers ad-
vanced analyses and the creation of models and subcircuits. It also includes coverage of transmission
lines, the special elements which are used to connect components in PCBs and integrated circuits.
Finally, it includes a description of Ultiboard, the tool for PCB creation from a circuit description
in Multisim. Both books completely cover most of the important features available for a successful
circuit simulation with Multisim.
KEYWORDS
circuit simulation, electrical circuits, electronic circuits, subcircuits, models, transmission
lines, temperature analysis, sensitivity analysis, noise, Monte Carlo analysis, worst-case
analysis, microcontroller simulations, printed- circuit board design
ix
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi
2 Transmission Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.2 Parameters of Lossless Transmission Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.3 Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
2.4 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
2.5 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Preface
This book is a companion for the Circuit Analysis and Simulation book published in 2011. That
book covers basic analyses with Multisim. This book is concerned with advanced analyses. That is,
those analyses that are more specialized and that can be done after a circuit has been tested with one
or more of the types of analyses covered in the companion book.
The book starts by presenting a way to modify models and offering two techniques to create
subcircuits. Thus, users can build their own libraries containing parts, models, and subcircuits. The
second chapter covers transmission lines. They are very important in the simulation of integrated
circuits, but they can be used to simulate other kind of circuits like, for example, digital filters.
The third chapter covers advanced topics such as sensitivity, noise, Monte Carlo and worst-case,
parametric, and temperature analyses. Each of these analyses is usually carried out after any one of
the basic analyses has been finished and the behavior of the circuit is satisfactory to the designer.
Thus, many of the characteristics of the circuit can be thoroughly evaluated. The fourth chapter
is devoted to the simulation of microcontrollers. This is a unique feature to Multisim, that is, the
incorporation of microcontrollers in a circuit simulation together with analog components in a
mixed-mode fashion. Two of the most popular microcontrollers are available in the microcontroller
libraries. The last chapter is devoted to printed circuit board (PCB) design using Ultiboard, which
is a tool especially designed for this purpose. Two examples illustrate the procedure for the PCB
design.
Two of the authors (DBL and OCV) acknowledge the help provided by our undergraduate
students Carmen María Saavedra, Gerardo de la Rosa, Miguel Angel Juárez Rivas, Ricardo Gómez
Crespo, and Daniel Treviño García for simulating each one of the circuits and providing valuable
feedback to improve the book.
The authors also thank their families for the continued support during the writing of both
books, for their patience and understanding.
CHAPTER 1
We show with three examples the procedures to accomplish these three tasks.
From the oscilloscope window in Figure 1.2 we can see that the amplifier gain is given by:
Vout −550.090mV
Av = = = −95.91
Vin 5.735mV
Now, we edit the model for the 2N3904 bipolar transistor.
To edit this component we double click on the bipolar transistor 2N3904 to open the window
of Figure 1.3. In this window we click on the Edit Model button to obtain the Edit Model window
of Figure 1.4. In this window we see that the Bf = 416.4. We change this value to 50.0 and press
enter. The new value is shown in Figure 1.5.
We now click on the Change Part Model to return to the window of Figure 1.3 and press the
OK button.The circuit now looks as shown in Figure 1.6. We note an asterisk following the transistor
number. This means that its model has been modified. We run the analysis again by pressing the
Run button and take a look at the output shown in the oscilloscope as shown in Figure 1.7. We
measure the voltage gain and it has changed to
206.878 mV
Av = = −29.13
−7.103 mV
1.1. EDITING A COMPONENT MODEL IN MULTISIM 3
Figure 1.2: Input and output waveforms for the common emitter amplifier.
which is less than the value obtained in the case of β = 416.4 where we used the original value for
β.
Example 1.2 Copying a component from the Master Database to either the Corporate or User
database.
In this example we want to copy a component from the Master database to the User database. We
use the transistor 2N3904 from Example 1.1. In this circuit, or in any circuit with the transistor,
we select it and then we select Tools →Database →Save Component to Database. This opens the
4 1. MODELS AND SUBCIRCUITS
dialog window shown in Figure 1.8. We select the User Database and the transistors family as shown
in Figure 1.9.
Then we click on the Add family button and the dialog window shown in Figure 1.10 opens.
There we change the default name Def to Bipolar, as is shown in the figure. We press the OK
button. This closes the window and it returns to the Select Destination Family window, and the new
family group is displayed, as shown in Figure 1.11. When we click on the OK button, a message
indicates the successful copying of the element to the target database and the window is closed,
and the Database Manager window shown in Figure 1.12 is open, showing the User Database with
1.1. EDITING A COMPONENT MODEL IN MULTISIM 5
the transistor 2N3904 as the only element available in the database. We are now ready to edit this
transistor and change its parameters.
Example 1.3 Editing the 2N3904 bipolar transistor model in the User database.
We continue with Example 1.2. Here we are going to modify the β of the transistor and then we
test the changes in the common emitter amplifier from Example 1.1. In order to do so we have to
modify the model of the bipolar transistor 2N3904. To achieve our goal we have to complete the
following steps.
1. To edit the model we select Tools →Database →Database Manager to obtain the window in
Figure 1.14. This figure is identical to Figure 1.12 because is the same component we have not
6 1. MODELS AND SUBCIRCUITS
added new components. If there are more components in the database, we look for the required
component. Once this is done we press the Edit button. This opens the Component Properties
window of Figure 1.15. There we see that the value for the parameter Bf is 416. To edit the
model we press on the Add/Edit button which opens the dialog window of Figure 1.16.
We proceed to make the desired changes. In this example we wish to change Bf from its
nominal value of 416.4 to the desired value of 85, as shown in Figure 1.17. We press the Select
button in the same window and Multisim warns us that the model has changed and if we wish to
proceed, as shown in Figure 1.18 and then, after clicking the OK, Multisim takes us to the window
of Figure 1.19 where we press the Overwrite button. This opens the Select a Model window of
Figure 1.20 which shows the model for our component.
1.1. EDITING A COMPONENT MODEL IN MULTISIM 7
Figure 1.7: Input and output waveforms for amplifier with BF=50. The gain has decreased because BF
has decreased.
8 1. MODELS AND SUBCIRCUITS
Figure 1.9: Expansion of the User database with the Transistors family selected.
1.1. EDITING A COMPONENT MODEL IN MULTISIM 9
Figure 1.11: Expansion of the User database with the new family displayed.
Figure 1.12: Elements in the User Database. Only the transistor 2N3904 is displayed.
Figure 1.13: Message indicating the successful copy to the User Database.
1.1. EDITING A COMPONENT MODEL IN MULTISIM 11
Figure 1.14: Database Manager with the Components tab for the User Database.
We could also have renamed the component if after changing the desired parameters, in
Figure 1.17 we press the Rename key and this takes us to the window shown in Figure 1.22 where
we enter the new name.
Figure 1.19: Dialog window to overwrite the model after the changes are made.
Figure 1.20: The parameter BF has been changed to 85 for the 2N3904.
1.1. EDITING A COMPONENT MODEL IN MULTISIM 15
Figure 1.23: Common emitter amplifier with new transistor from the User Database 2N3904_new
which has Bf = 54.
Figure 1.24: Input and output waveforms for the common emitter amplifier. The output voltage is much
less than in the Example 1.1.
1.2. CREATING SUBCIRCUITS IN MULTISIM 17
Example 1.6 Subcircuit for an operational amplifier macromodel available in the database.
In this example we create a subcircuit block for the operational amplifier macromodel of Figure 1.36.
The circuit description in terms of the connections at nodes 1, 2, 3, Vin+, Vin-, and Vout is:
Rin VIN+ VIN- 2MEG
Epole 1 0 VIN+ VIN- 200000
Rpole 1 2 1k
1.2. CREATING SUBCIRCUITS IN MULTISIM 21
SC1/IO2 IO2
IO3
C2
10nF
5 8 2 6 U2
+
4
SC1/IO1 IO6
0 7
IO1 R4 _
3
SC1/IO6 IO7
15.9kΩ
5 UA741MU
IO4
IO5
SC1/IO4
Figure 1.32: Schematic diagram for the subcircuit before deleting unneeded pins.
22 1. MODELS AND SUBCIRCUITS
SC1/IO3 IO3
C2
10nF
5 8 2 6 U2
+
4
SC1/IO1 IO6
0 7 SC1/IO6
IO1 R4 3 _
15.9kΩ
5 UA741MU
IO5
SC1/IO5
Figure 1.35: Frequency response for the filter using the subcircuit.
R1=1K 300
Vin+ 1 2 3
Vout
+ Rout
+ +
2MΩ Rin E1 C1 15.92µF Eout
_ _
_
Vin _
Cpole 2 0 15.92u
Eout 3 0 2 0 1
Rout 3 OUT 300
where the component name is given first, the nodes where the component is connected follow,
and finally the value. For the VCVS Epole, which describes the dominant pole, and Eout, which
gives the low output impedance, we need, after the first two node names, the nodes where the VCVS
takes is value, and finally the gain.
The procedure starts by selecting from the main menu Tools →Component Wizard which
opens the dialog window of Figure 1.37. In this window we provide subcircuit information such as
the component name, author’s name, component type from among Analog, Digital, Verilog_HDL,
or VHDL. Finally, we briefly describe the function realized by the subcircuit. We can see that this
is the first window out of either 8, 7 or 6. The number of steps required in the subcircuit creation
24 1. MODELS AND SUBCIRCUITS
process depends upon the option we select in the radius buttons in this dialog window. For our
example we select Simulation only (model) which needs 7 steps.
We provide then the following information:
Component type name: UDLAP_741
Author Name: Baez_Guerrero_Cervantes
Component Type: Analog
Function: Op-amp single pole macromodel.
We select the radius button for: Simulation only (model). The window with the data is shown
in Figure 1.38. We then press Next and obtain the second window for the Component Wizard,
shown in Figure 1.39.
In this second window we select the radius button for: Single Section Component. This
indicates that the part only has a macromodel. If the part has two or more macromodels, we select
the button: Multi-Section Component.This is the case of TTL digital circuits where there are usually
more than one circuit in the package. We also select 3 as the number of pins since we have two inputs
and one output. Then, we click on the Next button. The window of Figure 1.40 is displayed now.
In this step we edit the subcircuit symbol. Although we can edit the symbol with the Symbol
editor, it is better if we start from a known circuit symbol from the Database. Since we are creating an
op amp subcircuit, we can use one from the Multisim Master Database. Thus, we click on the Copy
from DB button to arrive at Figure 1.41. Here we can select a symbol by going to the appropriate
library and we select either a component with the required symbol or a symbol looking closer to what
1.2. CREATING SUBCIRCUITS IN MULTISIM 25
Figure 1.38: First dialog window for Component Wizard with data for the macromodel.
Figure 1.40: Component Wizard window No. 3 to edit the subcircuit symbol.
We are now ready to edit the symbol to fit our requirements. We now press the Edit button.
This takes us to the Symbol Editor shown in Figure 1.43.
The Symbol editor has toolbars which allows adding or deleting components in the circuit
symbol. We can also delete rows from the spreadsheet at the bottom of the Symbol editor. After
deleting the lines and pins that we do not need we get to the circuit symbol of Figure 1.44. We save
the changes and close the Symbol Editor window to get to the window of Figure 1.45. If we are
satisfied with the symbol, we press the Next button to arrive at Figure 1.46a where we select the pin
function from the several options available for each pin, namely, bidirectional, unidirectional, input,
output, and power. For the input pins we select INPUT and for the output pin we select OUTPUT
as shown in Figure 1.46b.
28 1. MODELS AND SUBCIRCUITS
Pressing the Next button we get to step 5 of the Component Wizard shown in Figure 1.47.
In this window we write the model name and the circuit description, as shown in Figure 1.48. We
use the netlist that describes the macromodel and we have added the row:
.SUBCKT UDLAP_741 vin+ vin- out
This row indicates that the circuit description is a subcircuit with the name UDLAP_741.
The three variables vin+, vin-, and out are the three pins to the subcircuit and they must always
be given in this order. There are three rows that start with an asterisk. These are comment rows
and do not affect the macromodel. There is also a row with .ENDS which indicates the end of the
subcircuit description. When we are finished, we press the Next button to get to Figure 1.49 that
describes the mapping information between the symbol pins and the model nodes. If we agree with
that description, we click on the Next button.
Finally, we get to the Component Wizard window shown in Figure 1.50. In this window we
select the Database; in our example we select the User Database. We also select the family; in this
example we choose the Analog group and add the family AO. This part of the process is similar to
the one shown in Example 1.5. We click on the finish button and this ends the subcircuit creation
procedure.
We can check the existence of the new part if we select the components in the User Database
in the Analog group and the family AO, as shown in Figure 1.51.
1.2. CREATING SUBCIRCUITS IN MULTISIM 31
1.3 CONCLUSIONS
An important part of the simulation is the modelling of each of the circuit components. In this chapter
we have learned how to modify existing models, so they are suitable with a designer particular needs.
We have also covered the way a subcircuit is created. Subcircuits are useful whenever either a circuit
is repeated or it is going to be used as a module. We have also covered the way schematic symbols.
1.4 PROBLEMS
1.1. The inverter circuit in Figure 1.55 uses NMOS transistors. Use the model shown below for
them. Test the circuit with a square signal. (The + sign at the beginning of a row a indicates
continuation row.)
.MODEL CMOSN NMOS LEVEL = 2 PHI = 0.600000 TOX = 4.3500E-08
+ XJ = 0.2U TPG = 1 VTO = 0.8756 DELTA = 8.5650E+00 LD = 2.395E-07
+ KP = 4.5494E-05 UO = 573.1 UEXP = 1.5920E-01 UCRIT = 5.9160E+04
+ RSH = 1.0310E+01 GAMMA = 0.4179 NSUB = 3.3160E+15 NFS = 8.1800E+12
+ VMAX = 6.0280E+04 LAMBDA = 2.9330E-02 CGDO = 2.8518E-10
+ CGSO = 2.8518E-10 CGBO = 4.0921E-10 CJ = 1.0375E-04 MJ = 0.6604
+ CJSW = 2.1694E-10 MJSW = 0.178543 PB = 0.800000
* Weff = Wdrawn - Delta_W
* The suggested Delta_W is -4.0460E-07
1.4. PROBLEMS 35
2
VDD
12 V
0
Q1
2N6659
Vout
Q2
1
2N6659
Vin
12 V
0 0
1.2. MOSIS provides models for diodes and transistors in different processes. The page is
www.mosis.com. Test the inverter circuit in Example 1.1 with transistors with 0.5 microns
process.
1.3. Test an inverter 7404 TTL by changing the rise and fall time to 10 msec.
1.4. The netlist below belongs to the TLC2201 op amp macromodel. Create a part for this
circuit and store in a family group in the MISC group. Build a non-inverting amplifier with
a gain of +10. Use 9K and 1 K resistors.
* TLC2201 OPERATIONAL AMPLIFIER “MACROMODEL” SUBCIRCUIT
* CREATED USING PARTS RELEASE 4.03 ON 08/06/90 AT 15:18
* REV (N/A) SUPPLY VOLTAGE: 5V
* CONNECTIONS: NON-INVERTING INPUT
* | INVERTING INPUT
*| | POSITIVE POWER
*| | | NEGATIVE POWER SUPPLY
*| | | | OUTPUT
36 1. MODELS AND SUBCIRCUITS
*| | | | |
.SUBCKT TLC2201 1 2 3 4 5
*
C1 11 12 11.00E-12
C2 6 7 50.00E-12
DC 5 53 DX
DE 54 5 DX
DLP 90 91 DX
DLN 92 90 DX
DP 4 3 DX
EGND 99 0 POLY(2) (3,0) (4,0) 0 .5 .5
FB 7 99 POLY(5) VB VC VE VLP VLN 0 537.9E3 -50E3 50E3 50E3 -50E3
GA 6 0 11 12 282.7E-6
GCM 0 6 10 99 2.303E-9
HLIM 90 0 VLIM 1K
ISS 3 10 DC 125.0E-6
J1 11 2 10 JX
J2 12 1 10 JX
R2 6 9 100.0E3
RD1 60 11 3.537E3
RD2 60 12 3.537E3
RO1 8 5 188
RO2 7 99 187
RP 3 4 5.71E3
RSS 10 99 1.600E6
VAD 60 4 -.5
VB 9 0 DC 0
VC 3 53 DC .928
VE 54 4 DC .728
VLIM 7 8 DC 0
VLP 91 0 DC 2.800
REFERENCES 37
VLN 0 92 DC 2.800
.MODEL DX D(IS=800.0E-18)
.MODEL JX PJF(IS=500.0E-15 BETA=1.279E-3 VTO=-.177)
.ENDS
REFERENCES
[1] A.S. Sedra and K.C. Smith, Microelectronic Circuits, Holt, Rinehart, and Winston, New York,
2005. Cited on page(s) 12
[2] L.P. Huelsman, Introduction to the Theory and Design of Active and Passive Filters, McGraw-
Hill Co., New York, 1991. Cited on page(s) 17
39
CHAPTER 2
Transmission Lines
2.1 INTRODUCTION
Transmission lines are parts of a circuit that interconnect the different components of a circuit. They
are also used to model transmission lines in communication systems. In many integrated circuits
there are losses due to the interconnections between the different components. These losses are due
to limitations such as the bandwidth, attenuation, and distortion, among many other factors, which
in many cases are negligible because the circuits operate at low frequencies. An interconnection
consisting of two conductors and a dielectric can be considered as a transmission line. Transmission
lines have distributed parameters and have a characteristic impedance which is a dynamic parameter
defined by the ratio of voltage and current in any given point along the transmission line. It is
denoted by Z0 and can be expressed in terms of the distributed inductance and the capacitance
of the transmission line. The propagation delay is also a characteristic of the transmission line and
depends upon the same parameters. Transmission lines can be used to study impedance coupling
effects. An interesting application of transmission lines occurs when the delay is used in the simulation
of the delay of digital filters. An example shows this application of transmission lines. Multisim has
available lossless transmission lines as well as lossy ones.
2.3 EXAMPLES
In this section we present four examples using lossless transmission lines in Multisim. The last
example shows the use of transmission lines in the simulation of digital filters.
(a) (b)
(a) (b)
Figure 2.2: Dialog windows to specify the parameters of transmission lines. a) Type 1, b) Type 2.
a circuit with a 50 ohms Type 1 transmission line with an input voltage V1= 10 v, a period of 4
nsec, and a duty cycle of 25%; that is, the pulse width is 1 nsec. The parameters for W1 are given in
Figure 2.4 which is opened by double clicking on the transmission line W1.
In this example, the transmission line has a delay of 2 nsec, so we expect the signal to arrive
at the output 2 nsec later of the input. We run a transient analysis with a TSTOP of 4 nsec. Plots of
input and output signals are shown in Figure 2.5. We can see there that the output signal is delayed
2.3. EXAMPLES 41
by 2 nsec when it traveled through the transmission line. Furthermore, the transmission line W1 is
perfectly balanced because the terminating resistances have the same values as the impedance Z0 of
the line. This makes that the amplitude of the output voltage be half of the amplitude of the voltage
of the input signal.
Let us consider the case when resistors R1 and R2 are not equal valued. If R1 = 10 and R2
= 100 , for the same transient analysis we obtain he plots of Figure 2.6. In this case, we see that
the output voltage is larger now than in the case of a balanced transmission line.
Figure 2.7: Pulse with small duty cycle shorter than the transmission line delay and R1 = R2 = Z0 =
50 .
44 2. TRANSMISSION LINES
Figure 2.8: Input and output signals when the duty cycle is very small.
Figure 2.9: Circuit with impedances decoupled and very small duty cycle.
Figure 2.10 shows a series of reflections that occur inside the transmission line and they are due
to the mismatch that exists among the impedance of the transmission line W1 and the terminating
resistors R1and R2. The first output pulse occurs 2 nsec after the input is applied to the line whereas
the second output pulse occurs 4 nsec after the first output pulse because part of the output signal is
reflected back to the input where it is again reflected to the output. Part of this pulse appears at the
2.3. EXAMPLES 45
Figure 2.10: Input and output signals when the impedances are not coupled. Note the reflections in the
output signal due to the decoupling and the very small duty cycle.
output and part is reflected back to the input where the process is repeated again, each time with less
amplitude as we can see in Figure 2.10. There we can still appreciate a very small pulse at 14 nsec.
(a)
(b)
B0 z2 + B1 z + B2
H (z) =
z 2 + A1 z + A 2
The digital filter can be realized in Multisim with the circuit of Figure 2.15. In this circuit
W1 and W2 emulate the delays; VCVS V2 and V3 simulate ideal operational amplifiers to realize
the adders and the multipliers. V2 together with resistors R1, R6, R4, and R2a form a summing
amplifier. V3 together with R10, R11a, R6, and R8 form a second inverting summing amplifier.
VCVS V1 and V4 are unity gain buffers to feed the signal to the other stages. VCVS V7 together
with R5 realize the negative coefficient B1, while V6 together with R8 realize the B0 coefficient.
Coefficients B0 , B1 , B2 , A1 and A2 , determine what type of filter is realized. These coefficients can
be obtained using software for digital filter design such as Winfilters [2]. The circuit we wish to
realize is a second order passband Butterworth filter with a 3 dB passband from 900 Hz to 1100 Hz.
The sampling frequency is 6 KHz which is equivalent to a sampling period of T = 1/6000 = 166.67
μ sec. Using Winfiltros we obtain the transfer function
z2 − 1
H (z) =
z2 − 0.9096707z + 0.809374
Then the parameters of the transmission lines are
Z0= 1 y TD = 166.67 μS
Where TD is the sampling period of the digital filter. We do an AC analysis form 10 Hz to
2 KHz to obtain the frequency response shown in Figure 2.16. It is known that digital filters must
obey Nyquist theorem; that is, they can only process frequencies up to half the sampling frequency.
If we make an AC analysis beyond 3 KHz, which is half the sampling frequency we obtain the
response of Figure 2.17.
Figure 2.17: Frequency response of the digital filter after an AC analysis up to 6 KHz.
2.3. EXAMPLES 51
km, R = 15, C= 70nF, L = 175 μH, G = 9μS, at a frequency f = 2 MHz, we have ω = 2πf =
2×π×2×106 = 12.6 Mrad/sec.
R + j ωL 15 + j (12.6 × 106 )(175 × 10−6 )
Z0 = = = 35.4756 + 35.2351i
G + j ωC 9 × 10−6 + j (12.6 × 106 )(70 × 10−9 )
parameters are shown in Figure 2.19. The length is normalized to unity. We note that from the pre-
vious example there is an impedance mismatch between the real part of the characteristic impedance
and resistor R1. We perform an AC analysis and measure the input impedance given by the voltage
at node 3 divided by the current passing through resistance R1, that is, we wish to plot V(3)/I/R1).
The analysis setup is shown in Figures 2.20 a and b. The resulting plot is shown in Figure 2.21.
With the cursor we see that at almost 2 MHz the input impedance is 50.1 .
52 2. TRANSMISSION LINES
(a) (b)
2.4 CONCLUSIONS
In this chapter we have introduced transmission lines.Transmission lines appear in integrated circuit,
printed circuit boards, and communication systems. The examples presented here show the use of
transmission lines. Multisim has two types of transmission lines denoted by Types 1 and 2. They
are equivalent and the only difference is the set of parameters that define them. The use of the
transmission delay is used to simulate digital filters.
2.5 PROBLEMS
2.1. In the circuit of Figure 2.3 a lossless transmission line with TD = 2μs, and Z0 = 50 , apply
a signal Piecewise linear with the following parameters:
time voltage
0 0
1n 100
6u 100
6.001u 0
50u 0
Use R1 = 150 and R2 = 1u. Plot the voltage measured at the input of the transmission line.
54 BIBLIOGRAPHY
2.2. Repeat Exercise 2.1 but with R1 = 1μ and R2 = 150 . Repeat with an input signal
defined by
time voltage
0 0
0.001u 30
and plot the voltage at the output of the transmission line.
2.3. Obtain the characteristic impedance for a lossy transmission line with R = 2.25 /m, L =
1μH/m, C = 100 pF/m, and G = 0 at 500 MHz. Using Multisim plot the input impedance
if the load is R = infinite and if R = 10.
2.4. In the circuit of Figure 2.18 use LEN = 20, R = 10, L = 100u, G = 10u, and C = 70n. Apply
a square signal with a period of 0.8ms and a 50% duty-cycle with voltage levels 0 and 1 V.
Observe and explain the low-pass behavior.
2.5. In the circuit in Example 2.1 change R2 to a) Infinity, b) 0, c) 200, and d) 25.
2.6. Repeat Exercise 2.5 for Example 2.6.
REFERENCES
[1] H. Nielinger, Digital (IIR) Filter Biquad Section Simulated with PSpice, IEEE Trans. on
Education, Nov. 1993, Vol. 36, No. 4, pp 383-385. Cited on page(s) 45, 69
[2] D. Báez-López et al, Multimedia Based Analog and Digital Filter Design, Computer Applica-
tions in Engineering Education, pp.1-8, No.1, vol. 6, 1998. Cited on page(s) 48
[3] P. R. Clayton, Analysis of Multiconductor Transmission Lines, 2nd Edition, J. Wiley, NY, 2007.
Cited on page(s) 45
55
CHAPTER 3
∂F (x)
SxF (x) =
∂x
and it has units of volts (amperes) per unit value. Sensitivities are only evaluated for DC and AC
analyses. Sensitivity analysis is performed with respect to all elements of the circuit, whether active
or passive. The steps carried out for a sensitivity analysis are as follows:
2. Then the circuit is linearized around the bias point and all the derivatives of the selected node
voltages and branch currents are calculated with respect to each and every one of the elements
in the circuit.
The output includes the names of the elements, their values, the sensitivity in volts/unit or
amps/unity. We show the procedure by means of an example.
Figure 3.2: Dialog window to specify the output voltage variable for sensitivity analysis.
3.1. SENSITIVITY ANALYSIS 57
∂V (2)
= −500 × 10−3 volts/volt = −0.5 volts/volt
V (2)
SV 1 =
∂V 1
∂V (2)
= −250 × 10−6 volts/ohm = −0.25 mV /ohm
V (2)
SR1 =
∂R1
∂V (2)
= +250 × 10−6 volts/ohm = +0.25 mV /ohm
V (2)
SR2 =
∂R2
This information tells us that when R1 increases by 1 ohm, the voltage V(2) changes decreases 0.25
mV (it decreases because of the minus sign). Also that when R2 changes by 1 ohm, V(2) changes
+0.25 mV, and that when V1 changes 1 volt, then V(2) changes -0.5 volts.
Figure 3.6: Dialog window to specify output node voltage for AC sensitivity analysis.
Figure 3.7: Selection of the element with respect to which sensitivity is taken.
60 3. OTHER TYPES OF ANALYSES
where SNRin and SNRout are the signal-to-noise ratios measured at the input and at the output,
respectively. The Noise figure analysis can be done by selecting from the main menu Simulate →
Analyses → Noise Figure Analysis. This opens the dialog window shown in Figure 3.14. There we
select the input voltage source, which in this example is V3 and then we click on the Simulate button
to obtain Figure 3.15 showing the value for the noise figure in dB with a value for the common
emitter amplifier of NF = 34.5129 dB.
Figure 3.14: Dialog window to select the input voltage source for the Noise figure analysis.
3.3. MONTE CARLO AND WORST CASE ANALYSES 65
We have assigned a 10% tolerance to each passive component. From the main menu select Simu-
late →Analyses →Monte Carlo which opens the dialog window of Figure 3.17 where we assign
tolerances to the components we are interested in having their values varied in the Monte Carlo
analysis. We assign tolerance to each component by clicking on the Edit selected tolerance button
which in turn opens the dialog window of Figure 3.18 where we assign tolerance to the component
and we also choose which type of distribution it has from the two available choices either Gaussian
or uniform distribution.
For the capacitor we assign 20% tolerance with a Gaussian distribution and then press Accept.
We repeat the procedure for the resistor but apply a uniform distribution. After doing this we obtain
the window of Figure 3.19 which shows the tolerance and distribution for each and every component
with a tolerance assigned. To end the tolerance assignment we click on the OK button.
Now we select the Analysis Parameters tab as in Figure 3.20. Here we specify the analysis
type from among DC Operating Point, AC Analysis, and Transient Analysis. For this example we
choose a transient analysis. First we edit the transient analysis. With a click on the Edit Analysis
button we open the window of Figure 3.21 where we give the data for the analysis. Since the voltage
source has a 100 Hz frequency, we choose 0.012 sec as the stop time in the transient analysis and
give a maximum step size of 1E-5 sec. After finishing entering the data for the analysis we press the
OK button and return to the window of Figure 3.20. There we enter the data for the Monte Carlo
3.3. MONTE CARLO AND WORST CASE ANALYSES 67
Feature Description
MAX Find the maximum value for each run.
MIN Find the minimum value for each run.
RISE_EDGE Find the first occurrence in that the response is greater than a specified
threshold value in the rising edge of the waveform.
FALL_EDGE Find the first occurrence when the answer is less than a specified threshold
value in the falling edge of the waveform.
From the spreadsheet data we can readily see that the Maximum Value deviation is given by
This result agrees with the one given by Multisim in the last row of the spreadsheet in Figure 3.23.
In another run with the same data, the statistics would be different due to the random nature of the
Monte Carlo analysis.
We now perform a Monte Carlo analysis with all the passive components having a 20%
tolerance with a Gaussian distribution (see Figure 3.26). We only look at the passband responses.
The output voltage is V(Output) and the number of runs is 5. This data is shown in the Analysis
Parameters tab of Figure 3.27. After entering these parameters we click on the Simulate button to
obtain the plots of Figure 3.28. The run at nominal values is thicker than the other runs. We see a
deviation from the 1 dB ripple than in some runs is less than 1 dB and in other cases is almost 2 dB
and in a case is even larger.
(a)
(b)
Figure 3.25: Frequency response for the active RC filter. a) Passband and stopband, b) Passband ripple.
3.3. MONTE CARLO AND WORST CASE ANALYSES 73
Figure 3.28: Passband ripple after the Monte Carlo analysis. Note that one of the runs produces almost
a 6 dB variation in the passband ripple, originally set at 1 dB.
Simulate →Analyses →Worst Case which opens the dialog window in Figure 3.30. There we assign
the tolerances.
After giving this data we pressed OK and we run Multisim. The output data Multisim gives
us are the nominal value and the value of maximum variation from the nominal value. The results
are shown in Figure 3.33. In Figure 3.34 we show the spreadsheet with the numerical results.
From the spreadsheet data we see that for the frequency response evaluated at 10 KHz, the
magnitude has changed by 23.4486 % of the nominal value !!
3.3. MONTE CARLO AND WORST CASE ANALYSES 75
Figure 3.30: Tolerance and distribution for the two components in the circuit.
Figure 3.34: Spreadsheet with data from the worst case analysis.
Figure 3.44 shows the ripple of the rectifier output. Here we see how the output ripple changes
with temperature.
Figure 3.37: Dialog window with the values for the parametric analysis.
80 3. OTHER TYPES OF ANALYSES
Figure 3.40: Step response of the RLC circuit with different resistor values.
Resistor Value= R [1+Resistor Value= R [1+ TC1 (T- Tnom) + TC2 (T-Tnom)2 ]
Figure 3.44: Temperature variation of the ripple in the full wave rectifier. Full wave rectifier circuit.
coefficient is 1000 ppm then for each degree change the resistor value changes by
For TC1 = 100 ppm/o C, the change in resistor value for each degree change in temperature is
0.1 /o C. Thus, the values of TC1 are usually very small. Similarly, the values for the quadratic
temperature coefficient are very small. For Multisim, the value of TC1 is calculated as
where coef is the manufacturer specification for the temperature coefficient.Thus, if the manufacturer
specifies a temperature coefficient of 200ppm/ o C, the value of TC1 is 0.0002R /o C, where R is
the resistor value. Usually manufacturers only specify the linear temperature coefficient, but some
carbon resistors present very small quadratic temperature dependence. Now let us consider the
resistive voltage divider of Figure 3.45.
If we run a DC Operating Point Analysis, we obtain that V(2) = 6 volts. By clicking on resistor
R1 we obtain the dialog window of Figure 3.46. In this window we see, besides the spaces for the
resistor value and tolerance, the spaces for the the analysis temperature TEMP, the temperature
coefficients TC1 and TC2, and the nominal temperature TNOM. For this example we specify the
following values: TEMP = 50 o C, TC1 = 0.001, TC2 = 0.001, and TNOM = 27o C. After entering
these values for R1 only we run again a DC Operating Point Analysis to obtain the value of voltage
84 3. OTHER TYPES OF ANALYSES
V(2) = 5.83885 as seen on Figure 3.47.This value is the result of the change in resistor value operating
at a temperature of 50 o C. We can check the new value for R1 with the following:
Resistor value = 1000 [1+Resistor value = 1000 [1+ 0.001 (50 - 27) + 0.001 (50 - 27)2 ] = 1552
1000
V (2) = 12 = 4.702194
1000 + 1552
which is the same value as that obtained in the Multisim simulation.
3.6 CONCLUSIONS
In this chapter we covered three types of advanced analyses that complement the basic types of
analyses. The analyses covered are the sensitivity analysis which is carried out jointly with the
calculation operation point analysis (Bias Point), while the noise analysis is performed in conjunction
with an AC analysis. The Monte Carlo analysis, worst case analysis, parametric and temperature
analyses can be performed in conjunction with any analysis (AC, DC, transient).
3.7 PROBLEMS
3.1. For the circuit in Figure 3.48 perform a sensitivity analysis. The output voltage is the voltage
across RL.
86 3. OTHER TYPES OF ANALYSES
3.2. In the circuit of Figure 3.49 make a Monte Carlo analysis after an AC analysis. Use 10%
tolerances.
3.3. Repeat Exercise 3.2 but now make a Worst case analysis. Use 5% tolerance for the resistors
and 10% for the capacitors.
3.4. The circuit of Figure 3.50 is an IF filter. Make a noise analysis and obtain the noise figure.
3.5. Make a temperature analysis for the circuit in Figure 3.51. Use : a) TC1 = TC2 = 0.001,
b) TC1 = TC2 = 0.002.
3.7. PROBLEMS 87
CHAPTER 4
Simulating Microcontrollers
4.1 INTRODUCTION TO MULTISIM MCU
Multisim MCU is an add-on to Multisim that enables the user to build and simulate circuits
based on microcontroller units. The letters MCU stand for Microcontroller Unit Co-Simulation for
SPICE-Based Circuits
Microcontroller circuits are capable of handling several tasks (reading/writing data to a mem-
ory, interfacing sensors, acquiring real world signals, etc.) based on a program written by the user.
Multisim MCU can simulate the behavior of a microcontroller running custom code.
The advantages of programming and testing in a simulated environment are numerous. One of
the main benefits of this approach is the ability to run and debug microcontroller circuits interacting
with electronic components. This is something that most debuggers fail to deliver.
4. The workspace name for our first example is named accordingly, example01 (Figure 4.1).
5. The next step (2 of 3) defines the project settings. This time we will use a standard project
type. The programming language should be adequate for the language we plan to use, and
so it should be the compiler and the project name can be anything meaningful, for example
Blinking LED (Figure 4.2).
6. The last step (3 of 3) allows you to start with an empty source file or with a predefined source
file. We will use main.asm (or main.c) as our source file (Figure 4.3).
The suggested values for our first project can be seen in Figures 4.1 to 4.3. This is the complete
procedure for configuring a microcontroller using the MCU Wizard.
Now we select the type of project. This is a standard project. The other option allows us to use
a pre-compiled hex file that Multisim do not need to recompile again. We do not use this feature
4.2. MULTISIM MCU BASICS 93
Figure 4.4: Design Toolbox showing the tree view of a MCU project.
here. We select assembly language as our programming language and the compiler automatically
shows Microchip MPASM for PIC 16. An appropriate name for the project is Blinking LED.
In the next window we are asked if we want to create a blank project or add a source code file
(Figure 4.3). For our needs, starting with a source code file named main.asm is perfectly acceptable.
Up to this point we can see the tree view for the project in the Design Toolbox window. You
can access it via View → Design Toolbox (Figure 4.4). Inside this window we can see the structure
of our project and add or delete additional files.
If we double click on each branch of the tree view we can display the content of the file
main.asm and start to edit the code.The code is exactly the same as if we were programming a physical
microcontroller. In this particular case, a table of commands can be found on the manufacturer’s site:
http://ww1.microchip.com/downloads/en/DeviceDoc/33023A.pdf
and in the microcontroller’s datasheet
http://ww1.microchip.com/downloads/en/DeviceDoc/35007b.pdf
We use the following code:
#include ‘‘p16f84.inc’’ ; This includes PIC16F84 definitions for the
; MPASM assembler
;main routine
main
MOVLW 0x01
MOVWF PORTB
nop
nop
nop
nop
CLRF PORTB
nop
nop
nop
noP
GOTO main
END
Once we have typed or copied the code to the main.asm file we can build it (in the menu →
MCU → MCU PIC16F84 U1 → Build. In the spreadsheet window we can see the error log and
warnings, if any. In Figure 4.5 we can see the tab for Results.
Now that our microcontroller has been programmed we can make the electrical connections.
This time we will use a VDD power source and a VSS ground reference. We will also use a digital
indicator connected to pin RB0. Note that the Master Clear pin is inverted so it must be tied to
VDD for our circuit to operate properly (Figure 4.6). Now we run the circuit by clicking on the run
icon (or pressing F5).
4.2. MULTISIM MCU BASICS 95
Notice how the circuit does not have an oscillator connected to its respective pins. The in-
evitable question is how can we verify/modify the frequency of oscillation for this circuit? The answer
can be found right clicking on the microcontroller. In the Value tab we can see that the clock speed
is set to 12 MHz. We can make adjustments if necessary but we will leave it as it is for the moment
(Figure 4.8).
96 4. SIMULATING MICROCONTROLLERS
If we have correctly programmed the microcontroller and made the right electrical connections
now it is time to run our simulation and see if the LED blinks (Figure 4.7).
As you should have noticed we added an oscilloscope to the circuit. Probably you are seeing the
LED flashing very quickly and we would like to measure the flickering frequency. Using cursors on
the scope’s window we can see that the signal’s period is 4.32 us thus the frequency is approximately
231 KHz. We can slow it down modifying the code. Try including more nop commands. They are
used when you want to waste time. Basically, a nop command tells the microprocessor to execute
no operation. The same measurement can be done using the frequency meter from the instruments
toolbar.
and follow up when reading the code. The disadvantage is that C needs to be translated to assembly
by the compiler and this translation sometimes may not be the most efficient way of doing it. In the
next section we will see how we can use the debugging tools for optimizing the generated code.
This time we will use the following code:
#include "pic.h"
void main()
{
bitclr(STATUS, RP0); // Select Bank 0
bitset(STATUS, RP0); // Select Bank 1
TRISB = 0x00; // Set Port B pins to output mode
98 4. SIMULATING MICROCONTROLLERS
while(1)
{
PORTB=0x01; // Turn on RB0
delay(); // Wait
PORTB=0x00; // Turn off RB0
delay(); // Wait again
}
}
We can see that the code is much more compact this time. We now should build the code
and run it. Whenever the user wants to run an out-of-date program, Multisim will prompt the user
to re-build it. When executed we can see that the LED flashes more slowly this time. In this case,
the oscillation frequency can be adjusted by modifying the value of the counter in the delay()
function. With different values we can make the LED flash at different speeds. The variable count is
an integer and thus it can contain values from -32767 to 32766. If we try to count beyond its limits
we will see that it rolls up. This is something that programmers need to be careful.
Going into further details of assembly/C programming is out of the scope of this book. An
excellent reference for going deeper into C is found on the book Practical C Programming, by Steve
Oualline, O’Reilly 1991 [1].
4.3. DEBUGGING TOOLS 99
4.3 DEBUGGING TOOLS
Multisim has several useful debugging tools when using the MCU module. These tools help the
developer to test his/her program and find errors that frequently are hard to detect and fix when the
microcontroller is freely running.
In the menu MCU → MCU Windows we can activate the Memory View window. In this
window we can see the memory content of the microcontroller. For Example 4.2 it is shown in
Figure 4.11. We see the value of each one of its registers and the configuration data. This memory
view allows the programmer to inspect the contents of the memory when verifying the behavior of
a particular program.
Another frequently used task when debugging programs is stopping it from continuous ex-
ecution. Being able to stop the program in an arbitrary step of the code allows the programmer to
inspect the state of the memory and the related variables. This way a particular condition can be
verified and errors can be corrected.
The MCU module has several variants of this function included in the Debug View menu.
This function can be activated going to MCU → name of the microcontroller (PIC16F84 U1 in
these examples) → Debug View (Figure 4.12).
100 4. SIMULATING MICROCONTROLLERS
In the Debug View mode we can observe the disassembled code (Figure 4.12). If we are using
assembly language for programming this view is very similar, the main difference is that each variable
is substituted by its real value. Goto and Jump instructions keep their labels.
When programming using C the disassembled code will show us how the compiler is inter-
preting the C code and how it is translated to assembly code. This is a great way to learn about going
from a higher level language to a low level language like assembly.
In the top part of the Debug View window we can select the option if we want to debug using
disassembled code or the source code. The main difference is that the source code contains labels
and comments. Sometimes is more useful to work with fully-documented code.
When the debug mode is active we can stop the program when it executes each instruction.
This is accomplished using the Step Into function; this function is conveniently mapped to the F11
key. F10 key is mapped to the Step Over function. When we use these two functions we can execute
the program one step at a time and use Memory View to observe what is happening with the values
of different registers and memory locations.
Similarly, when in debug mode, if we have activated the MCU toolbar (View → Toolbars
→ MCU, and shown in Figure 4.13) we can select some relevant options that display the code in
specific ways. A listing of the tasks that can be done is given in Table 4.1 C code when disassembling
4.4. PERIPHERAL DEVICES 101
so we can verify the correspondence. We can enable/disable the memory addresses. We can see
the hexadecimal values for each opcode – opcodes are the numeric equivalent of each one of the
commands of the instruction set of the microcontroller. We can show labels and headings as well.
Button Description
Disassembly button. Determines whether we see the listing assembly text or the version
from the disassembler.
Show Line Numbers button. Displays the line numbers in the Debug View.
Show Hex Opcodes in Assembly Code button. Enables/disables the showing of the
hex values of opcodes for any text that shows listing assembly or disassembly in any of
the debug listing views.
Show Jump/Goto Labels button. Enables/disables the showing of the jump/goto labels
for any text that shows listing assembly or disassembly in any of the debug listing views.
Show Headings Above Code button. Enables/disables the showing of the heading
comments above each block of source or assembly code which labels the different fields
being shown in the text.
numeric keypads, a virtual serial terminal, a conveyor belt, a holding tank and two different traffic
lights (Figure 4.14).
4.5 EXAMPLES
In this section we will show three examples using the elements we have discussed so far. We will be
using C for these examples but the reader should feel free to adapt them to use assembly language
if desired.
The set of experiments will include this:
• Even/Odd counter
• LCD Display
• Traffic Light
4.5. EXAMPLES 103
Example 4.3 Even/Odd counter.
In this example, a microcontroller will receive user input on a pin by the way of an electromechanical
switch and the result will affect a count shown on a HEX display.
The circuit is shown on Figure 4.15.
As you can see from the previous figure we have included two elements in this circuit –the
switch and the display. The switch can be found in the Basic Components → Switches bin. This
switch in particular is a SPDT switch – single pole, double throw. Similarly, the display can be found in
the Indicators → Hex Display bin.The type, as is shown on Figure 4.15 , is DCD_HEX_DIG_RED.
The switch, as the label shows, is controlled by the space key, this basically means that whenever
we press the space key the switch will change from closed to open back and forth.The display receives
4 bits as input and decodes them as a BCD quantity and shows the appropriate symbol.
In order to accomplish this task we need to have a program with the following capabilities:
• Read from the input pin RA0 and write a count to Port B. This configuration is made by
setting the right bits to the TRISA and TRISB registers.
• Count from 0 to 15
• Modify the count to show only even numbers or odd numbers depending on the switch’s
position
The proposed solution is a program that addresses directly these requirements. First we will
configure the microcontroller for input on Port A and output on Port B. Then we will use a For loop
for counting from 0 to 15 (that is, from 0x0 to 0xF in HEX notation) and we will write data to the
output port using the input on Port A pin 0 (RA0) as a modifier so it can show even numbers or
104 4. SIMULATING MICROCONTROLLERS
odd numbers. There is also an ancillary function called delay so the count does not flash too quickly
on the display.
The proposed solution is shown next:
#include "pic.h"
int i;
void main()
{
bitclr(STATUS, RP0); // Select Bank 0
PORTB = 0x00; // Clear Port B
bitset(STATUS, RP0); // Select Bank 1
TRISB = 0x00; // Set Port B pins to output mode
TRISA = 0xFF; // Set Port A as inputs
while(1)
{
for(i=0;i<16;i+=2)
{
PORTB=i-RA0; // We subtract the value of RA0 so we can
delay(); // make an even or odd count
}
}
}
When this program is built (compiled and linked) we can start the simulation and see how
the display counts odd numbers when the switch is connected to 5V and when it is tied to ground
it will count even numbers. The book’s website shows an animation of this circuit.
4.5. EXAMPLES 105
Example 4.4 Writing data on an LCD display.
The following example will make use of the liquid crystal display (LCD) included on the Advanced
Peripherals library. This kind of displays is based on a very common controller –the Hitachi 44780.
Manufacturers still use most of the original specifications so they are interoperable and backwards
compatibility is not an issue.
As we can see in Figure 4.16 there are several connection pins on this module. We have the
usual supply pins (VCC and GND), a control voltage (CV) used for adjusting the contrast, 3 control
pins (E, RS and RW) and 8 data pins (D0...D7). We will connect them as follows:
• VCC at 5VDC
void delay(void)
{
int count = 0;
for (count = 0; count < 250; count++){ }
106 4. SIMULATING MICROCONTROLLERS
void toggle(void)
{
RA0=0;
RA0=1;
}
void main()
{
bitclr(STATUS, RP0); // Select Bank 0
bitset(STATUS, RP0); // Select Bank 1
TRISA = 0x00; // Set Port A pins to output mode
TRISB = 0x00; // Set Port B pins to output mode
lcdInit();
delay();
PORTB = 0x45; // writes letter E
toggle();
PORTB = 0x41; // writes letter A
toggle();
PORTB = 0x53; // writes letter S
toggle();
PORTB = 0x59; // writes letter Y
toggle();
PORTB = 0x20; // writes a space
toggle();
PORTB = 0x41; // writes a letter A
toggle();
PORTB = 0x53; // writes a letter S
toggle();
PORTB = 0x20; // writes a space
toggle();
PORTB = 0x41; // writes a letter A
toggle();
PORTB = 0x42; // writes a letter B
toggle();
PORTB = 0x43; // writes a letter C
toggle();
PORTB = 0x20; // writes a space
toggle();
108 4. SIMULATING MICROCONTROLLERS
}
We can see a pair of functions at the top of the program: toggle() and lcdInit(). The
toggle function just sends a pulse going from low to high whenever we want a new data to be fed
into the display. The delay function is the same we have used in the previous Examples 4.2 and 4.3.
When the program is compiled and the simulation starts we can see a quick flash of the LEDs
and after a while we can see that letters start to appear on the display. Since this is a small message
we are storing it right in the microcontroller’s memory. In a real world situation messages are usually
longer and need to be stored in an external memory and read as needed.
The data in the main section of the program is the message we want to display. In this case, the
message reads EASY AS ABC. Each character is coded into its ASCII representation in hexadecimal
notation. The used sequence (in hexadecimal) is:
45-41-53-59-20-41-53-20-41-42-43
As a practical exercise try to find out the code for the space, for the letter A and, using an
ASCII chart, try to see how to convert this string to all lowercase characters (Hint: they are separated
a fixed distance).
Now we will focus our attention on the lcdInit() routine. The purpose of this function is
to prepare the LCD for the right number of rows and characters, clear the screen and position the
cursor where we want. In Multisim we can get along without initializing the display just fine, but
anyway it is a good practice –and certainly a requirement most of the time –to always initialize a
display before using it.
If we look carefully at the connections in Figure 4.17 we see that there is a control pin labeled
RW. This signal is always tied to ground because we will be writing to the display. The reason for it
to be there is that a read/write procedure is used when the user wants to define custom characters
or reading the status of the several function of the display during execution.
This switch is special because it gives us the power to control devices that need a current larger
than a few miliamperes. Most of the time these switches are made of transistors or electromechanical
relays. We will use it as the switching element for controlling the inputs of the Traffic Light that
can be found on the Advanced Peripherals menu. This traffic light turns on each one of its lights
whenever a voltage is present at the input. If we would have chosen the microcontroller pins as the
control signals we would have seen that the lights never turn on, or perhaps they flash very quickly.
A real microcontroller would not withstand such operation and a resulting damaged pin would be
the consequence of this operation.
The connections are shown on Figure 4.19.The control signals come from the microcontroller
and they are used as inputs on the voltage controlled switches. These switches have their threshold
voltage modified to turn on and off at 2.5 volts.
We can also see that the other side of the switch has one connection going into the traffic
light and the other side is left open.
The microcontroller is programmed with a very basic main function. This does not mean it
is a simple function. Here you can see it:
void main()
{
bitclr(STATUS, RP0); // Select Bank 0
bitset(STATUS, RP0); // Select Bank 1
TRISB = 0x00; // Set Port B pins to output mode
state01(); // red on one side and green on the other
blinkGreen01(); // green light 01 blinks
110 4. SIMULATING MICROCONTROLLERS
1. A green light on one side is accompanied by a red light on the other side.
4.5. EXAMPLES 111
2. After some seconds, the green light starts to blink briefly before going into amber.
3. When the amber light turns off, the red light and the green light are reversed with respect to
the initial state.
4. The blinking and amber lights happen on one side as the other holds the red light on.
The complete program is shown next. There are three different delay functions. These may
need tuning when simulating this example on different computers since their timing depends on the
processor’s speed.
#include "pic.h"
void state01(void)
{
PORTB=33; // red on one side and green on the other
delayLong(); // long delay time on this state
}
void main()
{
bitclr(STATUS, RP0); // Select Bank 0
bitset(STATUS, RP0); // Select Bank 1
TRISB = 0x00; // Set Port B pins to output mode
state01(); // red on one side and green on the other
blinkGreen01(); // green light 01 blinks
amber01(); // still red on one side and amber on the other
state02(); // this state is like state 01 but inverted
blinkGreen02(); // green light 02 blinks
amber02(); // amber light on one side and red on the other
}
114 4. SIMULATING MICROCONTROLLERS
When the simulation is running we can see the complete sequence as a representation of a
working traffic light. First the cars in one street have the red light on while the cars on the other
street can cross safely. After a given time (defined in the delayLong() function) the green light
starts to blink before going into amber and finally to red. At this time the traffic light allows traffic
on the other street while stopping the cars on the other street.
This example concludes the chapter on Multisim capabilities for simulating microcontrollers.
We went through the steps on getting an appropriate environment for writing and compiling pro-
grams, both in assembly language and in C. Then we showed a set of applications that involved
a program being compiled and transferred to the microcontroller and external peripherals being
connected to it.
4.6 CONCLUSIONS
A simulator that handles a mixture of digital and electric circuits is a very powerful tool. A designer
can benefit from such software the moment he is free to explore new variations on the design without
the worries of time-consuming recalculations.
This chapter joins the analog/digital world with the world of microprocessors, the hearts of
today’s devices, gadgets and appliances. As we have shown, the inclusion of microcontrollers in other
types of circuits is a seamless job in Multisim.
Through examples we have show the reader some of the possibilities that Multisim opens.
The reader should feel free to try more complex programs and connections to more peripherals or
external circuits if so he/she desires.
REFERENCES
[1] S. Oualline, Practical C Programming, O’Reilly, Sebastopol, CA, 1991. Cited on page(s) 98
115
CHAPTER 5
• This schematic design can be simulated and/or debugged with the techniques explained in
this book and in the companion book Circuit Analysis with Multisim [1].
• When the circuit has been simulated—or even when it is being entered into the computer—it
is necessary to verify that each component has an adequate packaging defined. (Packaging is
a label that describes how the component is physically. Specifying this value Ultiboard knows
the dimensions, the pin spacing and the geometry of each device).
• A netlist is exported from Multisim to Ultiboard. The netlist is a text file that contains the
connections between components and the packaging of each one.
• The netlists are imported into Ultiboard and the placement of the components is made (au-
tomatically or user-defined). This step is harder than it seems on first inspection.
• Depending on the results the final tracks can be rearranged, modified or routed again.
• Finally, the final design is exported in a format known as Gerber. This is the file that a manu-
facturer needs when making large production runs of a design.
This is the outline of the steps needed for having a PCB design made with Ultiboard and the
autorouting option. In Section 3 we see a practical example of this method.
These dimensions are well-suited for PCBs that are relatively easy to convert in prototypes and that
can work with through-hole components, as their use is widespread in many applications.
The procedure is as follows:
• Start Ultiboard.
• Components are laid out as the user needs (with practice is easy to spot problematic areas, like
grouping pins for interconnections and/or divide the area in functional zones).
• When the components have been placed on the board, we need to connect each node. This
step is similar to the first method when the computer is ready to start its autorouting process.
• Instead of instructing the computer to start routing, the user should start making the electrical
connections drawing copper tracks between pads. A schematic diagram is certainly useful and
the netlist file can be a guide for verifying which nets are still left unconnected.
• The connections should be made using the widest setting for the track width. When the track
should go through a reduced space, it is perfectly acceptable to reduce the width only in that
segment. Using a wide track width makes the design easier to transfer and etch when doing
prototypes.
• When routing is finished, the design can be printed and transferred to a copper board us-
ing whichever method the user prefers (photosensitive emulsion, lithography, transfer sheets,
Gerber or DXF files for automatic manufacturing, etc.)
Both methods have several common points. We discuss an example with notes indicating whether
a step belongs to the automatic or to the manual method.
• A list of the corresponding package and footprint for each device or element.
118 5. PCB DESIGN WITH ULTIBOARD
In this section we show two examples, the first one uses the automatic method of letting the computer
do the routing itself. The second example cannot be reliably routed by the computer when a single-
layer board is selected; this forces us to do manual routing of the tracks.
Figure 5.4: Schematic drawing for the inverting amplifier with connection headers.
5.2. STEP-BY-STEP EXAMPLES 121
5.2.4 TRANSFERRING THE DESIGN TO ULTIBOARD
This step shows us how to transfer the design to Ultiboard. Depending upon the installed version
available we should choose to send the design to Ultiboard version 11 or previous versions. This is
done in the menu Transfer → Transfer to Ultiboard → Transfer to Ultiboard 11.
As a first requisite, Ultiboard asks for a file name. In this case, the file name is chosen as
Example01_Inverting_Amplifier.ewnet. Note that Multisim creates a file with the extension ewnet.
This is the file that Ultiboard uses to create the PCB.This launches the program and we see a window
like the one shown on Figure 5.5. This is the import netlist which describes how the elements are
connected in the circuit.
As we can see in the main Ultiboard window, the tracks are 10 mils in width. This is the
default width. We can change the units but the recommended units are mils. This is due to the
fact that the vast majority of components are manufactured using mils as a reference, including the
pin spacing of holes in a breadboard, so it is a safe procedure to work using the same units as the
component packages we are using. From the menu Options → PCB Properties, the window for
the PCB properties opens and in the Design rules tab we see the track width set at 10 mil. The
recommended value when working with simple designs is 25 mils.
122 5. PCB DESIGN WITH ULTIBOARD
As the designs get progressively more complex, and therefore, more dense, the track width
can be reduced to 10 mils or even less. The last parameter, clearances to trace is the minimum
distance between contiguous tracks. The value of 10 mils is appropriate for our needs. Once we have
imported the netlist we get the main window for Ultiboard, with the board outline and the imported
components placed outside of the board (Figure 5.7).
We can zoom in and out with the mouse scroll wheel so we get a better view of the components
and their connections.The yellow lines in Figure 5.8 are the imported nets; these allow the autorouter
to know which component is connected to another one.
Here we can see the labels for each component; for example, J1 and J2 are two headers, U1
is the DIP8 integrated circuit and R1 and R2 are the resistors. The yellow lines, as we explained
above, are the electric connections between elements; these come from the netlists and due to their
entangled look they are sometimes called ratsnest.
In the View → Toolbars → Select menu we can activate the selection toolbar shown in
Figure 5.9.
The first button enables the option for selecting components. When enabled we can drag
components to any convenient location before routing. We can also enable the autoplacement func-
5.2. STEP-BY-STEP EXAMPLES 123
tion in the Autoroute toolbar but we must take into account that the results are not always what we
are expecting. In this example we place the components as shown in Figure 5.10.
Now that the components are in place we can choose to use a manual placement of the tracks
or the autorouting utility. First we see what happens with autorouting. The autorouter is invoked
in the Autoroute → Start/Resume Autorouter menu. The results are similar to those shown in
Figure 5.11.
As we can see, the results are very good. We could check to see that each connection is done
properly to the corresponding pin in the IC.
5.2. STEP-BY-STEP EXAMPLES 125
For a simple design the autorouter works well. For complex designs there is a high probability
of tracks not being routed. In that case, we must manually draw the tracks.
Notice how we are using a 2N5088 BJT transistor instead of the LM35 sensor. This is done
because they both share the same TO-92 packaging and there is no LM35 in the parts bin.
Again, we are going to transfer the design from Multisim to Ultiboard (from the Transfer
→ Transfer to Ultiboard → Transfer to Ultiboard 11 menu). Once we are running Ultiboard we
are going to accept the default configuration and we have the components placed outside the board
outline of our PCB.
With this default configuration we can make a test to see the results for a fully automated
design. First, we need to autoplace the components (Autoroute → Start Autoplacement menu)
and with that result we are going to try the autorouting feature (Autoroute → Start / Resume
Autorouter). In our particular case we obtained 16 out of 17 tracks routed. This is a 94% of the
whole design. In this basic design that means that we have to manually route one track or maybe
use a wire jumper to make the connection. In a more complex design this could probably mean that
we have to manually route dozens of tracks.
In this case, we can place a pair of vias on the board. Vias are connectors for going from one
copper layer to another. Here we are going to use them in order to go from the copper top layer to
copper bottom layer.
5.2. STEP-BY-STEP EXAMPLES 127
Here it is evident that there is a need for a mixture of routing and placement techniques. Each
designer is going to develop his/her own set of techniques for the tracks that could not been routed
by the software (see Figure 5.13).
In these examples we can see the design possibilities that Ultiboard offers. The next step in
the PCB fabrication process is the electrical rules check. This is a check-up that can be run when a
design is apparently finished; we can specify some criteria like distance between adjacent tracks and
minimal width of tracks. This is useful when a design involves the use of RF (radio frequency) or
high frequency signals.
In Ultiboard we can activate the Electric Rules Check by going to the menu Design → DRC
and Netlists Check. If we check the design we have so far, we are hopefully not going to find any
errors, but in more complex circuits it is always a good practice to periodically check for errors so
we can fix them as they appear. This is going to save us a great deal of time in the long run.
If we wish to check the details or change the preferences for the electric rules, the menu we
use is found under Options → PCB Properties → Design Rules.
A pair of interesting options that the Educational version of Ultiboard has are the PCB
Transmission Line Calculator shown in Figure 5.14, and the PCB Differential Impedance Calculator
shown in Figure 5.15. They are available in the menu Tools → PCB Transmission Line Calculator
and Tools Tools → PCB Differential Impedance Calculator. Both are used for doing the calculations
related to the electromagnetic values belonging to the material and dimensions used in our designs.
128 5. PCB DESIGN WITH ULTIBOARD
If we select SVG, some design programs can handle very well the vector images obtained. As
a suggestion you can use a free program called Inkscape that natively works with SVG files.
For Gerber files we need to specify which layers are going to be exported and after that define
the aperture values. This is a value used by CNC machines for calculating the outline that should
130 5. PCB DESIGN WITH ULTIBOARD
be routed when making the PCB. DXF export is similar with the difference that the user does not
have to specify the apertures. DXF is a file type handled by CAD software.
5.4 CONCLUSIONS
In this chapter we have presented a few techniques for making PCBs using Multisim as a base for
schematic capture and Ultiboard for designing the copper tracks.
We have also shown some variations on the basic techniques and the results that can be
obtained. Finally, we listed the export options available so the user can choose the most appropriate
for his/her needs.
REFERENCES
[1] D. Báez-López, F. E. Guerrero-Castro, Circuit Analysis with Multisim, Synthesis Lectures on
Digital Circuits and Systems, Morgan and Claypool Publishers, Vol. 6, No. 3, 2011. Cited on
page(s) 116
131
Authors’ Biographies
DAVID BÁEZ-LÓPEZ
FÉLIX GUERRERO-CASTRO
OFELIA CERVANTES-VILLAGÓMEZ
Dr. Ofelia Cervantes-Villagómez holds a B.S. in Computer
Systems Engineering from Universidad de las Américas, Puebla,
(May 1981), a Master of Sciences in Computer Systems from
l’École Supérieure en Informatique in Grenoble, France, ( June
1984), and a Ph. D. degree from l ’Institut National Polytechnique
de Grenoble, France, ( January 1988). Dr. Cervantes-Villagómez is
co-founding member of the Laboratorio Nacional de Informática
Avanzada, A.C. (National Laboratory for Advanced Informatics,
A.C.) established in Jalapa. Ver. She was a member of the Direc-
tive Board for an eight-year period. Starting in the year 2000, she
was designated by CONACYT to promote cooperation between Mexico and France and Germany
to pursue research in Information Technologies. She participated also in the creation of the Mexican-
European Informatics Laboratory, which has as collaborating countries Mexico, Spain, France, and
Germany. Dr. Cervantes has experience as a professor, researcher and has consulted in Data Base
Modeling, Distributed Systems, Artificial Intelligence, Automatic Speech Processing and Business
Intelligence. She has taught a number of short courses and has many publications in these topics. She
was a visiting research fellow in IMAG, Grenoble France (1995) and Université du Québec à Trois
Rivières (2005). She has also been thesis director to several undergraduate and graduate students
at the M.S. and Ph.D. levels. Dr. Cervantes-Villagómez was president of the Mexican Artificial
Intelligence Society, President of the Mexican Association for International Education, as well as
founder and president of the first Chapter of the International Association of International Edu-
cators Phi-Beta Delta. Dr. Cervantes-Villagómez is still active in teaching and research at UDLA.
She is also the Honorary French Consul in Puebla since 2003.