mirror of
https://github.com/andreili/klipper.git
synced 2025-08-24 03:44:06 +02:00
manual_stepper: Support LIMIT_VELOCITY and LIMIT_ACCEL when using gcode axis
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
ee0bc3d697
commit
6c1d5d912a
@ -969,6 +969,7 @@ stepper move uses SYNC=0 then future G-Code movement commands may run
|
|||||||
in parallel with the stepper movement.
|
in parallel with the stepper movement.
|
||||||
|
|
||||||
`MANUAL_STEPPER STEPPER=config_name GCODE_AXIS=[A-Z]
|
`MANUAL_STEPPER STEPPER=config_name GCODE_AXIS=[A-Z]
|
||||||
|
[LIMIT_VELOCITY=<velocity>] [LIMIT_ACCEL=<accel>]
|
||||||
[INSTANTANEOUS_CORNER_VELOCITY=<velocity>]`: If the `GCODE_AXIS`
|
[INSTANTANEOUS_CORNER_VELOCITY=<velocity>]`: If the `GCODE_AXIS`
|
||||||
parameter is specified then it configures the stepper motor as an
|
parameter is specified then it configures the stepper motor as an
|
||||||
extra axis on `G1` move commands. For example, if one were to issue a
|
extra axis on `G1` move commands. For example, if one were to issue a
|
||||||
@ -979,6 +980,9 @@ xyz movements. If the motor is associated with a `GCODE_AXIS` then
|
|||||||
one may no longer issue movements using the above `MANUAL_STEPPER`
|
one may no longer issue movements using the above `MANUAL_STEPPER`
|
||||||
command - one may unregister the stepper with a `MANUAL_STEPPER
|
command - one may unregister the stepper with a `MANUAL_STEPPER
|
||||||
... GCODE_AXIS=` command to resume manual control of the motor. The
|
... GCODE_AXIS=` command to resume manual control of the motor. The
|
||||||
|
`LIMIT_VELOCITY` and `LIMIT_ACCEL` parameters allow one to reduce the
|
||||||
|
speed of `G1` moves if those moves would result in a velocity or
|
||||||
|
acceleration above the specified limits. The
|
||||||
`INSTANTANEOUS_CORNER_VELOCITY` specifies the maximum instantaneous
|
`INSTANTANEOUS_CORNER_VELOCITY` specifies the maximum instantaneous
|
||||||
velocity change (in mm/s) of the motor during the junction of two
|
velocity change (in mm/s) of the motor during the junction of two
|
||||||
moves (the default is 1mm/s).
|
moves (the default is 1mm/s).
|
||||||
|
@ -34,6 +34,7 @@ class ManualStepper:
|
|||||||
# Registered with toolhead as an axtra axis
|
# Registered with toolhead as an axtra axis
|
||||||
self.axis_gcode_id = None
|
self.axis_gcode_id = None
|
||||||
self.instant_corner_v = 0.
|
self.instant_corner_v = 0.
|
||||||
|
self.gaxis_limit_velocity = self.gaxis_limit_accel = 0.
|
||||||
# Register commands
|
# Register commands
|
||||||
stepper_name = config.get_name().split()[1]
|
stepper_name = config.get_name().split()[1]
|
||||||
gcode = self.printer.lookup_object('gcode')
|
gcode = self.printer.lookup_object('gcode')
|
||||||
@ -130,6 +131,8 @@ class ManualStepper:
|
|||||||
gcode_axis = gcmd.get('GCODE_AXIS').upper()
|
gcode_axis = gcmd.get('GCODE_AXIS').upper()
|
||||||
instant_corner_v = gcmd.get_float('INSTANTANEOUS_CORNER_VELOCITY', 1.,
|
instant_corner_v = gcmd.get_float('INSTANTANEOUS_CORNER_VELOCITY', 1.,
|
||||||
minval=0.)
|
minval=0.)
|
||||||
|
limit_velocity = gcmd.get_float('LIMIT_VELOCITY', 999999.9, above=0.)
|
||||||
|
limit_accel = gcmd.get_float('LIMIT_ACCEL', 999999.9, above=0.)
|
||||||
if self.axis_gcode_id is not None:
|
if self.axis_gcode_id is not None:
|
||||||
if gcode_axis:
|
if gcode_axis:
|
||||||
raise gcmd.error("Must unregister axis first")
|
raise gcmd.error("Must unregister axis first")
|
||||||
@ -149,6 +152,8 @@ class ManualStepper:
|
|||||||
raise gcmd.error("Axis '%s' already registered" % (gcode_axis,))
|
raise gcmd.error("Axis '%s' already registered" % (gcode_axis,))
|
||||||
self.axis_gcode_id = gcode_axis
|
self.axis_gcode_id = gcode_axis
|
||||||
self.instant_corner_v = instant_corner_v
|
self.instant_corner_v = instant_corner_v
|
||||||
|
self.gaxis_limit_velocity = limit_velocity
|
||||||
|
self.gaxis_limit_accel = limit_accel
|
||||||
toolhead.add_extra_axis(self, self.get_position()[0])
|
toolhead.add_extra_axis(self, self.get_position()[0])
|
||||||
toolhead.register_step_generator(self.rail.generate_steps)
|
toolhead.register_step_generator(self.rail.generate_steps)
|
||||||
def process_move(self, print_time, move, ea_index):
|
def process_move(self, print_time, move, ea_index):
|
||||||
@ -163,12 +168,18 @@ class ManualStepper:
|
|||||||
1., 0., 0.,
|
1., 0., 0.,
|
||||||
start_v, cruise_v, accel)
|
start_v, cruise_v, accel)
|
||||||
def check_move(self, move, ea_index):
|
def check_move(self, move, ea_index):
|
||||||
|
# Check move is in bounds
|
||||||
movepos = move.end_pos[ea_index]
|
movepos = move.end_pos[ea_index]
|
||||||
if ((self.pos_min is not None and movepos < self.pos_min)
|
if ((self.pos_min is not None and movepos < self.pos_min)
|
||||||
or (self.pos_max is not None and movepos > self.pos_max)):
|
or (self.pos_max is not None and movepos > self.pos_max)):
|
||||||
raise move.move_error()
|
raise move.move_error()
|
||||||
# XXX - support max accel/velocity
|
# Check if need to limit maximum velocity and acceleration
|
||||||
# XXX - support non-kinematic max accel/velocity
|
axis_ratio = move.move_d / abs(move.axes_d[ea_index])
|
||||||
|
limit_velocity = self.gaxis_limit_velocity * axis_ratio
|
||||||
|
limit_accel = self.gaxis_limit_accel * axis_ratio
|
||||||
|
if not move.is_kinematic_move and self.accel:
|
||||||
|
limit_accel = min(limit_accel, self.accel * axis_ratio)
|
||||||
|
move.limit_speed(limit_velocity, limit_accel)
|
||||||
def calc_junction(self, prev_move, move, ea_index):
|
def calc_junction(self, prev_move, move, ea_index):
|
||||||
diff_r = move.axes_r[ea_index] - prev_move.axes_r[ea_index]
|
diff_r = move.axes_r[ea_index] - prev_move.axes_r[ea_index]
|
||||||
if diff_r:
|
if diff_r:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user