## Subscribe

Skin Design:
Free Blogger Skins

## Saturday, September 6, 2008

### Example circuits and netlists USING THE SPICE CIRCUIT SIMULATION PROGRAM

The following circuits are pre-tested netlists for SPICE 2g6, complete with short descriptions when necessary. Feel free to "copy" and "paste" any of the netlists to your own SPICE source file for analysis and/or modification. My goal here is twofold: to give practical examples of SPICE netlist design to further understanding of SPICE netlist syntax, and to show how simple and compact SPICE netlists can be in analyzing simple circuits.

All output listings for these examples have been "trimmed" of extraneous information, giving you the most succinct presentation of the SPICE output as possible. I do this primarily to save space on this document. Typical SPICE outputs contain lots of headers and summary information not necessarily germane to the task at hand. So don't be surprised when you run a simulation on your own and find that the output doesn't exactly look like what I have shown here!

### Multiple-source DC resistor network, part 1

Without a .dc card and a .print or .plot card, the output for this netlist will only display voltages for nodes 1, 2, and 3 (with reference to node 0, of course).

Netlist:

`Multiple dc sourcesv1 1 0 dc 24v2 3 0 dc 15r1 1 2 10kr2 2 3 8.1kr3 2 0 4.7k.end`

Output:

`node    voltage    node     voltage   node    voltage(  1)   24.0000    (  2)    9.7470    (  3)   15.0000`

`voltage source currentsname       currentv1       -1.425E-03v2       -6.485E-04`

`total power dissipation   4.39E-02  watts`

### Multiple-source DC resistor network, part 2

By adding a .dc analysis card and specifying source V1 from 24 volts to 24 volts in 1 step (in other words, 24 volts steady), we can use the .print card analysis to print out voltages between any two points we desire. Oddly enough, when the .dc analysis option is invoked, the default voltage printouts for each node (to ground) disappears, so we end up having to explicitly specify them in the .print card to see them at all.

Netlist:

`Multiple dc sourcesv1 1 0v2 3 0 15r1 1 2 10kr2 2 3 8.1kr3 2 0 4.7k.dc v1 24 24 1.print dc v(1) v(2) v(3) v(1,2) v(2,3).end`

Output:

`v1           v(1)        v(2)        v(3)        v(1,2)      v(2,3)2.400E+01    2.400E+01   9.747E+00   1.500E+01   1.425E+01  -5.253E+00`

### RC time-constant circuit

For DC analysis, the initial conditions of any reactive component (C or L) must be specified (voltage for capacitors, current for inductors). This is provided by the last data field of each capacitor card (ic=0). To perform a DC analysis, the .tran ("transient") analysis option must be specified, with the first data field specifying time increment in seconds, the second specifying total analysis timespan in seconds, and the "uic" telling it to "use initial conditions" when analyzing.

Netlist:

`RC time delay circuitv1 1 0 dc 10c1 1 2 47u ic=0c2 1 2 22u ic=0r1 2 0 3.3k.tran .05 1 uic.print tran v(1,2).end`

Output:

`time          v(1,2)        0.000E+00     7.701E-065.000E-02     1.967E+001.000E-01     3.551E+001.500E-01     4.824E+002.000E-01     5.844E+002.500E-01     6.664E+003.000E-01     7.322E+003.500E-01     7.851E+004.000E-01     8.274E+004.500E-01     8.615E+005.000E-01     8.888E+005.500E-01     9.107E+006.000E-01     9.283E+006.500E-01     9.425E+007.000E-01     9.538E+007.500E-01     9.629E+008.000E-01     9.702E+008.500E-01     9.761E+009.000E-01     9.808E+009.500E-01     9.846E+001.000E+00     9.877E+00`

### Plotting and analyzing a simple AC sinewave voltage

This exercise does show the proper setup for plotting instantaneous values of a sine-wave voltage source with the .plot function (as a transient analysis). Not surprisingly, the Fourier analysis in this deck also requires the .tran (transient) analysis option to be specified over a suitable time range. The time range in this particular deck allows for a Fourier analysis with rather poor accuracy. The more cycles of the fundamental frequency that the transient analysis is performed over, the more precise the Fourier analysis will be. This is not a quirk of SPICE, but rather a basic principle of waveforms.

Netlist:

`v1 1 0 sin(0 15 60 0 0)rload 1 0 10k* change tran card to the following for better Fourier precision* .tran 1m 30m .01m     and include .options card:* .options itl5=30000.tran 1m 30m.plot tran v(1).four 60 v(1).end`

Output:

