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 <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2016-12-01 15:29:26 -05:00
parent fcaf359e89
commit c49d3fdb17
8 changed files with 52 additions and 53 deletions

View file

@ -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)