Operating point and the DC sweep

Find the DC state of a circuit with a diode, see how SPICE solves a nonlinear circuit, and sweep a source or the temperature to draw a curve.

Lesson
E1.2
Time
25 min
Runs on
ngspice
Check
5 questions

An input clamp diode was added to protect a sensor pin. The hand analysis treated it as off below 0.7 V. In normal use the pin sat at 0.45 V, where the diode already carried 359.7 nA, enough to load a high-impedance sensor and shift its reading.

DC sweepClamp diode current against its voltageA DC sweep of the voltage across the diode, with the current on a log axis. A straight line on a log axis is an exponential.
10 pA1 nA100 nA10 µA1 mA100 mADiode current200 mV300 mV400 mV500 mV600 mV700 mVDiode voltagepin at 0.45 V"turns on" at 0.7 V10 pA1 nA100 nA10 µA1 mA100 mADiode current200 mV400 mV600 mVDiode voltagepin at 0.45 V"turns on" at 0.7 V
  1. Diode voltage 450 mVi(vam) = 359.7 nA

    At 0.45 V the diode carries 359.7 nA. That is small, but it is not zero, and every bit of it is drawn from the sensor.

  2. Diode voltage 700 mVi(vam) = 5.67 mA

    At 0.7 V it carries 5.670 mA, about 16 000 times more. Nothing special happens here; the line just keeps climbing.

Read the plot as a table
Diode voltagei(vam)
200 mV23 pA
300 mV1.09 nA
400 mV52.04 nA
450 mV359.7 nA
500 mV2.486 µA
600 mV118.7 µA
700 mV5.67 mA

ngspice's default diode (IS = 10 fA, n = 1) at 27 °C, measured on ngspice 42.

A diode does not switch at 0.7 V: its current grows exponentially with voltage and is never zero.

The DC state of a circuit

1.8 V through 1 kΩ into a diodeV1 = 1.8 V drives R1 = 1 kΩ into node a. The diode D1 goes from a to ground.
1.8 V through 1 kΩ into a diode+V11.8 VR11 kΩD1default modelin1.8 Va0.6585 V
  1. The resistor sets the current

    R1 drops 1.8 − 0.6585 = 1.1415 V, so 1.1415 mA flows. The run prints i(v1) as −1.141 mA: the source delivers it.

    1.141 mA

  2. The diode sets the voltage

    The same current flows through D1, and the diode's exponential law turns 1.141 mA into 0.6585 V. Both parts must agree on one current and one voltage.

Read the circuit as text
  • V1 voltage source (1.8 V): + → in, − → 0
  • R1 resistor (1 kΩ): pin 1 → in, pin 2 → a
  • D1 diode (default model): anode → a, cathode → 0
  • in = 1.8 V
  • a = 0.6585 V

Node voltages from the operating point of the lab netlist below, measured on ngspice 42.

The operating point is a circuit's DC state: every node voltage and every branch current, with each source at its DC value. Capacitors carry no DC current, so SPICE treats them as open circuits, and inductors as short circuits. op computes it.

With only resistors, the operating point is one linear solve. The diode makes it harder, because its current is an exponential of its voltage. The resistor wants a current of (1.8 − va)/1 kΩ. The diode wants IS·(e^{va/UT} − 1), where IS = 10 fA is its saturation current and UT = kT/q = 25.86 mV at 27 °C is the thermal voltage. Only one va satisfies both.

DC sweepHow SPICE finds the crossingThe diode curve, the resistor's load line, and the tangent to the diode curve at a first guess of 0.70 V.
  • diode
  • resistor
  • tangent at 0.70 V
01 mA2 mA3 mA4 mA5 mA6 mACurrent600 mV620 mV640 mV660 mV680 mV700 mV720 mVVoltage at node aguess: 0.70 Vnext guess: 0.6792 Vanswer: 0.6585 V01 mA2 mA3 mA4 mA5 mA6 mACurrent600 mV650 mV700 mVVoltage at node aguess: 0.70 Vnext guess: 0.6792 Vanswer: 0.6585 V
Read the plot as a table
Voltage at node adioderesistortangent at 0.70 V
600 mV118.7 µA1.2 mA-16.25 mA
620 mV257.2 µA1.18 mA-11.87 mA
640 mV557.4 µA1.16 mA-7.483 mA
660 mV1.208 mA1.14 mA-3.099 mA
680 mV2.617 mA1.12 mA1.286 mA
700 mV5.67 mA1.1 mA5.67 mA
720 mV12.29 mA1.08 mA10.05 mA

The tangent is computed in ngspice from the diode's own current and conductance at 0.70 V. Measured on ngspice 42.

  1. Guess

    Start from va = 0.70 V. There the diode would carry 5.670 mA, but the resistor can only supply (1.8 − 0.70)/1 kΩ = 1.100 mA. The guess is wrong, and the gap says by how much.

  2. Replace the curve by its tangent

    Near the guess, the diode behaves like the straight tangent line: a resistor and a source. That circuit is linear, so one solve gives where the tangent meets the load line, 0.6792 V.

  3. Repeat

    Take 0.6792 V as the new guess, draw a new tangent there, and solve again. Each step lands closer to the crossing at 0.6585 V and 1.141 mA.