`time      v(1)     -2.000E+01  -1.000E+01    0.000E+00    1.000E+01- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.000E+00  0.000E+00 .         .             *             .       .1.000E-03  5.487E+00 .         .             .       *     .       .2.000E-03  1.025E+01 .         .             .             *       .3.000E-03  1.350E+01 .         .             .             .    *  .4.000E-03  1.488E+01 .         .             .             .      *.5.000E-03  1.425E+01 .         .             .             .     * .6.000E-03  1.150E+01 .         .             .             . *     .7.000E-03  7.184E+00 .         .             .         *   .       .8.000E-03  1.879E+00 .         .             .  *          .       .9.000E-03 -3.714E+00 .         .        *    .             .       .1.000E-02 -8.762E+00 .         . *           .             .       .1.100E-02 -1.265E+01 .     *   .             .             .       .1.200E-02 -1.466E+01 .  *      .             .             .       .1.300E-02 -1.465E+01 .  *      .             .             .       .1.400E-02 -1.265E+01 .     *   .             .             .       .1.500E-02 -8.769E+00 .         . *           .             .       .1.600E-02 -3.709E+00 .         .        *    .             .       .1.700E-02  1.876E+00 .         .             .  *          .       .1.800E-02  7.191E+00 .         .             .         *   .       .1.900E-02  1.149E+01 .         .             .             . *     .2.000E-02  1.425E+01 .         .             .             .     * .2.100E-02  1.489E+01 .         .             .             .      *.2.200E-02  1.349E+01 .         .             .             .    *  .2.300E-02  1.026E+01 .         .             .             *       .2.400E-02  5.491E+00 .         .             .       *     .       .2.500E-02  1.553E-03 .         .             *             .       .2.600E-02 -5.514E+00 .         .     *       .             .       .2.700E-02 -1.022E+01 .         *             .             .       .2.800E-02 -1.349E+01 .    *    .             .             .       .2.900E-02 -1.495E+01 .  *      .             .             .       .3.000E-02 -1.427E+01 .   *     .             .             .       .- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`

` fourier components of transient response v(1)  dc component =  -1.885E-03harmonic   frequency    fourier    normalized    phase     normalizedno            (hz)     component    component    (deg)    phase (deg)1          6.000E+01   1.494E+01     1.000000   -71.998       0.0002          1.200E+02   1.886E-02     0.001262   -50.162      21.8363          1.800E+02   1.346E-03     0.000090   102.674     174.6714          2.400E+02   1.799E-02     0.001204   -10.866      61.1325          3.000E+02   3.604E-03     0.000241   160.923     232.9216          3.600E+02   5.642E-03     0.000378  -176.247    -104.2507          4.200E+02   2.095E-03     0.000140   122.661     194.6588          4.800E+02   4.574E-03     0.000306  -143.754     -71.7579          5.400E+02   4.896E-03     0.000328  -129.418     -57.420total harmonic distortion =      0.186350  percent`

### Simple AC resistor-capacitor circuit

The .ac card specifies the points of ac analysis from 60Hz to 60Hz, at a single point. This card, of course, is a bit more useful for multi-frequency analysis, where a range of frequencies can be analyzed in steps. The .print card outputs the AC voltage between nodes 1 and 2, and the AC voltage between node 2 and ground.

Netlist:

`Demo of a simple AC circuitv1 1 0 ac 12 sinr1 1 2 30c1 2 0 100u.ac lin 1 60 60.print ac v(1,2) v(2).end`

Output:

`freq          v(1,2)      v(2)      6.000E+01     8.990E+00   7.949E+00`

### Low-pass filter

This low-pass filter blocks AC and passes DC to the Rload resistor. Typical of a filter used to suppress ripple from a rectifier circuit, it actually has a resonant frequency, technically making it a band-pass filter. However, it works well anyway to pass DC and block the high-frequency harmonics generated by the AC-to-DC rectification process. Its performance is measured with an AC source sweeping from 500 Hz to 15 kHz. If desired, the .print card can be substituted or supplemented with a .plot card to show AC voltage at node 4 graphically.

Netlist:

`Lowpass filterv1 2 1 ac 24 sinv2 1 0 dc 24rload 4 0 1kl1 2 3 100ml2 3 4 250mc1 3 0 100u.ac lin 30 500 15k.print ac v(4).plot ac v(4).end`

`freq          v(4)          5.000E+02     1.935E-011.000E+03     3.275E-021.500E+03     1.057E-022.000E+03     4.614E-032.500E+03     2.402E-033.000E+03     1.403E-033.500E+03     8.884E-044.000E+03     5.973E-044.500E+03     4.206E-045.000E+03     3.072E-045.500E+03     2.311E-046.000E+03     1.782E-046.500E+03     1.403E-047.000E+03     1.124E-047.500E+03     9.141E-058.000E+03     7.536E-058.500E+03     6.285E-059.000E+03     5.296E-059.500E+03     4.504E-051.000E+04     3.863E-051.050E+04     3.337E-051.100E+04     2.903E-051.150E+04     2.541E-051.200E+04     2.237E-051.250E+04     1.979E-051.300E+04     1.760E-051.350E+04     1.571E-051.400E+04     1.409E-051.450E+04     1.268E-051.500E+04     1.146E-05`

