A Klipper plugin for accurate Z homing

Overview

Stable Z Homing for Klipper

A Klipper plugin for accurate Z homing

This plugin provides a new G-code command, STABLE_Z_HOME, which homes Z repeatedly until the Z offset stabilizes. This is useful if you have a printer which homes by pushing the nozzle against the Z endstop, where any plastic on or oozing from the nozzle can affect the Z offset and hence cause variation in the height of your first layer. The plugin can optionally run a G-code script before each probe, allowing you to clean the nozzle immediately before the offset is measured.

Feed the Llama

This plugin is developed in my spare time. If you like it, please consider supporting further development and updates by making a donation.

Feed the Llama


Motivation

To illustrate the problem this plugin is designed to solve, here is an experiment run on a Voron V2.4, with the nozzle pushed against a pin connected to a microswitch used as the Z endstop. I measured the probed Z offset every 10 seconds, starting with the extruder cold, and heating the extruder to the printing temperature for ABS (250C here). The nozzle was not scrubbed or cleaned in any way before or during this run, for demonstration purposes.

You can see that the Z offset varies by as much as 0.15mm during the run. As the plastic on the nozzle melts and gets squashed, the nozzle appears to move 0.15mm closer to the bed. Then, the filament in the nozzle oozes, pushing the nozzle up by 0.10mm over the next minute. Finally, as the oozing subsides, the offset settles at around -0.10mm.

Graph

Installation

Clone the repo into the home directory of your Pi, then symlink stable_z_home.py into your Klipper installation, like this:

$ cd ~/klipper/klippy/extras
$ ln -s ~/Klipper-Stable-Z-Home/stable_z_home.py .

Add the following to your Klipper config file, adjusting the G-code, which will be run before each probe attempt, to your needs:

[stable_z_home]
gcode:
    # use nozzle brush to clean nozzle; requires PURGE parameter, see below
    CLEAN_NOZZLE PURGE=0  

You can then add STABLE_Z_HOME to your PRINT_START macro, to replace the final G28 Z you may have there. A good time to do this is between heating the extruder and your final purge, e.g.:

[gcode_macro PRINT_START]
gcode:
    # ...
    M104 S{EXTRUDER}
    M109 S{EXTRUDER}

    STABLE_Z_HOME  # instead of G28 Z

    CLEAN_NOZZLE PURGE=1
    # ...

Note that to use the CLEAN_NOZZLE macro, which is from edwardyeeks' excellent purge bucket and nozzle scrub macros which can be found here, you need to extend the macro with a PURGE argument which allows you to scrub the nozzle without purging. Skipping the purge before each probe attempt saves time and minimizes oozing. The macro is easily extended like this:

[gcode_macro clean_nozzle]
# Add a parameter at the top, with default value 1 (purge).
default_parameter_PURGE: 1

# ...

gcode:
      # ...

      # Replace the "if" condition around the purge section in the macro as follows.

      ## Check if user enabled purge option or not.
      {% if params.PURGE|int == 1 %}
      
        # ... perform the purge ...
      
      {% endif %}
      
      # ...

Configuration

The following parameters can be adjusted in the [stable_z_home] section:

[stable_z_home]
#gcode:
#  The G-code to run before each probe attempt. The default is none.
#retries:
#  The maximum number of probe attempts allowed. The default is 20.
#window:
#  The number of samples to use in the tolerance window. The default is 4.
#retry_tolerance:
#  The maximum range between the min and max values of the Z offset in the window
#  to consider the offset stable and complete the procedure. The default is
#  0.0025mm.

The parameters RETRIES, RETRY_TOLERANCE, and WINDOW, can also be passed to the STABLE_Z_HOME command, in which case they override the defaults set in the config section above.


Copyright (C) 2021 Matthew Lloyd

You might also like...
IDA Pro plugin that shows the comments in a database
IDA Pro plugin that shows the comments in a database

ShowComments A Simple IDA Pro plugin that shows the comments in a database Installation Copy the file showcomments.py to the plugins folder under IDA

Poetry workspace plugin for Python monorepos.

poetry-workspace-plugin Poetry workspace plugin for Python monorepos. Inspired by Yarn Workspaces. Adds a new subcommand group, poetry workspace, whic

A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv

poetry-exec-plugin A plugin for poetry that allows you to execute scripts defined in your pyproject.toml, just like you can in npm or pipenv Installat

