stepper: Add a get_homing_info() method to PrinterHomingStepper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
968ed58b61
commit
93d0526a77
|
@ -64,20 +64,21 @@ class CartKinematics:
|
|||
s = stepper
|
||||
# Determine moves
|
||||
position_min, position_max = s.get_range()
|
||||
if s.homing_positive_dir:
|
||||
pos = s.position_endstop - 1.5*(s.position_endstop - position_min)
|
||||
rpos = s.position_endstop - s.homing_retract_dist
|
||||
r2pos = rpos - s.homing_retract_dist
|
||||
hi = s.get_homing_info()
|
||||
if hi.positive_dir:
|
||||
pos = hi.position_endstop - 1.5*(hi.position_endstop - position_min)
|
||||
rpos = hi.position_endstop - hi.retract_dist
|
||||
r2pos = rpos - hi.retract_dist
|
||||
else:
|
||||
pos = s.position_endstop + 1.5*(position_max - s.position_endstop)
|
||||
rpos = s.position_endstop + s.homing_retract_dist
|
||||
r2pos = rpos + s.homing_retract_dist
|
||||
pos = hi.position_endstop + 1.5*(position_max - hi.position_endstop)
|
||||
rpos = hi.position_endstop + hi.retract_dist
|
||||
r2pos = rpos + hi.retract_dist
|
||||
# Initial homing
|
||||
homing_speed = s.homing_speed
|
||||
homing_speed = hi.speed
|
||||
if axis == 2:
|
||||
homing_speed = min(homing_speed, self.max_z_velocity)
|
||||
homepos = [None, None, None, None]
|
||||
homepos[axis] = s.position_endstop
|
||||
homepos[axis] = hi.position_endstop
|
||||
coord = [None, None, None, None]
|
||||
coord[axis] = pos
|
||||
homing_state.home(coord, homepos, s.get_endstops(), homing_speed)
|
||||
|
@ -89,7 +90,7 @@ class CartKinematics:
|
|||
homing_state.home(coord, homepos, s.get_endstops(),
|
||||
homing_speed/2.0, second_home=True)
|
||||
# Set final homed position
|
||||
coord[axis] = s.position_endstop + s.get_homed_offset()
|
||||
coord[axis] = hi.position_endstop + s.get_homed_offset()
|
||||
homing_state.set_homed_position(coord)
|
||||
def home(self, homing_state):
|
||||
# Each axis is homed independently and in order
|
||||
|
|
|
@ -59,22 +59,23 @@ class CoreXYKinematics:
|
|||
s = self.steppers[axis]
|
||||
# Determine moves
|
||||
position_min, position_max = s.get_range()
|
||||
if s.homing_positive_dir:
|
||||
pos = s.position_endstop - 1.5*(
|
||||
s.position_endstop - position_min)
|
||||
rpos = s.position_endstop - s.homing_retract_dist
|
||||
r2pos = rpos - s.homing_retract_dist
|
||||
hi = s.get_homing_info()
|
||||
if hi.positive_dir:
|
||||
pos = hi.position_endstop - 1.5*(
|
||||
hi.position_endstop - position_min)
|
||||
rpos = hi.position_endstop - hi.retract_dist
|
||||
r2pos = rpos - hi.retract_dist
|
||||
else:
|
||||
pos = s.position_endstop + 1.5*(
|
||||
position_max - s.position_endstop)
|
||||
rpos = s.position_endstop + s.homing_retract_dist
|
||||
r2pos = rpos + s.homing_retract_dist
|
||||
pos = hi.position_endstop + 1.5*(
|
||||
position_max - hi.position_endstop)
|
||||
rpos = hi.position_endstop + hi.retract_dist
|
||||
r2pos = rpos + hi.retract_dist
|
||||
# Initial homing
|
||||
homing_speed = s.homing_speed
|
||||
homing_speed = hi.speed
|
||||
if axis == 2:
|
||||
homing_speed = min(homing_speed, self.max_z_velocity)
|
||||
homepos = [None, None, None, None]
|
||||
homepos[axis] = s.position_endstop
|
||||
homepos[axis] = hi.position_endstop
|
||||
coord = [None, None, None, None]
|
||||
coord[axis] = pos
|
||||
homing_state.home(coord, homepos, s.get_endstops(), homing_speed)
|
||||
|
@ -87,7 +88,7 @@ class CoreXYKinematics:
|
|||
homing_speed/2.0, second_home=True)
|
||||
if axis == 2:
|
||||
# Support endstop phase detection on Z axis
|
||||
coord[axis] = s.position_endstop + s.get_homed_offset()
|
||||
coord[axis] = hi.position_endstop + s.get_homed_offset()
|
||||
homing_state.set_homed_position(coord)
|
||||
def motor_off(self, print_time):
|
||||
self.limits = [(1.0, -1.0)] * 3
|
||||
|
|
|
@ -17,12 +17,13 @@ class DeltaKinematics:
|
|||
for n in ['a', 'b', 'c']]
|
||||
stepper_a = stepper.PrinterHomingStepper(
|
||||
stepper_configs[0], need_position_minmax = False)
|
||||
a_endstop = stepper_a.get_homing_info().position_endstop
|
||||
stepper_b = stepper.PrinterHomingStepper(
|
||||
stepper_configs[1], need_position_minmax = False,
|
||||
default_position_endstop=stepper_a.position_endstop)
|
||||
default_position_endstop=a_endstop)
|
||||
stepper_c = stepper.PrinterHomingStepper(
|
||||
stepper_configs[2], need_position_minmax = False,
|
||||
default_position_endstop=stepper_a.position_endstop)
|
||||
default_position_endstop=a_endstop)
|
||||
self.steppers = [stepper_a, stepper_b, stepper_c]
|
||||
self.need_motor_enable = self.need_home = True
|
||||
self.radius = radius = config.getfloat('delta_radius', above=0.)
|
||||
|
@ -31,10 +32,12 @@ class DeltaKinematics:
|
|||
sconfig.getfloat('arm_length', arm_length_a, above=radius)
|
||||
for sconfig in stepper_configs]
|
||||
self.arm2 = [arm**2 for arm in arm_lengths]
|
||||
self.endstops = [s.position_endstop + math.sqrt(arm2 - radius**2)
|
||||
self.endstops = [(s.get_homing_info().position_endstop
|
||||
+ math.sqrt(arm2 - radius**2))
|
||||
for s, arm2 in zip(self.steppers, self.arm2)]
|
||||
self.limit_xy2 = -1.
|
||||
self.max_z = min([s.position_endstop for s in self.steppers])
|
||||
self.max_z = min([s.get_homing_info().position_endstop
|
||||
for s in self.steppers])
|
||||
self.min_z = config.getfloat('minimum_z_position', 0, maxval=self.max_z)
|
||||
self.limit_z = min([ep - arm
|
||||
for ep, arm in zip(self.endstops, arm_lengths)])
|
||||
|
@ -103,18 +106,18 @@ class DeltaKinematics:
|
|||
# All axes are homed simultaneously
|
||||
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
|
||||
# Initial homing
|
||||
homing_speed = min(s.homing_speed, self.max_z_velocity)
|
||||
# Initial homing - assume homing speed same for all steppers
|
||||
hi = self.steppers[0].get_homing_info()
|
||||
homing_speed = min(hi.speed, self.max_z_velocity)
|
||||
homepos = [0., 0., self.max_z, None]
|
||||
coord = list(homepos)
|
||||
coord[2] = -1.5 * math.sqrt(max(self.arm2)-self.max_xy2)
|
||||
homing_state.home(coord, homepos, endstops, homing_speed)
|
||||
# Retract
|
||||
coord[2] = homepos[2] - s.homing_retract_dist
|
||||
coord[2] = homepos[2] - hi.retract_dist
|
||||
homing_state.retract(coord, homing_speed)
|
||||
# Home again
|
||||
coord[2] -= s.homing_retract_dist
|
||||
coord[2] -= hi.retract_dist
|
||||
homing_state.home(coord, homepos, endstops,
|
||||
homing_speed/2.0, second_home=True)
|
||||
# Set final homed position
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 2016-2018 Kevin O'Connor <kevin@koconnor.net>
|
||||
#
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license.
|
||||
import math, logging
|
||||
import math, logging, collections
|
||||
import homing, chelper
|
||||
|
||||
# Tracking of shared stepper enable pins
|
||||
|
@ -172,6 +172,12 @@ class PrinterHomingStepper(PrinterStepper):
|
|||
ffi_lib.cartesian_stepper_alloc(axis), ffi_lib.free))
|
||||
def get_range(self):
|
||||
return self.position_min, self.position_max
|
||||
def get_homing_info(self):
|
||||
homing_info = collections.namedtuple('homing_info', [
|
||||
'speed', 'position_endstop', 'retract_dist', 'positive_dir'])(
|
||||
self.homing_speed, self.position_endstop,
|
||||
self.homing_retract_dist, self.homing_positive_dir)
|
||||
return homing_info
|
||||
def get_endstops(self):
|
||||
return [(self.mcu_endstop, self.get_name(short=True))]
|
||||
def get_homed_offset(self):
|
||||
|
|
Loading…
Reference in New Issue