S15 · Lesson 8 · Sensor lab
A least-squares calibration with its nonlinearity, a second-order system's step response and its parameters from a flush test, exact bridge outputs for quarter, half and full bridges, and a Steinhart–Hart thermistor fit against the simpler B model
Lessons 1 to 7 described sensors one formula at a time. Real instruments are characterized from data: a calibration run, a step test, a table of resistances. In this lab you'll write the calculations an instrument engineer runs on such data: fit a calibration line and quote its nonlinearity, find a catheter's natural frequency and damping from a flush test and check them against the step response they imply, compute exact bridge outputs, and fit a thermistor curve accurate to hundredths of a degree.
- The curve is the step response of a second-order sensor, such as a catheter and transducer, with the natural frequency and damping ratio on the sliders.
- Light damping rings and overshoots; the successive peaks shrink by a fixed ratio, from which a flush test reads the damping.
- Damping near 0.7 gives the fastest response that barely overshoots.
Predict
A flush test shows each peak 0.3 times the one before, 50 ms apart. A step of pressure applied to the same system would overshoot by about
The peak ratio gives ζ = 0.188 (lesson 23's formula), and a step response overshoots by = 0.55: 55%. A flush test's successive peaks shrink by the square of that, 0.30, one full period apart. Task 2 confirms it by computing the step response itself.
Name it
What the lab computes
- Calibration: the least-squares line through (input, output) pairs, and , and the nonlinearity: the largest deviation from the line as a percentage of the output span .
- Second-order dynamics: the underdamped step response with , and from a flush test's peak ratio d and damped frequency : , .
- Bridges: with excitation V and fractional change x, a quarter bridge gives , a half bridge with opposing arms , and a full bridge with two pairs of opposing arms Vx.
- Thermistors: the Steinhart–Hart equation (T in kelvins), fitted exactly through three calibration points, against the two-parameter B model .
Check
Write calibrate(xs, ys) returning (sensitivity, offset, nonlinearity in percent of span).
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write step2(fn, z, t), the underdamped step response, and flush_fit(d, fd) returning (ζ, ) from a flush test's peak ratio and damped frequency.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write bridge(V, x, kind) for kind "quarter", "half" or "full", returning the exact output voltage.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Check
Write sh_fit(points) returning Steinhart–Hart's (a, b, c) through three (resistance, °C) points, and sh_temp(R, abc) returning °C.
Python 3.14 with numpy and matplotlib, running in your browser. Tab indents; press Esc and then Tab to move on.
Explain why
Why does a least-squares calibration quote a smaller nonlinearity than a line drawn through the endpoints?
Nonlinearity is the largest deviation of the readings from a reference line, so it depends on which line is chosen. A line through the first and last calibration points matches those two exactly and leaves all the curvature as deviation at the points between, typically on one side. The least-squares line is free to move and tilt so that deviations fall on both sides and the sum of their squares is smallest, which roughly halves the largest one. Both are legitimate, but a specification must say which it used, and an instrument corrected by the least-squares line reads closest to the truth on average.