You are on page 1of 21

# 1

## PSpice Subcircuit Tutorial

//Simulation for PSpice 9.2

d(O_o)b

This tutorial will show how to draw subcircuits in PSpice Circuit Simulation Software. A subcircuit is a portion of a circuit. It can be a branch, one or more loops/mesh. In PSpice subcircuit is mainly used to write complex circuits. Consider a circuit so large that it cannot be drawn in a single Schematic window. So several subcircuits are drawn in several window and all of them are, then, collected together in a single window. For the sake of our tutorial we will consider a circuit that has a recurring mesh. We will create a subcircuit of that mesh and draw the circuit with our subcircuit part. Lets begin. Shall we?

Look at the circuit in the next page. This is the circuit that Im going to work with. Now, try to guess how many recurring mesh are there in that circuit.

A Simple Circuit

Well, there are 4 mesh that are recurring (R14 and R15 can be interchanged. And so, if you guessed 3 then that guess is wrong). So we will turn this mesh into a subcircuit. This is where the actual tutorial begins. Buckle up guys. O_O

Step 1: Drawing the subcircuit. Draw the mesh as usual. The mesh should look like this-

Now the two parts that are to be added to the circuit are generally called input/output interface. Their part names are IF_IN and IF_OUT. These parts look like this-

IF_IN:

IF_OUT:

I have added them to the circuit like this (Two of them are input and two of them are output):

You can if you wish make all of them are input or all of them are output or put input and output arbitrarily. They have no effect on the calculation but will have effect on the part symbol (that Ive described in the later part of the tutorial).

Now, on to labeling these interfaces To label them double click on a input/output interface part. And put an arbitrary value/word in the box. Ive labeled them like this:

Now we have finally drawn the subcircuit as it should be. Step 1 is done.

Step 2: Creating the Subcircuit This step requires some clicking in the toolbar. Firs save the *.sch file. I always save subcircuit files in a dedicated location. Give it any name you like. Follow the picture if you like (1>2>3>4 and note the location where you saved it. )-

The next work will be to get the *.sub file. To create it, click on Tools then Create Subcircuit. And you are done. See the picture if you need to

Now in the location where you have saved the *.sch file, you should get a whole bunch of files including a *.sub file. Both of them will have the same but different extensions.

Step 3: Including the Subcircuit in the Library (This step is optional in some versions of PSpice. In my version it isnt needed. So I cant guarantee this process is correct.) Now to do this, you have to add the *.sub file to the library. Click on Analysis then Library and Include Files

## Library and Include Files window should appear.

10

Here, you have to add the file to the library. In the File Name box include the file. I have included along with the location. Like: D:\Subcircuit\Special Subcircuit.sub without the inverted commas and click either Add Library* of Add Library. Add Library* adds the file globally (i.e. Its permanently added to schematics) and Add Library adds the file locally. There is no way to check if the addition was successful or not..

Step 4: Symbolizing the Subcircuit This step is short but important. In this step we will give this subcircuit a model name (that will be used to summon this subcircuit in the schematic window) and add to a library. Click on File then Symbolize then give it a suitable name (In my case I gave it SpSub) and click OK. Look at the picture if you need to:

11

If its done then a new dialogue box should appear where you will be asked to add this part to a library file. Usual practice is to add it to a *.slb file in UserLib directory (Usually C:\Program Files\Orcad\PSpice\UserLib). If there is no file in that directory, just give it an arbitrary name and click Open. Remember the filename should have a slb extension (In my case hyperlib.slb). Look the picture if necessary:

12

## Yay! We have created our Subcircuit successfully. :D

13

Step X: Editing the Symbol Now. The symbol that you have created may need some editing. To edit the symbol click File then Edit Library -

A new window should appear. Here, click on File then Open and open the slb file (hyperlib.slb in my case), that you created, in editing window

14

Now click on Part then Get. In the get window click on the part that you want to edit (SpSub in my case).

15

Once opened you should get a part that look like this:

16

Not, theres not much to edit. Just to show that, IF_IN parts are on the left side of the parts. And IF_OUT parts on the right side. You can move the 101 and 102 wands in the left dotted box. Dont take them outside this box. Otherwise the IF_IN parts will actually get detached from the circuit -_-. In this circuit 101 and 102 are sequentially drawn. You can make them 102 101 sequence too. Now, click Part then Attributes. You should get an attributes window. Here Ive made some changes and they see what affect they have on the symbol:

Look at REFDES=SpSub? line. This ? mark is important. If you put this part in the schematic window this ? mark will be turned into numeric subscript i.e. SpSub1, SpSub2 etc. Im leaving it to this. Play with the other options if you like.

17

Now save the symbol File then Save. (If any dialogue box appears then there are errors in the symbol. Dont save it without correcting the errors). Close the Symbol Window File then Close. And you are done editing.

Call the subcircuit using the name that you used to symbolize it. (SpSub in my case)

Not, lets get back to the main circuit (Page 3). In the next few pages there are several drawings to the main circuit. Look at them one by one and draw it with the subcircuit. If you feel like it, design shorter circuits to play with.

18

Subcircuits are marked in this picture. One is left for the reader.

19

20

## Circuit Drawn with the help of Subcircuit

21

This tutorial is prepared by Tariqul Islam. And distribute it as you like. I dont care.

d(O_o)b