toolhead: Add a SET_VELOCITY_LIMIT command
Add a command to adjust the maximum velocity, acceleration, and junction deviation parameters. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
d5dc6b785d
commit
bdd26e421b
|
@ -80,6 +80,10 @@ The following standard commands are supported:
|
||||||
cycles. If the WRITE_FILE parameter is enabled, then the file
|
cycles. If the WRITE_FILE parameter is enabled, then the file
|
||||||
/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>]
|
||||||
|
[ACCEL_TO_DECEL=<value>] [JUNCTION_DEVIATION=<value>]`: 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 [ADVANCE=<pressure_advance>]
|
- `SET_PRESSURE_ADVANCE [ADVANCE=<pressure_advance>]
|
||||||
[ADVANCE_LOOKAHEAD_TIME=<pressure_advance_lookahead_time>]`:
|
[ADVANCE_LOOKAHEAD_TIME=<pressure_advance_lookahead_time>]`:
|
||||||
Set pressure advance parameters.
|
Set pressure advance parameters.
|
||||||
|
|
|
@ -193,11 +193,15 @@ class ToolHead:
|
||||||
self.mcu = self.all_mcus[0]
|
self.mcu = self.all_mcus[0]
|
||||||
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.)
|
||||||
max_accel_to_decel = config.getfloat('max_accel_to_decel',
|
self.requested_accel_to_decel = config.getfloat(
|
||||||
self.max_accel * 0.5, above=0.)
|
'max_accel_to_decel', self.max_accel * 0.5, above=0.)
|
||||||
self.max_accel_to_decel = min(max_accel_to_decel, self.max_accel)
|
self.max_accel_to_decel = min(self.requested_accel_to_decel,
|
||||||
|
self.max_accel)
|
||||||
self.junction_deviation = config.getfloat(
|
self.junction_deviation = config.getfloat(
|
||||||
'junction_deviation', 0.02, minval=0.)
|
'junction_deviation', 0.02, 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.move_queue = MoveQueue()
|
||||||
self.commanded_pos = [0., 0., 0., 0.]
|
self.commanded_pos = [0., 0., 0., 0.]
|
||||||
# Print time tracking
|
# Print time tracking
|
||||||
|
@ -230,6 +234,10 @@ class ToolHead:
|
||||||
'delta': delta.DeltaKinematics}
|
'delta': delta.DeltaKinematics}
|
||||||
self.kin = config.getchoice('kinematics', kintypes)(
|
self.kin = config.getchoice('kinematics', kintypes)(
|
||||||
self, printer, config)
|
self, printer, config)
|
||||||
|
# SET_VELOCITY_LIMIT command
|
||||||
|
gcode = printer.lookup_object('gcode')
|
||||||
|
gcode.register_command('SET_VELOCITY_LIMIT', self.cmd_SET_VELOCITY_LIMIT,
|
||||||
|
desc=self.cmd_SET_VELOCITY_LIMIT_help)
|
||||||
# Print time tracking
|
# Print time tracking
|
||||||
def update_move_time(self, movetime):
|
def update_move_time(self, movetime):
|
||||||
self.print_time += movetime
|
self.print_time += movetime
|
||||||
|
@ -399,6 +407,33 @@ 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))
|
||||||
|
cmd_SET_VELOCITY_LIMIT_help = "Set printer velocity limits"
|
||||||
|
def cmd_SET_VELOCITY_LIMIT(self, params):
|
||||||
|
print_time = self.get_last_move_time()
|
||||||
|
gcode = self.printer.lookup_object('gcode')
|
||||||
|
max_velocity = gcode.get_float(
|
||||||
|
'VELOCITY', params, self.max_velocity,
|
||||||
|
above=0., maxval=self.config_max_velocity)
|
||||||
|
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)
|
||||||
|
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
|
||||||
|
msg = ("max_velocity: %.6f\n"
|
||||||
|
"max_accel: %.6f\n"
|
||||||
|
"max_accel_to_decel: %.6f\n"
|
||||||
|
"junction_deviation: %.6f"% (
|
||||||
|
max_velocity, max_accel, self.requested_accel_to_decel,
|
||||||
|
junction_deviation))
|
||||||
|
self.printer.set_rollover_info("toolhead", "toolhead: %s" % (msg,))
|
||||||
|
gcode.respond_info(msg)
|
||||||
|
|
||||||
def add_printer_objects(printer, config):
|
def add_printer_objects(printer, config):
|
||||||
printer.add_object('toolhead', ToolHead(printer, config))
|
printer.add_object('toolhead', ToolHead(printer, config))
|
||||||
|
|
Loading…
Reference in New Issue