From c9fbc03e79902126eaabb3157adafd58f63c7092 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9l=C3=A8ne=20Corbineau?= Date: Tue, 14 Jan 2025 19:00:04 +0100 Subject: [PATCH] Added simple controller --- GCode_Interpreterdc.py | 1 + controller.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/GCode_Interpreterdc.py b/GCode_Interpreterdc.py index 1947c10..1effc21 100644 --- a/GCode_Interpreterdc.py +++ b/GCode_Interpreterdc.py @@ -66,6 +66,7 @@ class GCodeToMotors: z_throttle : int = 0 feedrate: float = 0. # In m/mn + ctrl_step: float = 1e-5 # in s abs_mode: bool = False diff --git a/controller.py b/controller.py index bd2461b..3fbef74 100644 --- a/controller.py +++ b/controller.py @@ -51,15 +51,30 @@ class PIDController(Controller): gtm.z_throttle = 0 -class Dezimpots(Controller): +class DummyController(Controller): def __init__(self): super().__init__() def __call__(self, gtm, *args, **kwargs): print("Call Me") + feed = self.feedrate + dx, dy, dz = self.delta_units + feed_x = feed * dx/(dx**2 + dy**2 + dz**2) + feed_y = feed * dy/(dx**2 + dy**2 + dz**2) + feed_z = feed * dz/(dz**2 + dy**2 + dz**2) + gtm.x_direction = 1 if gtm.delta_steps[0] > 0 else 0 gtm.y_direction = 1 if gtm.delta_steps[1] > 0 else 0 gtm.z_direction = 1 if gtm.delta_steps[2] > 0 else 0 + gtm.throttle_x = floor(gtm.FAST_XY_FEEDRATE/feed_x) + gtm.throttle_y = floor(gtm.FAST_XY_FEEDRATE/feed_y) + gtm.throttle_z = floor(gtm.FAST_Z_FEEDRATE/feed_z) + gtm.throttle_x = 0 if gtm.throttle_x >= 65536 else gtm.throttle_x + gtm.throttle_y = 0 if gtm.throttle_y >= 65536 else gtm.throttle_y + gtm.throttle_z = 0 if gtm.throttle_z >= 65536 else gtm.throttle_z + + # If we are close enough, we're good + return (gtm.ctrl_step*(feed*1000./60) >= 2.*(dx**2+dy**2+dz**2)**.5):