The issues/questions raised about the automatic bed leveling using e.g. a BLTouch probe at this stack require a more in depth description of the automatic leveling functionality in general, this answers aims on describing how this works.
Definition of "bed leveling"
Let us begin with saying that such sensors systems alone will never level your bed, this is a misconception that is easily concluded from the terms being used (terms like Auto Bed Leveling, ABL). Using such sensors will not physically change the "level" of your bed.1) Furthermore, the process of leveling your build surface/heated bed is commonly known as tramming.
Tramming is the process of adjusting the build surface to be parallel to the X-axis and Y-axis of the 3D printer.
But, when do you need such a functionality2)? What if the bed surface isn't completely flat/square? Tramming such a surface is difficult and that surface will not be perpendicular to the X-Y plane of the nozzle... Why a bed is not perfectly flat can be caused by the manufacturing process, handling (during shipment, dropping tools on the surface, etc.), the way the bed is mounted and thermal stresses of non-uniform heating.
Basics
Many printers use endstops to determine the origin of the printer, these aren't essential for the printer, but very useful for the operator. Endstops allow for setting the reference from a known position to the origin of the printer. In fact, the sophisticated leveling sensors are nothing more than the simple Z-endstop except that the sensor is mounted onto the print head, it allows for probing the bed in more positions than an endstop limit switch mounted on the frame’s Z-axis.
In order to be able to print consistently, you should provide a bed that is properly trammed (to aid adhesion/prevent objects to not stick to the build plate). But, if for some reason, the surface contains imperfections, the normal tramming of the build surface using just the Z-endstop and the leveling screws might not be sufficient.
What does this so-called "leveling" do?
Using the ABL features from firmware will enable the use of a sensor to scan the surface of the build surface/heated bed to create a digital representation of the topology of the surface. This scanned surface includes the imperfections of the surface (this is depending on the option to process the measurement points of the scanning process, the more probing points the better the geometry can be mapped). E.g. just scanning 3 points will only result in a tilted plane (e.g. Ultimaker), but, scanning multiple points in a grid style process, the surface can be mapped to a complex surface describing the shape. So, if a surface isn't fully flat/square, the scanned surface provides a digital copy of the shape of the build plate.
How is the scanned surface applied?
Note that this scanning of the surface is generally done at a distance from the actual nozzle (except for pressure sensor systems where the nozzle is used as the probe), the images below show this for a BLTouch sensor and an inductive/capacitive sensor. For an inductive sensor this is the distance of detecting metal (minus the distance to the nozzle), for a BLTouch this is based on the triggering point of the extendable probe, see this answer (the image below depict the terminology). The operator of the printer needs to determine at which distance this bed has been scanned. This is commonly known as determining the Z-offset. The Z-offset can be set using a terminal or through the display. Setting this Z-offset is described in detail in "Specifying Z offset in Marlin firmware".
Once the shape of the bed is captured (G-code command G29
) and stored and the correct distance (Z-offset) set with M851 Zx.xx
(or through the display), the use of the shape needs to be activated in the starting G-code section of the G-code file of the print.
The nozzle will now be following the bed shape to improve the bed adhesion, this compensation is by default set to be smeared out in 10 mm, but can be disabled or changed to any other value using M420 Zxx
. The nozzle will print in the X-Y plane without compensation after the compensation distance. If you do not tram the bed correctly, the bottom of that print object will thus not be square to the height! See question "Does auto leveling result in sheared prints?".
1) Do note that actual leveling the bed is possible in some firmware flavors, but this is only possible if more individual controlled Z-steppers are used to move the bed/nozzle assembly!
2) Please note that firmware development has progressed over the years, e.g. using a recent version of Marlin, you can change the firmware to use UBL (see question What is ABL or UBL? Is this the same?). With UBL you technically do not need a leveling sensor, but, this is a laborious process to do this manually.