TT Lab
Get started
Learn Learning paths Courses

Electronics Foundations — Validating Sensor Inputs

Create a Sensor Input Design Review

Continue in TT Lab

Goal

Calculate the voltage divider input with the Python standard library and verify the load, tolerance, time, ADC, and fault hypotheses. It is not SPICE or a real board but explicitly stated resistors and a first-order RC model.

Why it matters

Matching one voltage is not enough. You can explain why a measured value changes only if you examine the current after connecting the load, the power consumption, the tolerance end values, and the acquisition time. Distinguishing real measurements from synthetic observations is also part of verification.

Steps

  1. Calculate the no-load model of 5 V and two 10 kΩ resistors and save it to /root/circuit-review/01-unloaded.json.
  2. Add a 10 kΩ load and save the voltage, current, and drop fraction to /root/circuit-review/02-loaded.json.
  3. Save the three consumed powers and the supply power, in W, to /root/circuit-review/03-power.json.
  4. Compare the 16 end-value combinations of supply ±5% and each of the three resistors ±1%, and save the count and range to /root/circuit-review/04-corners.json.
  5. Add 100 nF to the nominal circuit and save the time constant, the voltage at 1 ms, and the 1% settling time to /root/circuit-review/05-settling.json.
  6. Using the virtual ADC convention on the step card, save two codes and the input validity to /root/circuit-review/06-adc.json.
  7. Compare the 2.49±0.02 V synthetic observation with three fault candidates and save the predictions, the candidates, and the next check to /root/circuit-review/07-diagnosis.json.

Notes

The step card has all the field names. JSON numbers are not strings, and NaN and infinity are not allowed. The numeric tolerance is the larger of a relative 0.00001 or an absolute 0.00000001. The virtual ADC code must be an integer. Only the standard libraries json, math, and itertools are used, so no extra installation is needed. If the shell and Python are new to you, see the Linux basics course first. Copy and keep your outputs before the session ends. No equipment is connected, nothing is soldered, and no real voltage is applied.

Before connecting the instrument

Calculate vout_v and current_a of the no-load model in which a 10 kΩ top resistor and a 10 kΩ bottom resistor are connected in series to an ideal 5 V supply.

The series current is set by the sum of the two resistors. The output is the voltage across the bottom resistor.

The load becomes part of the circuit

Connect a 10 kΩ load between the output and ground of the same circuit. Calculate vout_v, the top current top_a, the sum of the bottom and load currents return_a, and the voltage drop fraction drop_fraction relative to no load.

The bottom resistor and the load are in parallel. Also check separately that the currents add up.

Balance the power ledger

For the loaded circuit of 02, calculate the top top_w, the bottom bottom_w, the load load_w, and the supply_w delivered by the supply, in W. The sum of the three consumed powers must match the supply power.

The voltage across each resistor is different. Avoid the mistake of putting the output voltage as is on the top resistor.

Find the worst combination of tolerances

Calculate all 16 end-value combinations of a 5 V ±5% supply and three resistors of 10 kΩ ±1% each. Record case_count, min_v, and max_v. Each error is independent, and no statistical distribution is assumed.

Each of the four variables has two end values, so there are 2⁴. Increasing all the resistors at the same time does not by itself give the worst condition.

Even after 1 ms it is still moving

Connect 100 nF to ground at the output of the nominal circuit of 02. This is an ideal first-order model with an initial voltage of 0 V and the supply raised to 5 V at t=0. Find tau_s, v_at_1ms at the 1 ms point, and t_1pct_s, the first time the error relative to the final value reaches 1% or less.

If you make the voltage source 0 V, the three resistors are in parallel. The final value is the output voltage with the load, and the residual error fraction is exp(-t/τ).

A saturated code does not make the input safe

The virtual 12-bit ADC is code=min(4095,max(0,floor(v/3.3*4096))). The normal range is defined as 0 to 3.3 V. Record code_loaded, the steady-state output of 02, code_overrange, the displayed code for a 5 V input, and input_valid, whether 5 V is within the normal input range.

Do not mix the code calculation convention with the calibration formula that divides by 4095. Returning a saturated code does not mean the physical pin can withstand the overvoltage.

Separate fault candidates from the next measurement

The educational synthetic observation is 2.49 V ±0.02 V (not a real measurement). Use only nominal parts and limit the candidates to three: normal, bottom_open (only the bottom resistor open), and load_short (only the load is an ideal short). In predicted_v write the voltage of each candidate, and in consistent write the list of candidate names inside the observation interval. Record the next check, next_check, as power_off_isolated_resistance, which means turning off the power, isolating the bottom resistor, and checking its resistance.

Even if the bottom is broken, the 10 kΩ load remains. One candidate being left and having proved every real-world fault cause are different things.