Browse Source

Added option 'H' to G29 P4.

- Added `H` to set a nozzle height adjustment to surface of the bed.
- Updated G29 P4 comments to reflect changes.
dot-bob 7 years ago
parent
commit
a1632cfa0a
2 changed files with 122 additions and 127 deletions
  1. 1
    1
      Marlin/ubl.h
  2. 121
    126
      Marlin/ubl_G29.cpp

+ 1
- 1
Marlin/ubl.h View File

@@ -115,7 +115,7 @@
115 115
       #endif
116 116
 
117 117
       static float measure_point_with_encoder();
118
-      static float measure_business_card_thickness(float&);
118
+      static float measure_business_card_thickness(float);
119 119
       static bool g29_parameter_parsing();
120 120
       static void find_mean_mesh_height();
121 121
       static void shift_mesh_height();

+ 121
- 126
Marlin/ubl_G29.cpp View File

@@ -84,25 +84,23 @@
84 84
    *
85 85
    *   A     Activate   Activate the Unified Bed Leveling system.
86 86
    *
87
-   *   B #   Business   Use the 'Business Card' mode of the Manual Probe subsystem. This is invoked as
88
-   *                    G29 P2 B. The mode of G29 P2 allows you to use a business card or recipe card
89
-   *                    as a shim that the nozzle will pinch as it is lowered. The idea is that you
90
-   *                    can easily feel the nozzle getting to the same height by the amount of resistance
91
-   *                    the business card exhibits to movement. You should try to achieve the same amount
92
-   *                    of resistance on each probed point to facilitate accurate and repeatable measurements.
93
-   *                    You should be very careful not to drive the nozzle into the business card with a
94
-   *                    lot of force as it is very possible to cause damage to your printer if your are
95
-   *                    careless. If you use the B option with G29 P2 B you can omit the numeric value
96
-   *                    on first use to measure the business card's thickness. Subsequent usage of 'B'
97
-   *                    will apply the previously-measured thickness as the default.
98
-   *                    Note: A non-compressible Spark Gap feeler gauge is recommended over a Business Card.
87
+   *   B #   Business   Use the 'Business Card' mode of the Manual Probe subsystem with P2.
88
+   *                    Note: A non-compressible Spark Gap feeler gauge is recommended over a business card.
89
+   *                    In this mode of G29 P2, a business or index card is used as a shim that the nozzle can
90
+   *                    grab onto as it is lowered. In principle, the nozzle-bed distance is the same when the
91
+   *                    same resistance is felt in the shim. You can omit the numerical value on first invocation
92
+   *                    of G29 P2 B to measure shim thickness. Subsequent use of 'B' will apply the previously-
93
+   *                    measured thickness by default.
99 94
    *
100
-   *   C     Continue   Continue, Constant, Current Location. This is not a primary command. C is used to
101
-   *                    further refine the behaviour of several other commands. Issuing a G29 P1 C will
102
-   *                    continue the generation of a partially constructed Mesh without invalidating what has
103
-   *                    been done. Issuing a G29 P2 C will tell the Manual Probe subsystem to use the current
104
-   *                    location in its search for the closest unmeasured Mesh Point. When used with a G29 Z C
105
-   *                    it indicates to use the current location instead of defaulting to the center of the print bed.
95
+   *   C     Continue   G29 P1 C continues the generation of a partially-constructed Mesh without invalidating
96
+   *                    previous measurements.
97
+   *
98
+   *   C     Constant   G29 P2 C specifies a Constant and tells the Manual Probe subsystem to use the current
99
+   *                    location in its search for the closest unmeasured Mesh Point.
100
+   *
101
+   *                    G29 P3 C specifies the Constant for the fill. Otherwise, uses a "reasonable" value.
102
+   *
103
+   *   C     Current    G29 Z C uses the Current location (instead of bed center or nearest edge).
106 104
    *
107 105
    *   D     Disable    Disable the Unified Bed Leveling system.
108 106
    *
@@ -112,17 +110,18 @@
112 110
    *                    specified height, no correction is applied and natural printer kenimatics take over. If no
113 111
    *                    number is specified for the command, 10mm is assumed to be reasonable.
114 112
    *
