In response to popular demand for opamp models that could be used for ngspice and gnucap simulation, here are three.
These models work with any gEDA opamp symbol that has a pinout compatible with the defacto industry standard for SPICE opamp models:
"opamp-1" and "opamp-2" in the "Basic devices" section of the standard gschem library are suitable. They conform to this standard.
"opbw" is a model representing an idealized opamp with unity gain bandwidth of about 160 kHz, and unlimited DC gain.
"opgain" is a model representing an idealized opamp with gain of 1000 and unlimited bandwidth.
"opmediocre" simulates a mediocre bipolar opamp. It also has a unity gain bandwidth around 160 kHz, but having the basic internal structure of a simple opamp, it suffers from the usual physical limitations: slew rate, crossover distortion, limited phase margin, input bias current, etc.
To use, attach a model-name attribute (e.g. model-name=opmediocre) to the opamp symbol in your circuit, and arrange to include the subcircuit file above in your simulation. If you don't understand this, see optest.sch and Makefile in the downloadable project below for one way to accomplish it.
You can download the development project that I used to create this library. Once you've downloaded it, try the following:
tar xzf opamp.tar.gz cd opamp make test
You should see a bunch of gnetlist and ngspice spewage followed by an ngspice prompt ("ngspice 1 ->"). The "make test" command builds the subcircuit library (unless it already exists), makes the SPICE circuit file for the test simulation (unless it already exists), and invokes ngspice on that file. Look at the Makefile if you want to know how this happens: it's pretty simple.The circuit is already set up for small signal AC analysis, so you can type
run plot abs(m) abs(b) plot phase(m) phase(b)to compare gain and phase response of the opbw (output netname=b) and opmediocre (output netname=m) models in a unity-gain buffer circuit. Note the gain "peaking" due the the extra (more realistic) phase shift in the opmediocre model.
Although AC is set up, you're not limited to that. Type
tran 100n 100u plot m bTo see transient response. The opbw buffer circuit is pretty clean, but the opmediocre circuit shows slew rate limiting and ringing.
Look at the schematics and the Makefile for more information.
I think this is a good example of a very simple gEDA simulation project. Even on this scale, the Makefile is helpful. Bigger projects need more elaborate Makefiles, but the productivity gain is greater.
Copyright 2010, all rights reserved unless specified otherwise.
gedasymbols.org is maintained by DJ Delorie