Skip to content

How To Use It

Titus Meyer edited this page Feb 24, 2023 · 9 revisions

☝️ NOTE: If you calibrate Z within a SAVE_GCODE_STATE and RESTORE_GCODE_STATE, the calibrated offset will be lost after running RESTORE_GCODE_STATE!

Command CALIBRATE_Z

💡 NEW: The configured position for probing on the bed can now be overridden by using the new "BED_POSITION" parameter.

The z-offset calibration is started by:

CALIBRATE_Z [BED_POSITION=<X mm, Y mm>]

The optional "BED_POSITION" parameter can be used to specify a different position on the bed to be probed. However, if the "bed_xy_position" is not configured and there is no bed mesh or relative reference index, this parameter becomes mandatory.

The "BED_POSITION" argument overrides any configured bed position.

If the probe is not attached to the printhead, calibration will be aborted (if a normally closed configuration is used). So, macros can help here to attach and detach the probe like this:

[gcode_macro CALIBRATE_Z]
rename_existing: BASE_CALIBRATE_Z
gcode:
    {% set bed_position = params.BED_POSITION|default('None') %}
    G28                         # can also be a conditional homing macro
    M117 Z-Calibration..
    ATTACH_PROBE                # a macro for fetching the probe first
    {% if bed_position != 'None' %}
      BASE_CALIBRATE_Z BED_POSITION={bed_position}
    {% else %}
      BASE_CALIBRATE_Z
    {% endif %}
    DETACH_PROBE                # and parking it afterwards (or DOCK_PROBE in klicky macros)
    M117

💡 INFO: Meanwhile, it's possible to use the "start_gcode" or "before_switch_gcode" and the "end_gcode" instead of rewriting the CALIBRATE_Z command!

Then the CALIBRATE_Z command needs to be added to the PRINT_START macro.

❗ And remove any z-offset adjustments here (like SET_GCODE_OFFSET) ❗

The print start sequence might look like this:

  1. Home all axes
  2. Heat up the bed and nozzle (and chamber)
  3. Get probe, make QGL or Z-Tilt, park probe
  4. Purge and clean the nozzle if available
  5. (Get probe), CALIBRATE_Z, (park probe)
  6. (Adjust z-offset if needed)
  7. Print intro line
  8. Start printing...

For textured plates, it might be necessary to adjust the offset to be closer to the bed. This can be done from the slicers start GCode by adding a parameter to the PRINT_START macro after the Z calibration:

# Adjust the G-Code z-offset if needed
SET_GCODE_OFFSET Z_ADJUST={params.Z_ADJUST|default(0.0)|float} MOVE=1

Then, you can use PRINT_START Z_ADJUST=0.0 in your slicer. This does not reset the offset set by the calibration but adjusts it by the given value!

☝️ NOTE: Do not home Z again after performing this calibration or it will need need to be performed again!

Now, I wish you happy printing with a perfect first layer every time - no matter what you have just modded on your printhead or bed, or what nozzle and flex plate you plan to use for your next project. It's just perfect 😃

Resetting the Calibration

The calibration can be reset by executing this GCode command:

SET_GCODE_OFFSET Z=0.0

Command PROBE_Z_ACCURACY

There is also a PROBE_Z_ACCURACY command to test the accuracy of the z endstop:

PROBE_Z_ACCURACY [PROBE_SPEED=<mm/s>] [LIFT_SPEED=<mm/s>] [SAMPLES=<count>] [SAMPLE_RETRACT_DIST=<mm>]

It calculates the maximum, minimum, average, median and standard deviation of multiple probe samples at the endstop by taking the configured nozzle position at the endstop. The optional parameters default to their corresponding settings in the z_calibration config section.