<p>If you have managed to setup 3-point levelling, you should be able to enable bi-linear levelling in the firmware.</p>

<p>From the <a href="https://github.com/MarlinFirmware/Configurations/blob/master/config/default/Configuration.h" rel="nofollow noreferrer">configuration.h</a> file for Marlin firmware you can find the following options:</p>

<pre>
/**
 * Choose one of the options below to enable G29 Bed Leveling. The parameters
 * and behavior of G29 will change depending on your selection.
 *
 *  If using a Probe for Z Homing, enable Z_SAFE_HOMING also!
 *
 * - AUTO_BED_LEVELING_3POINT
 *   Probe 3 arbitrary points on the bed (that aren't collinear)
 *   You specify the XY coordinates of all 3 points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_LINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_BILINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a mesh, best for large or uneven beds.
 *
 * - AUTO_BED_LEVELING_UBL (Unified Bed Leveling)
 *   A comprehensive bed leveling system combining the features and benefits
 *   of other systems. UBL also includes integrated Mesh Generation, Mesh
 *   Validation and Mesh Editing systems.
 *
 * - MESH_BED_LEVELING
 *   Probe a grid manually
 *   The result is a mesh, suitable for large or uneven beds. (See BILINEAR.)
 *   For machines without a probe, Mesh Bed Leveling provides a method to perform
 *   leveling in steps so you can manually adjust the Z height at each grid-point.
 *   With an LCD controller the process is guided step-by-step.
 */
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
//#define AUTO_BED_LEVELING_BILINEAR
//#define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING
</pre>

