main
John Lauer Board34 R9: connected side-fan carrier, full modeled probing pass, current evidence and narrated clips 4daaf8f
#!/usr/bin/env python3
"""Static sensitivity screen; no installed sensor or ADC qualification."""
import json, math, hashlib, ctypes, subprocess, tempfile
from pathlib import Path
from sensor_candidate_screen import interp_temp
R=Path(__file__).resolve().parents[1]
p=R/'design/sensor-candidate.json';d=json.loads(p.read_text());rows=d['rows']
assert d['candidate']=='NTCLE428E3103H301A'
assert all(lo<=nom<=hi for _,nom,lo,hi in rows)
assert all(a[1]>b[1] for a,b in zip(rows,rows[1:]))
scenarios=[]
# Exercise the actual current C conversion, including float rounding and range
# rejection. The previous report accidentally retained the superseded curve.
firmware=R/'firmware/ntcle428.c'
tmp=tempfile.TemporaryDirectory(prefix='load-sensor-budget-')
lib=Path(tmp.name)/'ntcle428.so'
subprocess.run(['gcc','-std=c11','-Wall','-Wextra','-Werror','-shared','-fPIC',str(firmware),'-lm','-o',str(lib)],check=True)
convert=ctypes.CDLL(str(lib)).load_ntcle428_nominal_c
convert.argtypes=[ctypes.c_float,ctypes.POINTER(ctypes.c_float)];convert.restype=ctypes.c_bool
def reading(code):
 out=ctypes.c_float()
 return out.value if convert(10000*code/(4095-code),ctypes.byref(out)) else None
samples={code:reading(code) for code in range(16,4080)}
for indicated in [55,54,53]:
 codes=[c for c,v in samples.items() if v is not None and v>=indicated]
 last_hot=max(codes)
 # ADC round-to-nearest switches at code + 0.5. Pull-up tolerance is isolated.
 ratio=(last_hot+.5)/(4095-last_hot-.5)
 earliest=interp_temp(rows,10100*ratio,2)
 latest=interp_temp(rows,9900*ratio,3)
 scenarios.append({'indicatedTripC':indicated,'largestTripAdcCode':last_hot,'earliestStaticActualC':earliest,'latestStaticActualC':latest})
out={'status':'conditional-static-sensitivity-not-qualified','candidate':d['candidate'],'sourceInputSha256':hashlib.sha256(p.read_bytes()).hexdigest(),'source':d['source'],'curve':'Compiled current firmware/ntcle428.c nominal table conversion; diagnostic only','firmwareSha256':hashlib.sha256(firmware.read_bytes()).hexdigest(),'pullupTolerancePercent':1,'adcModel':'ideal 12-bit rounding only; no offset, gain, INL, reference or noise error','scenarios':scenarios,'responseTimeSourceSeconds':2.5,'responseTimeMedium':'oil; cannot be reused as installed response or an RC time constant','limits':['Resistance tolerances use manufacturer Table 5 with log-resistance interpolation; interpolated extrema are a screen, not guaranteed between-tabulated bounds.','No attachment gradient, thermal lag, self-heating, ADC electrical error or resistor temperature drift included.','No software trip setting, formal case ceiling, BOM or hardware comparator change.','A 55 C indicated cutoff alone does not guarantee a 55 C actual case ceiling.']}
(R/'mechanical/sensor-trip-budget.json').write_text(json.dumps(out,indent=2)+'\n')
print(json.dumps(out,indent=2))