`freq       v(4)  1.000E-06     1.000E-04    1.000E-02    1.000E+00- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -5.000E+02  1.935E-01 .             .             .        *    .1.000E+03  3.275E-02 .             .             .   *         .1.500E+03  1.057E-02 .             .             *             .2.000E+03  4.614E-03 .             .           * .             .2.500E+03  2.402E-03 .             .         *   .             .3.000E+03  1.403E-03 .             .       *     .             .3.500E+03  8.884E-04 .             .      *      .             .4.000E+03  5.973E-04 .             .    *        .             .4.500E+03  4.206E-04 .             .   *         .             .  5.000E+03  3.072E-04 .             .  *          .             . 5.500E+03  2.311E-04 .             .  *          .             .6.000E+03  1.782E-04 .             . *           .             . 6.500E+03  1.403E-04 .             .*            .             .7.000E+03  1.124E-04 .             *             .             .7.500E+03  9.141E-05 .             *             .             . 8.000E+03  7.536E-05 .            *.             .             . 8.500E+03  6.285E-05 .            *.             .             .9.000E+03  5.296E-05 .           * .             .             . 9.500E+03  4.504E-05 .           * .             .             .1.000E+04  3.863E-05 .          *  .             .             . 1.050E+04  3.337E-05 .          *  .             .             .1.100E+04  2.903E-05 .         *   .             .             . 1.150E+04  2.541E-05 .         *   .             .             .1.200E+04  2.237E-05 .        *    .             .             .1.250E+04  1.979E-05 .        *    .             .             .1.300E+04  1.760E-05 .        *    .             .             .1.350E+04  1.571E-05 .       *     .             .             .1.400E+04  1.409E-05 .       *     .             .             .1.450E+04  1.268E-05 .       *     .             .             .1.500E+04  1.146E-05 .      *      .             .             . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`

### Multiple-source AC network

One of the idiosyncrasies of SPICE is its inability to handle any loop in a circuit exclusively composed of series voltage sources and inductors. Therefore, the "loop" of V1-L1-L2-V2-V1 is unacceptable. To get around this, I had to insert a low-resistance resistor somewhere in that loop to break it up. Thus, we have Rbogus between 3 and 4 (with 1 pico-ohm of resistance), and V2 between 4 and 0. The circuit above is the original design, while the circuit below has Rbogus inserted to avoid the SPICE error.

Netlist:

`Multiple ac sourcev1 1 0 ac 55 0 sinv2 4 0 ac 43 25 sinl1 1 2 450mc1 2 0 330ul2 2 3 150mrbogus 3 4 1e-12.ac lin 1 30 30.print ac v(2).end`

Output:

`freq          v(2)          3.000E+01     1.413E+02`

### AC phase shift demonstration

The currents through each leg are indicated by the voltage drops across each respective shunt resistor (1 amp = 1 volt through 1 Ω), output by the v(1,2) and v(1,3) terms of the .print card. The phase of the currents through each leg are indicated by the phase of the voltage drops across each respective shunt resistor, output by the vp(1,2) and vp(1,3) terms in the .print card.

Netlist:

`phase shiftv1 1 0 ac 4 sinrshunt1 1 2 1rshunt2 1 3 1l1 2 0 1r1 3 0 6.3k.ac lin 1 1000 1000.print ac v(1,2) v(1,3) vp(1,2) vp(1,3).end`

Output:

`freq          v(1,2)      v(1,3)      vp(1,2)     vp(1,3)   1.000E+03     6.366E-04   6.349E-04  -9.000E+01   0.000E+00`

### Transformer circuit

SPICE understands transformers as a set of mutually coupled inductors. Thus, to simulate a transformer in SPICE, you must specify the primary and secondary windings as separate inductors, then instruct SPICE to link them together with a "k" card specifying the coupling constant. For ideal transformer simulation, the coupling constant would be unity (1). However, SPICE can't handle this value, so we use something like 0.999 as the coupling factor.

Note that all winding inductor pairs must be coupled with their own k cards in order for the simulation to work properly. For a two-winding transformer, a single k card will suffice. For a three-winding transformer, three k cards must be specified (to link L1 with L2, L2 with L3, and L1 with L3).

The L1/L2 inductance ratio of 100:1 provides a 10:1 step-down voltage transformation ratio. With 120 volts in we should see 12 volts out of the L2 winding. The L1/L3 inductance ratio of 100:25 (4:1) provides a 2:1 step-down voltage transformation ratio, which should give us 60 volts out of the L3 winding with 120 volts in.

Netlist:

`transformer                                                                   v1 1 0 ac 120 sin     rbogus0 1 6 1e-3l1 6 0 100    l2 2 4 1l3 3 5 25     k1 l1 l2 0.999k2 l2 l3 0.999k3 l1 l3 0.999r1 2 4 1000   r2 3 5 1000   rbogus1 5 0 1e10rbogus2 4 0 1e10.ac lin 1 60 60.print ac v(1,0) v(2,0) v(3,0).end  `

