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 Activate commercial edition.

Files for This Tutorial

aop.lib; BandPassFilter.scm, filter.scm; OP_NON.cir*

A finished version of the models you build in the tutorials along with any files required to complete the tutorials are available at this location: <installation_directory>/tutorial_models/.
* The file OP_NON.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.

  1. Create a new model and save it with the file name Filter.scm.
  2. From the Palette Browser > Activate > CustomBlocks, drag one SpiceCustomBlock into your diagram and double-click it.
  3. From the Parameters tab, select the SPICE Netlist button.


    The Spice Netlist Editor appears.
  4. Copy the code from the OP_NON.cir file and paste it into the Spice Netlist Editor.


  5. Click OK.
  6. From the Parameters tab, select the button to define the Selected voltage outputs.
    The Select voltage output ports dialog appears.
  7. From the list of Available Channels, double-click 4.
  8. Click OK.
    Note: You do not need to define the input as the stimulus is already defined in the Spice netlist that you entered.
  9. From the Palette Browser, select Activate > SignalViewers.
  10. 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.
  11. From the Run tool, select Setup .
  12. Select the Simulation Time tab.
  13. For Final Time, enter 10e-6 seconds.
  14. 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.

  1. From the Demo Browser, select BandPassFilter.scm
    The BPF model constructed from Modelica blocks appears.


  2. 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 HyperSpice 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.

  1. From the Palette Browser > HyperSpice > Analog > Basic, drag one xinst block into the current diagram.
  2. 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.
  3. 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.
  4. Click OK.
  5. From the Palette Browser > HyperSpice > Analog > Basic, drag one include block into the current diagram, then double-click the block.
    The include block must reside in the diagram, but does not require a connection to the blocks in the diagram.
  6. For File name to include, enter: aop.lib. Keep the defaults for any remaining parameters.
  7. 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

  1. From the Run tool, select Setup .
  2. Select the Simulation Time tab.
  3. For Final Time, enter 10 seconds.

    Your model is ready to test.

  4. Click Run .
    To view the transient results, double-click the Scope block in the model. The plot should look something like this: