Tuesday, January 18, 2022

[3D Printer Series] Understanding how to set z_offset on Klipper

 Z-Offset is a general name for telling the printer how far the nozzle is from some reference point. The reference point can be either a z end stop or the probe position of a bed probe like a BLTouch. The confusing bit is what happens when you have both an end stop and a probe. In that case you'll want to use the end stop to move the z-axis to a fixed position and then rely on the bed probe only for bed leveling/compensation.

Klipper doesn't explain how the different options interact with each other making this process very confusing. Additionally, following their calibration guide will lead you down the wrong path if you are using a similar configuration as me. Here's how I do it and why:

Offset for z end stop/probe for bed mesh

We will essentially be using the z end stop as our absolute reference, but when we add bed mesh leveling there's an important config that makes our bed mesh work relative to the z end stop, and that is the key. You don't need to do PROBE_CALIBRATE as we never try to use the probed position for absolute positioning.

  1. Use the [bed_screws] and [screws_tilt_adjust] configuration to define where the bed level screws are on the xy plane. While you're at it, create an OctoPrint macro/button to move the nozzle above the first screw, this will come handy later.
  2. Next, tighten all the bed screws so the nozzle doesn't crash into the bed.
  3. Use your macro to move the head above the first screw and home the z-axis.
  4. Adjust the first bed screw so that the nozzle is about 1-2 mm above the bed.
  5. Use the SCREWS_TILT_CALCULATE command to level the other 3 screws, repeat till you get it pretty close
  6. ACCEPT when you are done
  7. SAVE_CONFIG
  8. Preheat the bed to your normal print temp
  9. Run Z_ENDSTOP_CALIBRATE but use a feeler gauge to get a precise gap between the nozzle and bed, then subtract out the thickness of the gauge. We do this instead of the paper test because the bed is now heated and the gauge is an accurate thickness. This is your effective z offset. If you get an out of bounds error, you will need to configure the min z position with a small negative number.
  10. ACCEPT when you are done
  11. SAVE_CONFIG
  12.  Add a [bed_mesh] config, but be sure to include a relative_reference_index that corresponds to the first screw position.
  13. Run BED_MESH_CALIBRATE
  14. SAVE_CONFIG, if you look at your printer.cfg, see if you can find the bed mesh values at the end. The value for the relative_reference_index should be 0 if you've configured it correctly.
  15. Do a single layer test print. I use calipers measure the thickness of the layer. I'll then manually change the [stepper_z] position_endstop to tweak the first layer until I get a thickness that matches the thickness specified in the gcode.

2 comments:

Seth said...

Thank you for this post, it's very helpful.

If I'm understanding correctly this would result in the printer bed being 1 or 2 mm below the z endstop, and the z-offset being a corresponding 1 or 2mm negative, so these instructions would need to be adjusted for a mechanical switch type endstop. Is that correct?

Sarit said...

The instructions don't need to be changed since I too am using a mechanical switch as the z endstop. After you run Z_ENDSTOP_CALIBRATE and SAVE_CONFIG you should notice something like:

[stepper_z]
position_endstop = 0.582

section in your printer.cfg.
If you hadn't added the feeler gauge thickness during Z_ENDSTOP_CALIBRATE you can manually add it to the position_endstop.