Output:

`freq          v(1)        v(2)        v(3)          6.000E+01     1.200E+02   1.199E+01   5.993E+01`

In this example, Rbogus0 is a very low-value resistor, serving to break up the source/inductor loop of V1/L1. Rbogus1 and Rbogus2 are very high-value resistors necessary to provide DC paths to ground on each of the isolated circuits. Note as well that one side of the primary circuit is directly grounded. Without these ground references, SPICE will produce errors!

### Full-wave bridge rectifier

Diodes, like all semiconductor components in SPICE, must be modeled so that SPICE knows all the nitty-gritty details of how they're supposed to work. Fortunately, SPICE comes with a few generic models, and the diode is the most basic. Notice the .model card which simply specifies "d" as the generic diode model for mod1. Again, since we're plotting the waveforms here, we need to specify all parameters of the AC source in a single card and print/plot all values using the .tran option.

Netlist:

`fullwave bridge rectifierv1 1 0 sin(0 15 60 0 0)rload 1 0 10kd1 1 2 mod1d2 0 2 mod1d3 3 1 mod1d4 3 0 mod1.model mod1 d.tran .5m 25m.plot tran v(1,0) v(2,3).end`

Output:

`legend:*: v(1)  +: v(2,3)  time      v(1)  (*)--------- -2.000E+01  -1.000E+01   0.000E+00   1.000E+01  2.000E+01(+)--------- -5.000E+00   0.000E+00   5.000E+00   1.000E+01  1.500E+01- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.000E+00  0.000E+00 .       +            *            .           .5.000E-04  2.806E+00 .       .      +     .   *        .           .1.000E-03  5.483E+00 .       .            +      *     .           .1.500E-03  7.929E+00 .       .            .     +   *  .           .2.000E-03  1.013E+01 .       .            .           +*           .2.500E-03  1.198E+01 .       .            .            .  * +      .3.000E-03  1.338E+01 .       .            .            .    *  +   .3.500E-03  1.435E+01 .       .            .            .     *    +.4.000E-03  1.476E+01 .       .            .            .      *    +4.500E-03  1.470E+01 .       .            .            .      *    +5.000E-03  1.406E+01 .       .            .            .     *   + .5.500E-03  1.299E+01 .       .            .            .   *  +    .6.000E-03  1.139E+01 .       .            .            . *+        .6.500E-03  9.455E+00 .       .            .         + *.           .7.000E-03  7.113E+00 .       .            .   +    *   .           .7.500E-03  4.591E+00 .       .           +.    *       .           .8.000E-03  1.841E+00 .       .   +        . *          .           .8.500E-03 -9.177E-01 .       .  +        *.            .           .9.000E-03 -3.689E+00 .       .        *+  .            .           .9.500E-03 -6.380E+00 .       .    *       . +          .           .1.000E-02 -8.784E+00 .       . *          .        +   .           .1.050E-02 -1.075E+01 .      *.            .            .+          .1.100E-02 -1.255E+01 .   *   .            .            .     +     .1.150E-02 -1.372E+01 .  *    .            .            .        +  .1.200E-02 -1.460E+01 . *     .            .            .           +1.250E-02 -1.476E+01 .*      .            .            .           +1.300E-02 -1.460E+01 . *     .            .            .           +1.350E-02 -1.373E+01 .  *    .            .            .        +  .1.400E-02 -1.254E+01 .   *   .            .            .     +     .1.450E-02 -1.077E+01 .      *.            .            .+          .1.500E-02 -8.726E+00 .       . *          .       +    .           .1.550E-02 -6.293E+00 .       .    *       . +          .           .1.600E-02 -3.684E+00 .       .        x   .            .           .1.650E-02 -9.361E-01 .       .      +    *.            .           .1.700E-02  1.875E+00 .       .      +     . *          .           .1.750E-02  4.552E+00 .       .           +.    *       .           .1.800E-02  7.170E+00 .       .            .   +    *   .           .1.850E-02  9.401E+00 .       .            .         + *.           .1.900E-02  1.146E+01 .       .            .            . *+        .1.950E-02  1.293E+01 .       .            .            .   *  +    .2.000E-02  1.414E+01 .       .            .            .     *    +.2.050E-02  1.464E+01 .       .            .            .     *     +2.100E-02  1.483E+01 .       .            .            .      *    +2.150E-02  1.430E+01 .       .            .            .     *    +.2.200E-02  1.344E+01 .       .            .            .    *   +  .2.250E-02  1.195E+01 .       .            .            .  *+       .2.300E-02  1.016E+01 .       .            .           +*           .2.350E-02  7.917E+00 .       .            .     +   *  .           .2.400E-02  5.460E+00 .       .            +      *     .           .2.450E-02  2.809E+00 .       .      +     .  *         .           .2.500E-02 -8.297E-04 .       +            *            .           .- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`

