Added ai stuff

This commit is contained in:
david rice
2026-04-08 12:55:34 +01:00
parent c19e8138df
commit d0e23c4e01
4 changed files with 779 additions and 0 deletions

View File

@@ -30,6 +30,16 @@ SIG_POINTS = 500_000 # 500 k pts → ~25 GSa/s
PROTO_SCALE = 1e-6 # 1 µs/div → 10 µs window
PROTO_POINTS = 500_000 # 500 k pts → 50 MSa/s (enough to see burst structure)
# Pass 3 — LP state capture: widens vertical range to show LP-11 (~1.2 V)
# Channels reconfigured to 200 mV/div, offset +0.6 V → display spans 0.2 V to 1.4 V.
# Saves Ch1 (CLK+) and Ch3 (DAT0+) single-ended so LP-11/LP-00 are distinguishable.
# Trigger: falling edge on Ch1 at 0.6 V → catches LP-11 → LP-01 SoT transition.
LP_SCALE = 500e-9 # 500 ns/div → 5 µs window
LP_POINTS = 200_000 # 200 k pts → ~40 GSa/s
LP_V_SCALE = 0.2 # V/div — 8 divs = 1.6 V range
LP_V_OFFSET = 0.6 # V — center display at 0.6 V (range 0.2 V to 1.4 V)
LP_TRIG_LEVEL = 0.6 # V — midpoint of LP-11 (1.2 V) → LP-01 (0 V) fall
DISPLAY_SETTLE_S = 1.0 # seconds to wait after display ON before arming scope
test_running = False # controls both worker threads
@@ -215,6 +225,48 @@ def _save_pass(tag, iteration, ts):
print(f" SAVE ERROR ({tag}): {e}")
def _save_pass_channels(tag, iteration, ts):
"""
Save Ch1 (CLK+) and Ch3 (DAT0+) as single-ended CSV for LP state analysis.
Single-ended is required for LP because differential (F1/F2) cannot distinguish
LP-11 (Vcm=1.2 V) from LP-00 (Vcm=0 V) — both give Vdiff=0.
"""
base = f"C:\\TEMP\\{ts}_{tag}_{iteration:04d}"
try:
scope.write(f':DISK:SAVE:WAVeform CHANnel1,"{base}_clk.csv",CSV')
time.sleep(2.5)
scope.write(f':DISK:SAVE:WAVeform CHANnel3,"{base}_dat.csv",CSV')
time.sleep(2.5)
print(f" SAVED: {base}_clk.csv {base}_dat.csv")
except Exception as e:
print(f" SAVE ERROR ({tag}): {e}")
def _configure_for_lp():
"""
Widen channel vertical scales to capture LP states and switch to a
falling-edge trigger to catch the LP-11 → LP-01 SoT transition.
"""
for ch in (1, 2, 3, 4):
scope.write(f":CHANnel{ch}:SCALe {LP_V_SCALE:.3f}")
scope.write(f":CHANnel{ch}:OFFSet {LP_V_OFFSET:.3f}")
time.sleep(0.05)
scope.write(":TRIGger:EDGE:SLOPe NEGative")
scope.write(f":TRIGger:EDGE:LEVel {LP_TRIG_LEVEL:.3f}")
time.sleep(0.1)
def _restore_hs_config():
"""Restore HS-mode channel scales, offsets, and trigger after LP capture."""
for ch in (1, 2, 3, 4):
scope.write(f":CHANnel{ch}:SCALe 0.1")
scope.write(f":CHANnel{ch}:OFFSet 0.0")
time.sleep(0.05)
scope.write(":TRIGger:EDGE:SLOPe POSitive")
scope.write(f":TRIGger:EDGE:LEVel 0.05")
time.sleep(0.1)
def dual_capture(iteration):
"""
Two-pass capture per test iteration:
@@ -242,6 +294,18 @@ def dual_capture(iteration):
else:
print(" SKIPPING PASS 2 SAVE.")
# ── Pass 3: LP / SoT structure ────────────────────────────────────────
# Widens vertical range to capture LP-11 (1.2 V) and falls-edge triggers
# on the LP-11 → LP-01 SoT transition. Saves Ch1 and Ch3 single-ended.
print(" PASS 3: LP TRANSITION...")
_configure_for_lp()
_set_timebase(LP_SCALE, LP_POINTS)
if _arm_and_wait(timeout=30):
_save_pass_channels("lp", iteration, ts)
else:
print(" SKIPPING PASS 3 SAVE.")
_restore_hs_config()
# ── Restore original timebase ─────────────────────────────────────────
_set_timebase(5e-9, 500_000)
scope.write(":RUN")