klipper_auto_tap icon indicating copy to clipboard operation
klipper_auto_tap copied to clipboard

[BUG] Move to probe position inside loop?

Open TheFuzzyGiggler opened this issue 1 year ago • 3 comments

#In your rev_hop function, you have the return to probe position inside your loop which is calling it every time. That doesn't seem right unless I'm missing something?

I forked this project and moved it outside and got better results

Your code:

def _tap_rev_hop(self, step_size: float, stop: float, probe_min, probe_speed: float):
        probe = self._probe(self.z_endstop.mcu_endstop, probe_min, probe_speed)[2] # Moves until TAP actuates
        steps = int((abs(probe) + stop) / step_size)
        for step in range(0, steps):
            # Why inside the loop? You only want to return to the probe position once
            self._move([None, None, probe], probe_speed) # Move back to probe position

Correction:

def _tap_rev_hop(self, step_size: float, stop: float, probe_min, probe_speed: float):
        probe = self._probe(self.z_endstop.mcu_endstop, probe_min, probe_speed)[2] # Moves until TAP actuates
        steps = int((abs(probe) + stop) / step_size)
        self._move([None, None, probe], probe_speed) # Move back to probe position
        for step in range(0, steps):
            z_pos = probe + (step * step_size) # checking z-position
            self._move([None, None, z_pos], probe_speed)
            self.printer.lookup_object('toolhead').wait_moves() # Wait for toolhead to move
            if not self._endstop_triggered():
                travel = abs(probe - z_pos)
                return(step, probe, z_pos, travel)
        return None

I'd make a pull request but I've already tweaked the code to add a new tap function to essentially "retap" and see how many steps it takes to retrigger moving at the step rate. It then reports the "retap" distance, the difference between the retap distance and the original distance found with the rev_hop and then takes the average of the two. They're usually extremely close (.005mm or so) but I was curious about the variance in triggering. I might add onto it and do short movements to trigger and untrigger to see how much variance there is out of curiosity but the tap looks about as accurate as predicted.

Also, Awesome project. If you deprecate it and I pick it up I'll 100% give you all the original credit and only annotate my changes.

TheFuzzyGiggler avatar Feb 26 '24 12:02 TheFuzzyGiggler