From 351adfd28d92b7b100a167d2930053108fc500a1 Mon Sep 17 00:00:00 2001 From: CamDavidsonPilon Date: Fri, 29 Nov 2024 13:53:51 -0500 Subject: [PATCH] fix estimate duty cycle not updating --- pioreactor/background_jobs/stirring.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pioreactor/background_jobs/stirring.py b/pioreactor/background_jobs/stirring.py index e38a9a4f..114f6bdd 100644 --- a/pioreactor/background_jobs/stirring.py +++ b/pioreactor/background_jobs/stirring.py @@ -290,6 +290,11 @@ def action_to_do_after_od_reading(self): self.poll_and_update_dc(2) def initialize_dodging_operation(self): + if config.getfloat("od_reading.config", "samples_per_second") >= 0.2: + self.logger.warning( + "Recommended to decrease `samples_per_second` to ensure there is time to start/stop stirring. Try 0.15 or less." + ) + self.set_duty_cycle(0) self.rpm_check_repeated_thread = RepeatedTimer( 1_000, @@ -424,7 +429,8 @@ def poll_and_update_dc(self, poll_for_seconds: Optional[float] = None) -> None: return result = self.pid.update(self._measured_rpm) - self.set_duty_cycle(self._estimate_duty_cycle + result) + self._estimate_duty_cycle += result + self.set_duty_cycle(self._estimate_duty_cycle) def on_ready_to_sleeping(self) -> None: self.rpm_check_repeated_thread.pause()