<hr>

<p><em>None of the answers address your question to solve it! The only sensible contribution comes from a comment of <a href="https://3dprinting.stackexchange.com/users/26/tom-van-der-zanden">@TomvanderZanden</a>.</em></p>

<hr>

<p>For the sensor to stay <em>within</em> the limits of the bed (considering the offset of the sensor and the size of the hotend carriage) you need to define where the sensor (plus carriage) may go to (to keep the sensor also on the bed, you also need to define the <a href="/q/8153/">sensor limits</a>). The suggested constants are important in defining the size of the bed and the build volume, but changing them does in fact do not solve your problem. Your problem is that you need to address where the sensor may probe within that specified volume i.e. the sensor probing area.</p>

<p>I use ABL (Auto Bel Leveling) on my Anet A8 using a left-front mounted sensor at position (<code>x = -26 mm</code>; <code>y = -40 mm</code> seen from the nozzle center). In order to have the sensor on the bed area without running into the limits of the carriage, you have to calculate (yourself!) what the dimension of the auto bed leveling area is. This is because the sensor is off set from the nozzle. If the sensor reaches for the whole bed, you need extra space on the axis. To explain this, if your <strong>sensor is at the left front</strong>, as in my case, the amount of extra space you have <strong>left on the right side</strong> of the X carriage will determine how far the carriage may go and thus limits the right probe position. If there is no extra space on the carriage (the safest assumption) you just need to add the sensor offset to the maximum bed size (what the nozzle can reach). E.g. my probe X offset is <code>-26 mm</code>. The maximum probe distance is therefore <code>-26 mm + 220 mm = 194 mm</code>.</p>

<p>This means that you need to set the following constants (amongst the settings to enable ABL; the probe and the type of leveling...) in the configuration.h of your Marlin Firmware installation:</p>

<pre><code>#define X_PROBE_OFFSET_FROM_EXTRUDER -26   // X offset: -left  +right  [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER -40   // Y offset: -front +behind [the nozzle]

// Set the boundaries for probing (where the probe can reach).
#define LEFT_PROBE_BED_POSITION (0 + 10)         // 10
#define RIGHT_PROBE_BED_POSITION (220 - 26 - 10) // 184
#define BACK_PROBE_BED_POSITION (220 - 40 - 10)  // 170
#define FRONT_PROBE_BED_POSITION (0 + 10)        // 10
</code></pre>

<p>Furthermore the settings you do mention need to be:</p>

<pre><code>// The size of the print bed
#define X_BED_SIZE 220
#define Y_BED_SIZE 220

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS -33 // Distance from end switch to X = 0 of origin
#define Y_MIN_POS -10 // Distance from end switch to Y = 0 of origin
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240
</code></pre>

<p>The <code>-33</code> and the <code>-10</code>  define how much the nozzle needs to travel from the endstop position to the print origin! This is not necessary to change when using ABL with a sensor (unless you are using a different print head carriage with a different center of the nozzle). Why these values are <code>-33</code> and <code>-10</code> (or values close to this; e.g. for my printer they are <code>-36</code> and <code>-8</code>) is explained in <a href="/a/6376/">this answer</a>.</p>

CC BY-SA 4.0
2018-09-09T13:27:53.953Z
2019-04-22T04:33:39.557Z
2019-04-22T04:33:39.557Z
0scar
<p>The problem is in the code.
Please use these:</p>

<pre><code>// The size of the print bed
#define X_BED_SIZE 220
#define Y_BED_SIZE 220

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 5
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240
</code></pre>

<p>Your problem will be ok.</p>

CC BY-SA 4.0
2018-09-09T14:13:43.040Z
You need to explain why these changes are valid - particularly in case someone else looks at this answer in the future with a similar question.
Sean Houlihane
CC BY-SA 4.0
2018-09-09T15:59:19.487Z
Actually, these are the wrong constants to change for this specific problem, these only define the nozzle offset from endstops to origin and max bed positions, this has nothing to do with the probe limit locations. The problem is indeed in the code, but not the code you addressed in your answer!
0scar
CC BY-SA 3.0
2018-03-01T08:55:32.263Z
2018-03-01T15:35:12.310Z
2018-03-01T15:35:12.310Z
Kemal SENYILMAZ
<p>I am using Marlin firmware with a RAMPS board on an Anet A8 printer. </p>

<p>The bed size for the printer is 220 x 220 mm and that is stated in the <code>configuration.h</code> file. When using mesh bed leveling, the nozzle jumps to the first corner on the bed perfectly after setting the x-min to 5.0 but the next two points are off the end of the bed. Here are my settings: </p>

<pre><code>// Travel limits after homing (units are in mm)

 #define X_MIN_POS 5.0
 #define Y_MIN_POS 0.0
 #define Z_MIN_POS 0
 #define X_MAX_POS 220
 #define Y_MAX_POS 220
 #define Z_MAX_POS 240
</code></pre>

<p>What could be my issue? </p>

