GUI: live STM32 telemetry + sweep guards + auto-logging + bench-plot
- stm32_link.py: port to the live 114-byte broadcast protocol (magic 0xAA55AA55, odd parity 8-O-1, 100 Hz publish, repetition-validated, no CRC); 39 params incl. adc4_trig_phase/iin_zero_sum, CLEAR_FLAGS, 30-bit flag table; commands stay CRC-16 framed; Telemetry aliases BroadcastData, efficiency uses iout_slow and eff_net subtracts P_sys - gui_workers.py: STM32Worker reader thread with counter dedup, rate/ loss counters, 20 s graph history, full-rate telemetry CSV writer - gui.py: right-side telemetry panel (link state, power + EFF net, heatsink/board temps, Vfly group, control, HRTIM, status-flag checkboxes, fault registers), Vfly + selectable corr/phase-ofs graphs, 20 s rolling window on all plots, dual CSV logging (merged stm_* columns + <stem>_telem.csv), logging on by default into logs/data_<timestamp>.csv, Plot Eff button - sweep guards: PSU 20 A input-current gate (conservative estimate + measured backstop + I-limit clamp), thermal pause at 57/77 C holding the load at 1 A until cooled 5 C below threshold, CC range pinned to R2 for the whole run with empirical range-max readback rejection - plot_eff.py + bench-plot entry point: efficiency vs Vin vs current maps from any logged CSV (sweep / data log / telem autodetect), file dialog when launched without args - bench.py: HIOKI FAST response speed, 5 s settle defaults; cli.py stm32-read prints the full broadcast; README + .gitignore updates Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+22
-13
@@ -572,20 +572,29 @@ def cmd_stm32_read(bench: MPPTTestbench, args: argparse.Namespace) -> None:
|
||||
print(f" {name:<20s} = {val}")
|
||||
print()
|
||||
|
||||
# Read telemetry
|
||||
# Read telemetry (100 Hz broadcast, 20 fresh publishes averaged)
|
||||
t = link.read_telemetry_avg(n=20)
|
||||
if t:
|
||||
from testbench.stm32_link import flags_to_names
|
||||
modes = ("OFF", "MPPT", "CV", "CC")
|
||||
mode = modes[t.ctrl_mode] if 0 <= t.ctrl_mode < len(modes) else str(t.ctrl_mode)
|
||||
print("Telemetry (20-sample avg):")
|
||||
print(f" Vin = {t.vin_V:8.2f} V")
|
||||
print(f" Vout = {t.vout_V:8.2f} V")
|
||||
print(f" Iin = {t.iin_A:8.2f} A")
|
||||
print(f" Iout = {t.iout_A:8.2f} A")
|
||||
print(f" Iin = {t.iin_A:8.2f} A (avg {t.iin_avg_ma:+d} mA)")
|
||||
print(f" Iout = {t.iout_slow/1000:8.2f} A (fast {t.iout_A:.2f} A)")
|
||||
print(f" Isys = {t.sys_current_ma:8d} mA")
|
||||
print(f" Pin = {t.power_in_W:8.2f} W")
|
||||
print(f" Pout = {t.power_out_W:8.2f} W")
|
||||
print(f" EFF = {t.efficiency:8.1f} %")
|
||||
print(f" EFF = {t.efficiency:8.1f} % (net {t.efficiency_net:.1f} %)")
|
||||
print(f" Vfly = {t.vfly/1000:8.2f} V")
|
||||
print(f" Temp = {t.etemp:8.1f} °C (FET)")
|
||||
print(f" Temp = {t.etemp:8.1f} °C (heatsink)")
|
||||
print(f" Tbrd = {t.btemp:8.1f} °C (board)")
|
||||
print(f" Mode = {mode}")
|
||||
if t.status_flags:
|
||||
print(f" Flags= 0x{t.status_flags:08X}")
|
||||
for name in flags_to_names(t.status_flags):
|
||||
print(f" {name}")
|
||||
|
||||
|
||||
def cmd_stm32_write(bench: MPPTTestbench, args: argparse.Namespace) -> None:
|
||||
@@ -1192,7 +1201,7 @@ examples:
|
||||
p_sweep.add_argument("--v-stop", type=float, required=True, help="Stop voltage (V)")
|
||||
p_sweep.add_argument("--v-step", type=float, required=True, help="Voltage step (V)")
|
||||
p_sweep.add_argument("--current-limit", type=float, required=True, help="Current limit (A)")
|
||||
p_sweep.add_argument("--settle", type=float, default=1.0, help="Settle time per step (s)")
|
||||
p_sweep.add_argument("--settle", type=float, default=5.0, help="Settle time per step (s)")
|
||||
p_sweep.add_argument("--load-mode", choices=["CC", "CR", "CV", "CP"], help="Set load mode before sweep")
|
||||
p_sweep.add_argument("--load-value", type=float, help="Set load value before sweep")
|
||||
p_sweep.add_argument("-o", "--output", help="CSV output file")
|
||||
@@ -1204,7 +1213,7 @@ examples:
|
||||
p_swl.add_argument("--i-start", type=float, required=True, help="Start load current (A)")
|
||||
p_swl.add_argument("--i-stop", type=float, required=True, help="Stop load current (A)")
|
||||
p_swl.add_argument("--i-step", type=float, required=True, help="Current step (A)")
|
||||
p_swl.add_argument("--settle", type=float, default=1.0, help="Settle time per step (s)")
|
||||
p_swl.add_argument("--settle", type=float, default=5.0, help="Settle time per step (s)")
|
||||
p_swl.add_argument("-o", "--output", help="CSV output file")
|
||||
|
||||
# efficiency
|
||||
@@ -1212,7 +1221,7 @@ examples:
|
||||
p_eff.add_argument("--voltage", type=float, required=True, help="Supply voltage (V)")
|
||||
p_eff.add_argument("--current-limit", type=float, required=True, help="Current limit (A)")
|
||||
p_eff.add_argument("--samples", type=int, default=5, help="Number of readings to average")
|
||||
p_eff.add_argument("--settle", type=float, default=2.0, help="Initial settle time (s)")
|
||||
p_eff.add_argument("--settle", type=float, default=5.0, help="Initial settle time (s)")
|
||||
p_eff.add_argument("-i", "--interval", type=float, default=1.0, help="Interval between samples")
|
||||
p_eff.add_argument("--load-mode", choices=["CC", "CR", "CV", "CP"])
|
||||
p_eff.add_argument("--load-value", type=float)
|
||||
@@ -1227,13 +1236,13 @@ examples:
|
||||
p_svi.add_argument("--l-step", type=float, required=True, help="Load step size")
|
||||
p_svi.add_argument("--load-mode", choices=["CC", "CP"], default="CC", help="Load mode: CC (current) or CP (power)")
|
||||
p_svi.add_argument("--current-limit", type=float, required=True, help="Supply current limit (A)")
|
||||
p_svi.add_argument("--settle", type=float, default=2.0, help="Settle time per step (s)")
|
||||
p_svi.add_argument("--settle", type=float, default=5.0, help="Settle time per step (s)")
|
||||
p_svi.add_argument("-o", "--output", help="CSV output file")
|
||||
|
||||
# shade-profile
|
||||
p_shade = sub.add_parser("shade-profile", help="Run a shade/irradiance profile from CSV")
|
||||
p_shade.add_argument("--profile", required=True, help="Profile CSV file (time,voltage,current_limit,...)")
|
||||
p_shade.add_argument("--settle", type=float, default=2.0, help="Settle time per step (s)")
|
||||
p_shade.add_argument("--settle", type=float, default=5.0, help="Settle time per step (s)")
|
||||
p_shade.add_argument("-o", "--output", help="CSV output file for results")
|
||||
|
||||
# supply (direct control)
|
||||
@@ -1275,7 +1284,7 @@ examples:
|
||||
p_tp.add_argument("--current-limit", type=float, required=True, help="Supply current limit (A)")
|
||||
p_tp.add_argument("--load-mode", choices=["CC", "CP"], default="CP", help="Load mode")
|
||||
p_tp.add_argument("--load-value", type=float, default=200.0, help="Load setpoint (A or W)")
|
||||
p_tp.add_argument("--settle", type=float, default=3.0, help="Settle time per step (s)")
|
||||
p_tp.add_argument("--settle", type=float, default=5.0, help="Settle time per step (s)")
|
||||
p_tp.add_argument("--no-plot", action="store_true", help="Skip plot")
|
||||
p_tp.add_argument("-o", "--output", help="CSV output file")
|
||||
|
||||
@@ -1291,7 +1300,7 @@ examples:
|
||||
p_tv.add_argument("--current-limit", type=float, required=True, help="Supply current limit (A)")
|
||||
p_tv.add_argument("--load-mode", choices=["CC", "CP"], default="CP", help="Load mode")
|
||||
p_tv.add_argument("--load-value", type=float, default=200.0, help="Load setpoint (A or W)")
|
||||
p_tv.add_argument("--settle", type=float, default=3.0, help="Settle time per step (s)")
|
||||
p_tv.add_argument("--settle", type=float, default=5.0, help="Settle time per step (s)")
|
||||
p_tv.add_argument("-o", "--output", help="Output prefix for CSVs (default: param name)")
|
||||
|
||||
# tune-deadtime
|
||||
@@ -1303,7 +1312,7 @@ examples:
|
||||
p_td.add_argument("--current-limit", type=float, default=20.0, help="Supply current limit (A)")
|
||||
p_td.add_argument("--load-mode", choices=["CC", "CP"], default="CP", help="Load mode")
|
||||
p_td.add_argument("--load-values", help="Comma-separated load values to test (e.g. 100,300,500)")
|
||||
p_td.add_argument("--settle", type=float, default=3.0, help="Settle time per step (s)")
|
||||
p_td.add_argument("--settle", type=float, default=5.0, help="Settle time per step (s)")
|
||||
p_td.add_argument("--apply", action="store_true", help="Apply best deadtimes after sweep")
|
||||
p_td.add_argument("-o", "--output", help="CSV output file")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user