Tuesday, September 15, 2009

The spice must flow

Sometimes you have analog problems, and unfortunately not every analog problem can be solved digitally in the Z-Domain. Therefore analog analysis tools like spice are useful when designing complex circuits.

If you want a book on spice I liked SPICE by Roberts and Sedra which you can get at Amazon.

Otherwise there is some good online documentation available.
ngspice manual
Spice3 User Manual

If you like the gEDA tool set you will love easy-spice. Personally, I think gschem needs some work before I can use it regularly. The main problems are that the drag and drop interface for manipulating nets is awkward and annoying to use and editing the values and attributes of components takes way too many steps.

gspiceui looks interesting but relies on Gwave for graphing waveforms. Unfortunately the version of Gwaves that comes with ubuntu is broken and painful to use.

So, the best bet seems to be editing the netlist with a text editor and running ngspice by hand, but at some point I should probably build the gEDA tools from source to see if they are any more usable.

Example Inverting 2:1 inverting opamp.cir

ngspice -b opamp.cir

Op Amp Example
* ASCII Output setup
.opt nopage
.width in=72
.width out=80
* Ground is node 0
* Inverting Amplifier with Pseudo-Ideal Opamp
* Eopamp [Vout node] [Vin node] [V+ node] [V- node] [Gain]
Eopamp 1 0 0 2 1e6
* R# [input node] [output node] [value]
R1 3 2 5k
R2 2 1 10K
Rload 1 0 100
* Vi [V+ node] [V- node] DC [DC voltage] SIN ( [V0] [Va] [f] [delay] [damping]
Vi 3 0 SIN ( 0V 1V 10Hz 0 0 )
.op * Operating point analysis
.control * Execute these statements as commands after loading simulation
set hcopydevtype=postscript
set hcopyfont=DejaVuSans-Bold-ISOLatin1
set hcopyfontsize=32
set hcopypscolor=true
set color0=rgb:f/f/f * background color
set color1=rgb:0/0/0 * foreground color
* transient response
* tran [step] [stop] [start] [max step]
tran 0.250u 0.200 0.00 0.100u
plot tran v(1) v(3) * plot the transient response of the input and output
hardcopy opamp.ps v(1) v(3) * output plot to postscript
.endc * end control commands
.end * the end...

No comments: