homing: Pass list of endstops (not steppers) to the homing code
The homing code wants the list of endstops to enable during a homing operation - it's confusing to pass the steppers. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
31db4cc772
commit
7785d3a87d
|
@ -51,14 +51,14 @@ class CartKinematics:
|
||||||
homepos[axis] = s.position_endstop
|
homepos[axis] = s.position_endstop
|
||||||
coord = [None, None, None, None]
|
coord = [None, None, None, None]
|
||||||
coord[axis] = pos
|
coord[axis] = pos
|
||||||
homing_state.home(list(coord), homepos, [s], homing_speed)
|
homing_state.home(coord, homepos, s.get_endstops(), homing_speed)
|
||||||
# Retract
|
# Retract
|
||||||
coord[axis] = rpos
|
coord[axis] = rpos
|
||||||
homing_state.retract(list(coord), homing_speed)
|
homing_state.retract(coord, homing_speed)
|
||||||
# Home again
|
# Home again
|
||||||
coord[axis] = r2pos
|
coord[axis] = r2pos
|
||||||
homing_state.home(
|
homing_state.home(coord, homepos, s.get_endstops(),
|
||||||
list(coord), homepos, [s], homing_speed/2.0, second_home=True)
|
homing_speed/2.0, second_home=True)
|
||||||
# Set final homed position
|
# Set final homed position
|
||||||
coord[axis] = s.position_endstop + s.get_homed_offset()
|
coord[axis] = s.position_endstop + s.get_homed_offset()
|
||||||
homing_state.set_homed_position(coord)
|
homing_state.set_homed_position(coord)
|
||||||
|
|
|
@ -59,14 +59,14 @@ class CoreXYKinematics:
|
||||||
homepos[axis] = s.position_endstop
|
homepos[axis] = s.position_endstop
|
||||||
coord = [None, None, None, None]
|
coord = [None, None, None, None]
|
||||||
coord[axis] = pos
|
coord[axis] = pos
|
||||||
homing_state.home(list(coord), homepos, [s], homing_speed)
|
homing_state.home(coord, homepos, s.get_endstops(), homing_speed)
|
||||||
# Retract
|
# Retract
|
||||||
coord[axis] = rpos
|
coord[axis] = rpos
|
||||||
homing_state.retract(list(coord), homing_speed)
|
homing_state.retract(coord, homing_speed)
|
||||||
# Home again
|
# Home again
|
||||||
coord[axis] = r2pos
|
coord[axis] = r2pos
|
||||||
homing_state.home(
|
homing_state.home(coord, homepos, s.get_endstops(),
|
||||||
list(coord), homepos, [s], homing_speed/2.0, second_home=True)
|
homing_speed/2.0, second_home=True)
|
||||||
if axis == 2:
|
if axis == 2:
|
||||||
# Support endstop phase detection on Z axis
|
# Support endstop phase detection on Z axis
|
||||||
coord[axis] = s.position_endstop + s.get_homed_offset()
|
coord[axis] = s.position_endstop + s.get_homed_offset()
|
||||||
|
|
|
@ -102,6 +102,7 @@ class DeltaKinematics:
|
||||||
def home(self, homing_state):
|
def home(self, homing_state):
|
||||||
# All axes are homed simultaneously
|
# All axes are homed simultaneously
|
||||||
homing_state.set_axes([0, 1, 2])
|
homing_state.set_axes([0, 1, 2])
|
||||||
|
endstops = [es for s in self.steppers for es in s.get_endstops()]
|
||||||
s = self.steppers[0] # Assume homing speed same for all steppers
|
s = self.steppers[0] # Assume homing speed same for all steppers
|
||||||
self.need_home = False
|
self.need_home = False
|
||||||
# Initial homing
|
# Initial homing
|
||||||
|
@ -109,14 +110,14 @@ class DeltaKinematics:
|
||||||
homepos = [0., 0., self.max_z, None]
|
homepos = [0., 0., self.max_z, None]
|
||||||
coord = list(homepos)
|
coord = list(homepos)
|
||||||
coord[2] = -1.5 * math.sqrt(self.arm_length2-self.max_xy2)
|
coord[2] = -1.5 * math.sqrt(self.arm_length2-self.max_xy2)
|
||||||
homing_state.home(list(coord), homepos, self.steppers, homing_speed)
|
homing_state.home(coord, homepos, endstops, homing_speed)
|
||||||
# Retract
|
# Retract
|
||||||
coord[2] = homepos[2] - s.homing_retract_dist
|
coord[2] = homepos[2] - s.homing_retract_dist
|
||||||
homing_state.retract(list(coord), homing_speed)
|
homing_state.retract(coord, homing_speed)
|
||||||
# Home again
|
# Home again
|
||||||
coord[2] -= s.homing_retract_dist
|
coord[2] -= s.homing_retract_dist
|
||||||
homing_state.home(list(coord), homepos, self.steppers
|
homing_state.home(coord, homepos, endstops,
|
||||||
, homing_speed/2.0, second_home=True)
|
homing_speed/2.0, second_home=True)
|
||||||
# Set final homed position
|
# Set final homed position
|
||||||
spos = self._cartesian_to_actuator(homepos)
|
spos = self._cartesian_to_actuator(homepos)
|
||||||
spos = [spos[i] + self.steppers[i].position_endstop - self.max_z
|
spos = [spos[i] + self.steppers[i].position_endstop - self.max_z
|
||||||
|
|
|
@ -29,58 +29,57 @@ class Homing:
|
||||||
return thcoord
|
return thcoord
|
||||||
def retract(self, newpos, speed):
|
def retract(self, newpos, speed):
|
||||||
self.toolhead.move(self._fill_coord(newpos), speed)
|
self.toolhead.move(self._fill_coord(newpos), speed)
|
||||||
def home(self, forcepos, movepos, steppers, speed, second_home=False):
|
def home(self, forcepos, movepos, endstops, speed, second_home=False):
|
||||||
# Alter kinematics class to think printer is at forcepos
|
# Alter kinematics class to think printer is at forcepos
|
||||||
self.toolhead.set_position(self._fill_coord(forcepos))
|
self.toolhead.set_position(self._fill_coord(forcepos))
|
||||||
# Start homing and issue move
|
# Start homing and issue move
|
||||||
if not second_home:
|
if not second_home:
|
||||||
est_move_d = sum([abs(forcepos[i]-movepos[i])
|
est_move_d = sum([abs(forcepos[i]-movepos[i])
|
||||||
for i in range(3) if movepos[i] is not None])
|
for i in range(3) if movepos[i] is not None])
|
||||||
est_steps = sum(
|
est_steps = sum([est_move_d / s.get_step_dist()
|
||||||
[est_move_d / mcu_stepper.get_step_dist()
|
for es, n in endstops for s in es.get_steppers()])
|
||||||
for s in steppers
|
|
||||||
for mcu_endstop, mcu_stepper, name in s.get_endstops()])
|
|
||||||
self.toolhead.dwell(est_steps * HOMING_STEP_DELAY, check_stall=False)
|
self.toolhead.dwell(est_steps * HOMING_STEP_DELAY, check_stall=False)
|
||||||
print_time = self.toolhead.get_last_move_time()
|
print_time = self.toolhead.get_last_move_time()
|
||||||
endstops = []
|
start_mcu_pos = [(s, name, s.get_mcu_position())
|
||||||
for s in steppers:
|
for es, name in endstops for s in es.get_steppers()]
|
||||||
for mcu_endstop, mcu_stepper, name in s.get_endstops():
|
for mcu_endstop, name in endstops:
|
||||||
|
min_step_dist = min([s.get_step_dist()
|
||||||
|
for s in mcu_endstop.get_steppers()])
|
||||||
mcu_endstop.home_start(
|
mcu_endstop.home_start(
|
||||||
print_time, ENDSTOP_SAMPLE_TIME, ENDSTOP_SAMPLE_COUNT,
|
print_time, ENDSTOP_SAMPLE_TIME, ENDSTOP_SAMPLE_COUNT,
|
||||||
mcu_stepper.get_step_dist() / speed)
|
min_step_dist / speed)
|
||||||
endstops.append((mcu_endstop, mcu_stepper, name,
|
|
||||||
mcu_stepper.get_mcu_position()))
|
|
||||||
self.toolhead.move(self._fill_coord(movepos), speed)
|
self.toolhead.move(self._fill_coord(movepos), speed)
|
||||||
move_end_print_time = self.toolhead.get_last_move_time()
|
move_end_print_time = self.toolhead.get_last_move_time()
|
||||||
self.toolhead.reset_print_time(print_time)
|
self.toolhead.reset_print_time(print_time)
|
||||||
for mcu_endstop, mcu_stepper, name, last_pos in endstops:
|
for mcu_endstop, name in endstops:
|
||||||
mcu_endstop.home_finalize(move_end_print_time)
|
mcu_endstop.home_finalize(move_end_print_time)
|
||||||
# Wait for endstops to trigger
|
# Wait for endstops to trigger
|
||||||
for mcu_endstop, mcu_stepper, name, last_pos in endstops:
|
for mcu_endstop, name in endstops:
|
||||||
try:
|
try:
|
||||||
mcu_endstop.home_wait()
|
mcu_endstop.home_wait()
|
||||||
except mcu_endstop.error as e:
|
except mcu_endstop.error as e:
|
||||||
raise EndstopError("Failed to home stepper %s: %s" % (
|
raise EndstopError("Failed to home stepper %s: %s" % (
|
||||||
name, str(e)))
|
name, str(e)))
|
||||||
post_home_pos = mcu_stepper.get_mcu_position()
|
# Verify retract led to some movement on second home
|
||||||
if second_home and self.verify_retract and last_pos == post_home_pos:
|
if second_home and self.verify_retract:
|
||||||
raise EndstopError("Endstop %s still triggered after retract" % (
|
for s, name, pos in start_mcu_pos:
|
||||||
name,))
|
if s.get_mcu_position() == pos:
|
||||||
|
raise EndstopError(
|
||||||
|
"Endstop %s still triggered after retract" % (name,))
|
||||||
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 query_endstops(print_time, query_flags, steppers):
|
def query_endstops(print_time, query_flags, steppers):
|
||||||
if query_flags == "get_mcu_position":
|
if query_flags == "get_mcu_position":
|
||||||
# Only the commanded position is requested
|
# Only the commanded position is requested
|
||||||
return [(name.upper(), mcu_stepper.get_mcu_position())
|
return [(s.name.upper(), s.mcu_stepper.get_mcu_position())
|
||||||
for s in steppers
|
for s in steppers]
|
||||||
for mcu_endstop, mcu_stepper, name in s.get_endstops()]
|
|
||||||
for s in steppers:
|
for s in steppers:
|
||||||
for mcu_endstop, mcu_stepper, name in s.get_endstops():
|
for mcu_endstop, name in s.get_endstops():
|
||||||
mcu_endstop.query_endstop(print_time)
|
mcu_endstop.query_endstop(print_time)
|
||||||
out = []
|
out = []
|
||||||
for s in steppers:
|
for s in steppers:
|
||||||
for mcu_endstop, mcu_stepper, name in s.get_endstops():
|
for mcu_endstop, name in s.get_endstops():
|
||||||
try:
|
try:
|
||||||
out.append((name, mcu_endstop.query_endstop_wait()))
|
out.append((name, mcu_endstop.query_endstop_wait()))
|
||||||
except mcu_endstop.error as e:
|
except mcu_endstop.error as e:
|
||||||
|
|
|
@ -150,6 +150,8 @@ class MCU_endstop:
|
||||||
if stepper.get_mcu() is not self._mcu:
|
if stepper.get_mcu() is not self._mcu:
|
||||||
raise pins.error("Endstop and stepper must be on the same mcu")
|
raise pins.error("Endstop and stepper must be on the same mcu")
|
||||||
self._steppers.append(stepper)
|
self._steppers.append(stepper)
|
||||||
|
def get_steppers(self):
|
||||||
|
return list(self._steppers)
|
||||||
def build_config(self):
|
def build_config(self):
|
||||||
self._oid = self._mcu.create_oid()
|
self._oid = self._mcu.create_oid()
|
||||||
self._mcu.add_config_cmd(
|
self._mcu.add_config_cmd(
|
||||||
|
|
|
@ -118,7 +118,7 @@ class PrinterHomingStepper(PrinterStepper):
|
||||||
if self.mcu_endstop.get_mcu().is_fileoutput():
|
if self.mcu_endstop.get_mcu().is_fileoutput():
|
||||||
self.homing_endstop_accuracy = self.homing_stepper_phases
|
self.homing_endstop_accuracy = self.homing_stepper_phases
|
||||||
def get_endstops(self):
|
def get_endstops(self):
|
||||||
return [(self.mcu_endstop, self.mcu_stepper, self.name)]
|
return [(self.mcu_endstop, self.name)]
|
||||||
def get_homing_speed(self):
|
def get_homing_speed(self):
|
||||||
# Round the configured homing speed so that it is an even
|
# Round the configured homing speed so that it is an even
|
||||||
# number of ticks per step.
|
# number of ticks per step.
|
||||||
|
@ -162,8 +162,7 @@ class PrinterMultiStepper(PrinterHomingStepper):
|
||||||
if extraendstop is not None:
|
if extraendstop is not None:
|
||||||
mcu_endstop = pins.setup_pin(printer, 'endstop', extraendstop)
|
mcu_endstop = pins.setup_pin(printer, 'endstop', extraendstop)
|
||||||
mcu_endstop.add_stepper(extra.mcu_stepper)
|
mcu_endstop.add_stepper(extra.mcu_stepper)
|
||||||
self.endstops.append(
|
self.endstops.append((mcu_endstop, extra.name))
|
||||||
(mcu_endstop, extra.mcu_stepper, extra.name))
|
|
||||||
else:
|
else:
|
||||||
self.mcu_endstop.add_stepper(extra.mcu_stepper)
|
self.mcu_endstop.add_stepper(extra.mcu_stepper)
|
||||||
self.step_const = self.step_multi_const
|
self.step_const = self.step_multi_const
|
||||||
|
|
Loading…
Reference in New Issue