115
-   *   H #   Height     Specify the Height to raise the nozzle after each manual probe of the bed. The
116
-   *                    default is 5mm.
113
+   *   H #   Height     With P2, 'H' specifies the Height to raise the nozzle after each manual probe of the bed.
114
+   *                    If omitted, the nozzle will raise by Z_CLEARANCE_BETWEEN_PROBES.
117 115
    *
118
-   *   I #   Invalidate Invalidate specified number of Mesh Points. The nozzle location is used unless
119
-   *                    the X and Y parameter are used. If no number is specified, only the closest Mesh
120
-   *                    point to the location is invalidated. The 'T' parameter is also available to produce
121
-   *                    a map after the operation. This command is useful to invalidate a portion of the
122
-   *                    Mesh so it can be adjusted using other tools in the Unified Bed Leveling System. When
123
-   *                    attempting to invalidate an isolated bad point in the mesh, the 'T' option will indicate
124
-   *                    where the nozzle is positioned in the Mesh with (#). You can move the nozzle around on
125
-   *                    the bed and use this feature to select the center of the area (or cell) you want to
116
+   *   H #   Offset     With P4, 'H' specifies the Offset above the mesh height to place the nozzle.
117
+   *                    If omitted, Z_CLEARANCE_BETWEEN_PROBES will be used.
118
+   *
119
+   *   I #   Invalidate Invalidate the specified number of Mesh Points near the given 'X' 'Y'. If X or Y are omitted,
120
+   *                    the nozzle location is used. If no 'I' value is given, only the point nearest to the location
121
+   *                    is invalidated. Use 'T' to produce a map afterward. This command is useful to invalidate a
122
+   *                    portion of the Mesh so it can be adjusted using other UBL tools. When attempting to invalidate
123
+   *                    an isolated bad mesh point, the 'T' option shows the nozzle position in the Mesh with (#). You
124
+   *                    can move the nozzle around and use this feature to select the center of the area (or cell) to
126 125
    *                    invalidate.
127 126
    *
128 127
    *   J #   Grid       Perform a Grid Based Leveling of the current Mesh using a grid with n points on a side.
@@ -151,95 +150,81 @@
151 150
    *                    area cannot be automatically probed. For Delta printers the area in which DELTA_PROBEABLE_RADIUS
152 151
    *                    and DELTA_PRINTABLE_RADIUS do not overlap will not be automatically probed.
153 152
    *
154
-   *                    These points will be handled in Phase 2 and Phase 3. If the Phase 1 command is given the
155
-   *                    C (Continue) parameter it does not invalidate the Mesh prior to automatically
156
-   *                    probing needed locations. This allows you to invalidate portions of the Mesh but still
157
-   *                    use the automatic probing capabilities of the Unified Bed Leveling System. An X and Y
158
-   *                    parameter can be given to prioritize where the command should be trying to measure points.
159
-   *                    If the X and Y parameters are not specified the current probe position is used.
160
-   *                    P1 accepts a 'T' (Topology) parameter so you can observe mesh generation.
161
-   *                    P1 also watches for the LCD Panel Encoder Switch to be held down (assuming you have one),
162
-   *                    and will suspend generation of the Mesh in that case. (Note: This check is only done
163
-   *                    between probe points, so you must press and hold the switch until the Phase 1 command
164
-   *                    detects it.)
153
+   *                    Unreachable points will be handled in Phase 2 and Phase 3.
154
+   *
155
+   *                    Use 'C' to leave the previous mesh intact and automatically probe needed points. This allows you
156
+   *                    to invalidate parts of the Mesh but still use Automatic Probing.
157
+   *
158
+   *                    The 'X' and 'Y' parameters prioritize where to try and measure points. If omitted, the current
159
+   *                    probe position is used.
160
+   *
161
+   *                    Use 'T' (Topology) to generate a report of mesh generation.
162
+   *
163
+   *                    P1 will suspend Mesh generation if the controller button is held down. Note that you may need
164
+   *                    to press and hold the switch for several seconds if moves are underway.
165
+   *
166
+   *   P2    Phase 2    Probe unreachable points.
165 167
    *
166
-   *   P2    Phase 2    Probe areas of the Mesh that can't be automatically handled. Phase 2 respects an H
167
-   *                    parameter to control the height between Mesh points. The default height for movement
168
-   *                    between Mesh points is 5mm. A smaller number can be used to make this part of the
169
-   *                    calibration less time consuming. You will be running the nozzle down until it just barely
170
-   *                    touches the glass. You should have the nozzle clean with no plastic obstructing your view.
171
-   *                    Use caution and move slowly. It is possible to damage your printer if you are careless.
172
-   *                    Note that this command will use the configuration #define SIZE_OF_LITTLE_RAISE if the
173
-   *                    nozzle is moving a distance of less than BIG_RAISE_NOT_NEEDED.
168
+   *                    Use 'H' to set the height between Mesh points. If omitted, Z_CLEARANCE_BETWEEN_PROBES is used.
169
+   *                    Smaller values will be quicker. Move the nozzle down till it barely touches the bed. Make sure the
170
+   *                    nozzle is clean and unobstructed. Use caution and move slowly. This can damage your printer!
171
+   *                    (Uses SIZE_OF_LITTLE_RAISE mm if the nozzle is moving less than BIG_RAISE_NOT_NEEDED mm.)
174 172
    *
175
-   *                    The H parameter can be set negative if your Mesh dips in a large area. You can press
176
-   *                    and hold the LCD Panel's encoder wheel to terminate the current Phase 2 command. You
177
-   *                    can then re-issue the G29 P 2 command with an H parameter that is more suitable for the
178
-   *                    area you are manually probing. Note that the command tries to start you in a corner
179
-   *                    of the bed where movement will be predictable. You can force the location to be used in
180
-   *                    the distance calculations by using the X and Y parameters. You may find it is helpful to
181
-   *                    print out a Mesh Map (G29 T) to understand where the mesh is invalidated and where
182
-   *                    the nozzle will need to move in order to complete the command. The C parameter is
183
-   *                    available on the Phase 2 command also and indicates the search for points to measure should
184
-   *                    be done based on the current location of the nozzle.
173
+   *                    The 'H' value can be negative if the Mesh dips in a large area. Press and hold the
174
+   *                    controller button to terminate the current Phase 2 command. You can then re-issue "G29 P 2"
175
+   *                    with an 'H' parameter more suitable for the area you're manually probing. Note that the command
176
+   *                    tries to start in a corner of the bed where movement will be predictable. Override the distance
177
+   *                    calculation location with the X and Y parameters. You can print a Mesh Map (G29 T) to see where
178
+   *                    the mesh is invalidated and where the nozzle needs to move to complete the command. Use 'C' to
179
+   *                    indicate that the search should be based on the current position.
185 180
    *
186
-   *                    A B parameter is also available for this command and described up above. It places the
187
-   *                    manual probe subsystem into Business Card mode where the thickness of a business card is
188
-   *                    measured and then used to accurately set the nozzle height in all manual probing for the
189
-   *                    duration of the command. (S for Shim mode would be a better parameter name, but S is needed
190
-   *                    for Save or Store of the Mesh to EEPROM)  A Business card can be used, but you will have
191
-   *                    better results if you use a flexible Shim that does not compress very much. That makes it
192
-   *                    easier for you to get the nozzle to press with similar amounts of force against the shim so you
193
-   *                    can get accurate measurements. As you are starting to touch the nozzle against the shim try
194
-   *                    to get it to grasp the shim with the same force as when you measured the thickness of the
195
-   *                    shim at the start of the command.
181
+   *                    The 'B' parameter for this command is described above. It places the manual probe subsystem into
182
+   *                    Business Card mode where the thickness of a business card is measured and then used to accurately
183
+   *                    set the nozzle height in all manual probing for the duration of the command. A Business card can
184
+   *                    be used, but you'll get better results with a flexible Shim that doesn't compress. This makes it
185
+   *                    easier to produce similar amounts of force and get more accurate measurements. Google if you're
186
+   *                    not sure how to use a shim.
196 187
    *
197
-   *                    Phase 2 allows the T (Map) parameter to be specified. This helps the user see the progression
198
-   *                    of the Mesh being built.
188
+   *                    The 'T' (Map) parameter helps track Mesh building progress.
199 189
    *
200
-   *                    NOTE:  P2 is not available unless you have LCD support enabled!
190
+   *                    NOTE: P2 requires an LCD controller!
201 191
    *
202
-   *   P3    Phase 3    Fill the unpopulated regions of the Mesh with a fixed value. There are two different paths the
203
-   *                    user can go down. If the user specifies the value using the C parameter, the closest invalid
204
-   *                    mesh points to the nozzle will be filled. The user can specify a repeat count using the R
205
-   *                    parameter with the C version of the command.
192
+   *   P3    Phase 3    Fill the unpopulated regions of the Mesh with a fixed value. There are two different paths to
193
+   *                    go down:
206 194
    *
207
-   *                    A second version of the fill command is available if no C constant is specified. Not
208
-   *                    specifying a C constant will invoke the 'Smart Fill' algorithm. The G29 P3 command will search
209
-   *                    from the edges of the mesh inward looking for invalid mesh points. It will look at the next
210
-   *                    several mesh points to determine if the print bed is sloped up or down. If the bed is sloped
211
-   *                    upward from the invalid mesh point, it will be replaced with the value of the nearest mesh point.
212
-   *                    If the bed is sloped downward from the invalid mesh point, it will be replaced with a value that
213
-   *                    puts all three points in a line. The second version of the G29 P3 command is a quick, easy and
214
-   *                    usually safe way to populate the unprobed regions of your mesh so you can continue to the G26
215
-   *                    Mesh Validation Pattern phase. Please note that you are populating your mesh with unverified
216
-   *                    numbers. You should use some scrutiny and caution.
195
+   *                    - If a 'C' constant is specified, the closest invalid mesh points to the nozzle will be filled,
196
+   *                      and a repeat count can then also be specified with 'R'.
217 197
    *
218
-   *   P4    Phase 4    Fine tune the Mesh. The Delta Mesh Compensation System assume the existence of
219
-   *                    an LCD Panel. It is possible to fine tune the mesh without the use of an LCD Panel using
220
-   *                    G42 and M421; see the UBL documentation for further details.
198
+   *                    - Leaving out 'C' invokes Smart Fill, which scans the mesh from the edges inward looking for
199
+   *                      invalid mesh points. Adjacent points are used to determine the bed slope. If the bed is sloped
200
+   *                      upward from the invalid point, it takes the value of the nearest point. If sloped downward, it's
201
+   *                      replaced by a value that puts all three points in a line. This version of G29 P3 is a quick, easy
202
+   *                      and (usually) safe way to populate unprobed mesh regions before continuing to G26 Mesh Validation
203
+   *                      Pattern. Note that this populates the mesh with unverified values. Pay attention and use caution.
221 204
    *
222
-   *                    The System will search for the closest Mesh Point to the nozzle. It will move the
223
-   *                    nozzle to this location. The user can use the LCD Panel to carefully adjust the nozzle
224
-   *                    so it is just barely touching the bed. When the user clicks the control, the System
225
-   *                    will lock in that height for that point in the Mesh Compensation System.
205
+   *   P4    Phase 4    Fine tune the Mesh. The Delta Mesh Compensation System assumes the existence of
206
+   *                    an LCD Panel. It is possible to fine tune the mesh without an LCD Panel using
207
+   *                    G42 and M421. See the UBL documentation for further details.
226 208
    *
227
-   *                    Phase 4 has several additional parameters that the user may find helpful. Phase 4
228
-   *                    can be started at a specific location by specifying an X and Y parameter. Phase 4
229
-   *                    can be requested to continue the adjustment of Mesh Points by using the R(epeat)
230
-   *                    parameter. If the Repetition count is not specified, it is assumed the user wishes
231
-   *                    to adjust the entire matrix. The nozzle is moved to the Mesh Point being edited.
232
-   *                    The command can be terminated early (or after the area of interest has been edited) by
233
-   *                    pressing and holding the encoder wheel until the system recognizes the exit request.
234
-   *                    Phase 4's general form is G29 P4 [R # of points] [X position] [Y position]
209
+   *                    Phase 4 is meant to be used with G26 Mesh Validation to fine tune the mesh by direct editing
210
+   *                    of Mesh Points. Raise and lower points to fine tune the mesh until it gives consistently reliable
211
+   *                    adhesion.
235 212
    *
236
-   *                    Phase 4 is intended to be used with the G26 Mesh Validation Command. Using the
237
-   *                    information left on the printer's bed from the G26 command it is very straight forward
238
-   *                    and easy to fine tune the Mesh. One concept that is important to remember and that
239
-   *                    will make using the Phase 4 command easy to use is this:  You are editing the Mesh Points.
240
-   *                    If you have too little clearance and not much plastic was extruded in an area, you want to
241
-   *                    LOWER the Mesh Point at the location. If you did not get good adheasion, you want to
242
-   *                    RAISE the Mesh Point at that location.
213
+   *                    P4 moves to the closest Mesh Point (and/or the given X Y), raises the nozzle above the mesh height
214
+   *                    by the given 'H' offset (or default Z_CLEARANCE_BETWEEN_PROBES), and waits while the controller is
215
+   *                    used to adjust the nozzle height. On click the displayed height is saved in the mesh.
216
+   *
217
+   *                    Start Phase 4 at a specific location with X and Y. Adjust a specific number of Mesh Points with
218
+   *                    the 'R' (Repeat) parameter. (If 'R' is left out, the whole matrix is assumed.) This command can be
219
+   *                    terminated early (e.g., after editing the area of interest) by pressing and holding the encoder button.
220
+   *
221
+   *                    The general form is G29 P4 [R points] [X position] [Y position]
222
+   *
223
+   *                    The H [offset] parameter is useful if a shim is used to fine-tune the mesh. For a 0.4mm shim the
224
+   *                    command would be G29 P4 H0.4. The nozzle is moved to the shim height, you adjust height to the shim,
225
+   *                    and on click the height minus the shim thickness will be saved in the mesh.
226
+   *
227
+   *                    !!Use with caution, as a very poor mesh could cause the nozzle to crash into the bed!!
243 228
    *
244 229
    *                    NOTE:  P4 is not available unless you have LCD support enabled!
245 230
    *
@@ -494,28 +479,29 @@
494 479
               g29_y_pos = current_position[Y_AXIS];
495 480
             }
496 481
 
497
-            float height = Z_CLEARANCE_BETWEEN_PROBES;
498
-
499 482
             if (parser.seen('B')) {
500
-              g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness(height);
483
+              g29_card_thickness = parser.has_value() ? parser.value_float() : measure_business_card_thickness(Z_CLEARANCE_BETWEEN_PROBES);
501 484
               if (FABS(g29_card_thickness) > 1.5) {
502 485
                 SERIAL_PROTOCOLLNPGM("?Error in Business Card measurement.");
503 486
                 return;
504 487
               }
505 488
             }
506 489
 
507
-            if (parser.seen('H') && parser.has_value()) height = parser.value_float();
508
-
509 490
             if (!position_is_reachable_xy(g29_x_pos, g29_y_pos)) {
510 491
               SERIAL_PROTOCOLLNPGM("XY outside printable radius.");
511 492
               return;
512 493
             }
513 494
 
495
+            const float height = parser.seen('H') && parser.has_value() ? parser.value_float() : Z_CLEARANCE_BETWEEN_PROBES;
514 496
             manually_probe_remaining_mesh(g29_x_pos, g29_y_pos, height, g29_card_thickness, parser.seen('T'));
497
+
515 498
             SERIAL_PROTOCOLLNPGM("G29 P2 finished.");
499
+
516 500
           #else
501
+
517 502
             SERIAL_PROTOCOLLNPGM("?P2 is only available when an LCD is present.");
518 503
             return;
504
+
519 505
           #endif
520 506
         } break;
