1
$\begingroup$

In setting up a probe for automatic bed leveling, the limits of the probing area must be entered in the firmware of a 3D printer.

When using a sensor, how do you define the bed limits for the sensor in Marlin firmware?

E.g. the Marlin configuration.h contains the following inactive statements:

  // Set the boundaries for probing (where the probe can reach).
  //#define LEFT_PROBE_BED_POSITION MIN_PROBE_EDGE
  //#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE - MIN_PROBE_EDGE)
  //#define FRONT_PROBE_BED_POSITION MIN_PROBE_EDGE
  //#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - MIN_PROBE_EDGE)

How do you set the values for the constants of your custom setup? Is this generic or specific?

Probe positioning is defined in the Marlin configuration as:

 *      +-- BACK ---+
 *      |           |
 *    L |    (+) P  | R
 *    E |           | I
 *    F | (-) N (+) | G
 *    T |           | H
 *      |    (-)    | T
 *      |           |
 *      O-- FRONT --+
 *    (0,0)

The probe could be placed with a positive or negative X and Y value. Considering this position, how to setup the sensor bed limits?

$\endgroup$
2
$\begingroup$

There are a few questions on this topic, so a more generic solution would be informative and will prevent multiple question of others when their sensor has a slightly different location. This answer intends to cover any position with respect to the nozzle. It also does not matter what kind of sensor it is, it can be 3DTouch, BLTouch, inductive, capacitive, etc., as long as you are able to determine the offset to the nozzle (center to center).

For now, it is assumed that the nozzle can only reach the complete area of the bed, no extra space. So unless the sensor runs of the bed, the nozzle limits are used, otherwise the sensor limits the nozzle with respect to the sensor limits. This is the safest assumption and will prevent the carriage running into the end mounts. But if there is more room for travel, an additional offset may be added to the limits.

First, determine the offset of the sensor (e.g. by measurement or taken from the information of the printable sensor bracket found many share sites on the internet; Thingiverse is a good source for such brackets).

Sensor Offset

The position of the sensor is set using the following constants:

#define X_PROBE_OFFSET_FROM_EXTRUDER [XXX]   // X offset: -left  +right  [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER [YYY]   // Y offset: -front +behind [the nozzle]

where [XXX] and [YYY] are offset values that specify the center of the sensor with respect to the nozzle. If both are positive values, the sensor is located in the back-right, if both negative, the position is front-left (as seen from the front of the machine using the definition in the Marlin configuration file). The other positions that are possible are the back-left and the front-right (one positive and one negative value).

Second, let's set the sensor area limits!

Sensor Area Limits

In the following images, the nozzle, the sensor and the offsets are defined by: Legend of nozzle, sensor and offset

There are four possible positions of the sensor, this results in the following schematics for the sensor area limits (transparent red area):

  1. Sensor at the back-right: Probe area for back-right probe

This implies that the sensor can reach the back and the right borders, so the limits are set by:

#define LEFT_PROBE_BED_POSITION (X_PROBE_OFFSET_FROM_EXTRUDER)
#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE)
#define FRONT_PROBE_BED_POSITION (Y_PROBE_OFFSET_FROM_EXTRUDER)
#define BACK_PROBE_BED_POSITION (Y_BED_SIZE)

Note that if a minimum probe offset is defined by #define MIN_PROBE_EDGE [value] in the configuration (to account for sensor width/dimension), the bed limits are changed resulting in (where t = MIN_PROBE_EDGE):

Probe area for back-right probe with MIN_PROBE_EDGE offset

Limits are then set by:

#define LEFT_PROBE_BED_POSITION (X_PROBE_OFFSET_FROM_EXTRUDER + MIN_PROBE_EDGE)
#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE - MIN_PROBE_EDGE)
#define FRONT_PROBE_BED_POSITION (Y_PROBE_OFFSET_FROM_EXTRUDER + MIN_PROBE_EDGE)
#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - MIN_PROBE_EDGE)

In the following sensor position placements, this offset for MIN_PROBE_EDGE will be accounted for.

  1. Sensor at the back-left: Probe area for back-left probe

This implies that the sensor can reach the back and the left borders (for zero MIN_PROBE_EDGE), so the limits are set by:

#define LEFT_PROBE_BED_POSITION (MIN_PROBE_EDGE)
#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE  - X_PROBE_OFFSET_FROM_EXTRUDER - MIN_PROBE_EDGE)
#define FRONT_PROBE_BED_POSITION (Y_PROBE_OFFSET_FROM_EXTRUDER + MIN_PROBE_EDGE)
#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - MIN_PROBE_EDGE)
  1. Sensor at the front-left: Probe area for front-left probe

This implies that the sensor can reach the front and the left borders (for zero MIN_PROBE_EDGE), so the limits are set by:

#define LEFT_PROBE_BED_POSITION (MIN_PROBE_EDGE)
#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE  - X_PROBE_OFFSET_FROM_EXTRUDER - MIN_PROBE_EDGE)
#define FRONT_PROBE_BED_POSITION (MIN_PROBE_EDGE)
#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - Y_PROBE_OFFSET_FROM_EXTRUDER - MIN_PROBE_EDGE)
  1. Sensor at the front-right: Probe area for back-right probe

This implies that the sensor can reach the front and the right borders (for zero MIN_PROBE_EDGE), so the limits are set by:

#define LEFT_PROBE_BED_POSITION (X_PROBE_OFFSET_FROM_EXTRUDER + MIN_PROBE_EDGE)
#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE  - MIN_PROBE_EDGE)
#define FRONT_PROBE_BED_POSITION (MIN_PROBE_EDGE)
#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - Y_PROBE_OFFSET_FROM_EXTRUDER - MIN_PROBE_EDGE)

This should have tackled the basics for defining the sensor area limits. It becomes a little more complicated when there is extra travel space. A very easy use of extra travel space can be found in the configuration file; e.g:

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS [XX]
#define Y_MIN_POS [YY]

where [XX] and [YY] are offset values from endstop to origin (orange arrows represent X_MIN_POS and Y_MIN_POS):

Probe area for back-right probe including homing endstop offsets Results in offset constants for a back-right probe:

#define LEFT_PROBE_BED_POSITION (X_PROBE_OFFSET_FROM_EXTRUDER + X_MIN_POS + MIN_PROBE_EDGE)
#define RIGHT_PROBE_BED_POSITION (X_BED_SIZE - MIN_PROBE_EDGE)
#define FRONT_PROBE_BED_POSITION (Y_PROBE_OFFSET_FROM_EXTRUDER + Y_MIN_POS + MIN_PROBE_EDGE)
#define BACK_PROBE_BED_POSITION (Y_BED_SIZE - MIN_PROBE_EDGE)

For all other options, a similar addition of the homing offsets can applied.

A similar addition is possible if the print head is able to travel further on the X or Y axis at the other ends of the axes.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.