diff --git a/MainCode/adalm1000_logger.py b/MainCode/adalm1000_logger.py index a195842..a84acf0 100644 --- a/MainCode/adalm1000_logger.py +++ b/MainCode/adalm1000_logger.py @@ -670,13 +670,17 @@ class BatteryTester(QMainWindow): def update_status(self): """Update status information periodically""" + now = time.time() + if not hasattr(self, '_last_log_time'): + self._last_log_time = now + if self.test_running: # Update capacity calculations if in test mode if self.measuring and self.time_data: current_time = time.time() - self.start_time delta_t = current_time - self.last_update_time self.last_update_time = current_time - + if self.test_phase == "Discharge": current_current = abs(self.current_data[-1]) self.capacity_ah += current_current * delta_t / 3600 @@ -686,6 +690,25 @@ class BatteryTester(QMainWindow): self.charge_capacity += current_current * delta_t / 3600 self.charge_capacity_label.setText(f"{self.charge_capacity:.4f}") + # Logging (1x pro Sekunde) + if hasattr(self, 'log_writer') and (now - self._last_log_time >= 1.0): + if self.time_data: + current_time = self.time_data[-1] + voltage = self.voltage_data[-1] + current = self.current_data[-1] + self.log_writer.writerow([ + f"{current_time:.3f}", + f"{voltage:.6f}", + f"{current:.6f}", + self.test_phase, + f"{self.capacity_ah:.4f}", + f"{self.charge_capacity:.4f}", + f"{self.coulomb_efficiency:.1f}", + f"{self.cycle_count}" + ]) + self.current_cycle_file.flush() + self._last_log_time = now + def start_test(self): """Start the full battery test cycle""" # Clean up any previous test