### Common-base BJT transistor amplifier

This analysis sweeps the input voltage (Vin) from 0 to 5 volts in 0.1 volt increments, then prints out the voltage between the collector and emitter leads of the transistor v(2,3). The transistor (Q1) is an NPN with a forward Beta of 50.

Netlist:

`Common-base BJT amplifiervsupply 1 0 dc 24vin 0 4 dcrc 1 2 800re 3 4 100q1 2 0 3 mod1.model mod1 npn bf=50.dc vin 0 5 0.1.print dc v(2,3).plot dc v(2,3).end`

Output:

`vin           v(2,3)        0.000E+00     2.400E+011.000E-01     2.410E+012.000E-01     2.420E+013.000E-01     2.430E+014.000E-01     2.440E+015.000E-01     2.450E+016.000E-01     2.460E+017.000E-01     2.466E+018.000E-01     2.439E+019.000E-01     2.383E+011.000E+00     2.317E+011.100E+00     2.246E+011.200E+00     2.174E+011.300E+00     2.101E+011.400E+00     2.026E+011.500E+00     1.951E+011.600E+00     1.876E+011.700E+00     1.800E+011.800E+00     1.724E+011.900E+00     1.648E+012.000E+00     1.572E+012.100E+00     1.495E+012.200E+00     1.418E+012.300E+00     1.342E+012.400E+00     1.265E+012.500E+00     1.188E+012.600E+00     1.110E+012.700E+00     1.033E+012.800E+00     9.560E+002.900E+00     8.787E+003.000E+00     8.014E+003.100E+00     7.240E+003.200E+00     6.465E+003.300E+00     5.691E+003.400E+00     4.915E+003.500E+00     4.140E+003.600E+00     3.364E+003.700E+00     2.588E+003.800E+00     1.811E+003.900E+00     1.034E+004.000E+00     2.587E-014.100E+00     9.744E-024.200E+00     7.815E-024.300E+00     6.806E-024.400E+00     6.141E-024.500E+00     5.657E-024.600E+00     5.281E-024.700E+00     4.981E-024.800E+00     4.734E-024.900E+00     4.525E-025.000E+00     4.346E-02`

`vin        v(2,3) 0.000E+00    1.000E+01    2.000E+01     3.000E+01- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.000E+00  2.400E+01 .             .             .     *       .1.000E-01  2.410E+01 .             .             .     *       .2.000E-01  2.420E+01 .             .             .     *       .3.000E-01  2.430E+01 .             .             .     *       .4.000E-01  2.440E+01 .             .             .     *       .5.000E-01  2.450E+01 .             .             .     *       . 6.000E-01  2.460E+01 .             .             .     *       . 7.000E-01  2.466E+01 .             .             .      *      . 8.000E-01  2.439E+01 .             .             .     *       . 9.000E-01  2.383E+01 .             .             .    *        .1.000E+00  2.317E+01 .             .             .   *         .1.100E+00  2.246E+01 .             .             .  *          . 1.200E+00  2.174E+01 .             .             . *           . 1.300E+00  2.101E+01 .             .             .*            .  1.400E+00  2.026E+01 .             .             *             . 1.500E+00  1.951E+01 .             .            *.             .   1.600E+00  1.876E+01 .             .           * .             .  1.700E+00  1.800E+01 .             .          *  .             .   1.800E+00  1.724E+01 .             .         *   .             . 1.900E+00  1.648E+01 .             .        *    .             . 2.000E+00  1.572E+01 .             .       *     .             . 2.100E+00  1.495E+01 .             .      *      .             .  2.200E+00  1.418E+01 .             .     *       .             .  2.300E+00  1.342E+01 .             .    *        .             .  2.400E+00  1.265E+01 .             .   *         .             .  2.500E+00  1.188E+01 .             .  *          .             .    2.600E+00  1.110E+01 .             . *           .             .   2.700E+00  1.033E+01 .             *             .             .   2.800E+00  9.560E+00 .            *.             .             .  2.900E+00  8.787E+00 .           * .             .             . 3.000E+00  8.014E+00 .          *  .             .             .  3.100E+00  7.240E+00 .         *   .             .             .  3.200E+00  6.465E+00 .        *    .             .             . 3.300E+00  5.691E+00 .       *     .             .             .   3.400E+00  4.915E+00 .      *      .             .             .  3.500E+00  4.140E+00 .     *       .             .             . 3.600E+00  3.364E+00 .    *        .             .             .  3.700E+00  2.588E+00 .   *         .             .             . 3.800E+00  1.811E+00 .  *          .             .             .   3.900E+00  1.034E+00 .*            .             .             .  4.000E+00  2.587E-01 *             .             .             .   4.100E+00  9.744E-02 *             .             .             .   4.200E+00  7.815E-02 *             .             .             .   4.300E+00  6.806E-02 *             .             .             .  4.400E+00  6.141E-02 *             .             .             .  4.500E+00  5.657E-02 *             .             .             .  4.600E+00  5.281E-02 *             .             .             .  4.700E+00  4.981E-02 *             .             .             .   4.800E+00  4.734E-02 *             .             .             . 4.900E+00  4.525E-02 *             .             .             .   5.000E+00  4.346E-02 *             .             .             .           - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`

