<p>Auto bed leveling requires some settings (constants) in the configuration of your Marlin firmware.</p>

<p>It is recommended to <a href="http://marlinfw.org/docs/features/auto_bed_leveling.html" rel="nofollow noreferrer">read about the implementation of automatic bed leveling</a> first. There are a few options to choose the kind of leveling, for 3D printers a commonly chosen option is <code>AUTO_BED_LEVELING_BILINEAR</code> which is the best option if you do not know if your bed is flat or not. If you are certain it is flat but tilted (e.g. when you have a milled bed or a glass plate in 3D printing) you could go for <code>AUTO_BED_LEVELING_3POINT</code> or <code>AUTO_BED_LEVELING_LINEAR</code>.</p>

<p>What further is important is the sensor type you choose. Do you want a touch or a proximity sensor. The latter is your preference (as specified in your question), which is a little simpler as you do not need to configure for servos for deploying and stowing.</p>

<p>You need to set: </p>

<pre><code>#define FIX_MOUNTED_PROBE
</code></pre>

<p>for using a fixed proximity sensor.</p>

<p>In the configuration file you also need to specify the position of the probe in relation to the nozzle (in your case tool center):</p>

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

<p>and optionally:</p>

<pre><code>#define Z_PROBE_OFFSET_FROM_EXTRUDER 0   // Z offset: -below +above  [the nozzle]
</code></pre>

<p>This latter is not necessary as you can always set the distance of the sensor trigger point to the nozzle/tool plane by G-code command <code>M851 Z-x.xx</code> </p>

<p>You would also need to set the boundaries of the probe area to prevent the tool to hit unwanted positions (fill out values or leave the constants):</p>

<pre><code>// 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)
</code></pre>

<p>Once properly setup, command <a href="http://marlinfw.org/docs/gcode/G029-abl.html" rel="nofollow noreferrer"><code>G29</code></a> runs the leveling of the bed, options are available for that command to store the bed mesh to EEPROM.</p>

<p>Enabling <code>LCD_BED_LEVELING</code> constant in the configuration file will add a Bed Leveling sub-menu to the LCD. But you could also work with SD-card stored files that load these codes.</p>

<p><a href="https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling" rel="nofollow noreferrer">This</a> reference explains the automatic leveling in more detail, but there are many more detailed guides to follow from the internet. Be sure that you get a recent guide to that is easier to set in the latest firmware.</p>

CC BY-SA 4.0
2018-10-02T13:21:41.093Z
Thanks!. Can I uncomment MESH_BED_LEVELING and AUTO_BED_LEVELING_BILINEAR at the same time?. I want to test the result of this manually before going to the automatic solution. With both methods activated, both options will appear on the menu?. (auto and manual).
Ariel Larraburu
CC BY-SA 4.0
2018-10-02T13:32:35.357Z
No I do not think it is possible, if you look into the config file you see that if you enable both, `AUTO_BED_LEVELING_BILINEAR` is executed is some `#if` statement and it will then never go to the `#elif` of `MESH_BED_LEVELING `.
0scar
CC BY-SA 4.0
2018-10-02T13:03:57.043Z
2018-10-02T20:45:13.403Z
2018-10-02T20:45:13.403Z
0scar
<p>I just finished a CNC that uses Marlin Firmware. The dimensions of it are quite large (3200 x 2000 mm) and the table is not perfect. I'm thinking of adding a proximity sensor to store a mesh in the eeprom and thus compensate for any errors. I'm not sure how to do this. I would like to be able to execute an action from the display (full graphics) and have samples taken over the whole table, but I do not know how to tell the firmware where to take the samples, nor what the dimensions of it are.</p>

<bed-leveling><cnc>
How do I add auto bed levelling to my Marlin-based CNC?
Ariel Larraburu
# How do I add auto bed levelling to my Marlin-based CNC?

(Asked by: username_0 on 2018-10-02)

I just finished a CNC that uses Marlin Firmware. The dimensions of it are quite large (3200 x 2000 mm) and the table is not perfect. I'm thinking of adding a proximity sensor to store a mesh in the eeprom and thus compensate for any errors. I'm not sure how to do this. I would like to be able to execute an action from the display (full graphics) and have samples taken over the whole table, but I do not know how to tell the firmware where to take the samples, nor what the dimensions of it are.

**Tags:** bed-leveling, cnc


---

## 1 answers

### Answer by username_1 on 2018-10-02. Score: 3 | Accepted answer

Auto bed leveling requires some settings (constants) in the configuration of your Marlin firmware.

It is recommended to [read about the implementation of automatic bed leveling](http://marlinfw.org/docs/features/auto_bed_leveling.html) first. There are a few options to choose the kind of leveling, for 3D printers a commonly chosen option is `AUTO_BED_LEVELING_BILINEAR` which is the best option if you do not know if your bed is flat or not. If you are certain it is flat but tilted (e.g. when you have a milled bed or a glass plate in 3D printing) you could go for `AUTO_BED_LEVELING_3POINT` or `AUTO_BED_LEVELING_LINEAR`.

What further is important is the sensor type you choose. Do you want a touch or a proximity sensor. The latter is your preference (as specified in your question), which is a little simpler as you do not need to configure for servos for deploying and stowing.

You need to set:

```
#define FIX_MOUNTED_PROBE

```

for using a fixed proximity sensor.

In the configuration file you also need to specify the position of the probe in relation to the nozzle (in your case tool center):

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

```

and optionally:

```
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0   // Z offset: -below +above  [the nozzle]

```

This latter is not necessary as you can always set the distance of the sensor trigger point to the nozzle/tool plane by G-code command `M851 Z-x.xx`

You would also need to set the boundaries of the probe area to prevent the tool to hit unwanted positions (fill out values or leave the constants):

```
// 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)

```

Once properly setup, command [`G29`](http://marlinfw.org/docs/gcode/G029-abl.html) runs the leveling of the bed, options are available for that command to store the bed mesh to EEPROM.

Enabling `LCD_BED_LEVELING` constant in the configuration file will add a Bed Leveling sub-menu to the LCD. But you could also work with SD-card stored files that load these codes.

[This](https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling) reference explains the automatic leveling in more detail, but there are many more detailed guides to follow from the internet. Be sure that you get a recent guide to that is easier to set in the latest firmware.

> **Comments:**
> **username_0**: Thanks!. Can I uncomment MESH_BED_LEVELING and AUTO_BED_LEVELING_BILINEAR at the same time?. I want to test the result of this manually before going to the automatic solution. With both methods activated, both options will appear on the menu?. (auto and manual).  
> **username_1**: No I do not think it is possible, if you look into the config file you see that if you enable both, `AUTO_BED_LEVELING_BILINEAR` is executed is some `#if` statement and it will then never go to the `#elif` of `MESH_BED_LEVELING `.  

---

