Circuit Simulation

Home... Introduction... My Interests... Favorite Links

Berkeley SPICE is a software package to simulate the operation of electronic devices, and one version of it is available at no charge from WinSpice. This version is designed for Windows but can be made to run on Linux using WINE. Spice Opus is another, similar program also available for both operating systems. Below WinSpice is being used to simulate the operation of a Colpitts oscillator. At the left is a schematic diagram of the circuit with the nodes numbered, and at the right is the output obtained from the program. The simulation file itself is plain text which conforms to certain rules of syntax, and can be composed with any text editor.

Colpitts oscillator
v1 1 0 dc 10v
r1 1 2 1k
l1 2 3 1uh
c1 2 0 10nf
c2 3 0 10nf
q4 2 3 0 qnl
.model qnl npn

The nodes are numbered as in the schematic at the left. Node numbers are arbitrary, except that the ground is always designated as "0". SPICE statements are not case-sensitive. Voltage sources always begin with "v," resistors with "r," capacitors with "c," and BJT's with "q." The latter, as a non-linear device, needs a model specification; in this case, all the defaults are selected. The node numbers for a triode transistor correspond, in the following order, to: collector, base, emitter.

After the program starts, the first step is to tell it where to find your file:

Spice Opus 1 -> source c:\circuits\colpitts.cir
Circuit: colpitts oscillator

(By displaying its title, this statement indicates that the file has been loaded.)

Spice Opus 2 -> tran 1us 6us

This calls for a plot of voltage as a function of time, from 1us to 6us.

Spice Opus 3 -> setplot You are now presented with the plots that are available for your analysis. In this case only the transient analysis is available and I select it. The final step is to specify the names and ranges of the variables:

Spice Opus 4 -> plot v(2) xlabel t[us] ylabel 'Output'

This calls for the plot of the voltage at node 2 as a function of time; the x-axis is to be labeled with 't[us]' and the vertical scale as 'Output.'

If you'd rather submit the instructions for the analysis in batch mode, the following lines can be inserted into the control file between the title and the first component specification:

tran 1us 6us
plot v(2) xlabel t[us] ylabel 'Output'

The graph of the output waveform(s) will then appear immediately, with no prompting of the user for additional input.