# Auto leveling with Marlin and RAMPS 1.4 does not work

I configured Marlin 1.1.3 for auto-leveling with a fix mounted sensor connected to the Z end-stop pin.

I have the following settings in my config:

#define X_PROBE_OFFSET_FROM_EXTRUDER 25
#define Y_PROBE_OFFSET_FROM_EXTRUDER 20
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0   // Z offset: -below +above  [the nozzle]

#define Z_CLEARANCE_DEPLOY_PROBE   10 // Z Clearance for Deploy/Stow
#define Z_CLEARANCE_BETWEEN_PROBES  5 // Z Clearance between probe points

#define AUTO_BED_LEVELING_BILINEAR

#define GRID_MAX_POINTS_X 7
#define GRID_MAX_POINTS_Y GRID_MAX_POINTS_X

// The Z probe minimum outer margin (to validate G29 parameters).
#define MIN_PROBE_EDGE 10

// Set the boundaries for probing (where the probe can reach).
#define LEFT_PROBE_BED_POSITION 25
#define RIGHT_PROBE_BED_POSITION 150
#define FRONT_PROBE_BED_POSITION 30
#define BACK_PROBE_BED_POSITION 180


I enter M111 S38 to enable LEVELING+INFO+ERROR debugging. Then I enter G28 to home all axes and then enter G29 to start auto-leveling.

The auto-leveling starts successfully and after finishing I see the scan grid in console:

12:41:35.983 : Bilinear Leveling Grid:
12:41:35.983 : 0      1      2      3      4      5      6
12:41:35.983 : 0 -3.127 -3.405 -3.405 -3.292 -3.595 -3.487 -3.537
12:41:35.983 : 1 -3.110 -3.367 -3.337 -3.220 -3.470 -3.350 -3.365
12:41:35.983 : 2 -3.138 -3.367 -3.330 -3.215 -3.442 -3.345 -3.385
12:41:35.984 : 3 -3.013 -3.225 -3.182 -3.047 -3.225 -3.132 -3.150
12:41:35.984 : 4 -2.970 -3.165 -3.097 -2.972 -3.160 -3.045 -3.065
12:41:35.984 : 5 -2.875 -3.075 -3.005 -2.847 -2.990 -2.872 -2.875
12:41:35.984 : 6 -2.680 -2.845 -2.755 -2.615 -2.753 -2.617 -2.622
12:41:35.985 : G29 uncorrected Z:10.00
12:41:35.985 : corrected Z:12.85
12:41:35.985 : <<< gcode_G29
12:41:35.985 : X:120.00 Y:160.00 Z:12.85 E:0.00 Count X:9600 Y:12800 Z:4000
12:41:35.985 : current_position=(120.00, 160.00, 12.85) : sync_plan_position


So the auto-leveling scanning seems to be successful.

Here is a visual of the leveling grid (but upside down to make it easier to view):

Naturally I DO NOT enter G28 after the scanning.

I enter G0 Z1 to down nozzle almost to table. But when I enter for example G0 X25 Y30 and look at level and then I enter G0 X150 Y150 I see the big difference between nozzle levels relatively to table. So it seems that height compensation does not work. I expect that Z axis would lift up or down depending on auto-leveling results but Z motor do not work when I move X/Y.

By the way I tried 3 point autoleveling. It was pretty rough but Z axis corrected it's level when I moved axes using G0 commands. And to avoid questions "why my table is inclined so much?" I deliberately inclined the table to be sure that auto leveling works. By the way, I tried different Z_PROBE_OFFSET_FROM_EXTRUDER so the current 0 setting is not actual but situation is the same with any value of this option.

What I am doing wrong?

• I plotted your leveling grid and the axis that is opposite your incline is going up and down quite a bit. Could your table be wobbling/rocking and this is throwing off the auto-level? Jun 20, 2017 at 1:24
• hmm, i didn' thought abot it, will check Jun 20, 2017 at 4:30
• btw what software did you use to visualize the mesh? Jun 20, 2017 at 19:17
• I created the visualization using Excel. Jun 21, 2017 at 2:01

Bed leveling is disabled by default. So the mesh was scanned but is not apllied after G29 command. To apply the mesh we need to enable bed leveling using

M420 S1


command

In additional to Sergey's answer M420 S1 should be put into custom start GCODE. By default marlin disables autobed after G28 unless specifically configured otherwise

/**
* Normally G28 leaves leveling disabled on completion. Enable
* this option to have G28 restore the prior leveling state.
*/
#define RESTORE_LEVELING_AFTER_G28