Coder Social home page Coder Social logo

klipper_auto_tap's Introduction

Klipper Auto TAP

Klipper module for automatic z-offset configuration on Voron TAP

This project is being deprecated due to me switching from TAP to Klicky. Feel free to continue post and/or message me for assistance, or help with the code. This repo will be archived March 1st, 2024.

NOTICE: It may not be possible for this to work on versions of tap besides ChaoticLab's CNC Tap. If you decide to try this anyway, please share your results in Issue 5 so we can try to fix this problem.

This module is under development: Please ensure the calculated offset seems reasonable for your printer! See Validate Results for how to validate the offset.

This module calculates the distance your toolhead lifts to actuate TAP. Doing this enables automatic z-offset calculation. i.e. make G0 Z0.2 put the nozzle at 0.2mm above the bed. This is a fairly slow process since the toolhead needs to move by step (0.005), check if the endstop is still triggered, and repeat. Check how it works for more information.

On textured PEI, the offset may need to be slightly lowered to get proper first-layer squish. YMMV.

This is only known to work on QGL based printers, namely the Voron 2. If you use a different printer and want to help add support, please create an issue, and/or send a message on discord. Please include Auto TAP's console output so I can try to fix the issue.

Known issues

  • Issue 2: TILT_ADJUST printers calculate wrong offset
    • If you run a trident, or other printer that uses something other than QGL for leveling, the results won't be accurate.
  • Issue 5: TAP implementation changes expected offset
    • Different implementations of TAP (CL CNC, Mellow CNC, stock) have different expected offsets, the results may not be accurate depending on what version of tap you are using. Please validate results.

Table of Contents

Overview

  • License: MIT

How does it work?

  1. Home your printer
    • When your printer homes Z, your toolhead is lifted until the endstop is triggered, making that lifted point your z0
  2. Move to park position
  3. For each sample, tap!
    1. Probe the bed, and keep it at the position where endstop triggers
    2. Slowly lift the toolhead by step until the endstop isn't triggered
    3. Calculate travel distance travel = abs(probe z - measure distance)
    4. Save the resulting probe, measure distance, and travel
  4. Calculate Z-Offset based on TAP_VERSION

Using Klipper Auto TAP

Installation

To install this module, you need to clone the repository and run the install.sh script

Automatic installation

cd ~
git clone https://github.com/Anonoei/klipper_auto_tap.git
cd klipper_auto_tap
./install.sh

Manual installation

  1. Clone the repository
    1. cd ~
    2. git clone https://github.com/Anonoei/klipper_auto_tap.git
    3. cd klipper_auto_tap
  2. Link auto_tap to klipper
    1. ln -sf ~/klipper_auto_tap/auto_tap.py ~/klipper/klippy/extras/auto_tap.py
  3. Restart klipper
    1. sudo systemctl restart klipper

Moonraker Update Manager

[update_manager klipper_auto_tap]
type: git_repo
path: ~/klipper_auto_tap
origin: https://github.com/anonoei/klipper_auto_tap.git
primary_branch: main
install_script: install.sh
managed_services: klipper

Configuration

To configure auto tap you need to specify which version of TAP you are running

Name tap_version Validated Modification
ChaoticLab CNC Tap CL_CNC True * 2
Voron Tap R8 R8 False * 10 + 1
Voron Tap R6 R6 False * 23
VITALII MetalTap VITALII_CNC True * 21.5

If your version of tap is not validated, please make sure you validate results before using the calculated offset, and let me know if it worked for you!

Then, place this in your printer.cfg

[auto_tap]
tap_version: <your tap_version>

The values listed below are the defaults Auto TAP uses. You can include them if you wish to change their values, or run into issues.

[auto_tap]
tap_version: <your version> ; Set during the first part of configuration
x: Unset                    ; X position to probe, Defaults to the middle of the x axis `(max - min)/2`
y: Unset                    ; Y position to probe, Defaults to the middle of the y axis `(max - min)/2`
z: 10                       ; Z position to park
probe_to: -2                ; Lower probe until it triggers, or reaches this value
set: True                   ; Set probe offset after calculation
settling_probe: True        ; Perform a dummy probe before starting
stop: 2.0                   ; Lift Z up to this amount for TAP to de-actuate
step: 0.005                 ; Lift Z by this amount each check
samples: Unset              ; Number of samples to take, Defaults to your config's probe sample count
retract: Unset              ; Lift up by this amount at end, Defaults to your config's probe retract distance
probe_speed: Unset          ; Probe at this speed, Defaults to your config's probe travel speed
lift_speed: Unset           ; Retract at this speed, Defaults to your config's probe lift speed
travel_speed: 1000          ; Speed for travel to park position

