From c87c090264fb9fd91bc87fbc63a05c5e53e3c484 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 2 Jan 2017 18:58:45 -0500 Subject: [PATCH] extruder: Calculate sane defaults for extrude only velocity and accel Instead of requiring the user enter velocity and accel parameters for extrude only moves, calculate sane defaults from the printer's maximum velocity and accel. Signed-off-by: Kevin O'Connor --- config/avrsim.cfg | 2 -- config/example-delta.cfg | 2 -- config/example.cfg | 12 ++++++++---- config/makergear-m2-2012.cfg | 2 -- klippy/cartesian.py | 2 +- klippy/delta.py | 3 +-- klippy/extruder.py | 9 +++++++-- klippy/toolhead.py | 5 ++++- 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/config/avrsim.cfg b/config/avrsim.cfg index 9fbcfb7c..83afde34 100644 --- a/config/avrsim.cfg +++ b/config/avrsim.cfg @@ -44,8 +44,6 @@ enable_pin: ar25 step_distance: .004242 nozzle_diameter: 0.500 filament_diameter: 3.500 -max_velocity: 200000 -max_accel: 3000 heater_pin: ar4 thermistor_pin: analog1 thermistor_type: EPCOS 100K B57560G104F diff --git a/config/example-delta.cfg b/config/example-delta.cfg index 41e238ec..01ab6482 100644 --- a/config/example-delta.cfg +++ b/config/example-delta.cfg @@ -48,8 +48,6 @@ enable_pin: !ar24 step_distance: .0022 nozzle_diameter: 0.400 filament_diameter: 1.750 -max_velocity: 200 -max_accel: 3000 heater_pin: ar10 thermistor_pin: analog13 thermistor_type: ATC Semitec 104GT-2 diff --git a/config/example.cfg b/config/example.cfg index 98d1c0d1..ce6a398d 100644 --- a/config/example.cfg +++ b/config/example.cfg @@ -125,12 +125,16 @@ filament_diameter: 3.500 # may be. If an extrude only move requests a distance greater than # this value it will cause an error to be returned. The default is # 50mm. -max_velocity: 200000 +#max_extrude_only_velocity: # Maximum velocity (in mm/s) of the extruder motor for extrude only -# moves. This parameter must be provided. -max_accel: 3000 +# moves. If this is not specified then it is calculated to match the +# limit an XY printing move with a max_extrude_cross_section +# extrusion would have. +#max_extrude_only_accel: # Maximum acceleration (in mm/s^2) of the extruder motor for extrude -# only moves. This parameter must be provided. +# only moves. If this is not specified then it is calculated to +# match the limit an XY printing move with a +# max_extrude_cross_section extrusion would have. #pressure_advance: 0.0 # The amount of raw filament to push into the extruder during # extruder acceleration. An equal amount of filament is retracted diff --git a/config/makergear-m2-2012.cfg b/config/makergear-m2-2012.cfg index 83deee9b..833ea72a 100644 --- a/config/makergear-m2-2012.cfg +++ b/config/makergear-m2-2012.cfg @@ -50,8 +50,6 @@ enable_pin: !PA4 step_distance: .004242 nozzle_diameter: 0.350 filament_diameter: 1.750 -max_velocity: 200000 -max_accel: 3000 pressure_advance: 0.07 heater_pin: PH6 thermistor_pin: PF0 diff --git a/klippy/cartesian.py b/klippy/cartesian.py index b2bd9661..636e9284 100644 --- a/klippy/cartesian.py +++ b/klippy/cartesian.py @@ -17,7 +17,7 @@ class CartKinematics: self.max_z_accel = config.getfloat('max_z_accel', 9999999.9) self.need_motor_enable = True self.limits = [(1.0, -1.0)] * 3 - def set_max_jerk(self, max_xy_halt_velocity, max_accel): + def set_max_jerk(self, max_xy_halt_velocity, max_velocity, max_accel): self.steppers[0].set_max_jerk(max_xy_halt_velocity, max_accel) self.steppers[1].set_max_jerk(max_xy_halt_velocity, max_accel) self.steppers[2].set_max_jerk(0., self.max_z_accel) diff --git a/klippy/delta.py b/klippy/delta.py index f8f85c02..041b6ce7 100644 --- a/klippy/delta.py +++ b/klippy/delta.py @@ -29,8 +29,7 @@ class DeltaKinematics: (cos(210.)*radius, sin(210.)*radius), (cos(330.)*radius, sin(330.)*radius), (cos(90.)*radius, sin(90.)*radius)] - def set_max_jerk(self, max_xy_halt_velocity, max_accel): - # XXX - this sets conservative values + def set_max_jerk(self, max_xy_halt_velocity, max_velocity, max_accel): for stepper in self.steppers: stepper.set_max_jerk(max_xy_halt_velocity, max_accel) def build_config(self): diff --git a/klippy/extruder.py b/klippy/extruder.py index 9e3d8143..7e314a7b 100644 --- a/klippy/extruder.py +++ b/klippy/extruder.py @@ -8,6 +8,7 @@ import stepper, heater, homing class PrinterExtruder: def __init__(self, printer, config): + self.config = config self.heater = heater.PrinterHeater(printer, config) self.stepper = stepper.PrinterStepper(printer, config, 'extruder') nozzle_diameter = config.getfloat('nozzle_diameter') @@ -17,11 +18,15 @@ class PrinterExtruder: 'max_extrude_cross_section', 4. * nozzle_diameter**2) self.max_extrude_ratio = max_cross_section / filament_area self.max_e_dist = config.getfloat('max_extrude_only_distance', 50.) - self.max_e_velocity = config.getfloat('max_velocity') - self.max_e_accel = config.getfloat('max_accel') + self.max_e_velocity = self.max_e_accel = None self.pressure_advance = config.getfloat('pressure_advance', 0.) self.need_motor_enable = True self.extrude_pos = 0. + def set_max_jerk(self, max_xy_halt_velocity, max_velocity, max_accel): + self.max_e_velocity = self.config.getfloat( + 'max_extrude_only_velocity', max_velocity * self.max_extrude_ratio) + self.max_e_accel = self.config.getfloat( + 'max_extrude_only_accel', max_accel * self.max_extrude_ratio) def build_config(self): self.heater.build_config() self.stepper.set_max_jerk(9999999.9, 9999999.9) diff --git a/klippy/toolhead.py b/klippy/toolhead.py index 614ab4b1..922749ec 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -179,7 +179,10 @@ class ToolHead: self.motor_off_time = self.reactor.NEVER self.flush_timer = self.reactor.register_timer(self._flush_handler) def build_config(self): - self.kin.set_max_jerk(0.005 * self.max_accel, self.max_accel) # XXX + xy_halt = 0.005 * self.max_accel # XXX + self.kin.set_max_jerk(xy_halt, self.max_speed, self.max_accel) + if self.extruder is not None: + self.extruder.set_max_jerk(xy_halt, self.max_speed, self.max_accel) self.kin.build_config() # Print time tracking def update_move_time(self, movetime):