bltouch: Use pin_down mode for probing

The BLTouch is more accurate when probing in "pin_down" mode than
"touch_mode" (at least on some hardware).  Rework the code to use that
mode.

When probing in pin_down mode, the BLTouch can go into an error state
if a pin_up is not sent immediately after a touch signal.  Rework the
pin_up code to reduce the time it takes to transmit the command.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-01-04 19:18:09 -05:00
parent 04f5baa182
commit 99f96f2832
1 changed files with 7 additions and 3 deletions

View File

@ -59,6 +59,10 @@ class BLTouchEndstopWrapper:
kin = self.printer.lookup_object('toolhead').get_kinematics() kin = self.printer.lookup_object('toolhead').get_kinematics()
for stepper in kin.get_steppers('Z'): for stepper in kin.get_steppers('Z'):
stepper.add_to_endstop(self) stepper.add_to_endstop(self)
def sync_mcu_print_time(self):
curtime = self.printer.get_reactor().monotonic()
est_time = self.mcu_pwm.get_mcu().estimated_print_time(curtime)
self.next_cmd_time = max(self.next_cmd_time, est_time + MIN_CMD_TIME)
def sync_print_time(self): def sync_print_time(self):
toolhead = self.printer.lookup_object('toolhead') toolhead = self.printer.lookup_object('toolhead')
print_time = toolhead.get_last_move_time() print_time = toolhead.get_last_move_time()
@ -100,14 +104,14 @@ class BLTouchEndstopWrapper:
def home_prepare(self): def home_prepare(self):
self.test_sensor() self.test_sensor()
self.sync_print_time() self.sync_print_time()
self.send_cmd('pin_down', duration=self.pin_move_time) self.send_cmd('pin_down', duration=self.pin_move_time - MIN_CMD_TIME)
self.send_cmd('touch_mode') self.send_cmd(None)
self.sync_print_time() self.sync_print_time()
self.mcu_endstop.home_prepare() self.mcu_endstop.home_prepare()
self.start_mcu_pos = [(s, s.get_mcu_position()) self.start_mcu_pos = [(s, s.get_mcu_position())
for s in self.mcu_endstop.get_steppers()] for s in self.mcu_endstop.get_steppers()]
def home_finalize(self): def home_finalize(self):
self.sync_print_time() self.sync_mcu_print_time()
self.send_cmd('reset') self.send_cmd('reset')
self.send_cmd('pin_up', duration=self.pin_move_time - MIN_CMD_TIME) self.send_cmd('pin_up', duration=self.pin_move_time - MIN_CMD_TIME)
self.send_cmd(None) self.send_cmd(None)