Changes

Jump to: navigation, search

An Overview of Analog and Mixed-Mode Circuit Simulation

5,231 bytes added, 15:19, 10 November 2016
/* Setting the Simulation Parameters */
[[File:rfspice_banner.png|right|640px]]
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D | Back to RF.Spice A/D Wiki Gateway]]'''
 
[[Image:Tutorial_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorials | RF.Spice A/D Tutorial Gateway]]'''
== SPICE Simulation of Analog Circuits ==
[[File:b2MAN_Fig212.png|thumb|500px|Running a live simulation of an Op-Amp circuit in RF.Spice A/D with circuit animation enabled.]]
[[File:b2MAN_Fig213.png|thumb|500px|Running a transient test of the same Op-Amp circuit as above in RF.Spice A/D.]]
An analog circuit consists of a source, one or more passive or active devices and a ground. The sources, devices and the ground are connected to one another using wires. Wires carry electric currents. The interconnections of wires create circuit nodes. Each node has a voltage, and each wire entering a node carries a current. A wire connecting two nodes forces the voltages of those two node to be equal. Analog circuits are governed by Kirchhoff’s current and voltage laws (KCL and KVL). Individual analog devices are characterized by v-i equations, which relate the terminal current(s) of a device to the voltages across those terminals or pins. Passive devices like resistors, capacitors and inductors are governed by linear v-i equations (Ohm’s law), while active devices like diodes and transistors are usually characterized by nonlinear v-i equations.
 
