From 589017a3d6de81a52c5a496a4b82ae202a4f990c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 22 Jul 2016 15:38:13 -0400 Subject: [PATCH] stepper: Have caller calculate max jerk velocity Allow the owner of the stepper object to cacluate the maximum step jerk velocity. This is used to ensure there is no communication error between mcu and host. Disable checking of jerk velocity for extruder stepper motors. Signed-off-by: Kevin O'Connor --- klippy/cartesian.py | 2 ++ klippy/extruder.py | 1 + klippy/stepper.py | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/klippy/cartesian.py b/klippy/cartesian.py index b2bc1b43..67c68be5 100644 --- a/klippy/cartesian.py +++ b/klippy/cartesian.py @@ -15,6 +15,8 @@ class CartKinematics: for n in steppers] self.stepper_pos = [0, 0, 0] def build_config(self): + for stepper in self.steppers[:2]: + stepper.set_max_jerk(0.005 * stepper.max_accel) # XXX for stepper in self.steppers: stepper.build_config() def set_position(self, newpos): diff --git a/klippy/extruder.py b/klippy/extruder.py index 67ee13ed..25655dc9 100644 --- a/klippy/extruder.py +++ b/klippy/extruder.py @@ -14,6 +14,7 @@ class PrinterExtruder: self.stepper_pos = 0 def build_config(self): self.heater.build_config() + self.stepper.set_max_jerk(9999999.9) self.stepper.build_config() def get_max_speed(self): return self.stepper.max_velocity, self.stepper.max_accel diff --git a/klippy/stepper.py b/klippy/stepper.py index 5a05e910..7c8438fc 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -15,6 +15,7 @@ class PrinterStepper: self.inv_step_dist = 1. / self.step_dist self.max_velocity = config.getfloat('max_velocity') self.max_accel = config.getfloat('max_accel') + self.max_jerk = 0. self.homing_speed = config.getfloat('homing_speed', 5.0) self.homing_positive_dir = config.getboolean( @@ -26,6 +27,8 @@ class PrinterStepper: self.clock_ticks = None self.need_motor_enable = True + def set_max_jerk(self, max_jerk): + self.max_jerk = max_jerk def build_config(self): self.clock_ticks = self.printer.mcu.get_mcu_freq() max_error = self.config.getfloat('max_error', 0.000050) @@ -33,9 +36,10 @@ class PrinterStepper: step_pin = self.config.get('step_pin') dir_pin = self.config.get('dir_pin') - jc = 0.005 # XXX + jc = self.max_jerk / self.max_accel inv_max_step_accel = self.step_dist / self.max_accel - min_stop_interval = int((math.sqrt(inv_max_step_accel + jc**2) - jc) + min_stop_interval = int((math.sqrt(3.*inv_max_step_accel + jc**2) + - math.sqrt(inv_max_step_accel + jc**2)) * self.clock_ticks) - max_error min_stop_interval = max(0, min_stop_interval) mcu = self.printer.mcu