# Calibrate Probe Z Offset

This section explains how to calibrate the <mark style="color:red;">`probe z_offset`</mark> which is critical to obtaining high quality prints. The z\_offset is the distance between the nozzle and bed when the probe triggers. The Klipper <mark style="color:red;">`PROBE_CALIBRATE`</mark> tool can be used to obtain this value - it will run an automatic probe to measure the probe's Z trigger position and then start a manual probe to obtain the nozzle Z height. The probe z\_offset will then be calculated from these measurements.

{% hint style="info" %}
Prior to starting this calibration, remove any filament completely from your printer and ensure your nozzle does not have any extruded filament hardened on the nozzle. This will ensure a proper probe z\_offset calibration.

This calibration will be performed with the Heater Bed at room temperature, please allow some time for the Heater Bed to cool down from the PID calibration.
{% endhint %}

* From the MainsailOS web interface;
  * Click the <mark style="color:red;">`Home All`</mark> button in the <mark style="color:red;">`Controls`</mark> section;
  * This should move the print head to the <mark style="color:red;">`safe_z_home`</mark> position;

{% hint style="info" %}
The <mark style="color:red;">`safe_z_home`</mark> position, is pre-defined in the <mark style="color:red;">`printer.cfg`</mark> file to these coordinates: <mark style="color:red;">`x-3, y-17, z10`</mark>
{% endhint %}

![Home All](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FPlhlGR1xRVqkmFGFJ4nK%2Fz1.png?alt=media\&token=b9d51d82-cdc1-4dd3-b906-87d6f7f58a9d)

* Move the print head to a position near the centre of the bed;
  * Send a <mark style="color:red;">`G1 X125 Y125 F3000`</mark> command in the <mark style="color:red;">`Console`</mark>;

![Move Print Head to Center Position](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FLzpGiT9zodvwKQFUa4lu%2Fz2.png?alt=media\&token=8adf45d5-7ea6-4e88-8fde-9f668c0c517d)

* Send a <mark style="color:red;">`PROBE_CALIBRATE`</mark> command in the <mark style="color:red;">`Console`</mark>;
  * This will return a Z position to start <mark style="color:red;">`the paper test`</mark> from;

![Probe Calibrate](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FNqL8VJpLDzDqUBUBu5Jb%2Fz3.png?alt=media\&token=6bcbe72b-dfa8-4f96-9718-348d2f154958)

* Using a standard weight copy paper, place the piece of paper on the <mark style="color:red;">`Heater Bed`</mark> under the <mark style="color:red;">`Extruder`</mark>;

![Copy Paper](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FDmnRwuUx3ub8q0Ah8xzE%2Fz4.jpg?alt=media\&token=6e6cdd37-2497-4139-b173-839de1ec2e06)

{% hint style="info" %}
The <mark style="color:red;">`TESTZ`</mark> command will be used to move the nozzle a relative distance from the nozzle's current position.  A <mark style="color:red;">`TESTZ Z=-.1`</mark> command will request the nozzle to move closer to the <mark style="color:red;">`Heater Bed`</mark> by .1mm.
{% endhint %}

{% hint style="info" %}
On one of my Anycubic Printers as an example, I had to lower the Z position from 2.915 to 1.835 (your printer will vary).  If I did all <mark style="color:red;">`TESTZ Z=-.1`</mark> commands it would have taken a lot of time.  If you are careful, you could start with a Z=-1 or Z=-0.5 to shorten the number of commands to send to the printer, just make sure that after every <mark style="color:red;">`TESTZ`</mark> command sent, you visually check the position of the nozzle.
{% endhint %}

{% hint style="warning" %}
You want to avoid having the nozzle crash into the bed and risk breaking the strain gauge on the printer.  It is best to take your time, just use common sense, and be cautious when entering the distance a Z=-1 and Z=-.1 is a big difference!
{% endhint %}

* Send a <mark style="color:red;">`TESTZ Z=-.1`</mark> command in the <mark style="color:red;">`Console`</mark>;
* After the nozzle stops moving, push the paper back and forth to check if the nozzle is in contact with the paper;
* Continue sending <mark style="color:red;">`TESTZ`</mark> commands until you feel a small amount of friction when moving the paper back and forth;
  * You only need a small amount of friction, you should still be able to move the paper back and forth feeling a slight contact with the nozzle without making the paper buckle;
  * If too much friction is found then send a <mark style="color:red;">`TESTZ Z=.1`</mark> command in the <mark style="color:red;">`Console`</mark> to raise the nozzle and test the paper friction again;
    * If you raised the nozzle too high, adjust the negative <mark style="color:red;">`TESTZ`</mark> command by splitting the last distance in half;
      * For this example you just went up Z=.1, try Z=-.05 or even Z=-.025 until you find the the sweet spot.
* Once you have the little bit of friction between the paper and the nozzle;
  * Send an <mark style="color:red;">`ACCEPT`</mark> command in the <mark style="color:red;">`Console`</mark>;
    * Record the <mark style="color:red;">`probe: z_offset: ###`</mark> setting as displayed in the <mark style="color:red;">`Console`</mark>, we will verify this setting matches what is saved in the <mark style="color:red;">`printer.cfg`</mark> file in one of the steps below;
