Electronics · Integrated circuits and programmable hardware
Capstone: a traceable sensor-to-indicator design
A working indicator is more than a sensor formula followed by an if statement. This capstone brings the electrical, timing and verification accounts together so that another reader can reproduce what the design was intended to do and judge what was actually demonstrated.
Lesson preparation and course links
Use the circuit, device and signal lessons. These advanced connections introduce their additional representations and lead to the final integrated design.
Back to the Electronics chapterAfter reading, you can
Specify and qualify a complete simulated electronic system using interface contracts, state rules, budgets and independently checkable evidence.
Begin with an observable requirement
Design a simulated low-energy temperature indicator that turns on for a rising estimated temperature at 35°C and turns off for a falling estimated temperature at 32°C. Between those thresholds it retains its previous state. This three-degree hysteresis band prevents repeated switching near one threshold. The instrument is a teaching indicator, not a medical, fire-protection or other safety-critical device.
Specify what will be demonstrated: valid measurement range 0°C to 50°C; a displayed estimate derived from sampled sensor voltage; distinct normal, indicator-on and fault states; a sample record with timestamps; and an explanation of the expected uncertainty. The response test requires indicator-on within 25 ms of a defined electrical-input step representing 20°C to 40°C. It does not claim an unmodelled physical sensor can follow an ambient-temperature step instantly. Requirements become useful when a test can decide whether each one was met.
Connect blocks through stated contracts
Use a fictional calibrated sensor contract VSENSOR = 0.50 V + (0.010 V/°C)T over the stated range. Its assumed residual error is bounded by ±0.50°C. Real voltage-output sensors illustrate this kind of interface, but their typical accuracy is not a substitute for this declared bound. A buffer and acquisition arrangement must present the sensor with an acceptable load and deliver the required ADC settling.
Assume a 12-bit ADC with a 2.56 V reference and nearest-level rounding for interior codes. Reconstruct VSENSOR from D × 2.56/4096, then calculate TEST = (VSENSOR − 0.50 V)/(0.010 V/°C). Keep these transfer definitions with the recorded data. A reference shared with another subsystem may have noise and loading effects; stating a nominal voltage does not prove those effects are absent.
Use a small state machine and a time budget
A state machine records the operating state and transition rules. Keep state, indicatorLatch, validRun, upRun and downRun. Reset begins in STARTUP with the latch OFF, all counters zero and no valid reading. Sample every 1 ms; each result belongs to its sample sequence and normally returns within 0.5 ms. A result missing the next 1 ms deadline is invalid. Ignore later results for an expired sequence.
The table defines automatic recovery: three consecutive valid samples leave STARTUP or FAULT. Threshold counters run during qualification, so the same third sample can restore validity and turn the indicator on; there is no second three-sample wait. Electrical validity uses inclusive 0.45–1.05 V diagnostic guard limits. Estimates outside 0–50°C are labelled outside the calibrated measurement range, rather than reported as qualified temperatures.
In FAULT, indicate 500 ms ON then 500 ms OFF with an explicit fault flag. Keep that timer separate from acquisition. Normal operation turns on after three valid estimates at or above 35°C, off after three at or below 32°C, and holds its latch between thresholds. These are sampled rules, not proof of continuous between-sample stability.
| Condition, in priority order | Counter and latch action | State and output |
|---|---|---|
| Reset | Set all counters to 0; indicatorLatch = OFF; invalidate prior reading. | STARTUP; output OFF, not-yet-valid flag. |
| Invalid voltage or missed deadline | Immediately set all counters to 0 and latch OFF. | FAULT; fault flag and 500 ms ON/OFF pattern. |
| Valid current-sequence result | Increment validRun, capped at 3. Set upRun = min(3, upRun + 1) if T_EST ≥ 35°C, otherwise 0. Set downRun similarly for T_EST ≤ 32°C, otherwise 0. | Continue with the following rows in the same sample. |
| STARTUP or FAULT with validRun < 3 | Keep latch OFF; qualification continues. | Preserve STARTUP or FAULT output. |
| validRun = 3, including the qualifying third sample | If upRun = 3 set latch ON; if downRun = 3 set latch OFF; otherwise retain latch. | NORMAL; output follows latch and fresh reading flag. |
Define the response stimulus before quoting a response time
For an original signal-conditioning model, place an ideal first-order low-pass response with time constant τ = 10 ms before the ADC and assume the buffer satisfies its load and acquisition contract. A time constant describes the rate of an exponential response. For a step from sensor voltage 0.70 V to 0.90 V, representing 20°C to 40°C, the filtered voltage follows V(t) = 0.90 − 0.20 exp(−t/τ).
The ideal 35°C threshold corresponds to 0.85 V and is crossed when exp(−t/τ) = 0.25, at about 13.86 ms. With a conservative whole-range error allowance of ±0.74°C, the latest effective rising threshold is 0.8574 V, crossed at about 15.46 ms. Allow up to 1 ms sample phase, 0.5 ms conversion, 2 ms for two further confirming samples and 0.5 ms output scheduling: a conservative bound is about 19.46 ms, inside the 25 ms requirement. This is an electrical-step model, not physical thermal response. An anti-alias guarantee additionally needs an interference spectrum and attenuation requirement.
Make the budgets add up
Assume a 3.3 V supply and separate worst-case current allowances of 5.00 mA for the microcontroller, 1.00 mA for analogue circuitry, 0.05 mA for the sensor and 4.00 mA for the indicator branch. Their simultaneous total is 10.05 mA and the corresponding supply power is 33.165 mW. A real implementation must also include startup, regulator loss, transient load and device-specific pin and package limits.
At the 35°C threshold, the declared uncertainty terms are ±0.50°C sensor error, ±1.0 mV ADC offset, a separate ±0.10% reference contribution and ideal rounding. Convert voltage errors to temperature using 10 mV/°C before combining their bounds. The hysteresis width is an operating choice; it does not calibrate away error or make the reported temperature exact. Keep typical values, guaranteed limits and measured results visibly distinct.
Test boundaries and failures as well as the happy path
Create input records for rising and falling ramps, the defined step, threshold hovering, out-of-range voltage, missing samples, reset and a held input. Record the exact stimulus, sample timestamps, raw codes, calculated temperature, internal state and output state. Compare the results with a prewritten expected sequence. A test that merely repeats the implementation’s arithmetic can miss a shared mistake, so also check selected cases by an independent hand calculation.
Fault injection means deliberately introducing a controlled failure into the model, such as withholding a conversion or moving the input outside its valid range. Observe whether the fault indication and recovery rules are met. A plausible voltage can still come from a disconnected or stuck sensor; range checking alone cannot detect every failure. Finish with a requirement-to-evidence table, an explicit list of untested physical effects and a redesign decision where a requirement was missed.
Check the threshold, uncertainty and supply accounts
The ideal ADC step is 2.56/4096 = 0.000625 V = 0.625 mV. At 35°C the sensor model gives 0.50 + 0.010 × 35 = 0.85 V, corresponding to ideal code 1360. At 32°C it gives 0.82 V, corresponding to code 1312. The code difference is 48 steps, representing the 3°C hysteresis band.
Interior rounding contributes at most 0.3125 mV, or 0.03125°C. The assumed 1.0 mV offset contributes 0.10°C. At 0.85 V, a separately counted 0.10% reference contribution is 0.85 mV, or 0.085°C. Adding the stated absolute bounds gives 0.50 + 0.10 + 0.085 + 0.03125 = 0.71625°C, about 0.72°C. Other errors remain excluded only because this is the declared teaching model.
At the top of the range, the reference contribution rises to 0.10°C, so the corresponding sum becomes 0.73125°C. Rounding that outward to 0.74°C gives the conservative whole-range allowance used in the response calculation. The supply account is 5.00 + 1.00 + 0.05 + 4.00 = 10.05 mA. At 3.3 V, P = VI = 0.033165 W. This is a simultaneous-current allowance, not a measured average or battery-life prediction. Timing and fault tests must be demonstrated independently of these arithmetic checks.
Try the reasoning
Why are the 35°C turn-on and 32°C turn-off rules different from an accuracy specification?
Show the answer and reasoning
They define the state machine’s hysteresis. Measurement uncertainty can shift the physical temperatures at which estimates cross those thresholds. The 3°C band reduces repeated switching but does not remove sensor or conversion error.
What ideal code change corresponds to 1°C in this model?
Show the answer and reasoning
The sensor changes by 10 mV per degree and the ADC step is 0.625 mV, so the change is 10/0.625 = 16 codes per degree. This is a scale calculation, not a guarantee that every real reading resolves 0.0625°C accurately.
Three consecutive samples arrive at 10, 11 and 12 ms. What span do they cover?
Show the answer and reasoning
They cover 2 ms from first to last. The capstone deliberately specifies three sampled observations, rather than calling them three milliseconds of continuously observed stability.
The sensor disconnects but the ADC input happens to remain at a plausible voltage. Must range checking detect the fault?
Show the answer and reasoning
No. Plausible-but-wrong signals can remain inside range. Detecting them needs additional diagnostics or redundancy justified by the application. Record this limitation rather than claiming complete fault coverage.
The defined 20°C-to-40°C electrical step crosses the ideal 35°C threshold after about 13.86 ms. Can that number be advertised as the physical sensor’s ambient-temperature response?
Show the answer and reasoning
No. It follows from the specified electrical filter model. A physical sensor has its own thermal coupling and response, and software sampling, uncertainty and output scheduling add separate effects.
After a fault, three valid samples all estimate 40°C. Does the design need three more samples before the indicator turns on?
Show the answer and reasoning
No. Fault entry reset the latch and all counters. Each recovery sample increments validRun and upRun together. On the third, validRun = 3 and upRun = 3, so that same sample enters NORMAL and sets the latch ON. A later fault immediately resets the latch and counters again.
What to carry forward
Complete an electronic design by binding its requirements, models, implementation states and test evidence, while naming the physical effects and failure modes that remain outside the demonstration.
References
Sources supporting this lesson’s explanations and examples.
- TMP36 — Voltage Output Temperature Sensors: Product Information and Data SheetAnalog DevicesReference guide
- AN-1393 — Translating System Level Protection and Measurement Requirements to ADC SpecificationsClaire Croke; Analog DevicesReference guide
- Pico SDK High Level APIs — pico_timeRaspberry Pi LtdReference guide
- Schematic Capture in Eeschema — Electrical Rules Check and NetlistsKiCad ProjectReference guide