<p>If you are using 3-point levelling you enabled constant <code>AUTO_BED_LEVELING_3POINT</code> by removing the comment characters (<code>//</code>):</p>

<pre><code>#define AUTO_BED_LEVELING_3POINT
</code></pre>

<p>to enable bi-linear levelling, you should remove the comment characters before constant <code>#define AUTO_BED_LEVELING_BILINEAR</code>:</p>

<pre><code>#define AUTO_BED_LEVELING_BILINEAR
</code></pre>

<p>Definition of the grid is done by specifying how many point you want to have using constants <code>GRID_MAX_POINTS_X</code> and <code>GRID_MAX_POINTS_Y</code>:</p>

<pre>
#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

  // Set the number of grid points per dimension.
  #define GRID_MAX_POINTS_X 3
  #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X
</pre>

<p>The code above shows the default definition of a 9 point (3 x 3) grid.</p>

<p>Note that this will only work well if the area for the sensor to reach safely is correctly defined. If the sensor is missing the build plate, you have not correctly defined the limits for the sensor. Question <a href="/q/8153">"How to set Z-probe boundary limits in firmware when using automatic bed leveling?"</a> has an <a href="/a/8154">accepted answer</a> that describes how to define an area on the plate that the sensor may reach (the answer on this question also discusses Marlin 2.x).</p>

<hr>

<h2>In the specific case of the OP (after posting the config files)</h2>

<hr>

<p>From the posted configuration files your probe position can be obtained:</p>

<pre><code>#define NOZZLE_TO_PROBE_OFFSET { 25, 55, 0 }
</code></pre>

<p>So your probe is at the right-back when facing the printer. Also your bed area attempt (commented) and the current active bed area can be obtained:</p>

<pre>
#if PROBE_SELECTED && !IS_KINEMATIC
  //#define MIN_PROBE_EDGE_LEFT 5
  //#define MIN_PROBE_EDGE_RIGHT 200
  //#define MIN_PROBE_EDGE_FRONT 55
  //#define MIN_PROBE_EDGE_BACK 200
  #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
#endif
</pre>

<p>From these excerpts it is clear that the bed limits are incorrectly defined. </p>

<p>Following the theory from <a href="/a/8154/">this answer</a> the probe is only allowed to visit the following (dark red) area:</p>

<p><a href="https://i.sstatic.net/gpeCz.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/gpeCz.png" alt="Probe area for back-right probe Marlin 2.0.x"></a></p>

<p>This area is defined as:</p>

<pre>
  #define MIN_PROBE_EDGE_LEFT (PROBE_OFFSET_X_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (PROBE_OFFSET_Y_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)
</pre>

<p>which translates to:</p>

<pre>
  #define MIN_PROBE_EDGE_LEFT (25 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (55 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)
</pre>

<p>As seen in the commented <code>//#define MIN_PROBE_EDGE_LEFT 5</code> and uncommented <code>#define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE</code> (equals 10) left probe limits, you are at least respectively 20&nbsp; or 15&nbsp;mm short, hence the sensor is not on the plate on the left.</p>

CC BY-SA 4.0
2020-02-10T10:07:24.327Z
I did try that, but the printer is still ignoring probe offset and probing boundaries. I've tried also [this bugfix](https://github.com/MarlinFirmware/Marlin/pull/16367) but still probing outside of the bed
vale.maio2
CC BY-SA 4.0
2020-02-10T14:50:49.673Z
@vale.maio2 I've updated the answer, from your config files it was clear that the incorrect value for the left boundary was used causing the sensor to be off-plate on the left.
0scar
CC BY-SA 4.0
2020-02-10T15:49:08.587Z
thank you very much for your correction, but now when selecting the auto levelling, it just probes the center of the bed and stops there, same when printing something. Unfortunately I have to switch back to 3 points.
vale.maio2
CC BY-SA 4.0
2020-02-10T17:03:25.257Z
@vale.maio2 That means that `Z_SAFE_HOMING` is active, strange that it stops... Look for more information on enabling bi-linear leveling [here](https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling). Did you also determine the correct Z-offset and set it with `M851`?
0scar
CC BY-SA 4.0
2020-02-10T19:45:04.410Z
yes it's active but it's not an issue with 3 point levelling. I'll have a read at that documentation, but I've also discovered that the bed is absolutely uneven. I need to make it even fist, then even 3 point levelling should suffice. Thank you again for your input.
vale.maio2
CC BY-SA 4.0
2020-02-12T10:24:14.667Z
@vale.maio2 Note that the 3-point X coordinates for the 2 left points are also incorrect, but because of the width of the sensor, you manage to get probings at X = 20, factually this should be `25 + MIN_PROBE_EDGE`! Note that the answer does answer where you need to adjust the grid points, too bad you run into another issue.
0scar
CC BY-SA 4.0
2020-02-10T08:13:11.290Z
2020-02-19T19:41:04.063Z
2020-02-19T19:41:04.063Z
0scar
<p>Currently on 2.1.1 it is just</p>
<pre><code>#define PROBING_MARGIN
</code></pre>
<p>On <a href="https://github.com/MarlinFirmware/Configurations/blob/import-2.1.x/config/default/Configuration.h#L1500" rel="nofollow noreferrer">line 1500</a> of <code>Configuration.h</code></p>
<p>For example,</p>
<pre><code>#define PROBING_MARGIN 10
</code></pre>

CC BY-SA 4.0
2022-11-15T20:25:42.590Z
Hi and welcome to SE.3DP. Thanks for the update. I have added code formatting for you and a link to the actual line in the code, just to bulk your answer out a bit - to make it more substantial. Please don't forget to take the [tour].
Greenonline
CC BY-SA 4.0
2022-11-15T18:26:42.743Z
2022-11-15T20:19:09.723Z
2022-11-15T20:19:09.723Z
Diz
<p>Note for anyone looking at the answer above, but in 2.1.x:
The <code>#define</code> lines have been renamed:</p>
<pre><code>#if PROBE_SELECTED &amp;&amp; !IS_KINEMATIC
  #define PROBING_MARGIN_LEFT PROBING_MARGIN
  #define PROBING_MARGIN_RIGHT PROBING_MARGIN
  #define PROBING_MARGIN_FRONT PROBING_MARGIN
  #define PROBING_MARGIN_BACK PROBING_MARGIN
#endif
</code></pre>

CC BY-SA 4.0
2022-10-08T02:20:04.227Z
2022-11-15T20:23:24.823Z
2022-11-15T20:23:24.823Z
Gavin S.
<p>I'm using firmware Marlin 2.0.3 on an Anet A8 printer. I'm using a Roko SN04-N NPN bed leveller. I've managed to set up 3 points bed levelling but I wanted to try the bilinear levelling.</p>

<p>Issue is, the sensor goes out of the aluminum bed ever so slightly during levelling, resulting in the printing head crashing on the bed.</p>

<p>Where can I set the grid for the bilinear levelling in the config file? I didn't find the option in the file and Google wasn't of any help this time.</p>

CC BY-SA 4.0
2020-02-10T10:38:23.990Z
Did you define "[Z-probe boundary limits](/q//8153/)"? Please post your changes to the configuration.h and configuratio_adv.h as in the latter file the boundaries are set in Marlin 2.x; e.g. #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE. Without posting the values, it would be guessing what is wrong. If you used the Anet A8 configuration files from [Anet A8 config.](https://github.com/MarlinFirmware/Configurations/tree/master/config/examples/Anet/A8) you will find that these are incomplete with respect to bed limits, these files require updating!
0scar
CC BY-SA 4.0
2020-02-10T11:11:23.340Z
@0scar yes I did and it's ignoring it! [This is my configuration.g](https://pastebin.com/i4jtrk2W) and this [is my configuration_adv.h](https://pastebin.com/Vf42M9Ed). I think I got the config for the Anet from the Marlin examples, but I'm not 100%sure. Where should I find a complete setting?
vale.maio2
CC BY-SA 4.0
2020-02-10T14:46:07.333Z
No it is not ignoring it, your bed limits are incorrect, I've updated the answer to your specific problem. Basically your left limit is incorrect (too far left), hence the sensor is not on the plate. Hope you can fix it now, happy printing! :-)
0scar
<marlin><bed-leveling>
Where to define grid for bilinear levelling in Marlin
vale.maio2
# Where to define grid for bilinear levelling in Marlin

(Asked by: username_0 on 2020-02-09)

I'm using firmware Marlin 2.0.3 on an Anet A8 printer. I'm using a Roko SN04-N NPN bed leveller. I've managed to set up 3 points bed levelling but I wanted to try the bilinear levelling.

Issue is, the sensor goes out of the aluminum bed ever so slightly during levelling, resulting in the printing head crashing on the bed.

Where can I set the grid for the bilinear levelling in the config file? I didn't find the option in the file and Google wasn't of any help this time.

**Tags:** marlin, bed-leveling
> **Comments:**
> **username_1**: Did you define "[Z-probe boundary limits](/q//8153/)"? Please post your changes to the configuration.h and configuratio_adv.h as in the latter file the boundaries are set in Marlin 2.x; e.g. #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE. Without posting the values, it would be guessing what is wrong. If you used the Anet A8 configuration files from [Anet A8 config.](https://github.com/MarlinFirmware/Configurations/tree/master/config/examples/Anet/A8) you will find that these are incomplete with respect to bed limits, these files require updating!  
> **username_0**: @0scar yes I did and it's ignoring it! [This is my configuration.g](https://pastebin.com/i4jtrk2W) and this [is my configuration_adv.h](https://pastebin.com/Vf42M9Ed). I think I got the config for the Anet from the Marlin examples, but I'm not 100%sure. Where should I find a complete setting?  
> **username_1**: No it is not ignoring it, your bed limits are incorrect, I've updated the answer to your specific problem. Basically your left limit is incorrect (too far left), hence the sensor is not on the plate. Hope you can fix it now, happy printing! :-)  

---

## 3 answers

### Answer by username_1 on 2020-02-10. Score: 4

If you have managed to setup 3-point levelling, you should be able to enable bi-linear levelling in the firmware.
From the configuration.h file for Marlin firmware you can find the following options:

/**
 * Choose one of the options below to enable G29 Bed Leveling. The parameters
 * and behavior of G29 will change depending on your selection.
 *
 *  If using a Probe for Z Homing, enable Z_SAFE_HOMING also!
 *
 * - AUTO_BED_LEVELING_3POINT
 *   Probe 3 arbitrary points on the bed (that aren't collinear)
 *   You specify the XY coordinates of all 3 points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_LINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a single tilted plane. Best for a flat bed.
 *
 * - AUTO_BED_LEVELING_BILINEAR
 *   Probe several points in a grid.
 *   You specify the rectangle and the density of sample points.
 *   The result is a mesh, best for large or uneven beds.
 *
 * - AUTO_BED_LEVELING_UBL (Unified Bed Leveling)
 *   A comprehensive bed leveling system combining the features and benefits
 *   of other systems. UBL also includes integrated Mesh Generation, Mesh
 *   Validation and Mesh Editing systems.
 *
 * - MESH_BED_LEVELING
 *   Probe a grid manually
 *   The result is a mesh, suitable for large or uneven beds. (See BILINEAR.)
 *   For machines without a probe, Mesh Bed Leveling provides a method to perform
 *   leveling in steps so you can manually adjust the Z height at each grid-point.
 *   With an LCD controller the process is guided step-by-step.
 */
//#define AUTO_BED_LEVELING_3POINT
//#define AUTO_BED_LEVELING_LINEAR
//#define AUTO_BED_LEVELING_BILINEAR
//#define AUTO_BED_LEVELING_UBL
//#define MESH_BED_LEVELING

If you are using 3-point levelling you enabled constant AUTO_BED_LEVELING_3POINT by removing the comment characters (//):
#define AUTO_BED_LEVELING_3POINT

to enable bi-linear levelling, you should remove the comment characters before constant #define AUTO_BED_LEVELING_BILINEAR:
#define AUTO_BED_LEVELING_BILINEAR

Definition of the grid is done by specifying how many point you want to have using constants GRID_MAX_POINTS_X and GRID_MAX_POINTS_Y:

#if EITHER(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_BILINEAR)

  // Set the number of grid points per dimension.
  #define GRID_MAX_POINTS_X 3
  #define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X

The code above shows the default definition of a 9 point (3 x 3) grid.
Note that this will only work well if the area for the sensor to reach safely is correctly defined. If the sensor is missing the build plate, you have not correctly defined the limits for the sensor. Question "How to set Z-probe boundary limits in firmware when using automatic bed leveling?" has an accepted answer that describes how to define an area on the plate that the sensor may reach (the answer on this question also discusses Marlin 2.x).

In the specific case of the OP (after posting the config files)

From the posted configuration files your probe position can be obtained:
#define NOZZLE_TO_PROBE_OFFSET { 25, 55, 0 }

So your probe is at the right-back when facing the printer. Also your bed area attempt (commented) and the current active bed area can be obtained:

#if PROBE_SELECTED && !IS_KINEMATIC
  //#define MIN_PROBE_EDGE_LEFT 5
  //#define MIN_PROBE_EDGE_RIGHT 200
  //#define MIN_PROBE_EDGE_FRONT 55
  //#define MIN_PROBE_EDGE_BACK 200
  #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_RIGHT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_FRONT MIN_PROBE_EDGE
  #define MIN_PROBE_EDGE_BACK MIN_PROBE_EDGE
#endif

From these excerpts it is clear that the bed limits are incorrectly defined. 
Following the theory from this answer the probe is only allowed to visit the following (dark red) area:

This area is defined as:

  #define MIN_PROBE_EDGE_LEFT (PROBE_OFFSET_X_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (PROBE_OFFSET_Y_FROM_EXTRUDER + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)

which translates to:

  #define MIN_PROBE_EDGE_LEFT (25 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_RIGHT (MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_FRONT (55 + MIN_PROBE_EDGE)
  #define MIN_PROBE_EDGE_BACK (MIN_PROBE_EDGE)

As seen in the commented //#define MIN_PROBE_EDGE_LEFT 5 and uncommented #define MIN_PROBE_EDGE_LEFT MIN_PROBE_EDGE (equals 10) left probe limits, you are at least respectively 20  or 15 mm short, hence the sensor is not on the plate on the left.

> **Comments:**
> **username_0**: I did try that, but the printer is still ignoring probe offset and probing boundaries. I've tried also [this bugfix](https://github.com/MarlinFirmware/Marlin/pull/16367) but still probing outside of the bed  
> **username_1**: @vale.maio2 I've updated the answer, from your config files it was clear that the incorrect value for the left boundary was used causing the sensor to be off-plate on the left.  
> **username_0**: thank you very much for your correction, but now when selecting the auto levelling, it just probes the center of the bed and stops there, same when printing something. Unfortunately I have to switch back to 3 points.  
> **username_1**: @vale.maio2 That means that `Z_SAFE_HOMING` is active, strange that it stops... Look for more information on enabling bi-linear leveling [here](https://3dprint.wiki/reprap/anet/a8/improvement/autobedleveling). Did you also determine the correct Z-offset and set it with `M851`?  
> **username_0**: yes it's active but it's not an issue with 3 point levelling. I'll have a read at that documentation, but I've also discovered that the bed is absolutely uneven. I need to make it even fist, then even 3 point levelling should suffice. Thank you again for your input.  
> **username_1**: @vale.maio2 Note that the 3-point X coordinates for the 2 left points are also incorrect, but because of the width of the sensor, you manage to get probings at X = 20, factually this should be `25 + MIN_PROBE_EDGE`! Note that the answer does answer where you need to adjust the grid points, too bad you run into another issue.  

---

### Answer by username_2 on 2022-11-15. Score: 1

Currently on 2.1.1 it is just
#define PROBING_MARGIN

On line 1500 of Configuration.h
For example,
#define PROBING_MARGIN 10

> **Comments:**
> **username_3**: Hi and welcome to SE.3DP. Thanks for the update. I have added code formatting for you and a link to the actual line in the code, just to bulk your answer out a bit - to make it more substantial. Please don't forget to take the [tour].  

---

### Answer by username_4 on 2022-10-08. Score: 0

Note for anyone looking at the answer above, but in 2.1.x:
The #define lines have been renamed:
#if PROBE_SELECTED && !IS_KINEMATIC
  #define PROBING_MARGIN_LEFT PROBING_MARGIN
  #define PROBING_MARGIN_RIGHT PROBING_MARGIN
  #define PROBING_MARGIN_FRONT PROBING_MARGIN
  #define PROBING_MARGIN_BACK PROBING_MARGIN
#endif


---

