bltouch: Raise the probe as soon as the endstop triggers
Start the raise sequence once the endstop notification arrives. This can reduce the response time as it does not require waiting for the homing sequence to fully finalize. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
c9ae89e142
commit
2a9a133f36
|
@ -38,7 +38,9 @@ class BLTouchEndstopWrapper:
|
||||||
self.mcu_pwm = ppins.setup_pin('pwm', config.get('control_pin'))
|
self.mcu_pwm = ppins.setup_pin('pwm', config.get('control_pin'))
|
||||||
self.mcu_pwm.setup_max_duration(0.)
|
self.mcu_pwm.setup_max_duration(0.)
|
||||||
self.mcu_pwm.setup_cycle_time(SIGNAL_PERIOD)
|
self.mcu_pwm.setup_cycle_time(SIGNAL_PERIOD)
|
||||||
|
# Command timing
|
||||||
self.next_cmd_time = self.action_end_time = 0.
|
self.next_cmd_time = self.action_end_time = 0.
|
||||||
|
self.finish_home_complete = self.wait_trigger_complete = None
|
||||||
# Create an "endstop" object to handle the sensor pin
|
# Create an "endstop" object to handle the sensor pin
|
||||||
pin = config.get('sensor_pin')
|
pin = config.get('sensor_pin')
|
||||||
pin_params = ppins.lookup_pin(pin, can_invert=True, can_pullup=True)
|
pin_params = ppins.lookup_pin(pin, can_invert=True, can_pullup=True)
|
||||||
|
@ -82,6 +84,7 @@ class BLTouchEndstopWrapper:
|
||||||
self.set_output_mode(self.output_mode)
|
self.set_output_mode(self.output_mode)
|
||||||
try:
|
try:
|
||||||
self.raise_probe()
|
self.raise_probe()
|
||||||
|
self.verify_raise_probe()
|
||||||
except self.printer.command_error as e:
|
except self.printer.command_error as e:
|
||||||
logging.warning("BLTouch raise probe error: %s", str(e))
|
logging.warning("BLTouch raise probe error: %s", str(e))
|
||||||
def sync_mcu_print_time(self):
|
def sync_mcu_print_time(self):
|
||||||
|
@ -117,12 +120,13 @@ class BLTouchEndstopWrapper:
|
||||||
def raise_probe(self):
|
def raise_probe(self):
|
||||||
self.sync_mcu_print_time()
|
self.sync_mcu_print_time()
|
||||||
if not self.pin_up_not_triggered:
|
if not self.pin_up_not_triggered:
|
||||||
# No way to verify raise attempt - just issue commands
|
|
||||||
self.send_cmd('reset')
|
self.send_cmd('reset')
|
||||||
self.send_cmd('pin_up', duration=self.pin_move_time)
|
self.send_cmd('pin_up', duration=self.pin_move_time)
|
||||||
|
def verify_raise_probe(self):
|
||||||
|
if not self.pin_up_not_triggered:
|
||||||
|
# No way to verify raise attempt
|
||||||
return
|
return
|
||||||
for retry in range(3):
|
for retry in range(3):
|
||||||
self.send_cmd('pin_up', duration=self.pin_move_time)
|
|
||||||
success = self.verify_state(False)
|
success = self.verify_state(False)
|
||||||
if success:
|
if success:
|
||||||
# The "probe raised" test completed successfully
|
# The "probe raised" test completed successfully
|
||||||
|
@ -134,6 +138,7 @@ class BLTouchEndstopWrapper:
|
||||||
self.gcode.respond_info(msg)
|
self.gcode.respond_info(msg)
|
||||||
self.sync_mcu_print_time()
|
self.sync_mcu_print_time()
|
||||||
self.send_cmd('reset', duration=RETRY_RESET_TIME)
|
self.send_cmd('reset', duration=RETRY_RESET_TIME)
|
||||||
|
self.send_cmd('pin_up', duration=self.pin_move_time)
|
||||||
def lower_probe(self):
|
def lower_probe(self):
|
||||||
self.test_sensor()
|
self.test_sensor()
|
||||||
self.sync_print_time()
|
self.sync_print_time()
|
||||||
|
@ -174,6 +179,7 @@ class BLTouchEndstopWrapper:
|
||||||
return
|
return
|
||||||
self.sync_print_time()
|
self.sync_print_time()
|
||||||
self.raise_probe()
|
self.raise_probe()
|
||||||
|
self.verify_raise_probe()
|
||||||
self.sync_print_time()
|
self.sync_print_time()
|
||||||
self.multi = 'OFF'
|
self.multi = 'OFF'
|
||||||
def probe_prepare(self, hmove):
|
def probe_prepare(self, hmove):
|
||||||
|
@ -182,17 +188,26 @@ class BLTouchEndstopWrapper:
|
||||||
if self.multi == 'FIRST':
|
if self.multi == 'FIRST':
|
||||||
self.multi = 'ON'
|
self.multi = 'ON'
|
||||||
self.sync_print_time()
|
self.sync_print_time()
|
||||||
def probe_finish(self, hmove):
|
|
||||||
if self.multi == 'OFF':
|
|
||||||
self.raise_probe()
|
|
||||||
self.sync_print_time()
|
|
||||||
if hmove.check_no_movement() is not None:
|
|
||||||
raise self.printer.command_error("BLTouch failed to deploy")
|
|
||||||
def home_start(self, print_time, sample_time, sample_count, rest_time,
|
def home_start(self, print_time, sample_time, sample_count, rest_time,
|
||||||
triggered=True):
|
triggered=True):
|
||||||
rest_time = min(rest_time, ENDSTOP_REST_TIME)
|
rest_time = min(rest_time, ENDSTOP_REST_TIME)
|
||||||
return self.mcu_endstop.home_start(print_time, sample_time,
|
self.finish_home_complete = self.mcu_endstop.home_start(
|
||||||
sample_count, rest_time, triggered)
|
print_time, sample_time, sample_count, rest_time, triggered)
|
||||||
|
# Schedule wait_for_trigger callback
|
||||||
|
r = self.printer.get_reactor()
|
||||||
|
self.wait_trigger_complete = r.register_callback(self.wait_for_trigger)
|
||||||
|
return self.finish_home_complete
|
||||||
|
def wait_for_trigger(self, eventtime):
|
||||||
|
self.finish_home_complete.wait()
|
||||||
|
if self.multi == 'OFF':
|
||||||
|
self.raise_probe()
|
||||||
|
def probe_finish(self, hmove):
|
||||||
|
self.wait_trigger_complete.wait()
|
||||||
|
if self.multi == 'OFF':
|
||||||
|
self.verify_raise_probe()
|
||||||
|
self.sync_print_time()
|
||||||
|
if hmove.check_no_movement() is not None:
|
||||||
|
raise self.printer.command_error("BLTouch failed to deploy")
|
||||||
def get_position_endstop(self):
|
def get_position_endstop(self):
|
||||||
return self.position_endstop
|
return self.position_endstop
|
||||||
def set_output_mode(self, mode):
|
def set_output_mode(self, mode):
|
||||||
|
|
Loading…
Reference in New Issue