Tutorial: Designing a Circuit with Spice Components
Learn how to design a circuit with a Band Pass Filter using Spice components.
Attention: Available only with Twin Activate commercial edition.
Files for This Tutorial
aop.lib; Band pass filter.scm, Filter.scm; opnon.cir*
* The file opnon.cir is a
non-inverting amplifier model provided for you with permission from the eCircuit
Center http://www.ecircuitcenter.com/Circuits/opmodel1/opmodel2.htm. In lieu of downloading the file, you can copy
the following code as required in the steps of the
tutorial.
OPNON.CIR - OPAMP NON-INVERTING AMPLIFIER
*
VS 1 0 AC 1 PWL(0US 0V 0.1US 1V)
*
R1 2 0 10K
R2 2 4 10K
XOP 1 2 4 OPAMP1
*
* OPAMP MACRO MODEL, SINGLE-POLE
* connections: non-inverting input
* | inverting input
* | | output
* | | |
.SUBCKT OPAMP1 1 2 6
* INPUT IMPEDANCE
RIN 1 2 10MEG
* DC GAIN (100K) AND POLE 1 (10HZ)
EGAIN 3 0 1 2 100K
RP1 3 4 1K
CP1 4 0 15.915UF
* OUTPUT BUFFER AND RESISTANCE
EBUFFER 5 0 4 0 1
ROUT 5 6 10
.ENDS
*
* ANALYSIS
.TRAN 0.1US 10US
*.AC DEC 5 1K 10MEG
*
* VIEW RESULTS
.PROBE
.END
Overview of the Spice Circuit Model
In this tutorial, you will construct a circuit out of blocks from the HyperSpice palette.
Create a Model with a Spice Custom Block
Add a SpiceCustomblock and Scope block to you model.
- Create a new model and save it with the file name Filter.scm.
- From the SpiceCustomBlock into your diagram and double-click it. , drag one
-
From the Parameters tab, select the SPICE Netlist button.
The Spice Netlist Editor appears. -
Copy the code from the opnon.cir file and paste it into
the Spice Netlist Editor.
- Click OK.
-
From the Parameters tab, select the button to define the Selected
voltage outputs.
The Select voltage output ports dialog appears.
-
From the list of Available Channels, double-click
4.
-
Click OK.
Note: You do not need to define the input as the stimulus is already defined in the Spice netlist that you entered.
- From the Palette Browser, select .
-
Drag one Scope block into your diagram and connect it to
the output of the SpiceCustomBlock.
This portion of the model is ready to run and test.
- From the Run tool, select Setup .
- Select the Simulation Time tab.
- For Final Time, enter 10e-5 seconds.
-
Click Run
.
Double-click the Scope block in the model. The plot should look something like this:
Create a Spice Model from a Modelica Model
Create a circuit with components from the HyperSpice palette. Base your model on the Modelica example that is provided.
-
From the Demo Browser, select BandPassFilter.scm
The BPF model constructed from Modelica blocks appears.
-
Beginning with the Filter.scm model you started, construct
a Spice version of the circuit model using the blocks from the HyperSpice
palette.
To create these components in your model Include these blocks from the Spice palette Voltage and current stimulus Voltage Constant; Voltage Pulse; Voltage SIN Linear components Resistor; Capacitor; Inductor Voltage and current constant sources Include blocks as required for your model. Semiconductor components Diode; BJTNPN; BJTPNP; Mos1N; Mos1P; Mos2P; Mos2N; Mos3N; Mos3P Sub circuits Include blocks as required for your model. Cable or S-parameter functions Include blocks as required for your model. Refer to the Extended Definitions to define the blocks.
Complete the Spice Model
Add an xinst block to your model and reference the block through a Spice.lib file.
- From the xinst block into the current diagram. , drag one
-
With a text editor of your choice, create a text file with the following code
and save the file as aop.lib.
.subckt opampideal 2 1 3 G1 0 3 2 1 100000000 R3 3 0 1 C3 3 0 636e-6 .ENDS
Note: In this tutorial example, the aop.lib file references the xinst block in your model through the.subckt
(sub circuit) description. Alternatively, you can use the.model
description to reference the block. -
In your model, double-click the xinst block and define
it as follows:
For this parameter Enter this value Instance Model name or subckt instance name opampideal Input ports number 2 Output ports number 1 Keep the defaults for any remaining parameters. - Click OK.
-
From the include block into the current
diagram, then double-click the block.
, drag one The include block must reside in the diagram, but does not require a connection to the blocks in the diagram.
- For File name to include, enter: aop.lib. Keep the defaults for any remaining parameters.
-
Because three operational amplifiers are required for your model, three include
blocks are also required. To duplicate the current include block, select it and
press Ctrl+D two times.
Your final model should look something like this:
Simulating the Diagram
- From the Run tool, select Setup .
- Select the Simulation Time tab.
-
For Final Time, enter 10 seconds.
Your model is ready to test.
-
Click Run
.
To view the transient results, double-click the Scope block in the model. The plot should look something like this: