Circuit simulation with Gnucap

Gnucap (GNU Circuit Analysis Package) is a free and open-source circuit simulator. The syntax is very similar to SPICE - and circuit descriptions written for Gnucap might in fact work with SPICE with very little modification.

A lot of students (and probably working engineers as well) are familiar with programs such as OrCAD, PSPICE, etc., which use SPICE as a circuit simulator in the background. What these programs actually do is generate a SPICE netlist - similar to the one shown below.

* Voltage clipper
Vin 1 0 sin(0 3 5)
R1 1 2 100
D1 2 3 diode
V1 3 0 dc 1
D1 0 4 diode
V2 4 2 dc 1
.model diode D
 
.print tran v(2)
.tran 0 1 1m >clipper.dat
.end

(This circuit description was actually written for Gnucap - but the syntax is almost the same as Spice.)

If you don't have a fancy front-end (such as OrCAD), you can run this simulation by saving this file as 'clipper.cir' and typing:
gnucap -b clipper.cir
on the command line.

The output can be viewed with a waveform viewer such as gwave:
gwave clipper.dat

Various examples of SPICE & Gnucap circuit descriptions can be found in my Git repository at http://designtrail.net/repo/electronics/ .
The circuits can all be simulated by a command similar to the above:
gnucap -b circuit.cir
(Replace "circuit.cir" with the name of the file.)

Tags: