homing: Remove no longer needed homing time delay code
Now that homing is implemented via "drip moves", it is no longer necessary to round the homing speed and it is no longer necessary to add a delay for cpu processing time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
43064d197d
commit
dd34768e3a
|
@ -5,7 +5,6 @@
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||||
import logging, math, collections
|
import logging, math, collections
|
||||||
|
|
||||||
HOMING_STEP_DELAY = 0.00000025
|
|
||||||
HOMING_START_DELAY = 0.001
|
HOMING_START_DELAY = 0.001
|
||||||
ENDSTOP_SAMPLE_TIME = .000015
|
ENDSTOP_SAMPLE_TIME = .000015
|
||||||
ENDSTOP_SAMPLE_COUNT = 4
|
ENDSTOP_SAMPLE_COUNT = 4
|
||||||
|
@ -32,25 +31,15 @@ class Homing:
|
||||||
return thcoord
|
return thcoord
|
||||||
def set_homed_position(self, pos):
|
def set_homed_position(self, pos):
|
||||||
self.toolhead.set_position(self._fill_coord(pos))
|
self.toolhead.set_position(self._fill_coord(pos))
|
||||||
def _get_homing_speed(self, speed, endstops):
|
|
||||||
# Round the requested homing speed so that it is an even
|
|
||||||
# number of ticks per step.
|
|
||||||
mcu_stepper = endstops[0][0].get_steppers()[0]
|
|
||||||
adjusted_freq = mcu_stepper.get_mcu().get_adjusted_freq()
|
|
||||||
dist_ticks = adjusted_freq * mcu_stepper.get_step_dist()
|
|
||||||
ticks_per_step = math.ceil(dist_ticks / speed)
|
|
||||||
return dist_ticks / ticks_per_step
|
|
||||||
def _endstop_notify(self):
|
def _endstop_notify(self):
|
||||||
self.endstops_pending -= 1
|
self.endstops_pending -= 1
|
||||||
if not self.endstops_pending:
|
if not self.endstops_pending:
|
||||||
self.toolhead.signal_drip_mode_end()
|
self.toolhead.signal_drip_mode_end()
|
||||||
def homing_move(self, movepos, endstops, speed, dwell_t=0.,
|
def homing_move(self, movepos, endstops, speed,
|
||||||
probe_pos=False, verify_movement=False):
|
probe_pos=False, verify_movement=False):
|
||||||
# Notify endstops of upcoming home
|
# Notify endstops of upcoming home
|
||||||
for mcu_endstop, name in endstops:
|
for mcu_endstop, name in endstops:
|
||||||
mcu_endstop.home_prepare()
|
mcu_endstop.home_prepare()
|
||||||
if dwell_t:
|
|
||||||
self.toolhead.dwell(dwell_t, check_stall=False)
|
|
||||||
# Start endstop checking
|
# Start endstop checking
|
||||||
print_time = self.toolhead.get_last_move_time()
|
print_time = self.toolhead.get_last_move_time()
|
||||||
start_mcu_pos = [(s, name, s.get_mcu_position())
|
start_mcu_pos = [(s, name, s.get_mcu_position())
|
||||||
|
@ -98,42 +87,30 @@ class Homing:
|
||||||
raise EndstopError("Probe triggered prior to movement")
|
raise EndstopError("Probe triggered prior to movement")
|
||||||
raise EndstopError(
|
raise EndstopError(
|
||||||
"Endstop %s still triggered after retract" % (name,))
|
"Endstop %s still triggered after retract" % (name,))
|
||||||
def home_rails(self, rails, forcepos, movepos, limit_speed=None):
|
def home_rails(self, rails, forcepos, movepos):
|
||||||
# Alter kinematics class to think printer is at forcepos
|
# Alter kinematics class to think printer is at forcepos
|
||||||
homing_axes = [axis for axis in range(3) if forcepos[axis] is not None]
|
homing_axes = [axis for axis in range(3) if forcepos[axis] is not None]
|
||||||
forcepos = self._fill_coord(forcepos)
|
forcepos = self._fill_coord(forcepos)
|
||||||
movepos = self._fill_coord(movepos)
|
movepos = self._fill_coord(movepos)
|
||||||
self.toolhead.set_position(forcepos, homing_axes=homing_axes)
|
self.toolhead.set_position(forcepos, homing_axes=homing_axes)
|
||||||
# Determine homing speed
|
# Perform first home
|
||||||
endstops = [es for rail in rails for es in rail.get_endstops()]
|
endstops = [es for rail in rails for es in rail.get_endstops()]
|
||||||
hi = rails[0].get_homing_info()
|
hi = rails[0].get_homing_info()
|
||||||
max_velocity = self.toolhead.get_max_velocity()[0]
|
self.homing_move(movepos, endstops, hi.speed)
|
||||||
if limit_speed is not None and limit_speed < max_velocity:
|
|
||||||
max_velocity = limit_speed
|
|
||||||
homing_speed = min(hi.speed, max_velocity)
|
|
||||||
homing_speed = self._get_homing_speed(homing_speed, endstops)
|
|
||||||
second_homing_speed = min(hi.second_homing_speed, max_velocity)
|
|
||||||
# Calculate a CPU delay when homing a large axis
|
|
||||||
axes_d = [mp - fp for mp, fp in zip(movepos, forcepos)]
|
|
||||||
est_move_d = abs(axes_d[0]) + abs(axes_d[1]) + abs(axes_d[2])
|
|
||||||
est_steps = sum([est_move_d / s.get_step_dist()
|
|
||||||
for es, n in endstops for s in es.get_steppers()])
|
|
||||||
dwell_t = est_steps * HOMING_STEP_DELAY
|
|
||||||
# Perform first home
|
|
||||||
self.homing_move(movepos, endstops, homing_speed, dwell_t=dwell_t)
|
|
||||||
# Perform second home
|
# Perform second home
|
||||||
if hi.retract_dist:
|
if hi.retract_dist:
|
||||||
# Retract
|
# Retract
|
||||||
|
axes_d = [mp - fp for mp, fp in zip(movepos, forcepos)]
|
||||||
move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
|
move_d = math.sqrt(sum([d*d for d in axes_d[:3]]))
|
||||||
retract_r = min(1., hi.retract_dist / move_d)
|
retract_r = min(1., hi.retract_dist / move_d)
|
||||||
retractpos = [mp - ad * retract_r
|
retractpos = [mp - ad * retract_r
|
||||||
for mp, ad in zip(movepos, axes_d)]
|
for mp, ad in zip(movepos, axes_d)]
|
||||||
self.toolhead.move(retractpos, homing_speed)
|
self.toolhead.move(retractpos, hi.speed)
|
||||||
# Home again
|
# Home again
|
||||||
forcepos = [rp - ad * retract_r
|
forcepos = [rp - ad * retract_r
|
||||||
for rp, ad in zip(retractpos, axes_d)]
|
for rp, ad in zip(retractpos, axes_d)]
|
||||||
self.toolhead.set_position(forcepos)
|
self.toolhead.set_position(forcepos)
|
||||||
self.homing_move(movepos, endstops, second_homing_speed,
|
self.homing_move(movepos, endstops, hi.second_homing_speed,
|
||||||
verify_movement=self.verify_retract)
|
verify_movement=self.verify_retract)
|
||||||
# Signal home operation complete
|
# Signal home operation complete
|
||||||
ret = self.printer.send_event("homing:homed_rails", self, rails)
|
ret = self.printer.send_event("homing:homed_rails", self, rails)
|
||||||
|
|
|
@ -66,10 +66,7 @@ class CartKinematics:
|
||||||
else:
|
else:
|
||||||
forcepos[axis] += 1.5 * (position_max - hi.position_endstop)
|
forcepos[axis] += 1.5 * (position_max - hi.position_endstop)
|
||||||
# Perform homing
|
# Perform homing
|
||||||
limit_speed = None
|
homing_state.home_rails([rail], forcepos, homepos)
|
||||||
if axis == 2:
|
|
||||||
limit_speed = self.max_z_velocity
|
|
||||||
homing_state.home_rails([rail], forcepos, homepos, limit_speed)
|
|
||||||
def home(self, homing_state):
|
def home(self, homing_state):
|
||||||
# Each axis is homed independently and in order
|
# Each axis is homed independently and in order
|
||||||
for axis in homing_state.get_axes():
|
for axis in homing_state.get_axes():
|
||||||
|
|
|
@ -60,10 +60,7 @@ class CoreXYKinematics:
|
||||||
else:
|
else:
|
||||||
forcepos[axis] += 1.5 * (position_max - hi.position_endstop)
|
forcepos[axis] += 1.5 * (position_max - hi.position_endstop)
|
||||||
# Perform homing
|
# Perform homing
|
||||||
limit_speed = None
|
homing_state.home_rails([rail], forcepos, homepos)
|
||||||
if axis == 2:
|
|
||||||
limit_speed = self.max_z_velocity
|
|
||||||
homing_state.home_rails([rail], forcepos, homepos, limit_speed)
|
|
||||||
def motor_off(self, print_time):
|
def motor_off(self, print_time):
|
||||||
self.limits = [(1.0, -1.0)] * 3
|
self.limits = [(1.0, -1.0)] * 3
|
||||||
for rail in self.rails:
|
for rail in self.rails:
|
||||||
|
|
|
@ -101,8 +101,7 @@ class DeltaKinematics:
|
||||||
homing_state.set_axes([0, 1, 2])
|
homing_state.set_axes([0, 1, 2])
|
||||||
forcepos = list(self.home_position)
|
forcepos = list(self.home_position)
|
||||||
forcepos[2] = -1.5 * math.sqrt(max(self.arm2)-self.max_xy2)
|
forcepos[2] = -1.5 * math.sqrt(max(self.arm2)-self.max_xy2)
|
||||||
homing_state.home_rails(self.rails, forcepos, self.home_position,
|
homing_state.home_rails(self.rails, forcepos, self.home_position)
|
||||||
limit_speed=self.max_z_velocity)
|
|
||||||
def motor_off(self, print_time):
|
def motor_off(self, print_time):
|
||||||
self.limit_xy2 = -1.
|
self.limit_xy2 = -1.
|
||||||
for rail in self.rails:
|
for rail in self.rails:
|
||||||
|
|
|
@ -63,10 +63,7 @@ class PolarKinematics:
|
||||||
else:
|
else:
|
||||||
forcepos[axis] += position_max - hi.position_endstop
|
forcepos[axis] += position_max - hi.position_endstop
|
||||||
# Perform homing
|
# Perform homing
|
||||||
limit_speed = None
|
homing_state.home_rails([rail], forcepos, homepos)
|
||||||
if axis == 2:
|
|
||||||
limit_speed = self.max_z_velocity
|
|
||||||
homing_state.home_rails([rail], forcepos, homepos, limit_speed)
|
|
||||||
def home(self, homing_state):
|
def home(self, homing_state):
|
||||||
# Always home XY together
|
# Always home XY together
|
||||||
homing_axes = homing_state.get_axes()
|
homing_axes = homing_state.get_axes()
|
||||||
|
|
Loading…
Reference in New Issue