This method is called Newton-Raphson iteration. It treats every nonlinear part the same way: replace it by its tangent at the guess, solve the linear circuit, and move the guess. The solver stops when the node voltages and branch currents change by less than 0.1 % between two steps.

Two habits follow from this picture. A good first guess helps: a guess near the crossing needs few steps, and a poor one can wander off and fail to converge. And the answer is only as exact as that 0.1 % tolerance, which shows up as tiny gaps between a run and a formula in later lessons.

Sweeping a source

A DC sweep repeats the operating point while it steps one source. dc V1 0 1.8 0.001 solves 1801 operating points, from 0 V to 1.8 V in 1 mV steps. Each one starts from the previous answer, which is close, so a sweep converges more easily than a cold op.

The lab's meas lines read the diode voltage where the current crosses each decade. Compare them with the diode law solved for voltage, v = n·UT·ln(I/IS + 1). The emission coefficient n is 1 for this diode, and UT is 25.86 mV.

CurrentMeasured v(a)n·UT·ln(I/IS + 1)
1 µAvd1u = 4.764449e-010.4764495 V
10 µAvd10u = 5.360055e-010.5360057 V
100 µAvd100u = 5.955615e-010.5955619 V
1 mAvd1m = 6.551179e-010.6551181 V

Every decade of current adds 59.56 mV, which is UT·ln 10. The 4.6 µV gap at 1 µA comes from meas drawing straight lines between sweep points 1 mV apart.

The slope of the curve at the operating point is the diode's small-signal conductance: how much the current changes for a tiny change of voltage. For a diode it is gd = I/(n·UT). At 1 mA that is 38.66 mS, a resistance of 25.86 Ω. AC analysis in E1.4 uses exactly this number.

A sweep can also step the temperature. dc TEMP -40 125 1 repeats the operating point from −40 °C to 125 °C. The diode voltage falls from 0.7724 V to 0.4869 V, about −1.73 mV per degree. A second sweep can follow the first, as in dc V1 0 1.8 0.01 TEMP -40 125 55. The first sweep then runs once for each value of the second, which draws one curve per temperature: −40, 15, 70 and 125 °C.

Asked in interviews
  1. What does an operating-point analysis compute?

    The DC solution: every node voltage and branch current with sources at their DC values, capacitors open and inductors shorted. AC and transient analyses start from it.

  2. How does SPICE solve a nonlinear circuit?

    Newton-Raphson: linearize every nonlinear device around a guess, solve the linear system, update the guess, and repeat until voltages and currents change by less than the tolerances (0.1 % relative by default). Gmin and source stepping (E1.6) help when that fails.

  3. What is the small-signal resistance of a diode at 1 mA?

    n·UT/I: about 26 Ω for n = 1 at room temperature, because UT = kT/q ≈ 25.9 mV. It halves when the current doubles.

Try it

Run it and read the print line first: the operating point, the source current and the diode conductance @d1[gd]. Then the meas lines: the diode voltage at four decades of current, and at three temperatures.

Now change R1 to 10k and predict the new va_27 before you run. The current falls by about ten times, so the diode voltage should fall by about one decade's worth, roughly 60 mV.

SPICEngspice 42 · simulator service
Edit the netlist, then run it
Expected measurements: vd1u = 4.764449e-01 vd10u = 5.360055e-01 vd100u = 5.955615e-01 vd1m = 6.551179e-01 va_m40 = 7.724430e-01 va_27 = 6.585400e-01 va_125 = 4.868616e-01

Check yourself

Predict the outputA 1 V source drives a 1 nF capacitor in series with 1 kΩ to ground. Type the line meas prints for the voltage across the resistor (for example vout = 6.585401e-01).
* a series capacitor, then a resistor to ground
V1 in 0 1
C1 in out 1n
R1 out 0 1k
.control
dc V1 0 1 1
meas dc vout FIND v(out) AT=1
.endc
.end
ConceptIn the lab the diode reads 0.6551 V at 1 mA. About what does it read at 10 µA?
ConceptEach line is added to the lab netlist on its own. Which one aborts the run?
ConceptWhy does SPICE iterate to find the lab's operating point, when it solves a resistor divider in one step?
ConceptOn the clamp-diode plot, read the voltage at 1 µA and at 1 mA. How far apart are they?

Remember

  • The operating point is the DC state: sources at their DC values, capacitors open, inductors shorted.
  • SPICE solves nonlinear circuits by Newton-Raphson: tangent at a guess, solve, repeat until the change is below 0.1 %.
  • A DC sweep repeats the operating point for each value of a source, a resistor or the temperature; each point starts from the last.
  • A diode's voltage rises 59.6 mV per decade of current at 27 °C, and its small-signal resistance is n·UT/I (25.9 Ω at 1 mA).
  • The diode voltage falls with temperature, by about 1.7 mV per degree on this bench.