Fix VOLTage:RANGe? timeout and EFF overflow blocking sweeps

- 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 <noreply@anthropic.com>
This commit is contained in:
2026-03-11 17:06:13 +07:00
parent 04191259d6
commit 5fe2ec4556

View File

@@ -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