<table>
<tr>
<td>
[[File:b2MAN_Fig212.png|thumb|left|720px|Running a live simulation of an Op-Amp circuit in RF.Spice A/D with circuit animation enabled.]]
</td>
</tr>
</table>
Sources supply your circuit with known voltages or currents. The voltages and currents at all other nodes of your circuit are the unknowns in an analog circuit simulation. Over the past 30 years, the faculty and graduate students at the University of California, Berkeley, have developed extensive computer algorithms for analog circuit simulation. This project, and the resulting computer code, are known as SPICE. [[RF.Spice A/D]] uses the Berkeley SPICE simulation engine (with a number of modifications and enhancements) for all circuit simulations. Since SPICE's algorithms have been in widespread use by the industry for a long period of time, you can be confident in the accuracy of the results you get from [[RF.Spice A/D]]. We have also incorporated major pieces of the XSPICE program from Georgia Institute of Technology. XSPICE expands the Berkeley SPICE by providing for mixed-mode simulation, a code modeling module that makes it easier to add new models, and inter-process communications. Further, we have modified the DC transfer function to allow for more general parameter sweeps, and we have added Monte Carlo simulations and parameterized AC and transient simulations.
SPICE algorithms incorporate the behavior a variety of devices including resistors, capacitors, inductors, mutual inductors, independent voltage and current sources, four types of dependent sources, switches, uniform distributed RC lines, and the five most common semiconductor devices: diodes, BJTs, JFETs, MOSFETS, and MESFETS. [[RF.Spice A/D]] uses the SPICE algorithms and offers the same circuit capabilities. The BSIM3v3.2 model is another piece that we have added to the simulation engine. This was developed by the bsim3 development team at UC Berkeley. SPICE offers default models of the semiconductor devices; however, the desired parameter values need to be specified. Default model [[parameters]] are available when you create a new model in the Device Editor. You can also specify additional device models if the defaults are not adequate. [[Image:Tutorial_icon.png|40px]] '''[[RF.Spice_A/D#Analog_Tutorial_Lessons| RF.Spice A/D Analog Tutorial Lessons Gateway]]''' <table><tr><td> [[File:b2MAN_Fig213.png|thumb|left|720px|Running a transient test of the same Op-Amp circuit as above in RF.Spice A/D.]]</td></tr></table>
== Analog Circuit Analysis Types ==
* Node voltages converge to within a tolerance of 0.1% or 1 microvolt, whichever is larger.
Failure to converge in DC analysis usually results from incorrectly specifying circuit connections, initial values, or model [[parameters]]. Regenerative switching circuits or circuits with positive feedback will often fail to converge unless the OFF option is used for some of the devices in the feedback path. AC frequency sweep analysis performs a nodal admittance solution of your circuit using the "Small-Signal Approximation". Under small-signal assumptions, all the nonlinear active devices of your circuit are replaced with locally linearized behavioral models established about their computed DC bias points.
The following table lists [[RF.Spice]]'s available analog circuit simulation and test types (click on each type to learn more about it):
{| class="wikitable"
! scope="col"| Output Data
|-
| [[Running_Live_Simulations_with_Circuit_Animation Performing Live Simulations with Circuit Animation or Virtual Instruments | Live Simulation]]
| Nonlinear Time-Domain Analysis
| Node Voltages, Branch Currents, Device Powers
| [[Analyzing_Circuits_Using_Predefined_Tests#Network_Analysis | Network Analysis Test]]
| Small-Signal Frequency-Domain Analysis
| Z, Y, H and S [[Parameters]]
|-
|}
== Defining Analog & Mixed-Mode Inputs & Outputs ==
[[Image:Source5.png|thumb|400px|A simple resistive circuit with a voltmeter and ammeter.]][[RF.Spice A/D]] allows both analog and digital stimuli for live simulations. For analog stimuli, you can use the voltage and current sources or the Function Generator or Power Supply in the [[Virtual Instruments]] panel. For a digital stimulus, you can use a digital input, a digital source or a digital clock. In a mixed-mode circuit, you may define both analog and digital stimuli. Note that when you place a voltage or current source in a circuit, Workshop automatically adds a corresponding Function Generator for you.  <table><tr><td> [[Image:Source5.png|thumb|left|480px|A simple resistive circuit with a voltmeter and ammeter.]]</td></tr></table> The transient properties of a voltage source or a current source can be set in the transient page '''Transient''' tab of their property dialogs. This allows you to define a variety waveforms including constant DC, sinusoidal, square wave, exponential, and piecewise linear. A piecewise linear waveform is defined as a table of values vs. time. You can edit this waveform table right form the dialog by clicking the button labeled {{key|Edit Table}} and entering the (time, value) pairs row by row in a text editor. Or you can also import these data from an external text file by clicking the button labeled {{key|Load From File}}. To run an AC-type test of your circuit, you need to define additional parameters in the '''Small-Signal AC and Distortion''' tab of the source's property dialog. You have to check the '''Use''' box and enter values for the '''Amplitude''' and '''Phase''' of your harmonic source. You can also define a '''Small-Signal Offset''' for your source from this dialog. This is particularly useful for settings the bias of active devices.
The voltmeter, ammeter and markers all can be used to probe voltages and currents for analog simulations. You can also probe the circuit using the [[Virtual Instruments]] virtual instruments such as the oscilloscope, voltmeter, ammeter, wattmeter, etc. You can use a digital output or digital probe to observe the state of your digital circuit. Mixed-mode circuits may involve both analog and digital probes. Note that virtual voltmeters and ammeters are added to the virtual instrument panel automatically every time you place a voltmeter or ammeter in your schematic. When you run one of RF.Spice's many test types on your circuit, you will have access to all the computed voltages and currents at all the nodes and branches of your circuit. However, before you run the test, you have to explicitly indicate which quantities you want to compute. This is done in the "Output Results Options" section of the '''Test Panel''', where you can designate one or more preset graph or table plots.
<table>
<tr>
<td> [[Image:Source1.png|thumb|360pxleft|480px|The DC and Transient tab of Voltage Source dialog showing a sinusoidal waveform.]] </td><td> [[Image:Source3.png|thumb|360px|The DC and Transient tab of Voltage Source dialog showing a square wave signal.]] </td>
</tr>
<tr>
<td> [[Image:Source3.png|thumb|left|480px|The DC and Transient tab of Voltage Source dialog showing a square wave signal.]] </td></tr><tr><td> [[Image:Source4.png|thumb|360pxleft|480px|The DC and Transient tab of Voltage Source dialog showing a piecewise linear waveform.]] </td></tr><tr><td> [[Image:Source2.png|thumb|360pxleft|480px|The Small-Signal AC and Distortion tab of Voltage Source dialog showing the AC signal settings.]] </td>
</tr>
</table>
== Setting the Simulation Parameters ==
[[File:Sim_Options1.png|thumb|500px|The SPICE Simulation Options dialog.]][[RF.Spice A/D]] operates based on a large number of numerical simulation [[parameters]] with default values. In most cases, you do note have to worry about setting or changing these values. However, in certain cases, the simulation of your circuit may not converge or hit a singularity. Then you might be able to improve the simulation speed by adjusting certain [[parameters]]. You do this by accessing the '''Simulate > SPICE [[Simulation Options]]...''' menu. The [[Simulation Options]] dialog is divided up into three tabs: Convergence, Mixed-Mode, and Miscellaneous.  <table><tr><td> [[File:Sim_Options1.png|thumb|left|640px|The SPICE Simulation Options dialog.]]</td></tr></table>
===Temperature options===
Temperature options can be found under the Miscellaneous Options tab. To set the operating temperature for the simulation, use temp. Tnom is used to set the temperature at which the model [[parameters]] were measured at. Don’t use this unless you create custom models and you know what temperature you measured their [[parameters]] at.
===Convergence options===
For transient convergence, a number of other options are relevant. itl4 controls the number of iterations in the transient solver at a given timepoint. Increase it to a larger value, e.g. 200, to help with convergence but this may not be enough.
Trtol and chgtol are not tolerance [[parameters]]. Trtol is related to truncation error in the Local Truncation Error timestep control algorithm that is used with the transient simulation. It is related to the timestep during the transient simulation. Chgtol is also used in the LTE algorithm. It's purpose is to prevent the transient from locking up. Both of these should not be used unless you are a spice expert.
Minbreak is the minimum break between timepoints while running a transient simulation. For very sharp transitions, minbreak should be reduced. Breakpoints are inserted by the piecewise linear sources and pulse sources and indicate changes in inputs to the circuit.
Method switches between integration algorithms for calculating capacitor voltages and inductor currents for transient solutions. The possible values are gear for the gear method and trap for the trapezoidal method. The default is trap. Maxord goes along with the gear method and is the maximum order for the multiorder integration method. Higher values of maxord are more accurate but may slow down the simulation.
===Mixed-Mode Circuit Options===
Some options relate to the analog to digital and digital to analog converters that B2.Spice automatically inserts between analog and digital portions of the circuit. The [[parameters]] bb_daOutlow, bb_daOutHigh, bb_adInLow, and bb_adInHigh are for low and high output voltages for D/A converters and for low and high threshold voltages at the input of A/D converters. Bb_daOutX is the indeterminate voltage at the output of the d-to-a converter.
Maxopalter is used in operating point analysis for the maximum alternations between analog and event solutions. Maxevtiter is the maximum number of iterations for event solution. Noopalter prevents the simulator from alternating between analog and event solutions. Ramptime is the transient analysis supply ramping time, but it only seems to be used with xspice models for the capacitor and inductor (rather than the regular spice capacitor and inductor.)
Bypass allows the device calculations to bypass updating values for unchanging elements. I presume that this would speed up the simulation.
Trytocompact is used with [[Transmission Lines|transmission lines]].
Keepopinfo is not used by [[B2RF.Spice A/D]].
For more information on these options, see Inside Spice by Ron Kielkowski published by McGraw Hill.
=== Signal Coverage Options ===
The simulation data directory specifies in which directory temporary data files are written to.
[[Image:Info_icon.png|40px]] Click here for '''[[== A Summary of SPICE Simulation Parameters]]'''== {| class="wikitable"|-! Option Name !! Option Description !! Default Value|-| gmin || Minimum conductance || 1e-12|-| reltol || Relative error tolerance || 0.001|- | itl1 || DC iteration limit || 40|- | itl2 || DC transfer curve iteration limit || 20|- | itl4 || Upper transient iteration limit || 10|- | itl6 || Number of source steps || X|- | gminsteps || Number of Gmin steps || X|- | shunt || Shunt resistance from analog nodes to ground (XSPICE) || X|- | abstol || Absolute error tolerance || 1pA|- | vntol || Voltage error tolerance || 1uV|- | Method || Integration method || trap|- | maxord || Maximum integration order || X|- | max_slope || Maximum slope for exponential function || X|- | smooth_domain|| Smoothing domain - used for unit step and ramp || X|- | solve_delta_x || Solves system for Delta-X, which is near zero, rather than for X|| False|-| bb_daOutLow || Low output voltage for implicit D to A converters (XSPICE) || 0V|-| bb_daOutHigh || High output voltage for implicit D to A converters (XSPICE) || 5V|-| bb_daOutX || Indeterminate output voltage for implicit D to A converters (XSPICE) || 2.5V|-| bb_adInLow || Low Input voltage threshold for implicit A to D converters (XSPICE) || 0.5V|-| bb_adInHigh || High Input voltage threshold for implicit A to D converters (XSPICE) || 4.5V|- | bb_daTLH || Low-To-High delay for implicit D to A converters (Xspice) || 1ns|-| bb_daTHL || High-To-Low delay for implicit D to A converters (Xspice) || 1ns|- | bb_adTLH || Low-To-High delay for implicit A to D converters (Xspice) || 1ns|-| bb_adTHL || High-To-Low delay for implicit A to D converters (Xspice) || 1ns|-| maxopalter || Maximum analog/event alternations in DCOP (XSPICE) || X|- | maxevtiter || Maximum event iterations at analysis point (XSPICE) || X|-| noopalter || Do not do analog/event alternation in DCOP (XSPICE) || X|- | ramptime || Transient analysis supply ramping time (XSPICE) || X|- | convlimit || Enable convergence assistance on code model (XSPICE) || X|-| convstep || Fractional step allowed by code model inputs between iterations (XSPICE) || X|- | convabsstep || Absolute step allowed by code model inputs between iterations (XSPICE) || X|-| autopartial || Use auto-partial computation for all models (XSPICE) || False|-| temp || Operating temperature || 27&deg;C|-| defl || Default MOSFET length || 100um|-| defw || Default MOSFET width || 100um|-| defad || Default MOSFET area of drain || 0m^2|-| defas || Default MOSFET area of source || 0m^2|-| tnom || Nominal temperature || 27&deg;C|-| Noopiter || Go directly to gmin stepping || False|-| minbreak || Minimum time between breakpoints || X|- | trtol || Truncation error overestimation factor || X|-| chgtol || Charge error tolerance || 0.01pC|-| pivtol || Minimum acceptable pivot || X|-| pivrel || Minimum acceptable ratio of pivot || X|-| oldlimit || Use SPICE 2 MOSFET limiting || False|-| bypass || Allow bypass of unchanging elements || X|-| trytocompact || Try compaction for LTRA lines || False|-| badmos3 || Use old mos3 model (discontinuous with respect to kappa) || False|-|}  In the above table, an "X" for the default value means unspecified. The SPICE engine will either ignores this parameter or generate a value for it internally.
== Additional Considerations for a Successful Simulation ==
Simulation Option : ITL5: This sets the maximum number of total iterations. It defaults to 5000. Try increasing it.
Make your circuit more realistic. Most importantly, add junction capacitances on transistors. These are in model [[parameters]] for transistors.
Decrease shunt resistance: Decrease the value of the shunt resistance using Set [[Simulation Options]].
Simulation Option : RELTOL: This is the relative error tolerance. The default is 0.1%. Try increasing it by a factor of 10, to 1.0 %. This is very useful in solving convergence problems due to the small time step of the transient algorithm.
Increase the absolute current tolerance
===Special Notes for the Op Amp===
<p>&nbsp;</p>
[[Image:Tutorial_icon.png|40px]] '''[[RF.Spice_A/D#RF.Spice_A.2FD_Tutorials | RF.Spice A/D Tutorial Gateway]]'''
 
[[Image:Back_icon.png|40px]] '''[[RF.Spice_A/D | Back to RF.Spice A/D Wiki Gateway]]'''
28,333
edits