Browse Source

Merge pull request #1774 from epatel/Development

Mesh bed leveling: Added G29 S3 + finer display steps during manual input + bug fix
Scott Lahteine 9 years ago
parent
commit
e03da4805b

+ 9
- 3
Documentation/MeshBedLeveling.md View File

@@ -7,7 +7,7 @@ Background
7 7
 
8 8
 This mesh based method of leveling/compensating can compensate for an non-flat bed. There are various opinions about doing this. It was primarily written to compensate a RigidBot BIG bed (40x30cm) that was somewhat bent.
9 9
 
10
-Currently there is no automatic way to probe the bed like the Auto Bed Leveling feature. This might soon be implemented though, stay tuned.
10
+Currently there is no automatic way to probe the bed like the Auto Bed Leveling feature. So, you can not enable `ENABLE_AUTO_BED_LEVELING` at the same time. This might soon be implemented though, stay tuned.
11 11
 
12 12
 Theory
13 13
 ------
@@ -28,6 +28,10 @@ In `Configuration.h` there are two options that can be enabled.
28 28
 
29 29
 There are also some values that can be set.
30 30
 
31
+The following will set the step distance used when manually turning the display encoder. Default is 0.025
32
+
33
+`MBL_Z_STEP` 
34
+
31 35
 Following four define the area to cover. Default 10mm from max bed size
32 36
 
33 37
 `MESH_MIN_X`<br/>
@@ -55,14 +59,14 @@ When selecting this option the printer will first do a homing, and then travel t
55 59
 
56 60
 If the EEPROM has been enable it can be good to issue a `M500` to get these points saved.
57 61
 
58
-Issuing a `G29` will return the state of the mesh leveling.
62
+Issuing a `G29` will return the state of the mesh leveling and report the probed points.
59 63
 
60 64
 Probing the bed with G-codes
61 65
 ----------------------------
62 66
 
63 67
 Probing the bed by G-codes follows the sequence much like doing it with the display.
64 68
 
65
-`G29` or `G29 S0` will return the state bed leveling.
69
+`G29` or `G29 S0` will return the state of the bed leveling and report the probed points. Where X=1 Y=1 is the top-left value and X=MESH_NUM_X_POINTS Y=MESH_NUM_Y_POINTS is bottom-right value. X per column and Y per row.
66 70
 
67 71
 `G29 S1` will initiate the bed leveling, homing and traveling to the first point to probe.
68 72
 
@@ -70,6 +74,8 @@ Then use your preferred Printer controller program, i.e. Printrun, to lower the
70 74
 
71 75
 `G29 S2` will store the point and travel to the next point until last point has been probed.
72 76
 
77
+`G29 S3 Xn Yn Zn.nn` will modify a single probed point. This can be used to tweak a badly probed point. Specify probe point where `Xn` and `Yn`, where `n` in `Xn` is between 1 and `MESH_NUM_X_POINTS`. Likewise for `Yn`. `Zn.nn` is the new Z value in that probed point. 
78
+
73 79
 Note
74 80
 ----
75 81
 

+ 4
- 0
Marlin/Configuration.h View File

@@ -426,6 +426,10 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
426 426
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
427 427
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
428 428
 
429
+#ifdef MANUAL_BED_LEVELING
430
+  #define MBL_Z_STEP 0.025  // Step size while manually probing Z axis
431
+#endif  // MANUAL_BED_LEVELING
432
+
429 433
 #ifdef MESH_BED_LEVELING
430 434
   #define MESH_MIN_X 10
431 435
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 47
- 7
Marlin/Marlin_main.cpp View File

