MainCode/adalm1000_logger.py aktualisiert

Got it working, from the push before.
(Deepseek)
This commit is contained in:
Jan 2025-06-13 18:16:00 +02:00
parent 81ccc8ccd7
commit 12fb82ce80

View File

@ -425,7 +425,7 @@ class BatteryTester:
self.cycle_count.set(0) self.cycle_count.set(0)
# Ensure plot is properly reset for new test # Ensure plot is properly reset for new test
self.reset_plot_data() self.reset_plot()
# Generate base filename without cycle number # Generate base filename without cycle number
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
@ -521,7 +521,7 @@ class BatteryTester:
self.coulomb_efficiency.set(0.0) self.coulomb_efficiency.set(0.0)
# Reset plot # Reset plot
self.reset_plot_data() self.reset_plot()
# Update UI # Update UI
self.status_var.set("Test stopped - Ready for new test") self.status_var.set("Test stopped - Ready for new test")
@ -773,21 +773,30 @@ class BatteryTester:
except Exception as e: except Exception as e:
print(f"GUI update error: {e}") print(f"GUI update error: {e}")
def reset_plot_data(self): def reset_plot(self):
"""Clear and reset plot data for a new test""" """Reset the plot completely for a new test"""
# Clear the data lines
self.line_voltage.set_data([], []) self.line_voltage.set_data([], [])
self.line_current.set_data([], []) self.line_current.set_data([], [])
# Reset to reasonable default ranges
# Reset the data buffers
self.time_data.clear()
self.voltage_data.clear()
self.current_data.clear()
# Set reasonable initial axis ranges
voltage_padding = 0.2 voltage_padding = 0.2
min_voltage = max(0, self.discharge_cutoff.get() - voltage_padding) min_voltage = max(0, self.discharge_cutoff.get() - voltage_padding)
max_voltage = self.charge_cutoff.get() + voltage_padding max_voltage = self.charge_cutoff.get() + voltage_padding
self.ax.set_xlim(0, 10) # Small initial time range self.ax.set_xlim(0, 10) # 10s initial range
self.ax.set_ylim(min_voltage, max_voltage) self.ax.set_ylim(min_voltage, max_voltage)
current_padding = 0.05 current_padding = 0.05
test_current = self.c_rate.get() * self.capacity.get() test_current = self.c_rate.get() * self.capacity.get()
max_current = test_current * 1.5 # Add 50% padding max_current = test_current * 1.5 # 50% padding
self.ax2.set_ylim(-max_current - current_padding, max_current + current_padding) self.ax2.set_ylim(-max_current - current_padding, max_current + current_padding)
# Force redraw
self.canvas.draw() self.canvas.draw()
def write_cycle_summary(self): def write_cycle_summary(self):