### Common-source JFET amplifier with self-bias

Netlist:

`common source jfet amplifier                     vin 1 0 sin(0 1 60 0 0)vdd 3 0 dc 20 rdrain 3 2 10k    rsource 4 0 1k     j1 2 1 4 mod1 .model mod1 njf.tran 1m 30m  .plot tran v(2,0) v(1,0).end  `

Output:

`legend:*: v(2)  +: v(1)  time      v(2)  (*)---------  1.400E+01    1.600E+01   1.800E+01  2.000E+01 2.200E+01(+)--------- -1.000E+00   -5.000E-01   0.000E+00  5.000E-01 1.000E+00- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.000E+00  1.708E+01 .           .     *    +          .           .1.000E-03  1.609E+01 .           .*         .        + .           .2.000E-03  1.516E+01 .       *   .          .          .  +        .3.000E-03  1.448E+01 .  *        .          .          .        +  .4.000E-03  1.419E+01 .*          .          .          .           +5.000E-03  1.432E+01 . *         .          .          .          +.6.000E-03  1.490E+01 .     *     .          .          .    +      .7.000E-03  1.577E+01 .         * .          .         +.           .8.000E-03  1.676E+01 .           .  *       .  +       .           .9.000E-03  1.768E+01 .           .    +    *.          .           .1.000E-02  1.841E+01 .         + .          . *        .           .1.100E-02  1.890E+01 .   +       .          .    *     .           .1.200E-02  1.912E+01 .+          .          .      *   .           .1.300E-02  1.912E+01 .+          .          .      *   .           .1.400E-02  1.890E+01 .   +       .          .    *     .           .1.500E-02  1.842E+01 .         + .          . *        .           .1.600E-02  1.768E+01 .           .    +    *.          .           .1.700E-02  1.676E+01 .           .  *       .  +       .           .1.800E-02  1.577E+01 .         * .          .         +.           .1.900E-02  1.491E+01 .     *     .          .          .    +      .2.000E-02  1.432E+01 . *         .          .          .          +.2.100E-02  1.419E+01 .*          .          .          .           +2.200E-02  1.449E+01 .  *        .          .          .        +  .2.300E-02  1.516E+01 .       *   .          .          .  +        .2.400E-02  1.609E+01 .           .*         .        + .           .2.500E-02  1.708E+01 .           .     *    +          .           .2.600E-02  1.796E+01 .           . +        *          .           .2.700E-02  1.861E+01 .        +  .          .  *       .           .2.800E-02  1.900E+01 .  +        .          .     *    .           .2.900E-02  1.916E+01 +           .          .      *   .           .3.000E-02  1.908E+01 .+          .          .      *   .           .- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`

### Inverting op-amp circuit

To simulate an ideal operational amplifier in SPICE, we use a voltage-dependent voltage source as a differential amplifier with extremely high gain. The "e" card sets up the dependent voltage source with four nodes, 3 and 0 for voltage output, and 1 and 0 for voltage input. No power supply is needed for the dependent voltage source, unlike a real operational amplifier. The voltage gain is set at 999,000 in this case. The input voltage source (V1) sweeps from 0 to 3.5 volts in 0.05 volt steps.

Netlist:

`Inverting opampv1 2 0 dce 3 0 0 1 999kr1 3 1 3.29kr2 1 2 1.18k.dc v1 0 3.5 0.05.print dc v(3,0).end`

Output:

`v1            v(3)          0.000E+00     0.000E+005.000E-02    -1.394E-011.000E-01    -2.788E-011.500E-01    -4.182E-012.000E-01    -5.576E-012.500E-01    -6.970E-013.000E-01    -8.364E-013.500E-01    -9.758E-014.000E-01    -1.115E+004.500E-01    -1.255E+005.000E-01    -1.394E+005.500E-01    -1.533E+006.000E-01    -1.673E+006.500E-01    -1.812E+007.000E-01    -1.952E+007.500E-01    -2.091E+008.000E-01    -2.231E+008.500E-01    -2.370E+009.000E-01    -2.509E+009.500E-01    -2.649E+001.000E+00    -2.788E+001.050E+00    -2.928E+001.100E+00    -3.067E+001.150E+00    -3.206E+001.200E+00    -3.346E+001.250E+00    -3.485E+001.300E+00    -3.625E+001.350E+00    -3.764E+001.400E+00    -3.903E+001.450E+00    -4.043E+001.500E+00    -4.182E+001.550E+00    -4.322E+001.600E+00    -4.461E+001.650E+00    -4.600E+001.700E+00    -4.740E+001.750E+00    -4.879E+001.800E+00    -5.019E+001.850E+00    -5.158E+001.900E+00    -5.297E+001.950E+00    -5.437E+002.000E+00    -5.576E+002.050E+00    -5.716E+002.100E+00    -5.855E+002.150E+00    -5.994E+002.200E+00    -6.134E+002.250E+00    -6.273E+002.300E+00    -6.413E+002.350E+00    -6.552E+002.400E+00    -6.692E+002.450E+00    -6.831E+002.500E+00    -6.970E+002.550E+00    -7.110E+002.600E+00    -7.249E+002.650E+00    -7.389E+002.700E+00    -7.528E+002.750E+00    -7.667E+002.800E+00    -7.807E+002.850E+00    -7.946E+002.900E+00    -8.086E+002.950E+00    -8.225E+003.000E+00    -8.364E+003.050E+00    -8.504E+003.100E+00    -8.643E+003.150E+00    -8.783E+003.200E+00    -8.922E+003.250E+00    -9.061E+003.300E+00    -9.201E+003.350E+00    -9.340E+003.400E+00    -9.480E+003.450E+00    -9.619E+003.500E+00    -9.758E+00`