* Send a <mark style="color:red;">`SAVE_CONFIG`</mark> command in the <mark style="color:red;">`Console`</mark>;
  * This will update the <mark style="color:red;">`printer.cfg`</mark> file with the new <mark style="color:red;">`probe: z_offset`</mark> settings and restart Klipper;
* Remove the paper from the print bed.

![Probe Z Offset](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FhtL1F6umZraHFsXAXhpE%2Fz5.png?alt=media\&token=7bd2086e-5f20-4c31-8778-d67cf9a925f9)

* Checking the <mark style="color:red;">`printer.cfg`</mark> file to ensure the new <mark style="color:red;">`probe: z_offset`</mark> settings are updated:
  * From the MainsailOS web interface, click <mark style="color:red;">`Machine`</mark>, then click on <mark style="color:red;">`printer.cfg`</mark>;

![Machine > printer.cfg](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FMa0GOnAruL0h5osc1aaJ%2Fz6.png?alt=media\&token=bde0b7d4-c250-450b-8dd6-5a4f0af8acc8)

* The <mark style="color:red;">`printer.cfg`</mark> file should load into an editor window;
* Scroll down until you see the <mark style="color:red;">`[probe]`</mark> section, the default z\_offset setting should be commented out and will not be used;

![Default z\_offset Settings](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FL6BwXTqfDUfCehlyvpPo%2Fz7.png?alt=media\&token=8a0e5b02-0670-49ba-94c2-eca08b6adaab)

* Continue scrolling down to the very bottom of the <mark style="color:red;">`printer.cfg`</mark> file until you reach the;
  * <mark style="color:red;">`#*# <---------------------- SAVE_CONFIG ---------------------->`</mark> section;
  * A new <mark style="color:red;">`[probe]`</mark> section should be present, along with the new z\_offset setting;
  * This should match what you recorded from the <mark style="color:red;">`Console`</mark> in a previous step;

![New z\_offset Settings](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FV6rGv7nyBMWQB6PqiWRC%2Fz8.png?alt=media\&token=20aff28d-cd6d-4277-80ed-8ecfcced0578)

* Once you have confirmed these settings;
  * Close the <mark style="color:red;">`printer.cfg`</mark> file by clicking the <mark style="color:red;">`X`</mark> near the top right of editor;
* Repeatability Check:
* After calibrating the probe Z offset it is a good idea to verify that the probe provides repeatable results. You will use the <mark style="color:red;">`PROBE_ACCURACY`</mark> command for this test;
* From the MainsailOS web interface;
  * Click the <mark style="color:red;">`Home All`</mark> button in the <mark style="color:red;">`Controls`</mark> section;

![Home All](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2Ftucw2c9lcxpGASfZ5h90%2Fz9.png?alt=media\&token=635306e1-8f52-4372-bc0b-7ee239a4dab4)

* Move the print head to a position near the centre of the bed (same position you used to calibrate the probe z offset);
  * Send a <mark style="color:red;">`G1 X125 Y125 F3000`</mark> command in the <mark style="color:red;">`Console`</mark>;

![Move Print Head to Center Position](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FUWRMiDeVOXvTFgAsoQXe%2Fz10.png?alt=media\&token=bbe3ce30-6915-4b27-918e-c455062c7719)

* Send a <mark style="color:red;">`PROBE_ACCURACY`</mark> command in the <mark style="color:red;">`Console`</mark>;
  * The command will run the probe ten times and produce output similar to the following;

![Probe Accuracy](https://3358793419-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEUZ4ecqSLgI2D4esAcVS%2Fuploads%2FTrLQqsnULTH09CRXWKY3%2Fz11.png?alt=media\&token=3d748491-c27d-470d-a9f3-5fefc5b45fcf)

{% hint style="info" %}
Ideally the tool will report an identical maximum and minimum value (if the probe obtains an identical result on all ten probes).  However, it's normal for the minimum and maximum values to differ by one Z 'step distance' or up to 5 microns (.005mm).

A 'step distance' is rotation\_distance/(full\_steps\_per\_rotation\*microsteps).  The distance between the minimum and the maximum value is called the range.  A range of 0.012500 would be considered normal.

If your 'standard deviation' is much greater than 0.012500 you may want to run through this calibration setting from the beginning and try again.
{% endhint %}

* Once you have confirmed these settings;
  * Close the <mark style="color:red;">`printer.cfg`</mark> file by clicking the <mark style="color:red;">`X`</mark> near the top right of editor;

{% hint style="info" %}
The official Klipper documentation has a section that explains Thermal Expansion, bottom of Bed Levelling.  Although it relates to the Probe Z Offset, I felt it has more relevance once you make your first couple of prints.  Therefore I've included it as a sub-section of [Making Prints](https://sean-dearing.gitbook.io/klipper-installation-for-anycubic-vyper/macros-and-slicer/making-prints) as you will need to print an object to see if you have to make any Z Offset adjustments.
{% endhint %}
