EXAMPLE1 - An Illustration of PSpice Capabilities * * This circuit, a differential pair, shows many of the capabilities of PSpice. * It creates a large amount of output for such a small circuit. Normally, * only a few kinds of analysis, such as transient analysis, would be run. * * This command sets options for the run. .OPT LIST ACCT NOMOD NOPAGE RELTOL=.001 * Sets the width of the output to 80 columns. .WIDTH OUT=80 * Sets the temperature for the run to 35 degrees celsius. .TEMP 35 * This command does a DC sweep. The voltage source VIN is swept from * -0.125 volts to 0.125 volts in steps of 0.005 volts. The non-linear * device equations are used. .DC VIN -0.125 0.125 0.005 * There is no command to do a small-signal bias point calculation. It * is done automatically after the DC sweep is finished. The non-linear * device equations are used to find the bias point. Then, the linearized, * small-signal equivalent circuit at the bias point is saved for the .TF, * .SENS, .AC, and .NOISE analysis. This command prints out the small- * signal parameters for each device. .OP * This command does a small-signal transfer function calculation assuming * VIN is the input and V(5), the voltage at node 5, is the output. .TF V(5) VIN * This does an AC analysis. The real and imaginary response of the circuit * is calculated as the inputs are swept from 100 kilohertz to 10 gigahertz * by decades with 10 points per decade. The only AC input this circuit has * is VIN. This is a linear analysis. .AC DEC 10 100KHZ 10GHZ * This command does noise calculations during the AC analysis. Each * device's noise contribution is calculated and propogated to node 5. * All the contributions are rms-summed at node 5. Besides the total * output noise printout done for every frequency, a detailed table of * each device's contribution is done every 30'th frequency. .NOISE V(5) VIN 30 * This command does a transient analysis. It first re-calculates the * circuit's bias point, then calculates the circuit's time response * from 0 nanoseconds to 1 microsecond using the full, non-linear device * equations, including non-linear capacitances. PSpice uses a variable * time step for the calculations, but this command causes the results * to be interpolated onto a 5 nanosecond print interval. Transient * analysis is the most frequently used analysis in PSpice. .TRAN 20NS 5uS * This does a harmonic decomposition on the waveform V(5) calculated * during transient analysis. It calculates the magnitude and phase * of the fundamental (1 megahertz) and the first eight harmonics. * The graphics post-processor, Probe, goes further and contains * a full FFT, allowing complete spectra to be displayed. .FOUR 1MEG V(5) * This command does a Monte Carlo analysis of the circuit. It runs * the DC sweep 5 times using the tolerances in .MODEL statements * and compares the waveform V(4,5) from each run against the nominal * V(4,5). It then lists a table of each run's deviation from the * nominal. The Monte Carlo option can also do Worst Case and Sensitivity * analysis. .MC 5 DC V(4,5) YMAX * PSpice allows parameters to be defined and used in expressions * throughout the circuit file. Parameters may also be passed into * subcircuits as arguments and used inside. Here, we define a * fudge factor for the supply voltages. .PARAM FACTOR=1.2 * The following statements describe the circuit to PSpice. It is a * simple differential pair, with +12 and -12 volts as the supplies. * VIN is the input for this circuit. It has an amplitude during AC analysis * of 1 volt and a sine waveform during transient of .1 volt at 1 megahertz. VIN 100 0 AC 1 SIN(0 0.1 1MEG) * The power supplies are + and - SUPPLY volts. As mentioned above, * expressions containing parameters can be used for values throughout * the circuit file. Expressions are enclosed by "{" and "}" and allow * arithmetic expressions. VCC 101 0 DC {10*FACTOR} VEE 102 0 {-10*FACTOR} * The transistors' nodes are in the order collector - base - emitter. * All transistors must refer to a model (QNL in this case). Q1 4 2 6 QNL Q2 5 3 6 QNL * Models for resistors are optional. If used they can specify such things * as scaling, temperature coefficients, and tolerances. RS1 100 2 1K RS2 3 0 1K RC1 4 101 CRES 10K RC2 5 101 CRES 10K Q3 6 7 102 QNL Q4 7 7 102 QNL RBIAS 7 101 20K CLOAD 4 5 5PF * This statement describes the CRES resistor by giving the values for * the parameters. Each type of model has its own set of parameters. * All parameters have default values. In CRES we have set the scaling * factor to 1, the linear temperature coefficient to .02, and the * quadratic temperature coefficient to .0045, and given each resistor * a 5% tolerance on its value during Monte Carlo analysis. .MODEL CRES RES (R=1 DEV=5% TC1=.02 TC2=.0045) * The bipolar transistor model is the Gummel-Poon model. It uses the * same equations as in the UC Berkeley Spice program. There are * actually 55 model parameters, but most of these are for second-order * effects that are rarely used. Most bipolar models for realistic * circuits specify between 12 and 25 parameters and default the rest. * Here, we have set the forward beta to 80, the base resistance to * 100 ohms, the collector-substrate capacitance to 2 picofarads, the * forward transit time to 0.3 nanoseconds, the reverse transit time to * 6 nanoseconds, the base-emitter capacitance to 3 picofarads, the * base-collector capacitance to 2 picofarads, and the forward Early * voltage to 50 volts. The capacitances are actually voltage dependent. * These numbers are the zero-bias values. .MODEL QNL NPN (BF=80 RB=100 CCS=2PF TF=0.3NS TR=6NS CJE=3PF CJC=2PF + VA=50) * The Analog Behavioral Modeling option allows one to define a transfer * function by formula and/or by table. Here, we implement an ideal * comparator to convert the differential output across nodes 4 and 5 into * a TTL output on node 'comp_out'. The voltage across 4 and 5 is * multiplied by 1e3 and that value is looked up in the table. The * table has an output of 0v for inputs < -5, 5v for inputs > 5, * and output=input in between. So, the comparator has a gain of 1,000 * and saturates at 0v and 5v. * Although not shown here, one can also define linear transfer functions * by Laplace transform formulas or by frequency response tables. * If your copy of PSpice includes the Analog Behavioral Modeling option, * or, if you are using the evaluation version, then remove the "*" in * front of E1 and add a "* " in front of E2. *E1 10 0 TABLE {V(4,5)*1e3} (-5v,0v 5v,5v) E2 10 0 (4,5) 10 RE1 10 comp_out 200 ; Output series resistance CCOMP comp_out 0 20pf ; Output load capacitance * These commands provide print and plot output for selected voltages * and currents. The plots are the so-called "line printer" plots. * That is, plots made out of characters. To get real, high-resolution * plots you need to use Probe; it is invoked by the .PROBE command. .PRINT DC V(4) V(5) .PLOT DC IC(Q2) .PLOT AC VCM(Q2) VCP(Q2) .PLOT NOISE INOISE ONOISE .PLOT TRAN V(4,5) V([comp_out]) * This .PROBE statement will save all analog and digital voltage and current * values for use by Probe. .PROBE .END