### Noninverting op-amp circuit

Another example of a SPICE quirk: since the dependent voltage source "e" isn't considered a load to voltage source V1, SPICE interprets V1 to be open-circuited and will refuse to analyze it. The fix is to connect Rbogus in parallel with V1 to act as a DC load. Being directly connected across V1, the resistance of Rbogus is not crucial to the operation of the circuit, so 10 kΩ will work fine. I decided not to sweep the V1 input voltage at all in this circuit for the sake of keeping the netlist and output listing simple.

Netlist:

`noninverting opampv1 2 0 dc 5rbogus 2 0 10ke 3 0 2 1 999kr1 3 1 20kr2 1 0 10k.end`

Output:

`node     voltage   node     voltage   node    voltage(  1)    5.0000    (  2)    5.0000    (  3)   15.0000`

### Instrumentation amplifier

Note the very high-resistance Rbogus1 and Rbogus2 resistors in the netlist (not shown in schematic for brevity) across each input voltage source, to keep SPICE from thinking V1 and V2 were open-circuited, just like the other op-amp circuit examples.

Netlist:

`Instrumentation amplifierv1 1 0rbogus1 1 0 9e12v2 4 0 dc 5rbogus2 4 0 9e12e1 3 0 1 2 999ke2 6 0 4 5 999ke3 9 0 8 7 999krload 9 0 10kr1 2 3 10krgain 2 5 10kr2 5 6 10kr3 3 7 10kr4 7 9 10kr5 6 8 10kr6 8 0 10k.dc v1 0 10 1.print dc v(9) v(3,6).end`

Output:

`v1            v(9)        v(3,6)    0.000E+00     1.500E+01  -1.500E+011.000E+00     1.200E+01  -1.200E+012.000E+00     9.000E+00  -9.000E+003.000E+00     6.000E+00  -6.000E+004.000E+00     3.000E+00  -3.000E+005.000E+00     9.955E-11  -9.956E-116.000E+00    -3.000E+00   3.000E+007.000E+00    -6.000E+00   6.000E+008.000E+00    -9.000E+00   9.000E+009.000E+00    -1.200E+01   1.200E+011.000E+01    -1.500E+01   1.500E+01`

### Op-amp integrator with sinewave input

Netlist:

`Integrator with sinewave inputvin 1 0 sin (0 15 60 0 0)r1 1 2 10kc1 2 3 150u ic=0e 3 0 0 2 999k.tran 1m 30m uic.plot tran v(1,0) v(3,0).end`

Output:

`legend:*: v(1)  +: v(3)  time       v(1)  (*)-------- -2.000E+01    -1.000E+01     0.000E+00     1.000E+01(+)-------- -6.000E-02    -4.000E-02    -2.000E-02     0.000E+00- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.000E+00  6.536E-08 .        .             *             +       .1.000E-03  5.516E+00 .        .             .       *    +.       .2.000E-03  1.021E+01 .        .             .        +    *       .3.000E-03  1.350E+01 .        .             .  +          .    *  .4.000E-03  1.495E+01 .        .          +  .             .      *.5.000E-03  1.418E+01 .        .   +         .             .     * .6.000E-03  1.150E+01 .      + .             .             . *     .7.000E-03  7.214E+00 . +      .             .         *   .       .8.000E-03  1.867E+00 .+       .             .  *          .       .9.000E-03 -3.709E+00 . +      .        *    .             .       .1.000E-02 -8.805E+00 .   +    . *           .             .       .1.100E-02 -1.259E+01 .    *   +             .             .       .1.200E-02 -1.466E+01 . *      .     +       .             .       .1.300E-02 -1.471E+01 . *      .            +.             .       .1.400E-02 -1.259E+01 .    *   .             .    +        .       .1.500E-02 -8.774E+00 .        . *           .         +   .       .1.600E-02 -3.723E+00 .        .        *    .            +.       .1.700E-02  1.870E+00 .        .             .  *          +       .1.800E-02  7.188E+00 .        .             .         * + .       .1.900E-02  1.154E+01 .        .             .      +      . *     .2.000E-02  1.418E+01 .        .             .+            .     * .2.100E-02  1.490E+01 .        .       +     .             .      *.2.200E-02  1.355E+01 .        . +           .             .    *  .2.300E-02  1.020E+01 .    +   .             .             *       .2.400E-02  5.496E+00 . +      .             .       *     .       .2.500E-02 -1.486E-03 .+       .             *             .       .2.600E-02 -5.489E+00 . +      .     *       .             .       .2.700E-02 -1.021E+01 .    +   *             .             .       .2.800E-02 -1.355E+01 .   *    . +           .             .       .2.900E-02 -1.488E+01 . *      .       +     .             .       .3.000E-02 -1.427E+01 .  *     .             .+            .       .- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`

