What is Spice?
SPICE is a general-purpose circuit simulation program for nonlinear dc, nonlinear transient, and linear ac analyses. Circuits may contain resistors, capacitors,
inductors, mutual inductors, independent voltage and current sources, four types of dependent sources, lossless and lossy transmission lines (two separate
implementations), switches, uniform distributed RC lines, and the five most common semiconductor devices: diodes, BJTs, JFETs, MESFETs, and MOSFETs.
How does Spice Work?
Basically, SPICE operates like this:
R circuit *First line is the circuit name, and it is compulsory *The lines that start with star character '*' are comment lines and they are ignored by Spice *V and R reserved characters for voltage source and resistors. *Spice is not case sensitive. The upper-case and lower-case letters are considered same. VS 1 0 dc 10V R1 1 2 5k r2 2 3 6k r3 2 0 4k R4 3 0 9k .tran 0.1 ms 0.1s .END
To launch the ngspice use command ngspice $ ngspice ngspice 1 -> To simulate "simpleR.cir" file use command "aspice" ngspice 1 -> aspice simpleR.cir To see varibles use command "display" ngspice 2 -> display Here are the vectors currently active: Title: R circuit Name: tran1 (Transient Analysis) Date: Thu Jan 29 10:38:41 2009 V(1) : voltage, real, 60 long V(2) : voltage, real, 60 long V(3) : voltage, real, 60 long time : time, real, 60 long [default scale] vs#branch : current, real, 60 long
The most used commands in Ngspice
aspice: Start a Spice run, and when it is finished load the resulting data. display: Prints a summary of currently defined vectors. edit: Print the current Spice input file into a file, call up the editor on that file and allow the user to modify it, and then read it back in, replacing the original file. print: Prints the vector Example: print v(2) plot: Plot the given exprs on the screen Example: plot v(2)-v(3) For more information type "help"
Some useful links
ngspice can be dowloaded from: http://sourceforge.net/project/showfiles.php?group_id=38962
Ngspice manual:
http://newton.ex.ac.uk/teaching/CDHW/Electronics2/userguide/
http://www.seas.upenn.edu/~jan/spice/spice.overview.html
http://bwrc.eecs.berkeley.edu/Classes/IcBook/SPICE/
Hasari Karci
29/01/2009