From c49d3fdb17d6ba8f90099826355200d5219ab6b6 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 1 Dec 2016 15:29:26 -0500 Subject: toolhead: Specify maximum acceleration and velocity in toolhead class Change the config file so the maximum accel and velocity are specified in the "printer" section instead of the individual "stepper" sections. The underlying code limits the velocity and accel of the toolhead relative to the print object, so it makes sense to configure the system that was as well. Signed-off-by: Kevin O'Connor --- klippy/stepper.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'klippy/stepper.py') diff --git a/klippy/stepper.py b/klippy/stepper.py index f770afdb..71a5c8c6 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -15,9 +15,7 @@ class PrinterStepper: self.step_dist = config.getfloat('step_distance') 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.min_stop_interval = 0. self.homing_speed = config.getfloat('homing_speed', 5.0) self.homing_positive_dir = config.getboolean( @@ -47,17 +45,16 @@ class PrinterStepper: self.position_max = config.getfloat('position_max', 0.) self.need_motor_enable = True - def set_max_jerk(self, max_jerk): - self.max_jerk = max_jerk + def set_max_jerk(self, max_halt_velocity, max_accel): + jc = max_halt_velocity / max_accel + inv_max_step_accel = self.step_dist / max_accel + self.min_stop_interval = (math.sqrt(3.*inv_max_step_accel + jc**2) + - math.sqrt(inv_max_step_accel + jc**2)) def build_config(self): max_error = self.config.getfloat('max_error', 0.000050) step_pin = self.config.get('step_pin') dir_pin = self.config.get('dir_pin') - jc = self.max_jerk / self.max_accel - inv_max_step_accel = self.step_dist / self.max_accel - min_stop_interval = (math.sqrt(3.*inv_max_step_accel + jc**2) - - math.sqrt(inv_max_step_accel + jc**2)) - max_error - min_stop_interval = max(0., min_stop_interval) + min_stop_interval = max(0., self.min_stop_interval - max_error) mcu = self.printer.mcu self.mcu_stepper = mcu.create_stepper( step_pin, dir_pin, min_stop_interval, max_error) -- cgit v1.2.3-70-g09d2