# Starting G-code for auto Z probe offset

So, I like to take off my glass build plate from my printer bed because I don't like to put any force on the bed bearings but this presents an issue. I have an inductive bed leveling probe and each time I remove the plate the Z offset seems to be off on the next print.

Instead of re-leveling my bed and setting the Z offset by hand, I thought of adding starting G-code to do that for me but I've hit a snag. I have an Ender 3 and use Slic3r.

The sequence of events I would like is as follows:

1. G28 - home axis
2. G0 X150 Y130 Z5 - Moves to X150 Y130 Z5
3. G30 S1 - Performs a bed leveling probe at the current point. This raises the head 10 mm and stops when the probe is triggered. The current Z height this stops at is what I want for the next command.
4. M851 Z[insert Z height from prev command here]

I know Slic3r has these placeholder values for some commands like M109 S[temperature_0] in the square brackets. Is there one for the current Z height?

• Z value is the difference between sensing probe and nozzle height vs bed surface, for example M851 Z-2.0, for me since my probe is low sensitive vs glass thickness the value is -0.7. This value is inside the firmware instead setting each part I run G29. I'm using 3 bed glass same thickness Oct 31 '19 at 4:58

## 1 Answer

The inductive sensors trigger to the metal plate under the glass bed. This implies that if you remove the slate of glass, the distance between the trigger point and the print bed is increased by the thickness of the glass slate. But, the trigger point is still exactly the same as if there were a slate of glass (as it triggers on the metal bed underneath). This extra distance need to be compensated for.

The method you are using is incorrect in determining the distance between the nozzle and bed with respect to the sensor trigger point. This answer on question: "Z Offset on autoleveling sensor setup" describes how you need to determine the distance between nozzle and bed from the trigger point. It includes a manual step to lower the nozzle a paper thickness above the build plate.

If you insist on using G-code (e.g. in your start G-code script), you can redefine the Z=0 level by adding a G-code G92. In case of a 3 mm glass plate, you should add after the homing (G28) and probing of the bed (G29) the following:

G1 Z0  ; This will move the nozzle to Z=0 as if there was a slate of glass,
but in fact it is still 3 mm offset
G92 Z3 ; This redefines the old Z=0 (with glass) to be Z=3 mm