521 507
 
@@ -537,19 +523,17 @@
537 523
                 if (location.x_index < 0) {
538 524
                   // No more REACHABLE INVALID mesh points to populate, so we ASSUME
539 525
                   // user meant to populate ALL INVALID mesh points to value
540
-                  for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++) {
541
-                    for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++) {
542
-                      if ( isnan(z_values[x][y])) {
526
+                  for (uint8_t x = 0; x < GRID_MAX_POINTS_X; x++)
527
+                    for (uint8_t y = 0; y < GRID_MAX_POINTS_Y; y++)
528
+                      if (isnan(z_values[x][y]))
543 529
                         z_values[x][y] = g29_constant;
544
-                      }
545
-                    }
546
-                  }
547 530
                   break; // No more invalid Mesh Points to populate
548 531
                 }
549 532
                 z_values[location.x_index][location.y_index] = g29_constant;
550 533
               }
551 534
             }
552
-          } else {
535
+          }
536
+          else {
553 537
             const float cvf = parser.value_float();
554 538
             switch((int)truncf(cvf * 10.0) - 30) {   // 3.1 -> 1
555 539
               #if ENABLED(UBL_G29_P31)
@@ -967,7 +951,7 @@
967 951
 
968 952
     static void echo_and_take_a_measurement() { SERIAL_PROTOCOLLNPGM(" and take a measurement."); }
969 953
 
970
-    float unified_bed_leveling::measure_business_card_thickness(float &in_height) {
954
+    float unified_bed_leveling::measure_business_card_thickness(float in_height) {
971 955
       has_control_of_lcd_panel = true;
972 956
       save_ubl_active_state_and_disable();   // Disable bed level correction for probing
973 957
 
@@ -1466,12 +1450,21 @@
1466 1450
   }
1467 1451
 
1468 1452
   #if ENABLED(NEWPANEL)
1453
+
1469 1454
     void unified_bed_leveling::fine_tune_mesh(const float &lx, const float &ly, const bool do_ubl_mesh_map) {
1470 1455
       if (!parser.seen('R'))    // fine_tune_mesh() is special. If no repetition count flag is specified
1471 1456
         g29_repetition_cnt = 1;   // do exactly one mesh location. Otherwise use what the parser decided.
1472
-
1457
+      
1458
+      #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1459
+        const bool is_offset = parser.seen('H');
1460
+        const float h_offset = is_offset ? parser.value_linear_units() : Z_CLEARANCE_BETWEEN_PROBES;
1461
+        if (is_offset && !WITHIN(h_offset, 0, 10)) {
1462
+          SERIAL_PROTOCOLLNPGM("Offset out of bounds. (0 to 10mm)\n");
1463
+          return;
1464
+        }
1465
+      #endif
1466
+      
1473 1467
       mesh_index_pair location;
1474
-      uint16_t not_done[16];
1475 1468
 
1476 1469
       if (!position_is_reachable_xy(lx, ly)) {
1477 1470
         SERIAL_PROTOCOLLNPGM("(X,Y) outside printable radius.");
@@ -1480,12 +1473,13 @@
1480 1473
 
1481 1474
       save_ubl_active_state_and_disable();
1482 1475
 
1483
-      memset(not_done, 0xFF, sizeof(not_done));
1484
-
1485 1476
       LCD_MESSAGEPGM(MSG_UBL_FINE_TUNE_MESH);
1486 1477
 
1487 1478
       do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
1488 1479
       do_blocking_move_to_xy(lx, ly);
1480
+
1481
+      uint16_t not_done[16];
1482
+      memset(not_done, 0xFF, sizeof(not_done));
1489 1483
       do {
1490 1484
         location = find_closest_mesh_point_of_type(SET_IN_BITMAP, lx, ly, USE_NOZZLE_AS_REFERENCE, not_done, false);
1491 1485
 
@@ -1521,8 +1515,8 @@
1521 1515
 
1522 1516
         do {
1523 1517
           new_z = lcd_mesh_edit();
1524
-          #ifdef UBL_MESH_EDIT_MOVES_Z
1525
-            do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + new_z);  // Move the nozzle as the point is edited
1518
+          #if ENABLED(UBL_MESH_EDIT_MOVES_Z)
1519
+            do_blocking_move_to_z(h_offset + new_z); // Move the nozzle as the point is edited
1526 1520
           #endif
1527 1521
           idle();
1528 1522
         } while (!ubl_lcd_clicked());
@@ -1581,7 +1575,8 @@
1581 1575
       }
1582 1576
       else lcd_return_to_status();
1583 1577
     }
1584
-  #endif
1578
+
1579
+  #endif // NEWPANEL
1585 1580
 
1586 1581
   /**
1587 1582
    * 'Smart Fill': Scan from the outward edges of the mesh towards the center.

Loading…
Cancel
Save