diff --git a/config/example.cfg b/config/example.cfg index cf02bf19..d8ca95fa 100644 --- a/config/example.cfg +++ b/config/example.cfg @@ -296,11 +296,16 @@ max_z_accel: 30 #motor_off_time: 600 # Time (in seconds) of idle time before the printer will try to # disable active motors. The default is 600 seconds. -#junction_deviation: 0.02 -# Distance (in mm) used to control the internal approximated -# centripetal velocity cornering algorithm. A larger number will -# permit higher "cornering speeds" at the junction of two moves. The -# default is 0.02mm. +#square_corner_velocity: 5.0 +# The maximum velocity (in mm/s) that the toolhead may travel a 90 +# degree corner at. A non-zero value can reduce changes in extruder +# flow rates by enabling instantaneous velocity changes of the +# toolhead during cornering. This value configures the internal +# centripetal velocity cornering algorithm; corners with angles +# larger than 90 degrees will have a higher cornering velocity while +# corners with angles less than 90 degrees will have a lower +# cornering velocity. If this is set to zero then the toolhead will +# decelerate to zero at each corner. The default is 5mm/s. # Looking for more options? Check the example-extras.cfg file. diff --git a/docs/FAQ.md b/docs/FAQ.md index d2fc3ccd..8a67dcf2 100644 --- a/docs/FAQ.md +++ b/docs/FAQ.md @@ -220,7 +220,7 @@ TMC driver. Trinamic has indicated that this could occur if the driver is in "stealthChop mode" and an abrupt velocity change occurs. If you experience this problem during homing, consider using a slower homing speed. If you experience this problem in the middle of a print, -consider using a lower junction_deviation setting. +consider using a lower square_corner_velocity setting. ### When I set "restart_method=command" my AVR device just hangs on a restart diff --git a/docs/G-Codes.md b/docs/G-Codes.md index d3da572b..25e30445 100644 --- a/docs/G-Codes.md +++ b/docs/G-Codes.md @@ -97,9 +97,9 @@ The following standard commands are supported: /tmp/heattest.txt will be created with a log of all temperature samples taken during the test. - `SET_VELOCITY_LIMIT [VELOCITY=] [ACCEL=] - [ACCEL_TO_DECEL=] [JUNCTION_DEVIATION=]`: Modify the - printer's velocity limits. Note that one may only set values less - than or equal to the limits specified in the config file. + [ACCEL_TO_DECEL=] [SQUARE_CORNER_VELOCITY=]`: Modify + the printer's velocity limits. Note that one may only set values + less than or equal to the limits specified in the config file. - `SET_PRESSURE_ADVANCE [EXTRUDER=] [ADVANCE=] [ADVANCE_LOOKAHEAD_TIME=]`: Set pressure advance parameters. If EXTRUDER is not specified, it diff --git a/klippy/toolhead.py b/klippy/toolhead.py index e3c4d5dc..94ee0891 100644 --- a/klippy/toolhead.py +++ b/klippy/toolhead.py @@ -198,19 +198,22 @@ class ToolHead: self.reactor = self.printer.get_reactor() self.all_mcus = self.printer.lookup_module_objects('mcu') self.mcu = self.all_mcus[0] + self.move_queue = MoveQueue() + self.commanded_pos = [0., 0., 0., 0.] + # Velocity and acceleration control self.max_velocity = config.getfloat('max_velocity', above=0.) self.max_accel = config.getfloat('max_accel', above=0.) self.requested_accel_to_decel = config.getfloat( 'max_accel_to_decel', self.max_accel * 0.5, above=0.) self.max_accel_to_decel = min(self.requested_accel_to_decel, self.max_accel) - self.junction_deviation = config.getfloat( - 'junction_deviation', 0.02, minval=0.) + self.square_corner_velocity = config.getfloat( + 'square_corner_velocity', 5., minval=0.) self.config_max_velocity = self.max_velocity self.config_max_accel = self.max_accel - self.config_junction_deviation = self.junction_deviation - self.move_queue = MoveQueue() - self.commanded_pos = [0., 0., 0., 0.] + self.config_square_corner_velocity = self.square_corner_velocity + self.junction_deviation = 0. + self._calc_junction_deviation() # Print time tracking self.buffer_time_low = config.getfloat( 'buffer_time_low', 1.000, above=0.) @@ -425,6 +428,9 @@ class ToolHead: # determined experimentally. return min(self.max_velocity, math.sqrt(8. * self.junction_deviation * self.max_accel)) + def _calc_junction_deviation(self): + scv2 = self.square_corner_velocity**2 + self.junction_deviation = scv2 * (math.sqrt(2.) - 1.) / self.max_accel cmd_SET_VELOCITY_LIMIT_help = "Set printer velocity limits" def cmd_SET_VELOCITY_LIMIT(self, params): print_time = self.get_last_move_time() @@ -435,27 +441,29 @@ class ToolHead: max_accel = gcode.get_float( 'ACCEL', params, self.max_accel, above=0., maxval=self.config_max_accel) - junction_deviation = gcode.get_float( - 'JUNCTION_DEVIATION', params, self.junction_deviation, - minval=0., maxval=self.config_junction_deviation) + square_corner_velocity = gcode.get_float( + 'SQUARE_CORNER_VELOCITY', params, self.square_corner_velocity, + minval=0., maxval=self.config_square_corner_velocity) self.requested_accel_to_decel = gcode.get_float( 'ACCEL_TO_DECEL', params, self.requested_accel_to_decel, above=0.) self.max_velocity = max_velocity self.max_accel = max_accel self.max_accel_to_decel = min(self.requested_accel_to_decel, max_accel) - self.junction_deviation = junction_deviation + self.square_corner_velocity = square_corner_velocity + self._calc_junction_deviation() msg = ("max_velocity: %.6f\n" "max_accel: %.6f\n" "max_accel_to_decel: %.6f\n" - "junction_deviation: %.6f"% ( + "square_corner_velocity: %.6f"% ( max_velocity, max_accel, self.requested_accel_to_decel, - junction_deviation)) + square_corner_velocity)) self.printer.set_rollover_info("toolhead", "toolhead: %s" % (msg,)) gcode.respond_info(msg) def cmd_M204(self, params): gcode = self.printer.lookup_object('gcode') accel = gcode.get_float('S', params, above=0.) self.max_accel = min(accel, self.config_max_accel) + self._calc_junction_deviation() def add_printer_objects(config): config.get_printer().add_object('toolhead', ToolHead(config)) diff --git a/test/klippy/commands.test b/test/klippy/commands.test index 03c45125..a9581dae 100644 --- a/test/klippy/commands.test +++ b/test/klippy/commands.test @@ -24,7 +24,7 @@ SET_GCODE_OFFSET Z=.1 M206 Z-.2 SET_GCODE_OFFSET Z_ADJUST=-.1 -SET_VELOCITY_LIMIT ACCEL=100 VELOCITY=20 JUNCTION_DEVIATION=.001 ACCEL_TO_DECEL=200 +SET_VELOCITY_LIMIT ACCEL=100 VELOCITY=20 SQUARE_CORNER_VELOCITY=1 ACCEL_TO_DECEL=200 M204 S500 SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=.001