Macro

Run the klipper command AUTO_TAP. You can also use the arguments below

Argument Default Description
TAP_VERSION Unset Defaults to the configuration value. You can use this to try other offsets.
X Unset X position to probe, Defaults to the middle of the x axis (max - min)/2
Y Unset Y position to probe, Defaults to the middle of the y axis (max - min)/2
Z 10 Z position to park
PROBE_TO -2 Lower probe until it triggers, or reaches this value
SET 1 Set probe offset after calculation
SETTLING_PROBE 1 Perform a dummy probe before starting
STOP 2.0 Lift Z up to this amount for TAP to de-actuate
STEP 0.005 Lift Z by this amount each check
SAMPLES Unset Number of samples to take, Defaults to your config's probe sample count
RETRACT Unset Lift up by this amount at end, Defaults to your config's probe retract distance
PROBE_SPEED 1.0 Probe at this speed
LIFT_SPEED Unset Retract at this speed, Defaults to your config's probe lift speed
TRAVEL_SPEED 1000 Speed for travel to park position
FORCE 0 Force AUTO_TAP to run, even if it was calculated previously

If you set values under Configuration, those will become the defaults.

If you run AUTO_TAP again, it will set the z-offset to the last calculated value unless you run AUTO_TAP FORCE=1.

Validate Results

After AUTO_TAP is run, by default it will apply the calculated offset.

  1. Run G0 Z(first layer height)
    • I use a first layer height of 0.25, so it's G0 Z0.25
  2. Verify there is a gap between the tip of the nozzle and the build surface, and it looks close to the Z distance you moved the toolhead to
  3. If your nozzle is touching the bed DO NOT USE THIS OFFSET
    1. Try running AUTO_TAP FORCE=1, and re-validate
    2. Create an issue, and/or post in Discord. Please include Auto TAP's console output, your printer model, and the version of tap you're using.

Example Usage

One and done:

  1. Run AUTO_TAP, and validate the offset
  2. Run Z_OFFSET_APPLY_PROBE to save the offset.
  3. Restart your printer
  4. Adjust as needed based on build surface material

Before starting print:

  1. Open your printers configuration
  2. In your PRINT_START macro, add AUTO_TAP after homing and leveling have been complete
  3. Adjust as needed based on build surface material

Tester Documentation

Thanks for your interest in testing Auto TAP! There are a few macro arguments that aren't included in the above documentation. If you're having issues with Auto TAP and want to see if different values work better for you, here they are!

  • Run AUTO_TAP FORCE=1 TAP_VERSION=DEV with any of the following arguments
    1. DEV_MULTIPLE - Value to multiply the travel distance by to calculate offset. The defaults are listed above next to tap_version (after *)
    2. DEV_ADDER - Value to add to the calculated offset. The defaults are listed above next to tap_version (after +, 0 if not listed)
    3. DEV_FUNC - Method to 'tap'
      • simple - Previous default, simply probes, and lifts the toolhead until the endstop is open
      • rev hop - Before each step, hop down to probe position then move up

If you want to check Auto TAP's variables, run AUTO_TAP FORCE=1 PRINT_CONFIG=1

klipper_auto_tap's People

Contributors

andremalenfant avatar anonoei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

klipper_auto_tap's Issues

TILT_ADJUST printers calculate wrong offset

First I really like your idea, but I think it doesn´t seem to work with a trident at the moment.

Today I installed your updated version trough moonraker, thanks for that!

I reverted my z_offset back to 0 and heated my chamber and did homing, plus z-tilt.

Then i did AUTO_TAP command with the following settings.
grafik

I calculated a offset of 0.110 which when saved translates to [probe_z_offset: -0.110].
My hand self measured z_offset for a nice first layer is: -0.865, which is far away from the AUTO_TAP one.

Never the less, I tried to make a test print, to fine tune the first layer, but the nozzle far too close to the bed, it is even dragging on the bed a little bit. This way the extruder can´t push any filament through the nozzle and my printer stops.

Chaning back to my old z_offset, it prints without any problems.

Am I doing something wrong?

