Module 21 - Circuit Simulation
Module 21 - Circuit Simulation
Software, documentation and related materials: Copyright 2008 Altium Limited. All rights reserved. You are permitted to print this document provided that (1) the use of such is for personal use only and will not be copied or posted on any network computer or broadcast in any media, and (2) no modifications of the document is made. Unauthorized duplication, in whole or part, of this document by any means, mechanical or electronic, including translation into another language, except for brief excerpts in published reviews, is prohibited without the express written permission of Altium Limited. Unauthorized duplication of this work may also be prohibited by local statute. Violators may be subject to both criminal and civil penalties, including fines and/or imprisonment. Altium, Altium Designer, Board Insight, Design Explorer, DXP, LiveDesign, NanoBoard, NanoTalk, P-CAD, SimCode, Situs, TASKING, and Topological Autorouting and their respective logos are trademarks or registered trademarks of Altium Limited or its subsidiaries. All other registered or unregistered trademarks referenced herein are the property of their respective owners and no trademark rights to the same are claimed. Module Seq = 21
21.1.1.1
These are predefined analog device models that are built-in to SPICE. They cover the various common analog component types, such as resistors, capacitors and inductors, as well as voltage and current sources, transmission lines and switches. The five most common semiconductor devices are also modeled - diodes, BJTs, JFETs, MESFETs and MOSFETs. A large number of model files (*.mdl) are also included, that define the behavior of specific instances of these devices.
21.1.1.2
These are predefined analog device models that are built-in to PSpice. To support these models, changes have been made to the general form for the corresponding SPICE3f5 device and/or additional parameter support has been added for use in a linked model file.
Note: These models are not listed separately in this reference. PSpice support information is included as part of the information for the relevant SPICE3f5 device model.
21.1.1.3
These are predefined analog device code models that are built-in to XSpice. Code models allow the specification of complex, non-ideal device characteristics, without the need to develop longwinded sub-circuit definitions that can adversely affect Simulator speed performance. The supplied models cover special functions such as gain, hysteresis, voltage and current limiting and definitions of sdomain transfer functions. The SPICE prefix for these models is A.
21.1.1.4
Sub-Circuit models
These are models for more complex devices, such as operational amplifiers, timers, crystals, etc, that have been described using the hierarchical sub-circuit syntax. A sub-circuit consists of SPICE elements that are defined and referenced in a fashion similar to device models. There is no limit on the size or complexity of sub-circuits and sub-circuits can call other subcircuits. Each sub-circuit is defined in a sub-circuit file (*.ckt). The SPICE prefix for theses models is X.
21 - 1
21.1.1.5
Digital models
These are digital device models that have been created using the Digital SimCode language. This is a special descriptive language that allows digital devices to be simulated using an extended version of the event-driven XSpice. It is a form of the standard XSpice code model. Source SimCode model definitions are stored in an ASCII text file (*.txt). Compiled SimCode models are stored in a compiled model file (*.scb). Multiple device models can be placed in the same file, with each reference by means of a special "func=" parameter. The SPICE prefix for theses models is A. Digital SimCode is a proprietary language - devices created with it are not compatible with other simulators, nor are digital components created for other simulators compatible with the Altium Designer-based mixed-signal Simulator.
21.1.2
Exercise/Demo
1. Select File New PCB Project from the menus. 2. Rename the new project file (with a .PrjPCB extension) by selecting File Save Project As. Navigate to a location where you would like to store the project on your hard disk, type the name Filter.PrjPCB in the File Name field and click on Save. 3. Select File New Schematic. A blank schematic sheet named sheet1.SchDoc displays in the design window of the Schematic Editor and the schematic sheet is now listed under Source Documents beneath the project name in the Projects panel. 4. Rename the new schematic file by selecting File Save As. 5. Now we can create the Filter circuit shown below in figure 86. Before we can run a simulation, the schematic must contain components with SIM models attached, voltage sources to power the filter, an excitation source, a ground reference for the simulations and some net labels on the points of the circuit where we wish to view waveforms. Note: This project is available in the Altium Designer circuit simulation examples.
21 - 2
Note: The Altium simulator supports Spice 3F5 models and PSPICE models. SPICE models used for circuit simulation (.ckt and .mdl files) are located within the integrated libraries in the C:\Program Files\Altium Designer Summer 08\Library folder. You must use the correct file extension for each model type. Tip: A circuit for simulation must always have a path to ground. If it doesnt youll receive iteration limit reached error. To fix this provide a path to ground or modified the advanced options value for RSHUNT to a figure of around 2-4Meg. Remember that the simulator assumes Capacitors are perfect, i.e. no leakage. 6. Click on the Search button in the Libraries panel. 7. To search for all LF411 type components, in all supplied libraries, enter LF411 in the upper part of the Libraries Search dialog. Set the Scope to Libraries on Path, and set the Path to C:\Program Files\Altium Designer Summer 08\Library, with the Include Subdirectories option enabled. Note that this will find all LF411 type components, you can check if the chosen component includes a Spice model by selecting it in the Libraries panel, and noting if there is a simulation model detailed in the Model Name region of the panel. Note: to search for only components that include a simulation model, you would have used the search string (Name like '*LF411*') and HasModel('SIM','*',true) 8. You may want to use a simulation model in your design other than the one already supplied with the component in its integrated library. If you download a model file from a manufacturers website, it is recommended that you copy it into your designs project folder. For the sake of this example, we will remove and re-add the SPICE model, LF411C.ckt. 9. Copy LF411C.ckt and paste this file into the folder where your project files reside using windows Explorer. If you have created the circuit from scratch, there is a copy of the model file in C:\Program Files\Altium Designer Summer 08\Examples\Circuit Simulation\Filter. 10. Add the model file to the project by selecting the project name (Filter.PrjPCB) in the Projects panel, right-click and select Add Existing to Project. Choose the model file and click Open.
21 - 3
11. Double-click on the op amp to open its Component Properties dialog. Delete the existing SIM model in the Models section by selecting it and clicking on Remove and confirming the deletion. 12. Click on Add in the Models section to display the Add New Model dialog. 13. Select Simulation from the Model Type drop-down list and click OK. The SIM ModelGeneral/Generic Editor dialog displays. 14. Select Spice Subcircuit from the Model Sub-Kind list, the Spice Prefix will automatically set to X. Note that the dialog name has changed to reflect the Model Sub-Kind. 15. Click the Browse button to open the Browse Libraries dialog. Because you have added the model file to the project it will automatically be available, select the LF411C.ckt model from the list and click OK to close the dialog. Note: The Model Name detailed in the Model Kind tab is not the name of the file, it is actually matched against the name found in the .SUBCKT statement in the model file. CKT files can contain multiple .SUBCKT sections so be careful the correct name is specified. 16. The final step is to configure the pin mapping from the model to the schematic symbol (generic numbering is used in Spice model files, not physical pin numbers). Click on the Port Map tab of the SIM Model-General / Spice Subcircuit dialog to show the current mapping, and the Model File tab to show the generic numbers used in the .SUBCKT statement in the model file.
17. Modify the Model Pin mapping by selecting the matching pins from the Model Pin drop-down lists, as shown in Figure 2. Close the dialogs when finished.
21 - 4
4. Now place the VSS power source, remembering to set the model file parameter Value to 5V. 5. Finally add the Sinusoidal (excitation) Voltage Source, VSIN, also available from the Simulation Sources. IntLib. Press TAB to edit its properties before placing and change the
21 - 5
frequency from 1 KHz to 50 KHz for this example. In the Component Properties dialog, clock on the SIM model VSIN in the models list and click on Edit. 6. Click on the Parameters tab to set up the voltage value required. Type in the parameter values as shown in the Sim Model-Voltage Source / Sinusoidal dialog.
7. Save your schematic. Note: Using values like 4k7 for a resistor or 5v5 does not work in Altium Designer. The values must be 4.7k and 5.5v respectively to function correctly.
21 - 6
4. Each individual analysis type is configured on a separate page of the Analyses Setup dialog. Click on the analysis name to activate the corresponding setup page.
21 - 7
2. Check that the Use Transient Defaults option is disabled, so that the Transient Analysis parameters can be modified. 3. To specify a 60u simulation window, set the Transient Stop Time field to 60u. 4. Now set the Transient Step Time field to 100n, indicating that the simulation should calculate a point every 100ns. 5. During simulation, the actual time step is varied automatically to achieve convergence and the required accuracy. The Maximum Step field limits the variation of the timestep size, so set the Transient Max Step Time to 200n.
21 - 8
2. Enter the parameter values as shown above. 3. When this analysis is run, an Operating Point analysis is run first to determine the DC bias of the circuit. The signal source is then replaced with a fixed amplitude sine wave generator and the circuit is analyzed over the specified frequency range, stepping in increments defined by the values in the Test Points and Sweep Type fields.
21 - 9
21.1.7
You are now ready to run the enabled analyses. Note that you can also run a simulation without entering the Analyses Setup dialog every time by clicking on the Run Simulation button on the Mixed Sim toolbar. 1. Click the OK button at the bottom of the Analyses Setup dialog to run the simulation. 2. If there are no errors in the circuit, a SPICE netlist (*.nsx) is created and passed to the simulator. Note that the netlist will be regenerated each time a simulation is run. 3. The simulation begins and a simulation data file (*.sdf) will open. The results of each analysis are shown as a separate chart in the SimData Editors Waveform Analysis window. The Operating Point analysis is performed first to determine the DC bias of the circuit. 4. When the simulation is finished, you should see outputs waveform.
21.1.7.1
A Bode plot consists of two curves- the log of gain and phase-as functions of the log of frequency. The gain is decibels (dB) and the phase are plotted linearly along the y axis on a chart that has several cycles of a log scale on the x axis. Each cycle represents a factor of ten in frequency. We can create a Bode plot using the waveform functions available in the Edit Waveform dialog. 1. In the AC Analysis tab of the Waveform Analyzer window, we will display dB(in), dB(out), PHASE(in) and PHASE(out). 2. In the Waveform Analyzer window, click on net in. Right-click on the selected net and select Edit Wave (or select Wave Edit Wave). The Edit Waveform dialog displays. The selected wave appears in the Expression field. 3. Select the function from the Complex Functions list, i.e. Magnitude (dB). Click on Create to see the waveform dB(net_name) on the plot. 4. To create dB(out), right-click on the plot and select Add Wave to Plot. The Add Wave to Plot dialog displays which works in the same way as the Edit Waveform dialog. 5. Repeat step 4 to create PHASE(in) and PHASE(out) on the second plot by selecting the Phase(Deg) complex function in the Add Wave to Plot dialog.
21 - 10
6. These waveforms could be displayed on different Y axes, if required, by selecting Add to new Y axis in the Edit Waveform dialog. Note that if you remove the new Y axis, all waves that are plotted to this axis are removed as well as any measurement cursors attached to these waves. There is no Undo functionality. If you added a new Y axis, it would appear as shown below.
21.1.7.2
Now we can determine the 3dB point using the measurement cursors. 1. Click on the net name DB(out) to select the wave in the Waveform Analyzer window. 2. Right-click and select Cursor A. Position cursor A in the low pass section by dragging the marker. 3. Right-click and select Cursor B. Position cursor B at a point such that B-A=-3 in the Measurement section of the Sim Data panel. 4. Read off the X value of cursor B in the Measurement Cursors section of the Sim Data panel and you will find the 3dB point = 20kHz.
21 - 11
21 - 12
7. Click OK to run the simulation. Each primary sweep appears as a waveform with the notation<net_name_P<sweep_number>, e.g. out_p01, in a new plot in the AC Analysis and Transient Analysis tabs of the Waveform Analyzer window. 8. Click on a sweep parameter name to display more information, e.g. clicking out_po1 displays the sweep information underneath the plot.
21 - 13
To change the value of a SPICE option, e.g. the iteration value for ITL1: 1. Select the variable, e.g. ITL1. Type in the new value in the Value field, or choose the value by clicking on the scroll arrows that appear. 2. Press Enter, or click in another field, and the Default (Def) option is then disabled.
Note: You could also choose a different integration method from this page, for example, if you have a circuit design with unexpected high frequency oscillations, you could change the standard integration method from Trapezoidal to Gear. The Trapezoidal method is relatively fast and accurate, but tends to oscillate under certain conditions. The Gear methods require longer simulation times but tend to be more stable. Theoretically, the higher the Gear order, the more accurate the results but the simulation time increases
21 - 14
21 - 15