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.
- 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.
- 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 voltage | i(vam) |
|---|---|
| 200 mV | 23 pA |
| 300 mV | 1.09 nA |
| 400 mV | 52.04 nA |
| 450 mV | 359.7 nA |
| 500 mV | 2.486 µA |
| 600 mV | 118.7 µA |
| 700 mV | 5.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
- 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
- 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 Va= 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.
- diode
- resistor
- tangent at 0.70 V
Read the plot as a table
| Voltage at node a | diode | resistor | tangent at 0.70 V |
|---|---|---|---|
| 600 mV | 118.7 µA | 1.2 mA | -16.25 mA |
| 620 mV | 257.2 µA | 1.18 mA | -11.87 mA |
| 640 mV | 557.4 µA | 1.16 mA | -7.483 mA |
| 660 mV | 1.208 mA | 1.14 mA | -3.099 mA |
| 680 mV | 2.617 mA | 1.12 mA | 1.286 mA |
| 700 mV | 5.67 mA | 1.1 mA | 5.67 mA |
| 720 mV | 12.29 mA | 1.08 mA | 10.05 mA |
The tangent is computed in ngspice from the diode's own current and conductance at 0.70 V. Measured on ngspice 42.
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.
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.
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.
| Current | Measured v(a) | n·UT·ln(I/IS + 1) |
|---|---|---|
| 1 µA | vd1u = 4.764449e-01 | 0.4764495 V |
| 10 µA | vd10u = 5.360055e-01 | 0.5360057 V |
| 100 µA | vd100u = 5.955615e-01 | 0.5955619 V |
| 1 mA | vd1m = 6.551179e-01 | 0.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
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.
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.
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.
Run the netlist to draw its plots here.
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-01Check yourself
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.