Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making the measurment reliable by waiting for "silence" aka. finishing all moves #151

Open
wants to merge 2 commits into
base: no_toolhead_sensor
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Klipper_Files/Extra module/ercf.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ def _do_calculate_calibration_ratio(self, tool):
self._select_tool(tool)
self._servo_down()
self._set_steps(1.)
self.toolhead.wait_moves()
self._counter.reset_counts()
encoder_moved = self._load_into_encoder()
self._load_to_end_of_bowden(load_length-encoder_moved)
Expand Down Expand Up @@ -482,12 +483,14 @@ def cmd_ERCF_CALIBRATE_ENCODER(self, gcmd):

for x in range(repeats):
# Move forward
self.toolhead.wait_moves()
self._counter.reset_counts()
self._gear_stepper_move_wait(dist, True, speed, accel)
plus_values.append(self._counter.get_counts())
self.gcode.respond_info("+ counts = %.3f"
% (self._counter.get_counts()))
# Move backward
self.toolhead.wait_moves()
self._counter.reset_counts()
self._gear_stepper_move_wait(-dist, True, speed, accel)
min_values.append(self._counter.get_counts())
Expand Down Expand Up @@ -676,6 +679,7 @@ def _check_filament_in_extruder(self, move_size = 20, threshold = 1):
self._servo_up()
self._log_debug("Checking for filament in extruder")
# reset the counter and move the extruder backwards by move_size
self.toolhead.wait_moves()
self._counter.reset_counts()
pos = self.toolhead.get_position()
pos[3] -= move_size
Expand All @@ -697,6 +701,7 @@ def _check_filament_in_extruder(self, move_size = 20, threshold = 1):
def _check_filament_in_encoder(self):
self._log_debug("Checking for filament in encoder")
self._servo_down()
self.toolhead.wait_moves()
self._do_buzz_gear_motor()
final_encoder_pos = self._counter.get_distance()
self._log_trace("After buzzing gear motor, encoder read %.1f" % final_encoder_pos)
Expand Down Expand Up @@ -731,6 +736,7 @@ def _unload_from_extruder(self):
out_of_extruder = False
for i in range(3):
self._log_debug("Testing if filament is still in the extruder - #%d" % i)
self.toolhead.wait_moves()
self._counter.reset_counts()
pos[3] -= self.encoder_move_step_size
self.toolhead.manual_move(pos, 20)
Expand All @@ -757,6 +763,7 @@ def _unload_encoder(self, max_steps=5):

self._log_debug("Unloading from the encoder")
for step in range(max_steps):
self.toolhead.wait_moves()
self._counter.reset_counts()
self._gear_stepper_move_wait(-self.encoder_move_step_size)
dist_moved = self._counter.get_distance()
Expand All @@ -765,6 +772,7 @@ def _unload_encoder(self, max_steps=5):
if delta >= 3.0:
# if there is a large delta here, we are out of the encoder
self.loaded_status = self.LOADED_STATUS_UNLOADED
self.toolhead.wait_moves()
self._counter.reset_counts()
self._gear_stepper_move_wait(-(self.parking_distance - delta))
if self._counter.get_distance() < 5.0:
Expand All @@ -787,6 +795,7 @@ def _unload_from_end_of_bowden(self, length):
self.toolhead.dwell(0.2)
self.toolhead.wait_moves()
motwok marked this conversation as resolved.
Show resolved Hide resolved

self.toolhead.wait_moves()
self._counter.reset_counts()

# Initial unload in sync (ERCF + extruder) for xx mms
Expand All @@ -800,6 +809,7 @@ def _unload_from_end_of_bowden(self, length):
#length -= counter_distance
#self._log_debug("Sync unload move done %.1f / %.1f (diff: %.1f)" % (counter_distance, self.sync_unload_length, counter_distance - self.sync_unload_length))

self.toolhead.wait_moves()
self._counter.reset_counts()
# initial attempt to unload the filament
for i in range(self.num_moves):
Expand Down Expand Up @@ -986,6 +996,7 @@ def _load_to_nozzle(self):
self._log_debug("Loading to the nozzle")

self._servo_up()
self.toolhead.wait_moves()
self._counter.reset_counts()
pos = self.toolhead.get_position()
pos[3] += self.end_of_bowden_to_nozzle
Expand Down Expand Up @@ -1249,9 +1260,11 @@ def cmd_ERCF_ENCODER_RUNOUT(self, gcmd):
self._log_info("Issue on tool %d" % self.tool_selected)
self._log_info("Checking if this is a clog or a runout...")

self.toolhead.wait_moves()
self._counter.reset_counts()
self._disable_encoder_sensor()
self._servo_down()
self.toolhead.wait_moves()
self._do_buzz_gear_motor()
self._servo_up()
moved = self._counter.get_distance()
Expand Down