Picture of bed with scratches:
IMG_20231004_104724

Printer Setup:
Voron Trident 300x300x250
Stealthburner with Rapido Hotend
Vitalii3D MetalTap with 2.4.1 OptoTap PCB at 24V

[BUG] Move to probe position inside loop?

#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.

Unable to parse "set_at_end: True"

As the title says, when restarting firmware the error does come up.

grafik

In the python script I couldn´t find "True" but the values 1 and 0 at the "set_at_end" line, so i figured that could work.
grafik

It seems that changing "True" to 1 does work, at least the error dissapears.
grafik

Is that correct?

Not really an issue: Trident calculating using lead screw rotation distance.

Hey, I´m currently trying to make the AUTO_TAP probing more accurate for Trident. I do maybe have an idea that could help with the accuracy. Since the Voron 2.4 you developed this on is belt driven on the Z axis, its almost "unlimited" in Z precision, only the stepper motor step angle (1.8 or 0.9) and the microsteps settings change that. Is that correct? For the Trident with the lead screw, we have another variable to take into consideration, namly the lead of the lead screw. This can range from 2, 4 to 8. But 2 and 4 are mostly used on Tridents, at least thats what I read. The lead says how much lift is generated in one rotation. A lead of 4 means, one rotation equals 4mm of lift. With a 1.8 degree stepper motor, that has 200 steps per rotation, that means that lead screw lifts only 0.02mm per step in a full step manner. Since we can use microstepping in our drivers, often 16 or 32, we can divide the lift per step by the microsteps and get a lift/microstep amount. In my case with 32 microsteps, I get a lift of 0.000625 per microstep. I used that value in your tool in the "step:" setting and a slow probe speed and now it has really accurate calculation because it now checks exactly every microstep if TAP is de-actuated. The stock step settings of 0.005 equal 4 microsteps with a 1.8 degree stepper motor.

Here are some pictures to visualize it a bit better.
grafik
grafik

I already tested some different combinations, to see if it makes a difference. Like 32 microsteps and 0.00125 or 16 microsteps and the correct corresponding 0.00125, but all those were a little off.

I did home and Z_tilt before every AUTO_TAP usage.

Can some other Trident users please check this too?

TAP implementation changes expected offset

Different implementations of TAP have different expected offsets.
Examples:

TAP Name Expected Result Offsets observed Travel observed Travel-to-offset
CL CNC Tap 0.03-1mm -0.15, -0.042 0.0740, 0.025 * 2
CL CNC 2 0.5-1.5mm -0.83 0.047 * 17.7
TAP R6 0.5-2mm -1.04 0.045 * 23
TAP R8 0.5-2mm -1.260, -1.320 0.0270 * 10 + 1
Mellow Tap 0.5-2mm -1.725
Vitalli CNC 0.5-2mm -0.865, -1.070 0.500

Thanks to the people below for providing these numbers

  • RedWish, Migo, Sanaa, EightFinger, Morfesto, cplmayo

Observed results

v2 Stock RC8 Results (Redwish), expected ~1.260

Samples: 5, Total Steps: 27
Probe Mean: 0.0038 / Min: 0.0013 / Max: 0.0050
Measure Mean: 0.0308 / Min: 0.0308 / Max: 0.0308
Travel Mean: 0.0270 / Min: 0.0250 / Max: 0.0300

v1 Vitalli MetalTap (EightFinger), expected ~0.865

Samples: 10, total Steps: 100
Probe Mean: -0.0235 / Min: -0.0356 / Max: -0.0069
Measure Mean: 0.0265 / Min: 0.0265 / Max: 0.0265
Travel Mean: 0.0500 / Min: 0.0500 / Max: 0.0500
Calculated STA Z-Offset: 0.052

CL CNC v2 (cplmayo), expected -0.830

Samples: 5, Total Steps: 47
Probe Mean: -0.0002 / Min: -0.0012 / Max: 0.0013
Measure Mean: 0.0468 / Min: 0.0468 / Max: 0.0468
Travel Mean: 0.0470 / Min: 0.0450 / Max: 0.0500
Calculated z-offset: 0.094

Error on startup: Unknown config object 'gcode_move'

This morning I started my printer like usual. Shortly after I did a restart and was greeted with this error:
grafik

Here is my klipper.log, where you can see that it has an issure within the auto_tap.py in line 91.
grafik

Any idea what is causing this?

