TExcelTAD
Home › Analog Electronics: Diodes, Transistors & Op-Amps › Mini Project: Design, Simulate and Characterise a Sensor Amplifier

Mini Project: Design, Simulate and Characterise a Sensor Amplifier

This project is the course's milestone: take an analog circuit from a written requirement, through hand design and simulation, to a bench prototype and a test report. The circuit is the front end of a temperature logger. A platinum RTD (resistance temperature detector) changes its resistance by about 3.85 Ω3.85\ \Omega per degree; a microcontroller's 12-bit ADC must read it from 00 to 100 ∘C100\ ^\circ\text{C}. Nearly every block of the course appears: a ratiometric divider, an instrumentation amplifier, a Sallen-Key low-pass, an error budget with real op-amp limits and tolerances, and noise and layout choices.

The requirement

Item Requirement
Sensor Pt1000, IEC 60751 class B, two-wire, leads under 0.5 Ω0.5\ \Omega
Range 00 to 100 ∘C100\ ^\circ\text{C}
Output 0.30.3 to 3.0 V3.0\ \text{V} into a 12-bit ADC with a 3.3 V3.3\ \text{V} reference
Supply 3.3 V3.3\ \text{V} (ADC reference) and 5 V5\ \text{V} for the op-amps, both from a USB-powered board
Rejection at least 20 dB20\ \text{dB} at 50 Hz50\ \text{Hz} (mains hum picked up by the sensor leads)
Accuracy electronics error below 0.5 ∘C0.5\ ^\circ\text{C} after a two-point calibration
Self-heating under 0.2 mW0.2\ \text{mW} in the sensor

The output window stops 0.3 V0.3\ \text{V} short of each rail so that a single-supply op-amp with a rail-to-rail output never clips (see the output-swing part of Real Op-Amps).

The architecture

Vref 3.3 V RTD divider 10 k + Pt1000 offset divider 10 k / 1 k: 0.3 V INA, G = 3 x 8.87 RG = RF = 10 k, REF 0.3 V Sallen-Key 10.7 Hz, Q 0.74 ADC vp vm vo

Both dividers hang from the same 3.3 V3.3\ \text{V} that the ADC uses as its reference. That makes the measurement ratiometric: if the reference drifts by 1 %, the input and the ADC's full scale move together and the code stays put. The offset divider is chosen to equal the RTD divider at 0 ∘C0\ ^\circ\text{C} (1 kΩ1\ \text{k}\Omega against 10 kΩ10\ \text{k}\Omega), so the INA amplifies only the change. Its REF pin, driven by a buffered copy of the same 0.3 V0.3\ \text{V}, shifts the output to the bottom of the window.

Step 1: excitation and self-heating

The RTD sits in a divider with R1=10 kΩR_1 = 10\ \text{k}\Omega:

vp=VrefRTRT+R1,RT=R0(1+AT+BT2),A=3.9083×10−3, B=−5.775×10−7v_p = V_\text{ref} \frac{R_T}{R_T + R_1}, \qquad R_T = R_0 (1 + AT + BT^2), \quad A = 3.9083 \times 10^{-3}, \ B = -5.775 \times 10^{-7}

