This commit is contained in:
david rice
2026-04-27 10:35:56 +01:00
parent 0fe208aef6
commit 6a51228d5f
4 changed files with 128 additions and 4 deletions

View File

@@ -63,8 +63,9 @@ PROTO_SCALE = 4e-6 # 4 µs/div → 40 µs window (was 1 µs/div)
PROTO_POINTS = 500_000
# Pass 3 — LP state capture (single-ended, widens vertical range to show LP-11)
LP_SCALE = 500e-9 # 500 ns/div → 5 µs window
LP_SCALE = 1e-6 # 1 µs/div → 20 µs actual window (was 500 ns/div)
LP_POINTS = 200_000
LP_TRIG_OFFSET = 9e-6 # shift centre 9 µs after trigger → 1 µs pre / 19 µs post
LP_V_SCALE = 0.2 # V/div
LP_V_OFFSET = 0.6 # V — centres display between LP-00 (0 V) and LP-11 (1.2 V)
LP_TRIG_LEVEL = 0.6 # V — catches LP-11 → LP-01 falling edge
@@ -645,6 +646,39 @@ def _fetch_registers(ts: str, iteration: int) -> None:
print(f" REGISTERS: SN65DSI83 error — {e}")
combined["sn65"] = None
# SN65DSI83 post-restart settling poll
try:
resp = requests.get(f"{DEVICE_BASE}/sn65_settling", timeout=10)
resp.raise_for_status()
settling = resp.json()
combined["sn65_settling"] = settling
n = settling.get("n_readings", 0)
n_err = settling.get("n_error", 0)
dur = settling.get("duration_s", 0)
if n_err:
# Print the first and last error readings for quick diagnosis
err_readings = [r for r in settling.get("readings", []) if r.get("any_error")]
times = [r["t_ms"] for r in err_readings]
print(f" SN65 SETTLING: *** {n_err}/{n} readings had csr_e5 errors "
f"over {dur:.1f} s (t={times[0]:.0f}{times[-1]:.0f} ms) ***")
for r in err_readings[:3]: # show up to first 3 error readings
print(f" t={r['t_ms']:6.1f} ms csr_0a={r['csr_0a']} "
f"csr_e5={r['csr_e5']} "
f"pll={'Y' if r['pll_lock'] else 'N'} "
f"clk={'Y' if r['clk_det'] else 'N'}")
else:
clk_false = sum(1 for r in settling.get("readings", [])
if r.get("clk_det") is False)
print(f" SN65 SETTLING: no csr_e5 errors in {n} readings over {dur:.1f} s"
+ (f" ({clk_false} readings with clk_det=False)" if clk_false else ""))
except requests.exceptions.RequestException as e:
print(f" REGISTERS: settling poll fetch failed — {e}")
combined["sn65_settling"] = None
except Exception as e:
print(f" REGISTERS: settling poll error — {e}")
combined["sn65_settling"] = None
# Save combined JSON
try:
DATA_DIR.mkdir(exist_ok=True)
@@ -673,15 +707,19 @@ def dual_capture(iteration: int) -> str:
print(f"CAPTURE #{iteration:04d} [{ts}]")
# ── Pass 1: LP / SoT startup ───────────────────────────────────────────
# Trigger position shifted so only 1 µs of LP-11 is pre-trigger; the
# remaining 19 µs shows the full HS burst so truncated bursts are visible.
print(" PASS 1: LP STARTUP TRANSITION...")
_configure_for_lp()
_set_timebase(LP_SCALE, LP_POINTS)
scope.write(f":TIMebase:POSition {LP_TRIG_OFFSET:.2E}")
if rigol_scope.is_connected():
rigol_scope.arm()
if _arm_and_wait(timeout=30):
_save_pass_channels("lp", iteration, ts)
else:
print(" SKIPPING LP SAVE.")
scope.write(":TIMebase:POSition 0") # restore centred for subsequent passes
if rigol_scope.is_connected():
DATA_DIR.mkdir(exist_ok=True)
v18_path = DATA_DIR / f"{ts}_pwr_{iteration:04d}_1v8.csv"