Viltali's CNC Tap Result Validation

Setup:
350mm Trident
Vitali's CNC Tap
Revo Nozzles

Screenshot_3

I've defined tap_version with RC8 which based off of the other issue page should work. Currently using a hand measured probe offset of -0.630 on my older PEI sheet. When running first AUTO_TAP it's giving a value of 1.250
Screenshot_6
And when validated when going to G0 Z0.25 the nozzle is definitely higher.

IMG_6582

When running Force=1 I end up with the same result
Screenshot_7

Getting various python syntax errors.

I am getting various syntax errors. Is this built to run with Python 3?

First one that comes:

Unhandled exception during connect
Traceback (most recent call last):
File "/home/pi/klipper/klippy/klippy.py", line 175, in _connect
self._read_config()
File "/home/pi/klipper/klippy/klippy.py", line 141, in _read_config
self.load_object(config, section_config.get_name(), None)
File "/home/pi/klipper/klippy/klippy.py", line 121, in load_object
mod = importlib.import_module('extras.' + module_name)
File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/home/pi/klipper/klippy/extras/auto_tap.py", line 15
def Calculate(self, travel: float):

Small doc improvements suggestions

Hello. Trying auto tap for first time and got few small documentation issues for improvement consideration.

  • "See Validate Results for how to validate the offset." - wrong link

  • VOC Discord - Auto TAP - also wrong link (at least nothing about auto tap opens in discord)

  • "If your version of tap is not validated, please make sure you validate results before using the calculated offset, and let me know if it worked for you!

Then, place this in your printer.cfg

[auto_tap]"

but klipper won't load auto_tap.py extras module without [auto_tap] in printer.cfg, so can't do any validation before adding anything to printer.cfg. Adding empty [auto_tap] section won't work (Option 'tap_version' in section 'auto_tap' must be specified).
so user has to add [auto_tap] tap_version: xyz before validation.

  • I guess validation should mention to do homing and quad gantry leveling first

CL_CNC Tap V2

Voron 2.4 350mm

Auto Tap is off by about 0.900 when I test with feeler gauge at 0.200.

Console output:

Auto TAP Results on CL_CNC using 'rev hop' method
Samples: 5, Total Steps: 47
Probe Mean: -0.0002 / Min: -0.0012 / Max: 0.0013
Measure Mean: 0.0468 / Min: 0.0468 / Max: 0.0468
Travel Mean: 0.0470 / Min: 0.0450 / Max: 0.0500
Calculated z-offset: 0.094

Auto TAP sample 5
Traveled: 0.0450 from z0.0013 to 0.0463 on step 9

Auto TAP sample 4
Traveled: 0.0450 from z0.0000 to 0.0450 on step 9

Auto TAP sample 3
Traveled: 0.0450 from z0.0000 to 0.0450 on step 9

Auto TAP sample 2
Traveled: 0.0500 from z-0.0012 to 0.0488 on step 10

Auto TAP sample 1
Traveled: 0.0500 from z-0.0012 to 0.0488 on step 10

Auto TAP performing 5 samples to calculate z-offset on CL_CNC tap using 'rev hop' method
Probe Min: -2.0, Stop: 2.0, Step: 0.005

AUTO_TAP FORCE=1

G1 Z0.25 F1500

G28

Auto TAP Results on CL_CNC using 'rev hop' method
Samples: 5, Total Steps: 45
Probe Mean: -0.0025 / Min: -0.0037 / Max: -0.0012
Measure Mean: 0.0425 / Min: 0.0425 / Max: 0.0425
Travel Mean: 0.0450 / Min: 0.0450 / Max: 0.0450
Calculated z-offset: 0.092

Auto TAP sample 5
Traveled: 0.0450 from z-0.0025 to 0.0425 on step 9

Auto TAP sample 4
Traveled: 0.0450 from z-0.0025 to 0.0425 on step 9

Auto TAP sample 3
Traveled: 0.0450 from z-0.0037 to 0.0413 on step 9

Auto TAP sample 2
Traveled: 0.0450 from z-0.0025 to 0.0425 on step 9

Auto TAP sample 1
Traveled: 0.0450 from z-0.0012 to 0.0438 on step 9

Auto TAP performing 5 samples to calculate z-offset on CL_CNC tap using 'rev hop' method
Probe Min: -2.0, Stop: 2.0, Step: 0.005

AUTO_TAP```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.