@@ -2013,7 +2013,7 @@ inline void gcode_G28() {
2013 2013
 
2014 2014
 #ifdef MESH_BED_LEVELING
2015 2015
 
2016
-  enum MeshLevelingState { MeshReport, MeshStart, MeshNext };
2016
+  enum MeshLevelingState { MeshReport, MeshStart, MeshNext, MeshSet };
2017 2017
 
2018 2018
   /**
2019 2019
    * G29: Mesh-based Z-Probe, probes a grid and produces a
@@ -2021,20 +2021,31 @@ inline void gcode_G28() {
2021 2021
    *
2022 2022
    * Parameters With MESH_BED_LEVELING:
2023 2023
    *
2024
-   *  S0 Produce a mesh report
2025
-   *  S1 Start probing mesh points
2026
-   *  S2 Probe the next mesh point
2024
+   *  S0              Produce a mesh report
2025
+   *  S1              Start probing mesh points
2026
+   *  S2              Probe the next mesh point
2027
+   *  S3 Xn Yn Zn.nn  Manually modify a single point
2027 2028
    *
2029
+   * The S0 report the points as below
2030
+   *
2031
+   *  +----> X-axis
2032
+   *  |
2033
+   *  |
2034
+   *  v Y-axis
2035
+   *  
2028 2036
    */
2029 2037
   inline void gcode_G29() {
2030 2038
 
2031 2039
     static int probe_point = -1;
2032 2040
     MeshLevelingState state = code_seen('S') || code_seen('s') ? (MeshLevelingState)code_value_short() : MeshReport;
2033
-    if (state < 0 || state > 2) {
2034
-      SERIAL_PROTOCOLLNPGM("S out of range (0-2).");
2041
+    if (state < 0 || state > 3) {
2042
+      SERIAL_PROTOCOLLNPGM("S out of range (0-3).");
2035 2043
       return;
2036 2044
     }
2037 2045
 
2046
+    int ix, iy;
2047
+    float z;
2048
+
2038 2049
     switch(state) {
2039 2050
       case MeshReport:
2040 2051
         if (mbl.active) {
@@ -2068,7 +2079,6 @@ inline void gcode_G28() {
2068 2079
           SERIAL_PROTOCOLLNPGM("Start mesh probing with \"G29 S1\" first.");
2069 2080
           return;
2070 2081
         }
2071
-        int ix, iy;
2072 2082
         if (probe_point == 0) {
2073 2083
           // Set Z to a positive value before recording the first Z.
2074 2084
           current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
@@ -2102,6 +2112,36 @@ inline void gcode_G28() {
2102 2112
           mbl.active = 1;
2103 2113
           enquecommands_P(PSTR("G28"));
2104 2114
         }
2115
+        break;
2116
+
2117
+      case MeshSet:
2118
+        if (code_seen('X') || code_seen('x')) {
2119
+          ix = code_value_long()-1;
2120
+          if (ix < 0 || ix >= MESH_NUM_X_POINTS) {
2121
+            SERIAL_PROTOCOLPGM("X out of range (1-" STRINGIFY(MESH_NUM_X_POINTS) ").\n");
2122
+            return;
2123
+          }
2124
+        } else {
2125
+            SERIAL_PROTOCOLPGM("X not entered.\n");
2126
+            return;
2127
+        }
2128
+        if (code_seen('Y') || code_seen('y')) {
2129
+          iy = code_value_long()-1;
2130
+          if (iy < 0 || iy >= MESH_NUM_Y_POINTS) {
2131
+            SERIAL_PROTOCOLPGM("Y out of range (1-" STRINGIFY(MESH_NUM_Y_POINTS) ").\n");
2132
+            return;
2133
+          }
2134
+        } else {
2135
+            SERIAL_PROTOCOLPGM("Y not entered.\n");
2136
+            return;
2137
+        }
2138
+        if (code_seen('Z') || code_seen('z')) {
2139
+          z = code_value();
2140
+        } else {
2141
+          SERIAL_PROTOCOLPGM("Z not entered.\n");
2142
+          return;
2143
+        }
2144
+        mbl.z_values[iy][ix] = z;
2105 2145
 
2106 2146
     } // switch(state)
2107 2147
   }

+ 12
- 0
Marlin/SanityCheck.h View File

@@ -92,6 +92,18 @@
92 92
   #endif
93 93
 
94 94
   /**
95
+   * Mesh Bed Leveling
96
+   */
97
+  #ifdef MESH_BED_LEVELING
98
+    #ifdef DELTA
99
+      #error MESH_BED_LEVELING does not yet support DELTA printers
100
+    #endif
101
+    #ifdef ENABLE_AUTO_BED_LEVELING
102
+      #error Select ENABLE_AUTO_BED_LEVELING or MESH_BED_LEVELING, not both
103
+    #endif
104
+  #endif
105
+
106
+  /**
95 107
    * Auto Bed Leveling
96 108
    */
97 109
   #ifdef ENABLE_AUTO_BED_LEVELING

+ 4
- 0
Marlin/configurator/config/Configuration.h View File

@@ -426,6 +426,10 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
426 426
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
427 427
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
428 428
 
429
+#ifdef MANUAL_BED_LEVELING
430
+  #define MBL_Z_STEP 0.025
431
+#endif  // MANUAL_BED_LEVELING
432
+
429 433
 #ifdef MESH_BED_LEVELING
430 434
   #define MESH_MIN_X 10
431 435
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/Felix/Configuration.h View File

@@ -364,6 +364,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
364 364
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
365 365
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
366 366
 
367
+#ifdef MANUAL_BED_LEVELING
368
+  #define MBL_Z_STEP 0.025
369
+#endif  // MANUAL_BED_LEVELING
370
+
367 371
 #ifdef MESH_BED_LEVELING
368 372
   #define MESH_MIN_X 10
369 373
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -387,6 +387,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
387 387
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
388 388
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
389 389
 
390
+#ifdef MANUAL_BED_LEVELING
391
+  #define MBL_Z_STEP 0.025
392
+#endif  // MANUAL_BED_LEVELING
393
+
390 394
 #ifdef MESH_BED_LEVELING
391 395
   #define MESH_MIN_X 10
392 396
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/K8200/Configuration.h View File

@@ -392,6 +392,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
392 392
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
393 393
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
394 394
 
395
+#ifdef MANUAL_BED_LEVELING
396
+  #define MBL_Z_STEP 0.025
397
+#endif  // MANUAL_BED_LEVELING
398
+
395 399
 #ifdef MESH_BED_LEVELING
396 400
   #define MESH_MIN_X 10
397 401
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -416,6 +416,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
416 416
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
417 417
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
418 418
 
419
+#ifdef MANUAL_BED_LEVELING
420
+  #define MBL_Z_STEP 0.025
421
+#endif  // MANUAL_BED_LEVELING
422
+
419 423
 #ifdef MESH_BED_LEVELING
420 424
   #define MESH_MIN_X 10
421 425
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -386,6 +386,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
386 386
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
387 387
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
388 388
 
389
+#ifdef MANUAL_BED_LEVELING
390
+  #define MBL_Z_STEP 0.025
391
+#endif  // MANUAL_BED_LEVELING
392
+
389 393
 #ifdef MESH_BED_LEVELING
390 394
   #define MESH_MIN_X 10
391 395
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -414,6 +414,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
414 414
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
415 415
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
416 416
 
417
+#ifdef MANUAL_BED_LEVELING
418
+  #define MBL_Z_STEP 0.025
419
+#endif  // MANUAL_BED_LEVELING
420
+
417 421
 #ifdef MESH_BED_LEVELING
418 422
   #define MESH_MIN_X 10
419 423
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -414,6 +414,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
414 414
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
415 415
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
416 416
 
417
+#ifdef MANUAL_BED_LEVELING
418
+  #define MBL_Z_STEP 0.025
419
+#endif  // MANUAL_BED_LEVELING
420
+
417 421
 #ifdef MESH_BED_LEVELING
418 422
   #define MESH_MIN_X 10
419 423
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/makibox/Configuration.h View File

@@ -384,6 +384,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
384 384
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
385 385
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
386 386
 
387
+#ifdef MANUAL_BED_LEVELING
388
+  #define MBL_Z_STEP 0.025
389
+#endif  // MANUAL_BED_LEVELING
390
+
387 391
 #ifdef MESH_BED_LEVELING
388 392
   #define MESH_MIN_X 10
389 393
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 4
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -386,6 +386,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
386 386
 // #define MANUAL_BED_LEVELING  // Add display menu option for bed leveling
387 387
 // #define MESH_BED_LEVELING    // Enable mesh bed leveling
388 388
 
389
+#ifdef MANUAL_BED_LEVELING
390
+  #define MBL_Z_STEP 0.025
391
+#endif  // MANUAL_BED_LEVELING
392
+
389 393
 #ifdef MESH_BED_LEVELING
390 394
   #define MESH_MIN_X 10
391 395
   #define MESH_MAX_X (X_MAX_POS - MESH_MIN_X)

+ 5
- 2
Marlin/ultralcd.cpp View File

@@ -1800,20 +1800,23 @@ static void _lcd_level_bed()
1800 1800
 {
1801 1801
   if (encoderPosition != 0) {
1802 1802
     refresh_cmd_timeout();
1803
-    current_position[Z_AXIS] += float((int)encoderPosition) * 0.05;
1803
+    current_position[Z_AXIS] += float((int)encoderPosition) * MBL_Z_STEP;
1804 1804
     if (min_software_endstops && current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS;
1805 1805
     if (max_software_endstops && current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS;
1806 1806
     encoderPosition = 0;
1807 1807
     plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], manual_feedrate[Z_AXIS]/60, active_extruder);
1808 1808
     lcdDrawUpdate = 1;
1809 1809
   }
1810
-  if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr32(current_position[Z_AXIS]));
1810
+  if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR("Z"), ftostr43(current_position[Z_AXIS]));
1811 1811
   static bool debounce_click = false;
1812 1812
   if (LCD_CLICKED) {
1813 1813
     if (!debounce_click) {
1814 1814
       debounce_click = true;
1815 1815
       int ix = _lcd_level_bed_position % MESH_NUM_X_POINTS;
1816 1816
       int iy = _lcd_level_bed_position / MESH_NUM_X_POINTS;
1817
+      if (iy&1) { // Zig zag
1818
+        ix = (MESH_NUM_X_POINTS - 1) - ix;
1819
+      }
1817 1820
       mbl.set_z(ix, iy, current_position[Z_AXIS]);
1818 1821
       _lcd_level_bed_position++;
1819 1822
       if (_lcd_level_bed_position == MESH_NUM_X_POINTS*MESH_NUM_Y_POINTS) {

Loading…
Cancel
Save