MainCode/adalm1000_logger.py aktualisiert
✅ User unchecks Continuous Mode during discharge: Status updates immediately: "Continuous Mode disabled..." Discharge continues until cutoff voltage. Test stops after discharge (no rest phase or new cycle). ✅ User leaves Continuous Mode enabled: Test continues looping indefinitely (original behavior). (D)
This commit is contained in:
parent
34be33434f
commit
c697388157
@ -47,9 +47,9 @@ class BatteryTester:
|
|||||||
|
|
||||||
# Battery test parameters
|
# Battery test parameters
|
||||||
self.capacity = tk.DoubleVar(value=0.2) # Battery capacity in Ah
|
self.capacity = tk.DoubleVar(value=0.2) # Battery capacity in Ah
|
||||||
self.charge_cutoff = tk.DoubleVar(value=1.45) # Charge cutoff voltage
|
self.charge_cutoff = tk.DoubleVar(value=1.43) # Charge cutoff voltage
|
||||||
self.discharge_cutoff = tk.DoubleVar(value=0.9) # Discharge cutoff voltage
|
self.discharge_cutoff = tk.DoubleVar(value=0.9) # Discharge cutoff voltage
|
||||||
self.rest_time = tk.DoubleVar(value=0.1) # Rest time in hours
|
self.rest_time = tk.DoubleVar(value=0.25) # Rest time in hours
|
||||||
self.c_rate = tk.DoubleVar(value=0.1) # C-rate for test (default C/5 = 0.2)
|
self.c_rate = tk.DoubleVar(value=0.1) # C-rate for test (default C/5 = 0.2)
|
||||||
|
|
||||||
# Test progress tracking
|
# Test progress tracking
|
||||||
@ -642,17 +642,32 @@ class BatteryTester:
|
|||||||
self.last_update_time = now
|
self.last_update_time = now
|
||||||
self.capacity_ah.set(self.capacity_ah.get() + current_current * delta_t / 3600)
|
self.capacity_ah.set(self.capacity_ah.get() + current_current * delta_t / 3600)
|
||||||
|
|
||||||
|
if not self.continuous_var.get() and self.continuous_mode: # Only update if it was previously enabled
|
||||||
|
self.continuous_mode = False # Ensure we don't start a new cycle
|
||||||
|
self.status_var.set(
|
||||||
|
f"Continuous Mode disabled | "
|
||||||
|
f"Discharging to {self.discharge_cutoff.get()}V (will stop after this cycle) | "
|
||||||
|
f"Current: {current_current:.3f}A | "
|
||||||
|
f"Capacity: {self.capacity_ah.get():.4f}Ah"
|
||||||
|
)
|
||||||
|
self.root.update() # Force UI update
|
||||||
|
|
||||||
|
else:
|
||||||
|
# Default status message
|
||||||
self.status_var.set(
|
self.status_var.set(
|
||||||
f"Discharging: {current_voltage:.3f}V / {self.discharge_cutoff.get()}V | "
|
f"Discharging: {current_voltage:.3f}V / {self.discharge_cutoff.get()}V | "
|
||||||
f"Current: {current_current:.3f}A | "
|
f"Current: {current_current:.3f}A | "
|
||||||
f"Capacity: {self.capacity_ah.get():.4f}Ah"
|
f"Capacity: {self.capacity_ah.get():.4f}Ah"
|
||||||
)
|
)
|
||||||
|
|
||||||
self.root.update()
|
self.root.update()
|
||||||
|
|
||||||
if current_voltage <= self.discharge_cutoff.get() or self.request_stop:
|
if current_voltage <= self.discharge_cutoff.get() or self.request_stop:
|
||||||
break
|
break
|
||||||
|
|
||||||
time.sleep(0.1) # More frequent checks
|
if not self.continuous_var.get():
|
||||||
|
self.test_running = False
|
||||||
|
break # Exit the main test loop
|
||||||
|
|
||||||
# 4. Rest period after discharge (only if not stopping)
|
# 4. Rest period after discharge (only if not stopping)
|
||||||
if self.test_running and not self.request_stop:
|
if self.test_running and not self.request_stop:
|
||||||
@ -688,19 +703,6 @@ class BatteryTester:
|
|||||||
# Write cycle summary to log file
|
# Write cycle summary to log file
|
||||||
self.write_cycle_summary()
|
self.write_cycle_summary()
|
||||||
|
|
||||||
# Short rest between cycles (only in continuous mode)
|
|
||||||
if self.continuous_mode and self.test_running and not self.request_stop:
|
|
||||||
rest_end_time = time.time() + (self.rest_time.get() * 3600)
|
|
||||||
while time.time() < rest_end_time and self.test_running and not self.request_stop:
|
|
||||||
time_left = max(0, rest_end_time - time.time())
|
|
||||||
self.test_phase.set("Resting Between Cycles")
|
|
||||||
self.status_var.set(
|
|
||||||
f"Resting between cycles | "
|
|
||||||
f"Time left: {time_left/60:.1f} min"
|
|
||||||
)
|
|
||||||
self.root.update()
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
# Finalize test if stopped or completed
|
# Finalize test if stopped or completed
|
||||||
self.safe_after(0, self.finalize_test)
|
self.safe_after(0, self.finalize_test)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user