toolhead: Replace junction_deviation with square_corner_velocity
The junction_deviation configuration parameter has a number of quirks that make it difficult to configure. Replace it with a "square_corner_velocity" configuration parameter. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
ca505bf4ac
commit
0025fbf10d
|
@ -296,11 +296,16 @@ max_z_accel: 30
|
||||||
#motor_off_time: 600
|
#motor_off_time: 600
|
||||||
# Time (in seconds) of idle time before the printer will try to
|
# Time (in seconds) of idle time before the printer will try to
|
||||||
# disable active motors. The default is 600 seconds.
|
# disable active motors. The default is 600 seconds.
|
||||||
#junction_deviation: 0.02
|
#square_corner_velocity: 5.0
|
||||||
# Distance (in mm) used to control the internal approximated
|
# The maximum velocity (in mm/s) that the toolhead may travel a 90
|
||||||
# centripetal velocity cornering algorithm. A larger number will
|
# degree corner at. A non-zero value can reduce changes in extruder
|
||||||
# permit higher "cornering speeds" at the junction of two moves. The
|
# flow rates by enabling instantaneous velocity changes of the
|
||||||
# default is 0.02mm.
|
# 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.
|
# Looking for more options? Check the example-extras.cfg file.
|
||||||
|
|
|
@ -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
|
is in "stealthChop mode" and an abrupt velocity change occurs. If you
|
||||||
experience this problem during homing, consider using a slower homing
|
experience this problem during homing, consider using a slower homing
|
||||||
speed. If you experience this problem in the middle of a print,
|
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
|
### When I set "restart_method=command" my AVR device just hangs on a restart
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,9 @@ The following standard commands are supported:
|
||||||
/tmp/heattest.txt will be created with a log of all temperature
|
/tmp/heattest.txt will be created with a log of all temperature
|
||||||
samples taken during the test.
|
samples taken during the test.
|
||||||
- `SET_VELOCITY_LIMIT [VELOCITY=<value>] [ACCEL=<value>]
|
- `SET_VELOCITY_LIMIT [VELOCITY=<value>] [ACCEL=<value>]
|
||||||
[ACCEL_TO_DECEL=<value>] [JUNCTION_DEVIATION=<value>]`: Modify the
|
[ACCEL_TO_DECEL=<value>] [SQUARE_CORNER_VELOCITY=<value>]`: Modify
|
||||||
printer's velocity limits. Note that one may only set values less
|
the printer's velocity limits. Note that one may only set values
|
||||||
than or equal to the limits specified in the config file.
|
less than or equal to the limits specified in the config file.
|
||||||
- `SET_PRESSURE_ADVANCE [EXTRUDER=<config_name>] [ADVANCE=<pressure_advance>]
|
- `SET_PRESSURE_ADVANCE [EXTRUDER=<config_name>] [ADVANCE=<pressure_advance>]
|
||||||
[ADVANCE_LOOKAHEAD_TIME=<pressure_advance_lookahead_time>]`:
|
[ADVANCE_LOOKAHEAD_TIME=<pressure_advance_lookahead_time>]`:
|
||||||
Set pressure advance parameters. If EXTRUDER is not specified, it
|
Set pressure advance parameters. If EXTRUDER is not specified, it
|
||||||
|
|
|
@ -198,19 +198,22 @@ class ToolHead:
|
||||||
self.reactor = self.printer.get_reactor()
|
self.reactor = self.printer.get_reactor()
|
||||||
self.all_mcus = self.printer.lookup_module_objects('mcu')
|
self.all_mcus = self.printer.lookup_module_objects('mcu')
|
||||||
self.mcu = self.all_mcus[0]
|
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_velocity = config.getfloat('max_velocity', above=0.)
|
||||||
self.max_accel = config.getfloat('max_accel', above=0.)
|
self.max_accel = config.getfloat('max_accel', above=0.)
|
||||||
self.requested_accel_to_decel = config.getfloat(
|
self.requested_accel_to_decel = config.getfloat(
|
||||||
'max_accel_to_decel', self.max_accel * 0.5, above=0.)
|
'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_to_decel = min(self.requested_accel_to_decel,
|
||||||
self.max_accel)
|
self.max_accel)
|
||||||
self.junction_deviation = config.getfloat(
|
self.square_corner_velocity = config.getfloat(
|
||||||
'junction_deviation', 0.02, minval=0.)
|
'square_corner_velocity', 5., minval=0.)
|
||||||
self.config_max_velocity = self.max_velocity
|
self.config_max_velocity = self.max_velocity
|
||||||
self.config_max_accel = self.max_accel
|
self.config_max_accel = self.max_accel
|
||||||
self.config_junction_deviation = self.junction_deviation
|
self.config_square_corner_velocity = self.square_corner_velocity
|
||||||
self.move_queue = MoveQueue()
|
self.junction_deviation = 0.
|
||||||
self.commanded_pos = [0., 0., 0., 0.]
|
self._calc_junction_deviation()
|
||||||
# Print time tracking
|
# Print time tracking
|
||||||
self.buffer_time_low = config.getfloat(
|
self.buffer_time_low = config.getfloat(
|
||||||
'buffer_time_low', 1.000, above=0.)
|
'buffer_time_low', 1.000, above=0.)
|
||||||
|
@ -425,6 +428,9 @@ class ToolHead:
|
||||||
# determined experimentally.
|
# determined experimentally.
|
||||||
return min(self.max_velocity,
|
return min(self.max_velocity,
|
||||||
math.sqrt(8. * self.junction_deviation * self.max_accel))
|
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"
|
cmd_SET_VELOCITY_LIMIT_help = "Set printer velocity limits"
|
||||||
def cmd_SET_VELOCITY_LIMIT(self, params):
|
def cmd_SET_VELOCITY_LIMIT(self, params):
|
||||||
print_time = self.get_last_move_time()
|
print_time = self.get_last_move_time()
|
||||||
|
@ -435,27 +441,29 @@ class ToolHead:
|
||||||
max_accel = gcode.get_float(
|
max_accel = gcode.get_float(
|
||||||
'ACCEL', params, self.max_accel,
|
'ACCEL', params, self.max_accel,
|
||||||
above=0., maxval=self.config_max_accel)
|
above=0., maxval=self.config_max_accel)
|
||||||
junction_deviation = gcode.get_float(
|
square_corner_velocity = gcode.get_float(
|
||||||
'JUNCTION_DEVIATION', params, self.junction_deviation,
|
'SQUARE_CORNER_VELOCITY', params, self.square_corner_velocity,
|
||||||
minval=0., maxval=self.config_junction_deviation)
|
minval=0., maxval=self.config_square_corner_velocity)
|
||||||
self.requested_accel_to_decel = gcode.get_float(
|
self.requested_accel_to_decel = gcode.get_float(
|
||||||
'ACCEL_TO_DECEL', params, self.requested_accel_to_decel, above=0.)
|
'ACCEL_TO_DECEL', params, self.requested_accel_to_decel, above=0.)
|
||||||
self.max_velocity = max_velocity
|
self.max_velocity = max_velocity
|
||||||
self.max_accel = max_accel
|
self.max_accel = max_accel
|
||||||
self.max_accel_to_decel = min(self.requested_accel_to_decel, 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"
|
msg = ("max_velocity: %.6f\n"
|
||||||
"max_accel: %.6f\n"
|
"max_accel: %.6f\n"
|
||||||
"max_accel_to_decel: %.6f\n"
|
"max_accel_to_decel: %.6f\n"
|
||||||
"junction_deviation: %.6f"% (
|
"square_corner_velocity: %.6f"% (
|
||||||
max_velocity, max_accel, self.requested_accel_to_decel,
|
max_velocity, max_accel, self.requested_accel_to_decel,
|
||||||
junction_deviation))
|
square_corner_velocity))
|
||||||
self.printer.set_rollover_info("toolhead", "toolhead: %s" % (msg,))
|
self.printer.set_rollover_info("toolhead", "toolhead: %s" % (msg,))
|
||||||
gcode.respond_info(msg)
|
gcode.respond_info(msg)
|
||||||
def cmd_M204(self, params):
|
def cmd_M204(self, params):
|
||||||
gcode = self.printer.lookup_object('gcode')
|
gcode = self.printer.lookup_object('gcode')
|
||||||
accel = gcode.get_float('S', params, above=0.)
|
accel = gcode.get_float('S', params, above=0.)
|
||||||
self.max_accel = min(accel, self.config_max_accel)
|
self.max_accel = min(accel, self.config_max_accel)
|
||||||
|
self._calc_junction_deviation()
|
||||||
|
|
||||||
def add_printer_objects(config):
|
def add_printer_objects(config):
|
||||||
config.get_printer().add_object('toolhead', ToolHead(config))
|
config.get_printer().add_object('toolhead', ToolHead(config))
|
||||||
|
|
|
@ -24,7 +24,7 @@ SET_GCODE_OFFSET Z=.1
|
||||||
M206 Z-.2
|
M206 Z-.2
|
||||||
SET_GCODE_OFFSET Z_ADJUST=-.1
|
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
|
M204 S500
|
||||||
|
|
||||||
SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=.001
|
SET_PRESSURE_ADVANCE EXTRUDER=extruder ADVANCE=.001
|
||||||
|
|
Loading…
Reference in New Issue