mirror of https://github.com/Desuuuu/klipper.git
bltouch: Attempt to verify that the probe raises after each probe attempt
Query the bltouch state during the pin_up command to try and verify that the probe does actually retract. This may be useful to detect if the bltouch enters into an "error" state. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
99f96f2832
commit
e36122797b
|
@ -58,6 +58,11 @@
|
||||||
#pin_move_time: 0.200
|
#pin_move_time: 0.200
|
||||||
# The amount of time (in seconds) that it takes the BLTouch pin to
|
# The amount of time (in seconds) that it takes the BLTouch pin to
|
||||||
# move up or down. The default is 0.200 seconds.
|
# move up or down. The default is 0.200 seconds.
|
||||||
|
#pin_up_reports_not_triggered: True
|
||||||
|
# Set if the BLTouch consistently reports the probe in a "not
|
||||||
|
# triggered" state after a successful "pin_up" command. This should
|
||||||
|
# be True for a genuine BLTouch; some BLTouch clones may require
|
||||||
|
# False. The default is True.
|
||||||
#x_offset:
|
#x_offset:
|
||||||
#y_offset:
|
#y_offset:
|
||||||
#z_offset:
|
#z_offset:
|
||||||
|
|
|
@ -38,6 +38,8 @@ class BLTouchEndstopWrapper:
|
||||||
self.mcu_endstop = mcu.setup_pin('endstop', pin_params)
|
self.mcu_endstop = mcu.setup_pin('endstop', pin_params)
|
||||||
# Setup for sensor test
|
# Setup for sensor test
|
||||||
self.next_test_time = 0.
|
self.next_test_time = 0.
|
||||||
|
self.pin_up_not_triggered = config.getboolean(
|
||||||
|
'pin_up_reports_not_triggered', True)
|
||||||
self.test_sensor_pin = config.getboolean('test_sensor_pin', True)
|
self.test_sensor_pin = config.getboolean('test_sensor_pin', True)
|
||||||
self.start_mcu_pos = []
|
self.start_mcu_pos = []
|
||||||
# Calculate pin move time
|
# Calculate pin move time
|
||||||
|
@ -74,6 +76,19 @@ class BLTouchEndstopWrapper:
|
||||||
self.mcu_pwm.set_pwm(self.next_cmd_time, Commands[cmd] / SIGNAL_PERIOD)
|
self.mcu_pwm.set_pwm(self.next_cmd_time, Commands[cmd] / SIGNAL_PERIOD)
|
||||||
self.next_cmd_time += max(duration, MIN_CMD_TIME)
|
self.next_cmd_time += max(duration, MIN_CMD_TIME)
|
||||||
return self.next_cmd_time
|
return self.next_cmd_time
|
||||||
|
def verify_state(self, check_start_time, check_end_time, triggered, msg):
|
||||||
|
# Perform endstop check to verify bltouch reports desired state
|
||||||
|
prev_positions = [s.get_commanded_position()
|
||||||
|
for s in self.mcu_endstop.get_steppers()]
|
||||||
|
self.mcu_endstop.home_start(check_start_time, ENDSTOP_SAMPLE_TIME,
|
||||||
|
ENDSTOP_SAMPLE_COUNT, ENDSTOP_REST_TIME,
|
||||||
|
triggered=triggered)
|
||||||
|
try:
|
||||||
|
self.mcu_endstop.home_wait(check_end_time)
|
||||||
|
except self.mcu_endstop.TimeoutError as e:
|
||||||
|
raise homing.EndstopError("BLTouch failed to %s" % (msg,))
|
||||||
|
for s, pos in zip(self.mcu_endstop.get_steppers(), prev_positions):
|
||||||
|
s.set_commanded_position(pos)
|
||||||
def test_sensor(self):
|
def test_sensor(self):
|
||||||
if not self.test_sensor_pin:
|
if not self.test_sensor_pin:
|
||||||
return
|
return
|
||||||
|
@ -87,17 +102,8 @@ class BLTouchEndstopWrapper:
|
||||||
check_start_time = self.send_cmd('reset', duration=self.pin_move_time)
|
check_start_time = self.send_cmd('reset', duration=self.pin_move_time)
|
||||||
check_end_time = self.send_cmd('touch_mode')
|
check_end_time = self.send_cmd('touch_mode')
|
||||||
self.send_cmd(None)
|
self.send_cmd(None)
|
||||||
# Perform endstop check to verify bltouch reports probe raised
|
self.verify_state(check_start_time, check_end_time, True,
|
||||||
prev_positions = [s.get_commanded_position()
|
"verify sensor state")
|
||||||
for s in self.mcu_endstop.get_steppers()]
|
|
||||||
self.mcu_endstop.home_start(check_start_time, ENDSTOP_SAMPLE_TIME,
|
|
||||||
ENDSTOP_SAMPLE_COUNT, ENDSTOP_REST_TIME)
|
|
||||||
try:
|
|
||||||
self.mcu_endstop.home_wait(check_end_time)
|
|
||||||
except self.mcu_endstop.TimeoutError as e:
|
|
||||||
raise homing.EndstopError("BLTouch sensor test failed")
|
|
||||||
for s, pos in zip(self.mcu_endstop.get_steppers(), prev_positions):
|
|
||||||
s.set_commanded_position(pos)
|
|
||||||
# Test was successful
|
# Test was successful
|
||||||
self.next_test_time = check_end_time + TEST_TIME
|
self.next_test_time = check_end_time + TEST_TIME
|
||||||
self.sync_print_time()
|
self.sync_print_time()
|
||||||
|
@ -113,8 +119,11 @@ class BLTouchEndstopWrapper:
|
||||||
def home_finalize(self):
|
def home_finalize(self):
|
||||||
self.sync_mcu_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)
|
check_start_time = self.send_cmd('pin_up', duration=self.pin_move_time)
|
||||||
self.send_cmd(None)
|
check_end_time = self.send_cmd(None)
|
||||||
|
if self.pin_up_not_triggered:
|
||||||
|
self.verify_state(check_start_time, check_end_time,
|
||||||
|
False, "raise probe")
|
||||||
self.sync_print_time()
|
self.sync_print_time()
|
||||||
# Verify the probe actually deployed during the attempt
|
# Verify the probe actually deployed during the attempt
|
||||||
for s, mcu_pos in self.start_mcu_pos:
|
for s, mcu_pos in self.start_mcu_pos:
|
||||||
|
|
|
@ -181,7 +181,8 @@ class MCU_endstop:
|
||||||
, self._oid)
|
, self._oid)
|
||||||
def home_prepare(self):
|
def home_prepare(self):
|
||||||
pass
|
pass
|
||||||
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):
|
||||||
clock = self._mcu.print_time_to_clock(print_time)
|
clock = self._mcu.print_time_to_clock(print_time)
|
||||||
rest_ticks = int(rest_time * self._mcu.get_adjusted_freq())
|
rest_ticks = int(rest_time * self._mcu.get_adjusted_freq())
|
||||||
self._homing = True
|
self._homing = True
|
||||||
|
@ -189,7 +190,8 @@ class MCU_endstop:
|
||||||
self._next_query_print_time = print_time + self.RETRY_QUERY
|
self._next_query_print_time = print_time + self.RETRY_QUERY
|
||||||
self._home_cmd.send(
|
self._home_cmd.send(
|
||||||
[self._oid, clock, self._mcu.seconds_to_clock(sample_time),
|
[self._oid, clock, self._mcu.seconds_to_clock(sample_time),
|
||||||
sample_count, rest_ticks, 1 ^ self._invert], reqclock=clock)
|
sample_count, rest_ticks, triggered ^ self._invert],
|
||||||
|
reqclock=clock)
|
||||||
for s in self._steppers:
|
for s in self._steppers:
|
||||||
s.note_homing_start(clock)
|
s.note_homing_start(clock)
|
||||||
def home_wait(self, home_end_time):
|
def home_wait(self, home_end_time):
|
||||||
|
|
Loading…
Reference in New Issue