(the IEC 60751 curve for T≥0 ∘CT \ge 0\ ^\circ\text{C}). At 100 ∘C100\ ^\circ\text{C}, RT=1385.05 ΩR_T = 1385.05\ \Omega and the current is 3.3/11385=0.290 mA3.3/11385 = 0.290\ \text{mA}, so the sensor dissipates 0.2902⋅1385=0.116 mW0.290^2 \cdot 1385 = 0.116\ \text{mW}: inside the requirement. A larger current would give more signal but heat the sensor; a typical probe in still air rises a few tenths of a degree per milliwatt (check the probe's datasheet value, often given as a self-heating coefficient).

Step 2: gain and offset

Given: vpv_p goes from 0.30000 V0.30000\ \text{V} at 0 ∘C0\ ^\circ\text{C} to 0.40146 V0.40146\ \text{V} at 100 ∘C100\ ^\circ\text{C}, a span of Δ=0.10146 V\Delta = 0.10146\ \text{V}; the output must span 2.7 V2.7\ \text{V}; the op-amps run from a single 5 V5\ \text{V} supply.

Find: the gain of a three-op-amp INA and how to split it between its two stages.

Solve: the total gain is G=2.7 V/0.10146 V=26.61G = 2.7\ \text{V}/0.10146\ \text{V} = 26.61. The obvious choice puts it all in the input stage, G1=1+2RF/RGG_1 = 1 + 2R_F/R_G with RG=1.95 kΩR_G = 1.95\ \text{k}\Omega for RF=25 kΩR_F = 25\ \text{k}\Omega. Look at the input-stage outputs before accepting it:

vo1=vp+RFRGΔ,vo2=vm−RFRGΔv_{o1} = v_p + \frac{R_F}{R_G}\Delta, \qquad v_{o2} = v_m - \frac{R_F}{R_G}\Delta

With RF/RG=12.8R_F/R_G = 12.8, at 100 ∘C100\ ^\circ\text{C} vo2=0.3−12.8⋅0.1015=−1.0 Vv_{o2} = 0.3 - 12.8 \cdot 0.1015 = -1.0\ \text{V}: impossible on a single 5 V5\ \text{V} supply, and the amplifier would quietly clip. The input common mode is only 0.3 V0.3\ \text{V}, so vo2v_{o2} stays above ground only if RF/RG<0.3/0.1015=2.96R_F/R_G < 0.3/0.1015 = 2.96. Split the gain:

RF=RG=10 kΩ:G1=1+2⋅1010=3,vo2,min⁡=0.3−0.1015=0.199 VG2=26.613=8.87  →  88.7 kΩ/10 kΩ (E96),G=3⋅8.87=26.61\begin{aligned} R_F = R_G = 10\ \text{k}\Omega: \quad G_1 &= 1 + \frac{2 \cdot 10}{10} = 3, \qquad v_{o2,\min} = 0.3 - 0.1015 = 0.199\ \text{V} \\ G_2 &= \frac{26.61}{3} = 8.87 \;\to\; 88.7\ \text{k}\Omega / 10\ \text{k}\Omega \text{ (E96)}, \qquad G = 3 \cdot 8.87 = 26.61 \end{aligned}

Check: 0.3+26.61⋅0.10146=3.000 V0.3 + 26.61 \cdot 0.10146 = 3.000\ \text{V} at 100 ∘C100\ ^\circ\text{C}, and the lowest internal node is 0.2 V0.2\ \text{V}, inside a rail-to-rail output's range. The sensitivity is 27 mV27\ \text{mV} per degree, or 33 ADC codes per degree: the ADC is not the limit. Single-supply INA chips document this trap as a "common-mode versus output voltage" plot; always check it.

Step 3: the hum filter

Temperature changes over seconds, so a corner near 10 Hz10\ \text{Hz} costs nothing. A unity-gain Sallen-Key with R=100 kΩR = 100\ \text{k}\Omega, C1=220 nFC_1 = 220\ \text{nF} (feedback) and C2=100 nFC_2 = 100\ \text{nF} (to ground) gives

f0=12πRC1C2=10.73 Hz,Q=12C1C2=0.742f_0 = \frac{1}{2\pi R \sqrt{C_1 C_2}} = 10.73\ \text{Hz}, \qquad Q = \frac{1}{2}\sqrt{\frac{C_1}{C_2}} = 0.742

close to Butterworth (Q=0.707Q = 0.707) with stock capacitor values. A second-order filter falls about 40 dB40\ \text{dB} per decade above f0f_0, so at 50 Hz50\ \text{Hz} (about 4.7 times f0f_0) expect a little under 27 dB27\ \text{dB} of rejection. The filter also limits the noise bandwidth (Noise in Analog Circuits) and serves as the ADC's anti-alias filter.

Step 4: the transfer curve and the error budget in Python

The model below computes the exact output against temperature, the ADC code, and the error you would make by treating the curve as a straight line between the two calibration points. Then it draws 5000 random boards with uniform resistor tolerances to show what calibration must remove.

python · try it yourself
import numpy as np

A, B = 3.9083e-3, -5.775e-7          # IEC 60751 coefficients, T >= 0 degC
R0, Rtop, Vref = 1000.0, 10e3, 3.3
RG, RF, G2 = 10e3, 10e3, 8.87

def rtd(T):
    return R0 * (1 + A * T + B * T**2)

def vout(T, r1=Rtop, r3=Rtop, r4=1e3, rg=RG):
    vp = Vref * rtd(T) / (rtd(T) + r1)
    vm = Vref * r4 / (r4 + r3)
    G = (1 + 2 * RF / rg) * G2
    return vm + G * (vp - vm)

lo, hi = vout(0), vout(100)
lsb = Vref / 4096
print(" T(C)   R(Ohm)  Vout(V)  code  linear est. error")
for T in [0, 25, 50, 75, 100]:
    v = vout(T)
    code = round(v / lsb)
    est = 100 * (v - lo) / (hi - lo)
    print(f"{T:5.0f} {rtd(T):8.2f} {v:8.4f} {code:5d} {round(est - T, 2) + 0.0:+10.2f} C")
print(f"sensitivity {1e3*(hi - lo)/100:.2f} mV/C, {(hi - lo)/100/lsb:.1f} LSB/C")

rng = np.random.default_rng(1)
N = 5000
for tol in [0.01, 0.001]:
    k = lambda: 1 + tol * rng.uniform(-1, 1, N)
    r1, r3, r4, rg = Rtop * k(), Rtop * k(), 1e3 * k(), RG * k()
    e0 = (vout(0, r1, r3, r4, rg) - lo) / ((hi - lo) / 100)
    e100 = (vout(100, r1, r3, r4, rg) - hi) / ((hi - lo) / 100)
    print(f"tolerance {100*tol:.1f} %: error at 0 C sd {e0.std():.2f} C, worst {abs(e0).max():.2f} C;"
          f" at 100 C sd {e100.std():.2f} C")
 T(C)   R(Ohm)  Vout(V)  code  linear est. error
    0  1000.00   0.3000   372      +0.00 C
   25  1097.35   1.0003  1242      +0.94 C
   50  1193.97   1.6833  2089      +1.23 C
   75  1289.87   2.3497  2916      +0.92 C
  100  1385.05   2.9999  3724      +0.00 C
sensitivity 27.00 mV/C, 33.5 LSB/C
tolerance 1.0 %: error at 0 C sd 2.59 C, worst 7.43 C; at 100 C sd 2.89 C
tolerance 0.1 %: error at 0 C sd 0.26 C, worst 0.77 C; at 100 C sd 0.29 C

Two lessons from these numbers. First, the curve is not straight: the RTD's own curvature and the divider's compression add up to 1.2 ∘C1.2\ ^\circ\text{C} at mid-range. That error is systematic, so the firmware removes it by inverting the exact equations (or a small lookup table), not by better parts. Second, with 1 % resistors (every resistor in the model gets the same uniform tolerance) an uncalibrated board can be 7 ∘C7\ ^\circ\text{C} off. A two-point calibration (an ice bath, or precision resistors of 1000.01000.0 and 1385.1 Ω1385.1\ \Omega in place of the sensor) removes offset and gain errors of any size; 0.1 % parts in the dividers make calibration a trim instead of a rescue. What calibration cannot remove is drift: resistor temperature coefficients, op-amp offset drift multiplied by the gain, and the sensor's own class tolerance (class B allows ±(0.3+0.005∣T∣) ∘C\pm(0.3 + 0.005\lvert T \rvert)\ ^\circ\text{C} under IEC 60751:2022, the current edition, valid from −50-50 to +500 ∘C+500\ ^\circ\text{C} for film and −196-196 to +600 ∘C+600\ ^\circ\text{C} for wire-wound thermometers).

Step 5: the whole chain in SPICE

The deck builds the chain from the course's op-amp macro-model (A0=105A_0 = 10^5, 1 MHz1\ \text{MHz} GBW; see the macro-model). The RTD is a resistor whose value the control loop changes with alter. A 1 mV1\ \text{mV} AC source in series with the sensor stands for hum picked up by its leads.

bash · try it yourself
cat > rtd.cir <<'EOF'
* Pt1000 RTD interface: divider, three-op-amp INA (G = 3 x 8.87), Sallen-Key low-pass
.subckt OA inp inn out
G1 0 n1 inp inn 1m
R1 n1 0 100meg
C1 n1 0 159.2p
E1 out 0 n1 0 1
.ends
VREF ref 0 3.3
R1 ref p 10k
VN p pr DC 0 AC 1m
RT pr 0 1000
R3 ref m 10k
R4 m 0 1k
XB m bref bref OA
XA1 p n1 o1 OA
RF1 o1 n1 10k
RG n1 n2 10k
RF2 o2 n2 10k
XA2 m n2 o2 OA
R5 o2 a 10k
R6 a out 88.7k
R7 o1 b 10k
R8 b bref 88.7k
XA3 b a out OA
R9 out s1 100k
R10 s1 s2 100k
C1 s1 fout 220n
C2 s2 0 100n
XA4 s2 fout fout OA
.control
foreach r 1000 1097.35 1193.97 1289.87 1385.05
  alter RT = $r
  op
  echo "RT = $r Ohm: o2 = 
amp;v(o2) V, vout =
amp;v(fout) V" end alter RT = 1193.97 ac dec 50 0.1 1k meas ac g1 find vdb(fout) at=1 meas ac g50 find vdb(fout) at=50 let att = g1 - g50 echo "50 Hz rejection:
amp;att dB" .endc .end EOF ngspice -b rtd.cir 2>&1 | grep -E '^(RT =|50 Hz)'
RT = 1000 Ohm: o2 = 0.299997 V, vout = 0.299964 V
RT = 1097.35 Ohm: o2 = 0.273681 V, vout = 1.00017 V
RT = 1193.97 Ohm: o2 = 0.248015 V, vout = 1.68307 V
RT = 1289.87 Ohm: o2 = 0.222974 V, vout = 2.34933 V
RT = 1385.05 Ohm: o2 = 0.198539 V, vout = 2.99949 V
50 Hz rejection: 26.713 dB

The simulated outputs agree with the Python column to better than 1 mV1\ \text{mV} (the op-amps' finite gain of 10510^5 accounts for the last digits), the input-stage output vo2v_{o2} falls to 0.199 V0.199\ \text{V} as Step 2 predicted, and the 50 Hz50\ \text{Hz} rejection of 26.7 dB26.7\ \text{dB} meets the 20 dB20\ \text{dB} requirement. The macro-model has no rails, so SPICE would happily have shown −1 V-1\ \text{V} for the first design too: printing the internal nodes and comparing them with the op-amp's input and output ranges is your job, not the simulator's.

Step 6: build and test

Parts. Four rail-to-rail CMOS op-amps (one quad package) on 5 V5\ \text{V} with a 100 nF100\ \text{nF} ceramic capacitor at the supply pin; 0.1 % thin-film resistors for R1R_1, R3R_3, R4R_4 and the four difference-stage resistors; the same for RFR_F, RGR_G and the 88.7 kΩ88.7\ \text{k}\Omega pair; film capacitors (C0G or polypropylene) for the filter. A precision decade resistance box stands in for the RTD during electrical tests; the real probe comes last.

What you would measure, with expected readings and their uncertainty:

Test Setup Expected Uncertainty and notes
Transfer curve decade box at 1000.01000.0, 1097.41097.4, 1194.01194.0, 1289.91289.9, 1385.1 Ω1385.1\ \Omega; DMM on the output 0.3000.300, 1.0001.000, 1.6831.683, 2.3502.350, 3.000 V3.000\ \text{V} box 0.1 % gives about ±0.4 ∘C\pm 0.4\ ^\circ\text{C} equivalent; offset drift and resistor mismatch add a few mV before calibration
Calibration two-point fit at 1000.01000.0 and 1385.1 Ω1385.1\ \Omega residuals at the middle points under 0.5 ∘C0.5\ ^\circ\text{C} (about 13 mV13\ \text{mV}) after the firmware's exact inversion DMM 0.05 % of reading
Hum rejection inject 10 mV10\ \text{mV} peak at 50 Hz50\ \text{Hz} from a battery-powered or isolated function generator in series with the decade box about 11 mV11\ \text{mV} peak at the output, against about 237 mV237\ \text{mV} peak at 1 Hz1\ \text{Hz} scope with averaging; the generator ground must not form a second path to the board
Noise output on the scope, AC-coupled, 20 MHz20\ \text{MHz} limit, or an ADC capture of 1000 samples well under one LSB (0.8 mV0.8\ \text{mV}) rms probe ground lead picks up hum: use the tip-and-barrel method
Step response switch the box between two values settles in about 0.1 s0.1\ \text{s} with a few percent overshoot (Q=0.74Q = 0.74)

Where the hum numbers come from: the injected signal is scaled by the divider (10/11.19=0.89410/11.19 = 0.894), amplified by 26.626.6 and, at 50 Hz50\ \text{Hz}, attenuated by the filter's 26.7 dB26.7\ \text{dB} (×0.0462\times 0.0462): 10 mV⋅0.894⋅26.6⋅0.0462=11 mV10\ \text{mV} \cdot 0.894 \cdot 26.6 \cdot 0.0462 = 11\ \text{mV}. SPICE's g1 and g50 give the same numbers for a 1 mV1\ \text{mV} source.

Hazards and safe setup. Everything runs from a USB-powered board at 5 V5\ \text{V} and 3.3 V3.3\ \text{V}, or a current-limited bench supply set to 5 V5\ \text{V} and 50 mA50\ \text{mA}. The ice-bath calibration uses kitchen ice and water; keep it away from the board and the supply. Do not immerse an RTD probe that is not rated for it, and never heat the probe with anything mains-powered on the bench beside the open circuit: use warm water from a kettle poured into an insulated cup, well away from the electronics. Electrostatic discharge can damage CMOS op-amp inputs: touch the bench ground before handling the board.

Write-up template

  1. Requirement (the table above) and any assumption you added.
  2. Architecture and why: ratiometric, offset by divider, filter placement.
  3. Hand design with Given / Find / Solve / Check for the divider, the gain and the filter.
  4. Simulation: the Python transfer curve and error budget, the SPICE chain, the Monte Carlo spread; one table that compares hand, Python and SPICE.
  5. Prototype: schematic with every value, photo, layout notes (where the ground of the RTD returns, where the decoupling capacitor sits).
  6. Measurements against the expected values with uncertainties; calibration constants.
  7. Discussion: which error dominates, what you would change (three-wire RTD to cancel lead resistance, a higher-resolution ADC, a dedicated INA chip, a reference that is not the supply).
  8. Conclusion: does the design meet each line of the requirement? Yes or no, with the number.

Extensions

  • Lead resistance: two 0.25 Ω0.25\ \Omega leads add 0.5 Ω0.5\ \Omega, about 0.13 ∘C0.13\ ^\circ\text{C}. Redraw the front end for a three-wire RTD.
  • Replace the three-op-amp INA by a single difference amplifier: what happens to the divider's accuracy when the amplifier's input resistance loads it?
  • Add a second-order filter in Python to reach 40 dB40\ \text{dB} at 50 Hz50\ \text{Hz}, and compare the step response.

Test yourself

Why do the RTD divider and the ADC share the same 3.3 V3.3\ \text{V} reference?

  1. To save a component
  2. So a drift in the reference cancels in the ratio the ADC reports
  3. Because the ADC needs current from the divider
  4. To raise the sensitivity

A three-op-amp INA on a single 5 V5\ \text{V} supply has inputs near 0.3 V0.3\ \text{V} and a differential input of 0.1 V0.1\ \text{V}. Why should most of the gain go in the difference stage?

  1. The difference stage has more bandwidth
  2. An input-stage gain of 26 would drive one input-stage output about 1.3 V1.3\ \text{V} below its input, i.e. below ground
  3. The gain resistor would dissipate too much power
  4. It improves the ratiometric property

The transfer curve bends by about 1.2 ∘C1.2\ ^\circ\text{C} at mid-range. What is the right fix?

  1. Use 0.01 % resistors
  2. Invert the exact equation in firmware
  3. Raise the filter corner
  4. Increase the RTD current

A second-order low-pass with f0=10.7 Hzf_0 = 10.7\ \text{Hz} attenuates 50 Hz50\ \text{Hz} hum by about…

  1. 6 dB6\ \text{dB}
  2. 13 dB13\ \text{dB}
  3. 27 dB27\ \text{dB}
  4. 54 dB54\ \text{dB}