previous | back | home | next
CACD Group
updated 2000.03.30
Author Janez Puhan

Getting started

Let us consider a simple transistor amplifier shown on figure below.

First we have to describe the circuit in a *.cir file. The circuit netlist can be put together with some schematic editor or it can be written in a text editor. The netlist of the simple amplifier is as follows:

Transistor amplifier

* this is amplifier.cir file
* input node 1
* output node 4
* voltage resources

v0 3 0 dc 10V
v1 1 7 dc 0V ac 1 sin 0 0.1V 10kHz
v2 7 0 dc 0.58V

* bipolar transistors

q1 6 2 5 2n2222
q2 4 6 3 2n2907

* resistors

r1 1 2 1k
r2 5 4 1k
r3 5 0 10

* model for a 2n2222 transistor
.model 2n2222 npn (is=19f bf=150 vaf=100 
+ ikf=0.18 ise=50p ne=2.5 br=7.5
+ var=6.4 ikr=12m isc=8.7p nc=1.2 rb=50 
+ re=0.4 rc=0.3 cje=26p tf=0.5n cjc=11p
+ tr=7n xtb=1.5 kf=0.032f af=1)

* model for a 2n2907 transistor
.model 2n2907 pnp (is=1.1P bf=200 nf=1.2 
+ vaf=50 ikf=0.1 ise=13p ne=1.9 br=6
+ rc=0.6 cje=23p vje=0.85 mje=1.25 tf=0.5n 
+ cjc=19p vjc=0.5 mjc=0.2 tr=34n xtb=1.5)
.end
When the netlist of the circuit is written (in our case the c:\spiceopus\amplifier.cir file) the circuit can be simulated. Run Spice Opus by clicking Start/Programs/Spice Opus/Spice Opus icon. The SPICE OPUS Command window will appear.

Spice Opus is waiting for our first command with prompt:

Spice Opus 1 -> _

First we have to load the netlist of the circuit into SPICE. We can do this with source command:
Spice Opus 1 -> source c:\spice3f4\amplifier.cir
Circuit: transistor amplifier

Spice Opus 2 -> _

We perform a DC, transient and AC analyses with dc, tran and ac command respectively. The voltage source v2 is swept from 0 to 1V in 5mV increments in the dc analysis. A transient analysis from 0 to 200us with a 10kHz sine wave input is performed by tran command. And the input frequency is swept from 1kHz to 10MHz with 25 points per decade in ac analysis:
Spice Opus 2 -> dc v2 0 1V 5mV
Spice Opus 3 -> tran 1us 200us
Spice Opus 4 -> ac dec 25 1kHz 100megHz
Spice Opus 5 -> _

The results are saved in a special data structures called plots. Our three analyses just created three new plots. We can change the current plot with a setplot command. The results of a particular analysis can be plotted by plot command.
Spice Opus 5 -> setplot
        Type the name of the desired plot:

        new      New plot
Current ac1      transistor amplifier (AC analysis)
        tran1    transistor amplifier (Transient analysis)
        dc1      transistor amplifier (DC transfer characteristic)
        const    Constant values (constants)
? dc1
Spice Opus 6 -> plot v(4) xlabel v(2)[V] ylabel Output[V]

Spice Opus 7 -> setplot tran1
Spice Opus 8 -> plot 10*v(1) v(4) xlabel t[s] ylabel '10*Input, Output [V]'

Spice Opus 9 -> setplot ac1
Spice Opus 10 -> _

To plot phase in degrees (not in radians) the units variable has to be set. We can see the discontinuity of the phase when plotted. That occur because Spice Opus calculates phase in an [-180°, 180°] interval.

Spice Opus 10 -> set units = degrees
Spice Opus 11 -> plot vdb(4) vp(4)

Spice Opus 12 -> _

The discontinuity can be eliminated with defining a new vector called phase. The expression for it transfers all positive components for 360°.

Spice Opus 12 -> let phase = vp(4) / 10 - 36 * (vp(4) gt 0)
Spice Opus 13 -> plot vdb(4) phase xlabel f[Hz] ylabel 'Magnitude[dB], Phase[deg]'

Spice Opus 14 -> _

At the end we will delete all plots and free memory with destroy command and leave Spice Opus with quit command.

Spice Opus 14 -> destroy all
Spice Opus 15 -> quit

  Spice-3f4 done
previous | back | home | next