# Understanding X and Y Axes Limits and Homing

### The X and Y Axis

Klipper needs to know from its `printer.cfg` settings how far the X and Y axes can safely move without hitting the printer’s frame.
It also needs to know where the origin (X=0 / Y=0) is. This origin is the beginning of the usable printer bed.
In the following, we assume a Cartesian printer that follows the conventions of a Cartesian Coordinate System. This is also the reason why it is a quasi-standard to define the origin as the left-front corner of the bed. This way, all logic and movement easily aligns with the familiar Cartesian coordinate system.

Viewed from the nozzle, the Cartesian coordinate system is shown in the following figure1):

Important
For simplicity, the following is assumed:

• The origin (X=0 / Y=0) is defined in the front left corner of the bed
• The moving part is the nozzle / print-head, while the bed remains static
• Moving the bed will flip the logic for the Y-axis:
• On a static bed, the head will move to the front to reach Y=0
• On a moving bed, the bed will move to the rear to reach Y=0
• The location where an endstop is mounted does not matter. All that matters is the role that is assigned to the respective endstop in the configuration
• This is a general explanation of the logic and does not cater to any specific setup.

### Basic Homing Theory

• After the printer is started or the power to the steppers is turned off, Klipper does not know where the print head is. In this state, any movement is dangerous because the movement limits are unknown, which can easily lead to a crash → Homing is needed
• There are two different basic homing scenarios:
• Homing towards `position_max` and `position_endstop` also near the max position
• Homing towards `position_min` with `position_endstop` also near the min position
• `position_endstop` must always be between `position_min` and `position_max` or an error is thrown
• The dominant homing direction is determined by the proximity of `position_endstop` to `position_min` respectively `position_max`. The head moves to the nearest position in each case
• Homing towards `position_max`
• Klipper starts moving in the positive direction (usually to the right for X and to the back for Y) until it hits the endstop
• After hitting the endstop, Klipper now knows that the bed’s origin (X=0 / Y=0) is `position_max` millimeters away from the current position
• Homing towards `position_min`
• Klipper starts moving in the negative direction (usually to the left for X and to the front for Y) until it hits the endstop
• After hitting the endstop, Klipper now knows that the bed’s origin (X=0 / Y=0) is `position_min` millimeters away from the current position

## Homing to position_max

• `Kinematic Limits` define the maximum travel before either an endstop or the frame is hit.
• `position_max` is the distance in mm between the endstop and the bed’s left edge (X), respectively the bed’s front edge (Y).
• In this setup, `position_max` typically is equal to `position_endstop`
• From the `position_endstop` Klipper needs to travel in the negative direction this amount of millimeters in order to reach the origin
• This defines the origin X=0 and Y=0 where the usable part of the bed starts.
• `position_min` would allow the print head to move past the origin into the negative quadrant of the coordinate system.
• If the space between the bed and the frame allows it, this setting can be useful, e.g. to increase the probeable area of the bed.
• It does not change the origin.

## Homing to position_min

• `Kinematic Limits` again define the maximum travel before either an endstop or the frame is hit.
• `position_min` now is the distance in mm between the endstop and the bed’s right edge (X), because the head already is in the negative quadrant.
• In this setup, `position_min` typically is equal to `position_endstop`
• From the `position_endstop` Klipper needs to travel in the positive direction this amount of millimeters in order to reach the origin
• This defines the origin X=0 and Y=0 where the usable part of the bed starts.
• Both logics can be mixed, depending on the printer physical layout.
• `position_endstop` always must be equal or greater (less negative) than `position_min`

## Usable Printer Bed

• Due to the printer’s / print head’s geometry and attached parts (fans, probe etc.), it is not uncommon that some areas of the bed cannot be reached
• As discussed above, `position_endstop` and `position_max` / `position_min` will still define the start of the usable bed, but this does no longer align with the physical boundaries of the bed
• In the slicer, this “effective size” needs to be set
• The slicer will define its own center of the bed as the middle of this range
• Viewed from the physical boundaries of the bed, the print might appear off-center
• All this relates to the nozzle coordinates. When tuning such values, the `GET_POSITION` command provides the relevant information

## Mesh Coordinates vs. Nozzle Coordinates

• The relevant coordinates for the bed mesh (`mesh_min` / `mesh_max`) do not relate to the nozzle coordinates but to the actual coordinates of the probe’s tip
• The probe’s tip coordinates are defined as offsets to the nozzle coordinates via the `x_offset` / `y_offset` settings in the `[bltouch]` / `[probe]` section
• It is important that these offsets are as precise as possible
• The easiest process to determine the proper starting and ending coordinates for `mesh_min` / `mesh_max` is:
1. Home the printer
2. Move the head towards the left-front corner until you have positioned the probe’s tip as close as possible to this left-front edge
3. Issue the `GET_POSITION` command and get the nozzle coordinates
4. Correct the obtained X value with the `x_offset` and the Y value with the `y_offset` (mind the algebraic sign)
5. Enter the corrected values as `mesh_min`
6. Repeat steps 2. to 5., but this time place the probe’s tip as close as possible to the back-right corner and use the result for `mesh_max`
• Setting these coordinates wrongly typically will lead to a Move out of range: X Y Z [E] error

Diagrams are created with Excalidraw and are attached for future reference:
Diagrams.zip (13.5 KB)

1) Credits to @mental

10 Likes