From 5fe2ec4556d292052a70cf51e355d9d6604ecc0f Mon Sep 17 00:00:00 2001 From: grabowski Date: Wed, 11 Mar 2026 17:06:13 +0700 Subject: [PATCH] Fix VOLTage:RANGe? timeout and EFF overflow blocking sweeps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Wrap get_voltage_range() in try/except since VOLTage:RANGe? is not supported on IT6537D — skip range check gracefully if unavailable - Exclude derived EFF* values from auto-range error threshold check in _wait_meter_ready(), as efficiency overflows at near-zero power Co-Authored-By: Claude Opus 4.6 --- testbench/bench.py | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/testbench/bench.py b/testbench/bench.py index 00cfbec..d6511a7 100644 --- a/testbench/bench.py +++ b/testbench/bench.py @@ -183,11 +183,15 @@ class MPPTTestbench: result = self.meter.measure(*self.METER_ITEMS) values = result.values - # Check if any value is an error code - if all(abs(v) < ERROR_THRESHOLD for v in values.values()): + # Check if any ranged value is an error code. + # Derived values like EFF* are excluded – they overflow when + # input/output power is near zero, which is normal. + _DERIVED = {"EFF1", "EFF2", "EFF3", "EFF4"} + ranged = {k: v for k, v in values.items() if k not in _DERIVED} + if all(abs(v) < ERROR_THRESHOLD for v in ranged.values()): return values - bad = [k for k, v in values.items() if abs(v) >= ERROR_THRESHOLD] + bad = [k for k, v in ranged.items() if abs(v) >= ERROR_THRESHOLD] print(f" (auto-ranging: {', '.join(bad)} -- retrying {attempt + 1}/{max_retries})") # Keep supply alive during the wait so it doesn't @@ -578,19 +582,25 @@ class MPPTTestbench: Raises ValueError if the configuration is invalid. """ - supply_max_v = self.supply.get_voltage_range() - if max_voltage > supply_max_v: - raise ValueError( - f"Requested voltage {max_voltage:.1f}V exceeds supply " - f"range {supply_max_v:.1f}V" - ) + # VOLTage:RANGe? is not supported on all models (e.g. IT6537D), + # so treat it as optional. + try: + supply_max_v = self.supply.get_voltage_range() + if max_voltage > supply_max_v: + raise ValueError( + f"Requested voltage {max_voltage:.1f}V exceeds supply " + f"range {supply_max_v:.1f}V" + ) + range_str = f"(range {supply_max_v:.0f}V)" + except Exception: + range_str = "(range query N/A)" max_power = max_voltage * current_limit print( f" Supply check: V_max={max_voltage:.1f}V, " f"I_limit={current_limit:.1f}A, " f"P_max={max_power:.0f}W " - f"(range {supply_max_v:.0f}V)" + f"{range_str}" ) # CP mode: at min voltage the load draws max current