tox-gh is a tox plugin which helps running tox on GitHub Actions with multiple different Python versions on multiple workers in parallel

tox-gh is a tox plugin which helps running tox on GitHub Actions with multiple different Python versions on multiple workers in parallel. This project is inspired by tox-travis.

A simple IDA Pro plugin to show all HexRays decompiler comments written by user
A simple IDA Pro plugin to show all HexRays decompiler comments written by user

XRaysComments A simple IDA Pro plugin to show all HexRays decompiler comments written by user Installation Copy the file xray_comments.py to the plugi

A QGIS integration plugin for Kart repositories

QGIS Kart Plugin A plugin to work with Kart repositories Installation The Kart plugin is available in the QGIS Plugins server. To install the latest v

Tutor plugin for integration of Open edX with a Richie course catalog
Tutor plugin for integration of Open edX with a Richie course catalog

Richie plugin for Tutor This is a plugin to integrate Richie, the learning portal CMS, with Open edX. The integration takes the form of a Tutor plugin

HashDB Binary Ninja Plugin

HashDB Plugin (v0.1) Author: Vector 35 Inc Plugin for interacting with the OALABS HashDB service. Description: Plugin that can be used to lookup hashe

A NetBox Plugin that gives a UI for generating, comparing and deploying configurations to devices.

netbox_config_plugin - A plugin to generate, compare and deploy configurations This plugin allows you to execute your code to generate a config for a

Comments
  • Nozzle hitting bed when probe fail.

    Nozzle hitting bed when probe fail.

    It will be nice to have option for probing with checking minimum Z limit instead of rehoming. Probe fails is rare but repeating greatly increases the likelihood of crash. Bed temperature drift typycally less then millimeter so better remember first home position and stop moving just before nozzle hit bed, then repeat probe.

    opened by thghca 0
  • New Klipper complain about stable_z_home section in config

    New Klipper complain about stable_z_home section in config

    Hello, New klipper (klipper v0.10.0-286-gfe2974b8) doesn't agree with your script in the config - I am getting this error message "Section 'stable_z_home' is not a valid config section" Will be possible to update this script for the new version of the klipper?

    Thanks, Daniel

    opened by canadank0 1
Owner
Matthew Lloyd
Matthew Lloyd
A simple but flexible plugin system for Python.

PluginBase PluginBase is a module for Python that enables the development of flexible plugin systems in Python. Step 1: from pluginbase import PluginB

Armin Ronacher 1k Dec 16, 2022
A Linux webcam plugin for BGMv2 as used in our demos.

The goal of this repository is to supplement the main Real-Time High Resolution Background Matting repo with a working demo of a videoconferencing plu

Andrey Ryabtsev 144 Dec 27, 2022
flake8 plugin which forbids match statements (PEP 634)

flake8-match flake8 plugin which forbids match statements (PEP 634)

Anthony Sottile 25 Nov 1, 2022
A minimalist production ready plugin system

pluggy - A minimalist production ready plugin system This is the core framework used by the pytest, tox, and devpi projects. Please read the docs to l

pytest-dev 876 Jan 5, 2023
A simple but flexible plugin system for Python.

PluginBase PluginBase is a module for Python that enables the development of flexible plugin systems in Python. Step 1: from pluginbase import PluginB

Armin Ronacher 935 Feb 20, 2021
A PDM plugin to publish to PyPI

PDM Publish A PDM plugin to publish to PyPI NOTE: Consider if you need this over using twine directly Installation If you installed pdm via pipx: pipx

Branch Vincent 20 Aug 6, 2022
Poetry plugin to bundle projects into various formats

Poetry bundle plugin This package is a plugin that allows the bundling of Poetry projects into various formats. Installation The easiest way to instal

Poetry 54 Jan 2, 2023
Simple card retirement plugin for Anki

Anki Retirement Addon Allow users to suspend, tag, delete, or move cards that reach a specific retirement interval Supports Anki version 2.1.45 Licens

null 3 Dec 23, 2022
A maubot plugin to invite users to Matrix rooms according to LDAP groups

LDAP Inviter Bot This is a maubot plugin that invites users to Matrix rooms according to their membership in LDAP groups.

David Mehren 14 Dec 9, 2022
Plugin to generate BOM + CPL files for JLCPCB

KiCAD JLCPCB tools Plugin to generate all files necessary for JLCPCB board fabrication and assembly Gerber files Excellon files BOM file CPL file Furt

bouni 566 Dec 29, 2022