SPICE - A Brief Overview-2

download SPICE - A Brief Overview-2

of 7

Transcript of SPICE - A Brief Overview-2

  • Fore translation in Bulgarian click here (courtesy of Cloudlakes.com)

    3. HOW TO GET STARTED WITH SPICE? (for beginners)(URL: http://www.seas.upenn.edu/~jan/spice/spice.guide.html)

    This document will explain how to run Spice or HSpice. It does not explain the Spice commands. Thiscan be found earlier in this document under How to Specify the Circuit Topology?, in your textbook,or the Spice User's Guide.

    In order to run Spice, you will have to go through the following steps:

    Draw a schematic of the circuit (can be skipped)Create an input fileRun the programLook at the output file and print the results

    3.1 Creating an Input File for Spice - Example

    We will first explain how to use PSpice without a Schematic Editor (see PSpice Primer for how to usethe Schematic Editor).

    a. Draw a schematic of the circuit, number the nodes and label all elements. Note that the commonnode (ground) always has number "0".

    A sample circuit is given below.

    Figure 1

    We are interested in the voltages v12, v2 and the current i4 when the input voltage vin is equal to 10V.We also want to find the Thevenin equivalent voltage and resistance seen by the terminals ab.

    In addition, we like to step the input voltage between 0 and 20 V in steps of 2V and print and plotv12, vo, v2 and i4 as a function of vin.

    Note that we inserted a DC voltage source, VMEAS, of zero value, in order to be able to measure thecurrent i4.

    spice guide http://www.seas.upenn.edu/~jan/spice/spice.guide.html#PSPICE

    1 de 7 30/01/13 15:59

  • b. Create the input file (source file) for PSpice.

    The source file needs the extension (usually ".cir") in its name. For a description of the data, controland output statement, refer to "How to Specify the Circuit Topology" earlier in this document, theSpice manual or the textbook.

    Create the input file with any editor, such as Emacs, Microsoft editor, Word perfect, NotePad underwindows, etc. Save it on the c: drive or on your disk on the a: drive. In case you store it on the c:drive, put it in a subdirectory (ex. c:\users\filename.cir; the subdirectory is required for the PSpiceversion that runs on the network in the PC labs and sits on the h: drive). Save the file as a textfile(when using a word processor such as MS Word).

    Example: c:\users\example1.cirEXAMPLE PSpiceVIN 1 0 DC 10F1 0 3 VMEAS 0.5VMEAS 4 0 DC 0R1 1 2 1KR2 2 3 10KR3 1 3 15KR4 2 4 40KR5 3 0 50K.OP.TF V(3,0) VIN.DC VIN 0 20 2.PRINT DC V(1,2) V(2,4) I(VMEAS).PLOT DC V(1,2) V(2,4).PLOT DC I(VMEAS).END

    Notes:

    1. The first line is a title line and can be anything. It cannot be omitted.2. The last line must be the .END statement.3. You can insert comment lines. Anytime a line starts with an "*", PSpice ignores the wholeline. Using an "*" is also handy to block out a command line.4. You can use upper or lower case letters.5. Don't forget to add a carriage return after the .END statement.

    c. Run Spice

    Once you are in PSpice, pull down the File menu at the top of the screen and select "Open ". Thesystem prompts you for the name of the file. Type in the file name of the circuit you have createdbefore. As an example: c:\users\example1.cir

    A window will appear telling you that Spice program is running, or that the simulation has beencompleted successfully, or that errors were detected. Click on the "OK" button.

    spice guide http://www.seas.upenn.edu/~jan/spice/spice.guide.html#PSPICE

    2 de 7 30/01/13 15:59

  • 4 PSPICE with Capture

    5. HSPICE

    5.1 Running HSPICE

    You can run HSPICE on Eniac (Sun Sparc), which is basically the same program as PSpice, exceptfor the Schematic editor and Probe. The advantage of using HSpice on Eniac is that you can run itfrom your room through a modem connection or over ResNet. In addition, it comes with auser-friendly and powerful graphical interface (gsi) provided you have access to an x-terminal.

    First, you have to create the input file that contains the data, control and output statements in the sameway as is done for PSpice. The format and commands are identical. You can create this input file withany editor. Once you have the input file, you can run HSpice by typing the following command at theunix prompt,

    hspice inputfilename

    in which inputfile is the name of your input file. The output will be displayed on the screen. You canalso store the output of HSPice in an output file, as follows,

    hspice inputfile > outputfile

    To view the output file, use your favorite editor. The file can be printed as any other document:lpr -w80 outputfile

    Notice that HSpice does not give the DC voltages unless you have specified a certain analysis type,such as for instance .TRAN, or .AC analysis (Spice automatically does a DC analysis before doing atransient or AC analysis). Thus, if you are only interested in the DC voltages in HSpice, you shouldspecify the .OP option, or the .DC option.

    5.2 Special Features of HSPICE

    HSpice has many capabilities. If you intend to use HSpice for Integrated Circuits simulation you willneed to make use of many of these. Please consult the MetaSoftware manual (available from the DSL,room 100M). Here are a couple of these features.

    a .Mathematical expressions in Hspice

    HSPICE supports a few mathematical functions which can be used to condition any output variable.The following general format should be used for all expressions:

    .print varname=PAR('sqrt(v3)')

    This instructs HSPICE to print the square root of the voltage "v3" and assign it the variable namevarname. The results can be found in the output file as well as gsi under the print'plot field. Apart

    spice guide http://www.seas.upenn.edu/~jan/spice/spice.guide.html#PSPICE

    3 de 7 30/01/13 15:59

  • from square root, other useful functions such as log(), sin() and tan() are supported. Consult theHSPICE manual for a complete listing.

    b. Node Names.

    Instead of using node numbers, you can use node names in the input file. This makes the files mucheasier to read. The same names will appear in the output file and the graphical display.

    5.3 Graphical Output: gsi

    In case you have access to an x-window terminal the output can also be viewed graphically using thegsi program. In order to use the graphical display, you have to include the statement "option post" inthe input file. This will create a *.sw# (for .sweep analysis) or a *.tr# file (for transient analysis) whichcontains the simulation results in a format that can be interpreted by gsi.

    To run gsi, type "gsi inputfilename". All node voltages will be saved for later display. In case youhave a large circuit and don't need to look at all the nodes, you can reduce the size of the file byspecifying which node voltages to save. This is done by the ".option post probe", followed by the".print nodenames" command. This last command is identical to the one you use to specify whatnode voltages, or currents you want Spice to save.

    Here is an example of the input file, with the .option post command for gsi.

    example hspice with gsivin input 0 dc 10f1 0 output vmeas 0.5vmeas 4 0 dc 0r1 input 2 1kr2 2 output 10kr3 input 3 15kr4 2 4 40kr5 output 0 50k.tf output vin.dc vin 0 20 2.option post*.print dc v(1,2) v(2,4) i(vmeas)*.plot dc v(1,2) v(2,4) i(vmeas).end

    To see the graphical output, type gsi example1 (if on an x-window terminal; if you are not familiarwith x-windows consult CETS). The gsi output is shown in the next figure. After typing "gsi", twowindows will open.

    spice guide http://www.seas.upenn.edu/~jan/spice/spice.guide.html#PSPICE

    4 de 7 30/01/13 15:59

  • The top one allows you to select what variables to display. After making the selection of the "type" ofvariables (voltages, current, etc.) and the "curves" to be displayed, click on the "Draw" button. Thecurves will be shown on the second window (Graph window).

    You can select the number of panels by going to the "Panels" menu and selecting the number ofpanels. There are several option and manipulations you can incorporate (see Features of gsi below).

    Features of gsi

    In the Graph window you have a number of interesting options. The measurement menu allows you touse cursors. To zoom in/out click on the right mouse button and select one of the zoom commands.Then with the left button draw a short line to indicate what you would like to zoom.

    To clear a panel, click on the right mouse button and select "Clear".

    Printing can be done by going to the "Print" menu. The print command will write the graphical outputto a file (labeled as filename.gr#)) which can then be printed later on (using the lpr command).

    Mathematical expressions can be plotted as well. In the top window, you will see a small box calledexpression. You can type mathematical expressions such as additions, multiplications, square, etc. of

    spice guide http://www.seas.upenn.edu/~jan/spice/spice.guide.html#PSPICE

    5 de 7 30/01/13 15:59

  • graphs. As an example lets calculate the power in a resistor (power = i(vmeas)*v(2)). To display theexpression, select expression in the "Types" window and "power" in the "Curves" window. Next, clickon the "Draw" button.

    6. Most common mistakesTypos in the source file: wrong node numbers, wrong units (ex. the value of a capacitor of 12picofarad, incorrectly specified as 12, instead of 12p.)

    1.

    Confuse M for mega instead of MEG: a 5 megaohm resistor should be specified as 5MEG andnot 5M. (M or m stands for milli).

    2.

    Typing the letter O instead for the number 0 (zero as in 10)3.Omitting the final carriage return after the .END statement.4.

    7. If Spice does not run.1. First check that /cad/bin is in your path. If not, you should alter the path to statement in your shellinitialization file to include /cad/bin.).

    2. To run hspice on eniac from an X-TERMINAL that runs on a computer different from eniac (letssay hobo in the EE domain):

    logon to hobo.ee (to which the display is connected) and type:

    xhost eniac.seas.upenn.edu

    login to eniac and type:

    rsh eniac.seas.upenn.edu; once on eniac type:setenv DISPLAY hobo.ee:0.0

    8. REFERENCESSPICE, A Guide to Circuit Simulation and Analysis Using PSpice, 3rd Ed., P. Tuinenga,Prentice Hall, Upper Saddle River, NJ, 1995. This book comes with a IBM-PC 3.5 disk with thePSpice Student Version.

    1.

    Schematic Capture with MicroSim PSpice, 3rd Ed., Marc. E. Herniter, Prentice Hall, UpperSaddle River, N.J, 1998. This book comes with a CD that contains an evaluation version ofPSpice.

    2.

    MicroSim PSpice with Circuit Analysis, 2nd Ed., F. Monssen, Prentice Hall, Upper SaddleRiver, NJ, 1998.

    3.

    MicroSim PSpice for Windows, Vol. I and II, R. W. Goody, Prentice Hall, Upper Saddle River,4.

    spice guide http://www.seas.upenn.edu/~jan/spice/spice.guide.html#PSPICE

    6 de 7 30/01/13 15:59

  • NJ, 1998.Spice for Circuits and Electronics Using PSpice, 2nd ed., M. H. Rashid, Prentice Hall,Englewood Cliffs, NJ, 1995. This book comes with a tear-out card to order a disk with thePSpice Student Version (available for both PC and MAC). The cost for the disk is about$7.50-$15.50

    5.

    Computer-Aided Circuit Analysis Using PSpice, 2nd Ed., W. Banzhaf, Prentice-Hall,Englewood Cliffs, NJ, 1992

    6.

    Hands On PSpice,"J.G. Gottling, Houghton Mifflin Co., MA, 19957.The Spice Book, A. Vladimirescu, John Wiley & Sons, New York, NY, 19948.Semiconductor Device Modeling with Spice, 2nd Ed., G. Massobrio and P. Antognetti,McGraw-Hill, NY, 1993

    9.

    Mosfet Modeling with Spice, D. Foty, Prentice Hall, Upper Saddle River, NJ, 1997.10.Macromodeling with Spice, J.A. Connelly/P. Choi, Prentice-Hall, Englewood Cliffs, NJ, 199211.Inside SPICE, Overcoming the Obstacles of Circuit Simulation, R. M. Kielkowski,MacGraw-Hill, Inc., New York, 1994.

    12.

    SPICE, Practical Device Modeling, R. W. Kielkowski, McGraw-Hill, Inc., New York, 1995.13.Introduction to PSpice, A Supplement to Electric Circuits, 4th ed., by J. W. Nilsson and SusanA. Reidel, Addison-Wesley Publ. Company, Reading, MA, 1993

    14.

    Spice, by G. Roberts and A. Sedra, Oxford University Press, 1997, 2nd Edition.15.HSPice Users' Manual, Meta-Software, Inc., Campbell, CA16.PSpice Users' Guide, MicroSim Corporation, Irvine, CA17.SPICE User's Guide18.

    Back to Table of Contents

    Jan Van der [email protected]

    Created Sept. 30, 1995; Updated Dec. 3, 2001

    spice guide http://www.seas.upenn.edu/~jan/spice/spice.guide.html#PSPICE

    7 de 7 30/01/13 15:59