diff --git a/src/py/bbctrl/Mach.py b/src/py/bbctrl/Mach.py index b3f6af8..ba4a8c5 100644 --- a/src/py/bbctrl/Mach.py +++ b/src/py/bbctrl/Mach.py @@ -50,9 +50,15 @@ axis_homing_procedure = ''' G90 G28.3 %(axis)s[#<_%(axis)s_home_position>] ''' +# The stepper drivers have a stall flag that is reset +# by moving the motors without a stall condition. +# The "wiggle" in the stall procedure is to clear the flag. +# This was to correct the issue where the stepper motors +# may already be in a stall condition when homing is started. +# For example, if a user tried to home twice in a row +# the second homing attempt would immediately think it +# was stalled if we didn't first back it up a bit stall_homing_procedure = ''' - G91 G1 %(axis)s [#<_%(axis)s_zero_backoff> * -1] F[#<_%(axis)s_search_velocity>] - G4 P0.25 G91 G1 %(axis)s [#<_%(axis)s_zero_backoff>] F[#<_%(axis)s_search_velocity>] G4 P0.25 G28.2 %(axis)s0 F[#<_%(axis)s_search_velocity>] @@ -275,11 +281,13 @@ class Mach(Comm): # Home axis self.mlog.info('Homing %s axis' % axis) self._begin_cycle('homing') + if mode.startswith('stall-'): procedure = stall_homing_procedure else: procedure = axis_homing_procedure - self.planner.mdi(procedure % {'axis': axis}, False) - # self.planner.mdi(axis_homing_procedure % {'axis': axis}, False) + gcode = procedure % {'axis': axis} + + self.planner.mdi(gcode, False) super().resume() diff --git a/src/py/bbctrl/Planner.py b/src/py/bbctrl/Planner.py index e5fc20b..2dda848 100644 --- a/src/py/bbctrl/Planner.py +++ b/src/py/bbctrl/Planner.py @@ -96,6 +96,12 @@ class Planner(): 'junction-accel': config.get('junction-accel'), } + # We place an upper limit of 1000 km/min^3 on jerk for MDI movements + if mdi: + for axis in 'xyzabc': + if axis in cfg['max-jerk']: + cfg['max-jerk'][axis] = min(1000 * 1000000, cfg['max-jerk'][axis]) + if with_limits: minLimit = state.get_soft_limit_vector('tn', -math.inf) maxLimit = state.get_soft_limit_vector('tm', math.inf)