aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-04-25 14:53:50 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-04-30 11:09:08 -0400
commit5a5ecd88e22a25ef9ec5336f3d3220af042678be (patch)
tree14c7779643433627acfca2797eba4f45f65c975e
parentd1946fb6ed672d549f79a09d531de11c1463ed22 (diff)
downloadkutter-5a5ecd88e22a25ef9ec5336f3d3220af042678be.tar.gz
kutter-5a5ecd88e22a25ef9ec5336f3d3220af042678be.tar.xz
kutter-5a5ecd88e22a25ef9ec5336f3d3220af042678be.zip
stepper: Do not set min_stop_interval in micro-controller
The min_stop_interval safety check is fragile and leads to a notable amount of complexity. Avoid these issues by not programming this safety check. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/extras/extruder_stepper.py1
-rw-r--r--klippy/extras/manual_stepper.py1
-rw-r--r--klippy/kinematics/cartesian.py7
-rw-r--r--klippy/kinematics/corexy.py8
-rw-r--r--klippy/kinematics/corexz.py7
-rw-r--r--klippy/kinematics/delta.py6
-rw-r--r--klippy/kinematics/extruder.py1
-rw-r--r--klippy/kinematics/polar.py5
-rw-r--r--klippy/kinematics/rotary_delta.py5
-rw-r--r--klippy/kinematics/winch.py5
-rw-r--r--klippy/stepper.py20
-rw-r--r--klippy/toolhead.py6
12 files changed, 5 insertions, 67 deletions
diff --git a/klippy/extras/extruder_stepper.py b/klippy/extras/extruder_stepper.py
index 9678472a..a62b3f83 100644
--- a/klippy/extras/extruder_stepper.py
+++ b/klippy/extras/extruder_stepper.py
@@ -12,7 +12,6 @@ class ExtruderStepper:
stepper_name = config.get_name().split()[1]
self.extruder_name = config.get('extruder', 'extruder')
self.stepper = stepper.PrinterStepper(config)
- self.stepper.set_max_jerk(9999999.9, 9999999.9)
self.stepper.setup_itersolve('extruder_stepper_alloc')
self.printer.register_event_handler("klippy:connect",
self.handle_connect)
diff --git a/klippy/extras/manual_stepper.py b/klippy/extras/manual_stepper.py
index 47f2795e..2f36b6d1 100644
--- a/klippy/extras/manual_stepper.py
+++ b/klippy/extras/manual_stepper.py
@@ -28,7 +28,6 @@ class ManualStepper:
self.trapq_free_moves = ffi_lib.trapq_free_moves
self.rail.setup_itersolve('cartesian_stepper_alloc', 'x')
self.rail.set_trapq(self.trapq)
- self.rail.set_max_jerk(9999999.9, 9999999.9)
# Register commands
stepper_name = config.get_name().split()[1]
gcode = self.printer.lookup_object('gcode')
diff --git a/klippy/kinematics/cartesian.py b/klippy/kinematics/cartesian.py
index c2ca350a..e2c21900 100644
--- a/klippy/kinematics/cartesian.py
+++ b/klippy/kinematics/cartesian.py
@@ -31,12 +31,6 @@ class CartKinematics:
ranges = [r.get_range() for r in self.rails]
self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.)
self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.)
- # Setup stepper max halt velocity
- max_halt_velocity = toolhead.get_max_axis_halt()
- self.rails[0].set_max_jerk(max_halt_velocity, max_accel)
- self.rails[1].set_max_jerk(max_halt_velocity, max_accel)
- self.rails[2].set_max_jerk(min(max_halt_velocity, self.max_z_velocity),
- max_accel)
# Check for dual carriage support
if config.has_section('dual_carriage'):
dc_config = config.getsection('dual_carriage')
@@ -46,7 +40,6 @@ class CartKinematics:
dc_rail.setup_itersolve('cartesian_stepper_alloc', dc_axis)
for s in dc_rail.get_steppers():
toolhead.register_step_generator(s.generate_steps)
- dc_rail.set_max_jerk(max_halt_velocity, max_accel)
self.dual_carriage_rails = [
self.rails[self.dual_carriage_axis], dc_rail]
self.printer.lookup_object('gcode').register_command(
diff --git a/klippy/kinematics/corexy.py b/klippy/kinematics/corexy.py
index 726ba3c6..451a88aa 100644
--- a/klippy/kinematics/corexy.py
+++ b/klippy/kinematics/corexy.py
@@ -34,14 +34,6 @@ class CoreXYKinematics:
ranges = [r.get_range() for r in self.rails]
self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.)
self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.)
- # Setup stepper max halt velocity
- max_halt_velocity = toolhead.get_max_axis_halt()
- max_xy_halt_velocity = max_halt_velocity * math.sqrt(2.)
- max_xy_accel = max_accel * math.sqrt(2.)
- self.rails[0].set_max_jerk(max_xy_halt_velocity, max_xy_accel)
- self.rails[1].set_max_jerk(max_xy_halt_velocity, max_xy_accel)
- self.rails[2].set_max_jerk(
- min(max_halt_velocity, self.max_z_velocity), self.max_z_accel)
def get_steppers(self):
return [s for rail in self.rails for s in rail.get_steppers()]
def calc_tag_position(self):
diff --git a/klippy/kinematics/corexz.py b/klippy/kinematics/corexz.py
index 2543977b..698e4c08 100644
--- a/klippy/kinematics/corexz.py
+++ b/klippy/kinematics/corexz.py
@@ -34,13 +34,6 @@ class CoreXZKinematics:
ranges = [r.get_range() for r in self.rails]
self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.)
self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.)
- # Setup stepper max halt velocity
- max_halt_velocity = toolhead.get_max_axis_halt()
- max_xy_halt_velocity = max_halt_velocity * math.sqrt(2.)
- max_xy_accel = max_accel * math.sqrt(2.)
- self.rails[0].set_max_jerk(max_xy_halt_velocity, max_xy_accel)
- self.rails[1].set_max_jerk(max_xy_halt_velocity, max_xy_accel)
- self.rails[2].set_max_jerk(max_xy_halt_velocity, max_xy_accel)
def get_steppers(self):
return [s for rail in self.rails for s in rail.get_steppers()]
def calc_tag_position(self):
diff --git a/klippy/kinematics/delta.py b/klippy/kinematics/delta.py
index 44331a91..0d17ed19 100644
--- a/klippy/kinematics/delta.py
+++ b/klippy/kinematics/delta.py
@@ -25,15 +25,11 @@ class DeltaKinematics:
self.rails = [rail_a, rail_b, rail_c]
config.get_printer().register_event_handler("stepper_enable:motor_off",
self._motor_off)
- # Setup stepper max halt velocity
+ # Setup max velocity
self.max_velocity, self.max_accel = toolhead.get_max_velocity()
self.max_z_velocity = config.getfloat(
'max_z_velocity', self.max_velocity,
above=0., maxval=self.max_velocity)
- max_halt_velocity = toolhead.get_max_axis_halt() * SLOW_RATIO
- max_halt_accel = self.max_accel * SLOW_RATIO
- for rail in self.rails:
- rail.set_max_jerk(max_halt_velocity, max_halt_accel)
# Read radius and arm lengths
self.radius = radius = config.getfloat('delta_radius', above=0.)
print_radius = config.getfloat('print_radius', radius, above=0.)
diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py
index 71f7b382..ea5161a9 100644
--- a/klippy/kinematics/extruder.py
+++ b/klippy/kinematics/extruder.py
@@ -36,7 +36,6 @@ class PrinterExtruder:
self.max_e_accel = config.getfloat(
'max_extrude_only_accel', max_accel * def_max_extrude_ratio
, above=0.)
- self.stepper.set_max_jerk(9999999.9, 9999999.9)
self.max_e_dist = config.getfloat(
'max_extrude_only_distance', 50., minval=0.)
self.instant_corner_v = config.getfloat(
diff --git a/klippy/kinematics/polar.py b/klippy/kinematics/polar.py
index 98b7c7e1..baa3a11c 100644
--- a/klippy/kinematics/polar.py
+++ b/klippy/kinematics/polar.py
@@ -36,11 +36,6 @@ class PolarKinematics:
min_z, max_z = self.rails[1].get_range()
self.axes_min = toolhead.Coord(-max_xy, -max_xy, min_z, 0.)
self.axes_max = toolhead.Coord(max_xy, max_xy, max_z, 0.)
- # Setup stepper max halt velocity
- max_halt_velocity = toolhead.get_max_axis_halt()
- stepper_bed.set_max_jerk(max_halt_velocity, max_accel)
- rail_arm.set_max_jerk(max_halt_velocity, max_accel)
- rail_z.set_max_jerk(max_halt_velocity, max_accel)
def get_steppers(self):
return list(self.steppers)
def calc_tag_position(self):
diff --git a/klippy/kinematics/rotary_delta.py b/klippy/kinematics/rotary_delta.py
index 9e57a11e..f61ed34a 100644
--- a/klippy/kinematics/rotary_delta.py
+++ b/klippy/kinematics/rotary_delta.py
@@ -23,13 +23,10 @@ class RotaryDeltaKinematics:
self.rails = [rail_a, rail_b, rail_c]
config.get_printer().register_event_handler("stepper_enable:motor_off",
self._motor_off)
- # Setup stepper max halt velocity
+ # Read config
max_velocity, max_accel = toolhead.get_max_velocity()
self.max_z_velocity = config.getfloat('max_z_velocity', max_velocity,
above=0., maxval=max_velocity)
- for rail in self.rails:
- rail.set_max_jerk(9999999.9, 9999999.9)
- # Read config
shoulder_radius = config.getfloat('shoulder_radius', above=0.)
shoulder_height = config.getfloat('shoulder_height', above=0.)
a_upper_arm = stepper_configs[0].getfloat('upper_arm_length', above=0.)
diff --git a/klippy/kinematics/winch.py b/klippy/kinematics/winch.py
index 942c0545..58737b58 100644
--- a/klippy/kinematics/winch.py
+++ b/klippy/kinematics/winch.py
@@ -22,11 +22,6 @@ class WinchKinematics:
s.setup_itersolve('winch_stepper_alloc', *a)
s.set_trapq(toolhead.get_trapq())
toolhead.register_step_generator(s.generate_steps)
- # Setup stepper max halt velocity
- max_velocity, max_accel = toolhead.get_max_velocity()
- max_halt_velocity = toolhead.get_max_axis_halt()
- for s in self.steppers:
- s.set_max_jerk(max_halt_velocity, max_accel)
# Setup boundary checks
acoords = list(zip(*self.anchors))
self.axes_min = toolhead.Coord(*[min(a) for a in acoords], e=0.)
diff --git a/klippy/stepper.py b/klippy/stepper.py
index fef10c44..a110843d 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -32,7 +32,6 @@ class MCU_stepper:
self._dir_pin = dir_pin_params['pin']
self._invert_dir = dir_pin_params['invert']
self._mcu_position_offset = self._tag_position = 0.
- self._min_stop_interval = 0.
self._reset_cmd_tag = self._get_position_cmd = None
self._active_callbacks = []
ffi_main, ffi_lib = chelper.get_ffi()
@@ -56,26 +55,15 @@ class MCU_stepper:
# Calculate the time it takes to travel a distance with constant accel
time_offset = start_velocity / accel
return math.sqrt(2. * dist / accel + time_offset**2) - time_offset
- def set_max_jerk(self, max_halt_velocity, max_accel):
- # Calculate the firmware's maximum halt interval time
- last_step_time = self._dist_to_time(self._step_dist,
- max_halt_velocity, max_accel)
- second_last_step_time = self._dist_to_time(2. * self._step_dist,
- max_halt_velocity, max_accel)
- self._min_stop_interval = second_last_step_time - last_step_time
def setup_itersolve(self, alloc_func, *params):
ffi_main, ffi_lib = chelper.get_ffi()
sk = ffi_main.gc(getattr(ffi_lib, alloc_func)(*params), ffi_lib.free)
self.set_stepper_kinematics(sk)
def _build_config(self):
- max_error = self._mcu.get_max_stepper_error()
- min_stop_interval = max(0., self._min_stop_interval - max_error)
self._mcu.add_config_cmd(
"config_stepper oid=%d step_pin=%s dir_pin=%s"
- " min_stop_interval=%d invert_step=%d" % (
- self._oid, self._step_pin, self._dir_pin,
- self._mcu.seconds_to_clock(min_stop_interval),
- self._invert_step))
+ " min_stop_interval=0 invert_step=%d" % (
+ self._oid, self._step_pin, self._dir_pin, self._invert_step))
self._mcu.add_config_cmd("reset_step_clock oid=%d clock=0"
% (self._oid,), on_restart=True)
step_cmd_tag = self._mcu.lookup_command_tag(
@@ -87,6 +75,7 @@ class MCU_stepper:
self._get_position_cmd = self._mcu.lookup_query_command(
"stepper_get_position oid=%c",
"stepper_position oid=%c pos=%i", oid=self._oid)
+ max_error = self._mcu.get_max_stepper_error()
ffi_main, ffi_lib = chelper.get_ffi()
ffi_lib.stepcompress_fill(self._stepqueue,
self._mcu.seconds_to_clock(max_error),
@@ -360,9 +349,6 @@ class PrinterRail:
def set_trapq(self, trapq):
for stepper in self.steppers:
stepper.set_trapq(trapq)
- def set_max_jerk(self, max_halt_velocity, max_accel):
- for stepper in self.steppers:
- stepper.set_max_jerk(max_halt_velocity, max_accel)
def set_position(self, coord):
for stepper in self.steppers:
stepper.set_position(coord)
diff --git a/klippy/toolhead.py b/klippy/toolhead.py
index ed9c8603..e1a79179 100644
--- a/klippy/toolhead.py
+++ b/klippy/toolhead.py
@@ -539,12 +539,6 @@ class ToolHead:
self.last_kin_move_time = max(self.last_kin_move_time, kin_time)
def get_max_velocity(self):
return self.max_velocity, self.max_accel
- def get_max_axis_halt(self):
- # Determine the maximum velocity a cartesian axis could halt
- # at due to the junction_deviation setting. The 8.0 was
- # 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