Spice Simulation and Control Statements

download Spice Simulation and Control Statements

of 9

Transcript of Spice Simulation and Control Statements

  • 8/6/2019 Spice Simulation and Control Statements

    1/9

    SPICE Simulation and Control StatementsOverviewThe National Instruments SPICE Simulation Fundamentals series is your free resource on the internet forlearning about circuit simulation. The series is a set of tutorials and information on SPICE simulation, OrCADpSPICE compatibility, SPICE modeling, and other concepts in circuit simulation.For more information, see the SPICE Simulation Fundamentals main page.The series is divided among a number of in-depth detailed articles that will give you HOWTO information onthe important concepts and details of SPICE simulation.Circuit simulation is an important part of any design process. By simulating your circuits, you can detecterrors early in the process, and avoid costly and time consuming prototype reworking. You can also easilyswap components to evaluate designs with varying bills of materials (BOMs).

    Available Analyses and Control StatementsSPICE is a rich and robust language capable of performing several advanced circuit analyses. The firstversion of SPICE provided a text-only interface, in which users were forced to manually type statements tocontrol the simulator. Modern simulation programs like Multisim provide a graphical interface to choose thesesame options. This article provides a listing of the commands and analyses available in SPICE as well astheir original syntax and usage.The following analyses and commands are available in SPICE:

    Operating Point AnalysisDC Transfer FunctionSmall-Signal AC AnalysisDistortion AnalysisNoise AnalysisPole-Zero AnalysisSensitivity Analysis (DC or Small S ignal AC)Transfer Function AnalysisTransient AnalysisSAVE OutputPRINT OutputPLOT OutputFourier Analysis of Transient Analysis Output

    Nationa llnst rument s. A ll r ight s reserved . LabVIEW, Nationa l I ns tr uments , NI , n i.com, t he Nationa l Inst rument s corpora te logo , and the Eag le l ogo are t rademarks o f Nationa lI ns truments . See n i.comlt rademarks for o ther NI t rademarks. Other product and company names are t rademarks or t rade names of thei r r especti ve compan ies. For paten ts cover ingNati onal Inst rument s products , r efe r to the appropr ia te loca tion: He lppatent s in your sof tware, t he paten ts .tx t f il e on your CO, or n i.com/patent s .

  • 8/6/2019 Spice Simulation and Control Statements

    2/9

    Specify In itial Node Voltage GuessesSet Initial Conditions

    SPICE Analyses and Control Statement SyntaxOperating Point AnalysisSyntax .OPExample .OPNotes ~he inclusion of this line in an input file directs SPICE

    o determine the DC operating point of a circuit withinductors shorted and capacitors opened. Note: a DCanalysis is automatically performed prior to aransient analysis to determine initial conditions, andprior to an AC small-signal, Noise, and Pole-Zeroanalysis to determine the linearized, small-signalmodels for nonlinear devices.

    DC Transfer FunctionSyntax DC SRCname Vstart Vstop Vincr [SRC2 START2

    STOP2 INCR2]Example DC VIN 0.25 5.0 0.25Notes ~he DC line defines the source and sweep limits for a

    DC transfer curve (capacitors open and inductorsshorted). SRCname is the name of an independent~oltage or current source. Vstart, Vstop, and Vincrare the starting, final, and incrementing valuesrespectively.

    Small-Signal AC AnalysisSyntax .AC DEC ND Fstart Fstop

    .AC OCT NO Fstart Fstop

    .AC LIN NP Fstart Fstop2 www.ni.com

    http://www.ni.com/http://www.ni.com/
  • 8/6/2019 Spice Simulation and Control Statements

    3/9

    Example .AC DEC 10 1 10K.AC DEC 10 1K 100MEG.AC LIN 100 1100HZ

    Notes If this line is included in the input file, SPICE performsan AC analysis of the circuit over a specified!Frequency range. DEC stands for decade variation,and ND is the number of points per decade. OCTstands for octave variation, and NO is the number ofpoints per octave. LIN stands for linear variation, andNP is the number of points. Fstart is the starting!Frequency, and Fstop is the final frequency. Note: Inorder for this analysis to be meaningful, at least oneindependent source must have been specified withan ac value.

    Distortion AnalysisSyntax DISTO DEC ND Fstart Fstop

    DISTO OCT NO Fstart Fstop DISTO LIN NP Fstart Fstop

    Example DISTO DEC 101kHz 100MhzNotes ~he Disto simulation command does a small-signal

    ~istortion analysis of a circuit. A multi-dimensional~olterra series analysis is done usingmulti-dimensional Taylor series to represent thenonlinearities at the operating point. Terms of up tohird order are used in the series expansions. If theoptional parameter F20VERF1 is not specified,DISTO does a harmonic analysis. In thissituationm, the distortion analysis in the circuit usesonly a single input frequency, F1. F1 is then isswept over the specified frequency arguments in theDISTO command (exactly as in the .AC command).Inputs at this frequency may be present at more thanpne input source, and their magnitudes and phases3 www.ni.com

    http://www.ni.com/http://www.ni.com/
  • 8/6/2019 Spice Simulation and Control Statements

    4/9

    are specified by the arguments of the DISTOF1keyword in the input file lines for the input sources(see the description for independent sources).

    Noise AnalysisSyntax .NOISE V(OUTPUT

  • 8/6/2019 Spice Simulation and Control Statements

    5/9

    .PZ 2 3 5 0 VOL ZER

    .PZ 4 1 4 1 CUR PZNotes CUR stands for a transfer function of the type (output

    ~oltage)/(input current) while VOL stands for aransfer fu nction of the type (output voltage )/(input~oltage). POL stands for pole analysis only, ZER forzero analysis only and PZ for both. This feature isprovided mainly for the situation of nonconvergence.~his ensures that at least one of either the poles orzeros of the circuit can be determined. Finally, N1and N2 are the two input nodes while N3 and N4 arehe two output nodes. The ability to define these inputand output nodes ensures complete freedom in thespecification of the output and input ports, andhus the type of transfer function.

    Sensitivity Analysis (DC or Small Signal AC)

    Syntax .SENS OUTvar.SENS OUTvar AC DEC ND Fstart Fstop.SENS OUTvar AC OCT NO Fstart Fstop.SENS OUTvar AC LIN NP Fstart Fstop

    Example .SENS V(1 ,OUT).SENS V(OUT) AC DEC 10 100 100k.SENS I(VTEST)

    Notes ~he sensitivity of OUTvar to all non-zero deviceparameters is calculated when the SENS analysis isspecifled. OUTvar is a circuit variable (node voltagepr voltage-source branch current). The first form ofhis analysis calculates the sensitivity of the DCoperatinq-point value of OUTvar The second formcalculates sensitivity of the AC values of OUTvar.~he parameters listed for AC sensitivity are the sameas in an AC analysis (see "".AC"" above for more

    5 www.ni.com

    http://www.ni.com/http://www.ni.com/
  • 8/6/2019 Spice Simulation and Control Statements

    6/9

    ~etails). The output values are in the dimensions ofchanqe in output per unit change of input(as opposed topercent change in output per percent change of input) .

    Transfer Function AnalysisSyntax .TF OUTvar inSRCExample .TF V(5, 3) VIN

    .TF I(VLOAD) VINNotes ~he TF command defines the small-signal output and

    input for the DC small-signal analysis. OUTvar is thesrnall-siqnal output variable and inSRC is thesrnall-siqnal input source. If this line is included,SPICE computes the DC small-signal value of theransfer function (output/input), input resistance andhe output resistance.

    Transient AnalysisSyntax .TRAN Tstep Tstop

  • 8/6/2019 Spice Simulation and Control Statements

    7/9

    pr(Tstop- Tstart)/50.0. TMAX is useful when one wishes to guarantee acornputinq interval which is smaller than the printerincrement, Tstep.

    PRINT OutputSyntax .PRINT PRtype OV1

    Example .PRINT TRAN V(4) I(VIN)Notes rrhe PRINT line defines the contents of a tabular

    listing of one to eight output variables. PRtype is theype of analysis (DC, AC, TRAN, NOISE, or DISTO)or which the specified outputs are desired.

    PLOT OutputSyntax .PLOT PLtype OV1 PL01, PHI1 Example .PLOT DC V(4) V(5) V(1)Notes rrhe PLOT line defines the contents of one

    plot for one to eight output variablesrom the analysis defined by the PLtypeparameter (DC, AC, TRAN, NOISE, or DISTO). Thesyntax for the OVI is identical to that for the .PRINTline and for the plot command in the interactivemode. There is no limit on the number of .PLOT linesspecified for each type of analysis.

    SAVE OutputSyntax .SAVE vector < ...>Example .SAVE i(vin) input outputNotes rrhe vectors listed on the .SAVE line are recorded in

    he rawfile for later use with spice3. The standard

    7 www.ni.com

    http://www.ni.com/http://www.ni.com/
  • 8/6/2019 Spice Simulation and Control Statements

    8/9

    ~ector names are accepted. If no .SAVE line is givenhen the default set of vectors are saved (node~oltages and voltage source branch currents). If.SAVE lines are given, only those vectors specifiedare saved.

    Fourier Analysis of Transient Analysis OutputSyntax .FOUR FREQ OV1 Example .FOUR 100K V(5)Notes ~he FOUR (or Fourier) line controls whether SPICE

    performs a Fourier analysis as a part of the transientanalysis. FREQ is the fundamental frequency, andOV1, ... , are the output variables for which theanalysis is desired. The Fourier analysis is performedover the interval where Tstopis the final time specified for the transient analysisand the period is one period of the fundamental!Frequency. The DC component and the first nineharmonics are determined. For maximum accuracy~MAX (see the .TRAN line) should be set toperiod/100.0 (or less for very high-Q circuits).

    Specify Initial Node Voltage GuessesSyntax .NODESET V(n1)=VAL V(n2)=VAL

    Example .NODESET V(12)=4.5 V(4)=2.23Notes ~he NODESET line helps the program find the DC or

    initial transient solution by making a preliminary pass~ith the specified nodes held to the given voltages.~he restriction is then released and the iteration~ontinues to the true solution. The .NODESET linemay be necessary for convergence on bistable ora-stable circuits. In general this line should not benecessary.

    8 www.ni.com

    http://www.ni.com/http://www.ni.com/
  • 8/6/2019 Spice Simulation and Control Statements

    9/9

    Set Initial ConditionsSyntax .IC V(n1)=VAL Example .IC V(11)=5 V(4)=-5 V(2)=2.2Notes ~he IC line is for setting initial transiet conditions. It

    has two different interpretations depending on~hether the UIC parameter is specified on the .TRAN~ontrolline. One should not confuse this line with the.NODESET line. The .NODESET line is only to helpDC convergence, and does not affect final biassolution (except for multi-stable circuits).

    Multisim for free for 30 days Multisim with an Interactive Demo

    Free Courseware for Circuits bout the NI Electronics Education Platform

    9 www.ni.com

    http://www.ni.com/http://www.ni.com/