CC BY-SA 3.0
2017-08-21T06:43:27.813Z
The settings you posted don't have much to do with bed leveling. They're just the movement limits for normal operation. You should post the probe offsets configured and the probing positions (e.g., `LEFT_PROBE_BED_POSITION` or `UBL_PROBE_PT_1_X`, depending on your configuration).
Tom van der Zanden
CC BY-SA 4.0
2018-09-09T15:56:54.327Z
@TomvanderZanden Too bad the OP did not answer on your comment, you were the only to understand that the wrong constants have been used in the Q (and A)!
0scar
<marlin><anet-a8><bed-leveling>
Nozzle jumps off the bed when using Marlin Mesh Bed Leveling
Krizzle
# Nozzle jumps off the bed when using Marlin Mesh Bed Leveling

(Asked by: username_0 on 2017-06-18)

I am using Marlin firmware with a RAMPS board on an Anet A8 printer. 
The bed size for the printer is 220 x 220 mm and that is stated in the configuration.h file. When using mesh bed leveling, the nozzle jumps to the first corner on the bed perfectly after setting the x-min to 5.0 but the next two points are off the end of the bed. Here are my settings: 
// Travel limits after homing (units are in mm)

 #define X_MIN_POS 5.0
 #define Y_MIN_POS 0.0
 #define Z_MIN_POS 0
 #define X_MAX_POS 220
 #define Y_MAX_POS 220
 #define Z_MAX_POS 240

What could be my issue?

**Tags:** marlin, anet-a8, bed-leveling
> **Comments:**
> **username_1**: The settings you posted don't have much to do with bed leveling. They're just the movement limits for normal operation. You should post the probe offsets configured and the probing positions (e.g., `LEFT_PROBE_BED_POSITION` or `UBL_PROBE_PT_1_X`, depending on your configuration).  
> **username_2**: @TomvanderZanden Too bad the OP did not answer on your comment, you were the only to understand that the wrong constants have been used in the Q (and A)!  

---

## 2 answers

### Answer by username_2 on 2018-09-09. Score: 7

None of the answers address your question to solve it! The only sensible contribution comes from a comment of @TomvanderZanden.

For the sensor to stay within the limits of the bed (considering the offset of the sensor and the size of the hotend carriage) you need to define where the sensor (plus carriage) may go to (to keep the sensor also on the bed, you also need to define the sensor limits). The suggested constants are important in defining the size of the bed and the build volume, but changing them does in fact do not solve your problem. Your problem is that you need to address where the sensor may probe within that specified volume i.e. the sensor probing area.
I use ABL (Auto Bel Leveling) on my Anet A8 using a left-front mounted sensor at position (x = -26 mm; y = -40 mm seen from the nozzle center). In order to have the sensor on the bed area without running into the limits of the carriage, you have to calculate (yourself!) what the dimension of the auto bed leveling area is. This is because the sensor is off set from the nozzle. If the sensor reaches for the whole bed, you need extra space on the axis. To explain this, if your sensor is at the left front, as in my case, the amount of extra space you have left on the right side of the X carriage will determine how far the carriage may go and thus limits the right probe position. If there is no extra space on the carriage (the safest assumption) you just need to add the sensor offset to the maximum bed size (what the nozzle can reach). E.g. my probe X offset is -26 mm. The maximum probe distance is therefore -26 mm + 220 mm = 194 mm.
This means that you need to set the following constants (amongst the settings to enable ABL; the probe and the type of leveling...) in the configuration.h of your Marlin Firmware installation:
#define X_PROBE_OFFSET_FROM_EXTRUDER -26   // X offset: -left  +right  [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER -40   // Y offset: -front +behind [the nozzle]

// Set the boundaries for probing (where the probe can reach).
#define LEFT_PROBE_BED_POSITION (0 + 10)         // 10
#define RIGHT_PROBE_BED_POSITION (220 - 26 - 10) // 184
#define BACK_PROBE_BED_POSITION (220 - 40 - 10)  // 170
#define FRONT_PROBE_BED_POSITION (0 + 10)        // 10

Furthermore the settings you do mention need to be:
// The size of the print bed
#define X_BED_SIZE 220
#define Y_BED_SIZE 220

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS -33 // Distance from end switch to X = 0 of origin
#define Y_MIN_POS -10 // Distance from end switch to Y = 0 of origin
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240

The -33 and the -10  define how much the nozzle needs to travel from the endstop position to the print origin! This is not necessary to change when using ABL with a sensor (unless you are using a different print head carriage with a different center of the nozzle). Why these values are -33 and -10 (or values close to this; e.g. for my printer they are -36 and -8) is explained in this answer.


---

### Answer by username_3 on 2018-03-01. Score: -1

The problem is in the code.
Please use these:
// The size of the print bed
#define X_BED_SIZE 220
#define Y_BED_SIZE 220

// Travel limits (mm) after homing, corresponding to endstop positions.
#define X_MIN_POS 5
#define Y_MIN_POS 0
#define Z_MIN_POS 0
#define X_MAX_POS X_BED_SIZE
#define Y_MAX_POS Y_BED_SIZE
#define Z_MAX_POS 240

Your problem will be ok.

> **Comments:**
> **username_4**: You need to explain why these changes are valid - particularly in case someone else looks at this answer in the future with a similar question.  
> **username_2**: Actually, these are the wrong constants to change for this specific problem, these only define the nozzle offset from endstops to origin and max bed positions, this has nothing to do with the probe limit locations. The problem is indeed in the code, but not the code you addressed in your answer!  

---