### Op-amp integrator with squarewave input

Netlist:

`Integrator with squarewave inputvin 1 0 pulse (-1 1 0 0 0 10m 20m)r1 1 2 1kc1 2 3 150u ic=0e 3 0 0 2 999k.tran 1m 50m uic.plot tran v(1,0) v(3,0).end`

Output:

`legend:*: v(1)  +: v(3)  time       v(1)  (*)-------- -1.000E+00   -5.000E-01     0.000E+00  5.000E-01  1.000E+00(+)-------- -1.000E-01   -5.000E-02     0.000E+00  5.000E-02  1.000E-01- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -0.000E+00 -1.000E+00 *         .             +           .         .1.000E-03  1.000E+00 .         .             +           .         *2.000E-03  1.000E+00 .         .           + .           .         *3.000E-03  1.000E+00 .         .         +   .           .         *4.000E-03  1.000E+00 .         .       +     .           .         *5.000E-03  1.000E+00 .         .      +      .           .         *6.000E-03  1.000E+00 .         .    +        .           .         *7.000E-03  1.000E+00 .         .  +          .           .         *8.000E-03  1.000E+00 .         .+            .           .         *9.000E-03  1.000E+00 .        +.             .           .         *1.000E-02  1.000E+00 .      +  .             .           .         *1.100E-02  1.000E+00 .    +    .             .           .         *1.200E-02 -1.000E+00 *    +    .             .           .         .1.300E-02 -1.000E+00 *      +  .             .           .         .1.400E-02 -1.000E+00 *        +.             .           .         .1.500E-02 -1.000E+00 *         .+            .           .         .1.600E-02 -1.000E+00 *         .  +          .           .         .1.700E-02 -1.000E+00 *         .    +        .           .         .1.800E-02 -1.000E+00 *         .      +      .           .         .1.900E-02 -1.000E+00 *         .       +     .           .         .2.000E-02 -1.000E+00 *         .         +   .           .         .2.100E-02  1.000E+00 .         .         +   .           .         *2.200E-02  1.000E+00 .         .       +     .           .         *2.300E-02  1.000E+00 .         .      +      .           .         *2.400E-02  1.000E+00 .         .    +        .           .         *2.500E-02  1.000E+00 .         .  +          .           .         *2.600E-02  1.000E+00 .         .+            .           .         *2.700E-02  1.000E+00 .        +.             .           .         *2.800E-02  1.000E+00 .      +  .             .           .         *2.900E-02  1.000E+00 .    +    .             .           .         *3.000E-02  1.000E+00 .  +      .             .           .         *3.100E-02  1.000E+00 . +       .             .           .         *3.200E-02 -1.000E+00 * +       .             .           .         .3.300E-02 -1.000E+00 *  +      .             .           .         .3.400E-02 -1.000E+00 *    +    .             .           .         .3.500E-02 -1.000E+00 *      +  .             .           .         .3.600E-02 -1.000E+00 *        +.             .           .         .3.700E-02 -1.000E+00 *         .+            .           .         .3.800E-02 -1.000E+00 *         .  +          .           .         .3.900E-02 -1.000E+00 *         .    +        .           .         .4.000E-02 -1.000E+00 *         .      +      .           .         .4.100E-02  1.000E+00 .         .      +      .           .         *4.200E-02  1.000E+00 .         .    +        .           .         *4.300E-02  1.000E+00 .         .  +          .           .         *4.400E-02  1.000E+00 .         .+            .           .         *4.500E-02  1.000E+00 .        +.             .           .         *4.600E-02  1.000E+00 .      +  .             .           .         *4.700E-02  1.000E+00 .    +    .             .           .         *4.800E-02  1.000E+00 .  +      .             .           .         *4.900E-02  1.000E+00 . +       .             .           .         *5.000E-02  1.000E+00 +         .             .           .         *- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -`

### Related Posts by Categories

Electronics Hoctro | Electrical