Browse Source

Probe Offset Wizard improvements (#20239)

swissnorp 4 years ago
parent
commit
649965ae32
No account linked to committer's email address

+ 8
- 2
Marlin/Configuration_adv.h View File

@@ -1084,8 +1084,14 @@
1084 1084
   #if HAS_BED_PROBE
1085 1085
     //#define PROBE_OFFSET_WIZARD
1086 1086
     #if ENABLED(PROBE_OFFSET_WIZARD)
1087
-      #define PROBE_OFFSET_START -4.0   // Estimated nozzle-to-probe Z offset, plus a little extra
1088
-      //#define PROBE_OFFSET_WIZARD_XY_POS XY_CENTER // Set a convenient position to do the measurement
1087
+      //
1088
+      // Enable to init the Probe Z-Offset when starting the Wizard.
1089
+      // Use the estimated nozzle-to-probe Z offset, plus a little more.
1090
+      //
1091
+      //#define PROBE_OFFSET_WIZARD_START_Z -4.0
1092
+
1093
+      // Set a convenient position to do the calibration (probing point and nozzle/bed-distance)
1094
+      //#define PROBE_OFFSET_WIZARD_XY_POS { X_CENTER, Y_CENTER }
1089 1095
     #endif
1090 1096
   #endif
1091 1097
 

+ 2
- 2
Marlin/src/gcode/calibrate/G28.cpp View File

@@ -324,7 +324,7 @@ void GcodeSuite::G28() {
324 324
         ? 0
325 325
         : (parser.seenval('R') ? parser.value_linear_units() : Z_HOMING_HEIGHT);
326 326
 
327
-    if (z_homing_height && (doX || doY || (ENABLED(Z_SAFE_HOMING) && doZ))) {
327
+    if (z_homing_height && (doX || doY || TERN0(Z_SAFE_HOMING, doZ))) {
328 328
       // Raise Z before homing any other axes and z is not already high enough (never lower z)
329 329
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) by ", z_homing_height);
330 330
       do_z_clearance(z_homing_height, true, DISABLED(UNKNOWN_Z_NO_RAISE));
@@ -337,7 +337,7 @@ void GcodeSuite::G28() {
337 337
     #endif
338 338
 
339 339
     // Home Y (before X)
340
-    if (ENABLED(HOME_Y_BEFORE_X) && (doY || (ENABLED(CODEPENDENT_XY_HOMING) && doX)))
340
+    if (ENABLED(HOME_Y_BEFORE_X) && (doY || TERN0(CODEPENDENT_XY_HOMING, doX)))
341 341
       homeaxis(Y_AXIS);
342 342
 
343 343
     // Home X

+ 21
- 12
Marlin/src/inc/SanityCheck.h View File

@@ -525,6 +525,8 @@
525 525
   #error "EVENT_GCODE_SD_STOP is now EVENT_GCODE_SD_ABORT."
526 526
 #elif defined(GRAPHICAL_TFT_ROTATE_180)
527 527
   #error "GRAPHICAL_TFT_ROTATE_180 is now TFT_ROTATION set to TFT_ROTATE_180."
528
+#elif defined(PROBE_OFFSET_START)
529
+  #error "PROBE_OFFSET_START is now PROBE_OFFSET_WIZARD_START_Z."
528 530
 #elif defined(POWER_LOSS_PULL)
529 531
   #error "POWER_LOSS_PULL is now specifically POWER_LOSS_PULL(UP|DOWN)."
530 532
 #elif defined(FIL_RUNOUT_INVERTING)
@@ -1345,25 +1347,32 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
1345 1347
     #error "Z_MIN_PROBE_PIN must be defined if Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN is not enabled."
1346 1348
   #endif
1347 1349
 
1350
+  /**
1351
+   * Check for improper NOZZLE_TO_PROBE_OFFSET
1352
+   */
1353
+  constexpr xyz_pos_t sanity_nozzle_to_probe_offset = NOZZLE_TO_PROBE_OFFSET;
1348 1354
   #if ENABLED(NOZZLE_AS_PROBE)
1349
-    constexpr float sanity_nozzle_to_probe_offset[] = NOZZLE_TO_PROBE_OFFSET;
1350
-    static_assert(sanity_nozzle_to_probe_offset[0] == 0.0 && sanity_nozzle_to_probe_offset[1] == 0.0,
1351
-                  "NOZZLE_AS_PROBE requires the X,Y offsets in NOZZLE_TO_PROBE_OFFSET to be 0,0.");
1352
-  #endif
1353
-
1354
-  #if DISABLED(NOZZLE_AS_PROBE)
1355
-    static_assert(PROBING_MARGIN >= 0, "PROBING_MARGIN must be >= 0.");
1356
-    static_assert(PROBING_MARGIN_BACK >= 0, "PROBING_MARGIN_BACK must be >= 0.");
1355
+    static_assert(sanity_nozzle_to_probe_offset.x == 0 && sanity_nozzle_to_probe_offset.y == 0,
1356
+                  "NOZZLE_AS_PROBE requires the XY offsets in NOZZLE_TO_PROBE_OFFSET to both be 0.");
1357
+  #else
1358
+    static_assert(sanity_nozzle_to_probe_offset.z <= 0.25,
1359
+                  "Are you sure your Probe triggers above the nozzle? Set a negative Z value in the NOZZLE_TO_PROBE_OFFSET.");
1360
+    #ifdef PROBE_OFFSET_WIZARD_START_Z
1361
+      static_assert(PROBE_OFFSET_WIZARD_START_Z <= 0.25,
1362
+                    "Are you sure your Probe triggers above the nozzle? Set a negative value for PROBE_OFFSET_WIZARD_START_Z.");
1363
+    #endif
1364
+    static_assert(PROBING_MARGIN       >= 0, "PROBING_MARGIN must be >= 0.");
1365
+    static_assert(PROBING_MARGIN_BACK  >= 0, "PROBING_MARGIN_BACK must be >= 0.");
1357 1366
     static_assert(PROBING_MARGIN_FRONT >= 0, "PROBING_MARGIN_FRONT must be >= 0.");
1358
-    static_assert(PROBING_MARGIN_LEFT >= 0, "PROBING_MARGIN_LEFT must be >= 0.");
1367
+    static_assert(PROBING_MARGIN_LEFT  >= 0, "PROBING_MARGIN_LEFT must be >= 0.");
1359 1368
     static_assert(PROBING_MARGIN_RIGHT >= 0, "PROBING_MARGIN_RIGHT must be >= 0.");
1360 1369
   #endif
1361 1370
 
1362 1371
   #define _MARGIN(A) TERN(IS_SCARA, SCARA_PRINTABLE_RADIUS, TERN(DELTA, DELTA_PRINTABLE_RADIUS, ((A##_BED_SIZE) / 2)))
1363
-  static_assert(PROBING_MARGIN < _MARGIN(X), "PROBING_MARGIN is too large.");
1364
-  static_assert(PROBING_MARGIN_BACK < _MARGIN(Y), "PROBING_MARGIN_BACK is too large.");
1372
+  static_assert(PROBING_MARGIN       < _MARGIN(X), "PROBING_MARGIN is too large.");
1373
+  static_assert(PROBING_MARGIN_BACK  < _MARGIN(Y), "PROBING_MARGIN_BACK is too large.");
1365 1374
   static_assert(PROBING_MARGIN_FRONT < _MARGIN(Y), "PROBING_MARGIN_FRONT is too large.");
1366
-  static_assert(PROBING_MARGIN_LEFT < _MARGIN(X), "PROBING_MARGIN_LEFT is too large.");
1375
+  static_assert(PROBING_MARGIN_LEFT  < _MARGIN(X), "PROBING_MARGIN_LEFT is too large.");
1367 1376
   static_assert(PROBING_MARGIN_RIGHT < _MARGIN(X), "PROBING_MARGIN_RIGHT is too large.");
1368 1377
   #undef _MARGIN
1369 1378
 

+ 2
- 0
Marlin/src/lcd/language/language_en.h View File

@@ -673,6 +673,8 @@ namespace Language_en {
673 673
   PROGMEM Language_Str MSG_REHEATING                       = _UxGT("Reheating...");
674 674
 
675 675
   PROGMEM Language_Str MSG_PROBE_WIZARD                    = _UxGT("Z Probe Wizard");
676
+  PROGMEM Language_Str MSG_PROBE_WIZARD_PROBING            = _UxGT("Probing Z Reference");
677
+  PROGMEM Language_Str MSG_PROBE_WIZARD_MOVING             = _UxGT("Moving to Probing Pos");
676 678
 
677 679
   PROGMEM Language_Str MSG_SOUND                           = _UxGT("Sound");
678 680
 

+ 1
- 1
Marlin/src/lcd/marlinui.h View File

@@ -624,7 +624,7 @@ public:
624 624
   //
625 625
   // Special handling if a move is underway
626 626
   //
627
-  #if EITHER(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)) || (ENABLED(PROBE_OFFSET_WIZARD) && defined(PROBE_OFFSET_WIZARD_XY_POS))
627
+  #if ANY(DELTA_CALIBRATION_MENU, DELTA_AUTO_CALIBRATION, PROBE_OFFSET_WIZARD) || (ENABLED(LCD_BED_LEVELING) && EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
628 628
     #define LCD_HAS_WAIT_FOR_MOVE 1
629 629
     static bool wait_for_move;
630 630
   #else

+ 1
- 1
Marlin/src/lcd/menu/menu.h View File

@@ -220,7 +220,7 @@ void _lcd_draw_homing();
220 220
 #endif
221 221
 
222 222
 #if ENABLED(PROBE_OFFSET_WIZARD)
223
-  void home_and_goto_probe_offset_wizard();
223
+  void goto_probe_offset_wizard();
224 224
 #endif
225 225
 
226 226
 #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))

+ 1
- 1
Marlin/src/lcd/menu/menu_advanced.cpp View File

@@ -488,7 +488,7 @@ void menu_backlash();
488 488
       EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
489 489
 
490 490
       #if ENABLED(PROBE_OFFSET_WIZARD)
491
-        SUBMENU(MSG_PROBE_WIZARD, home_and_goto_probe_offset_wizard);
491
+        SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
492 492
       #endif
493 493
 
494 494
       END_MENU();

+ 73
- 41
Marlin/src/lcd/menu/menu_probe_offset.cpp View File

@@ -28,12 +28,6 @@
28 28
 
29 29
 #if ENABLED(PROBE_OFFSET_WIZARD)
30 30
 
31
-#ifndef PROBE_OFFSET_START
32
-  #error "PROBE_OFFSET_WIZARD requires a PROBE_OFFSET_START with a negative value."
33
-#else
34
-  static_assert(PROBE_OFFSET_START < 0, "PROBE_OFFSET_START must be < 0. Please update your configuration.");
35
-#endif
36
-
37 31
 #include "menu_item.h"
38 32
 #include "menu_addon.h"
39 33
 #include "../../gcode/queue.h"
@@ -46,21 +40,20 @@
46 40
 #endif
47 41
 
48 42
 // Global storage
49
-float z_offset_backup, calculated_z_offset;
43
+float z_offset_backup, calculated_z_offset, z_offset_ref;
50 44
 
51 45
 TERN_(HAS_LEVELING, bool leveling_was_active);
52 46
 
53
-void prepare_for_calibration() {
54
-  z_offset_backup = probe.offset.z;
55
-
56
-  // Disable soft endstops for free Z movement
57
-  SET_SOFT_ENDSTOP_LOOSE(true);
58
-
59
-  // Disable leveling for raw planner motion
60
-  #if HAS_LEVELING
61
-    leveling_was_active = planner.leveling_active;
62
-    set_bed_leveling_enabled(false);
63
-  #endif
47
+inline void z_clearance_move() {
48
+  do_z_clearance(
49
+    #ifdef Z_AFTER_HOMING
50
+      Z_AFTER_HOMING
51
+    #elif defined(Z_HOMING_HEIGHT)
52
+      Z_HOMING_HEIGHT
53
+    #else
54
+      10
55
+    #endif
56
+  );
64 57
 }
65 58
 
66 59
 void set_offset_and_go_back(const float &z) {
@@ -77,7 +70,7 @@ void _goto_manual_move_z(const float scale) {
77 70
 
78 71
 void probe_offset_wizard_menu() {
79 72
   START_MENU();
80
-  calculated_z_offset = probe.offset.z + current_position.z;
73
+  calculated_z_offset = probe.offset.z + current_position.z - z_offset_ref;
81 74
 
82 75
   if (LCD_HEIGHT >= 4)
83 76
     STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT);
@@ -92,7 +85,7 @@ void probe_offset_wizard_menu() {
92 85
     char tmp[20], numstr[10];
93 86
     // Determine digits needed right of decimal
94 87
     const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
95
-                          !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) *  100 - int((SHORT_MANUAL_Z_MOVE) *  100)) ? 3 : 2;
88
+                         !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) *  100 - int((SHORT_MANUAL_Z_MOVE) *  100)) ? 3 : 2;
96 89
     sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
97 90
     #if DISABLED(HAS_GRAPHICAL_TFT)
98 91
       extern const char NUL_STR[];
@@ -107,47 +100,86 @@ void probe_offset_wizard_menu() {
107 100
 
108 101
   ACTION_ITEM(MSG_BUTTON_DONE, []{
109 102
     set_offset_and_go_back(calculated_z_offset);
110
-    do_z_clearance(20.0
111
-      #ifdef Z_AFTER_HOMING
112
-        - 20.0 + Z_AFTER_HOMING
113
-      #endif
114
-    );
103
+    current_position.z = z_offset_ref;  // Set Z to z_offset_ref, as we can expect it is at probe height
104
+    sync_plan_position();
105
+    z_clearance_move();                 // Raise Z as if it was homed
115 106
   });
116 107
 
117 108
   ACTION_ITEM(MSG_BUTTON_CANCEL, []{
118 109
     set_offset_and_go_back(z_offset_backup);
110
+    // If wizard-homing was done by probe with with PROBE_OFFSET_WIZARD_START_Z
111
+    #if EITHER(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, USE_PROBE_FOR_Z_HOMING) && defined(PROBE_OFFSET_WIZARD_START_Z)
112
+      set_axis_never_homed(Z_AXIS); // On cancel the Z position needs correction
113
+      queue.inject_P(PSTR("G28Z"));
114
+    #else // Otherwise do a Z clearance move like after Homing
115
+      z_clearance_move();
116
+    #endif
119 117
   });
120 118
 
121 119
   END_MENU();
122 120
 }
123 121
 
124
-#ifdef PROBE_OFFSET_WIZARD_XY_POS
122
+void prepare_for_probe_offset_wizard() {
123
+  if (ui.wait_for_move) return;
125 124
 
126
-  #define HAS_PROBE_OFFSET_WIZARD_XY_POS 1
125
+  #if defined(PROBE_OFFSET_WIZARD_XY_POS) || NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, USE_PROBE_FOR_Z_HOMING)
126
+    if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_PROBE_WIZARD_PROBING));
127 127
 
128
-  inline void goto_probe_offset_wizard() {
129
-    if (ui.wait_for_move) return;
128
+    #ifndef PROBE_OFFSET_WIZARD_XY_POS
129
+      #define PROBE_OFFSET_WIZARD_XY_POS XY_CENTER
130
+    #endif
131
+    // Get X and Y from configuration, or use center
130 132
     constexpr xy_pos_t wizard_pos = PROBE_OFFSET_WIZARD_XY_POS;
131
-    current_position = wizard_pos;
133
+
134
+    // Probe for Z reference
132 135
     ui.wait_for_move = true;
133
-    line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY)); // Could invoke idle()
136
+    z_offset_ref = probe.probe_at_point(wizard_pos, PROBE_PT_STOW, 0, true);
134 137
     ui.wait_for_move = false;
135
-    ui.synchronize();
136
-    prepare_for_calibration();
137
-    probe.offset.z = PROBE_OFFSET_START;
138
-    ui.goto_screen(probe_offset_wizard_menu);
139
-    ui.defer_status_screen();
140
-  }
141 138
 
142
-#endif
139
+  #endif
140
+
141
+  // Move Nozzle to Probing/Homing Position
142
+  ui.wait_for_move = true;
143
+  current_position += probe.offset_xy;
144
+  line_to_current_position(MMM_TO_MMS(HOMING_FEEDRATE_XY));
145
+  ui.synchronize(GET_TEXT(MSG_PROBE_WIZARD_MOVING));
146
+  ui.wait_for_move = false;
147
+
148
+  // Go to Calibration Menu
149
+  ui.goto_screen(probe_offset_wizard_menu);
150
+  ui.defer_status_screen();
151
+}
152
+
153
+void goto_probe_offset_wizard() {
154
+  ui.defer_status_screen();
155
+  set_all_unhomed();
156
+
157
+  // Store probe.offset.z for Case: Cancel
158
+  z_offset_backup = probe.offset.z;
159
+
160
+  #ifdef PROBE_OFFSET_WIZARD_START_Z
161
+    probe.offset.z = PROBE_OFFSET_WIZARD_START_Z;
162
+  #endif
163
+
164
+  // Store Bed-Leveling-State and disable
165
+  #if HAS_LEVELING
166
+    leveling_was_active = planner.leveling_active;
167
+    set_bed_leveling_enabled(false);
168
+  #endif
143 169
 
144
-void home_and_goto_probe_offset_wizard() {
170
+  // Home all axes
145 171
   queue.inject_P(G28_STR);
172
+
146 173
   ui.goto_screen([]{
147 174
     _lcd_draw_homing();
148
-    if (all_axes_homed())
149
-      ui.goto_screen(TERN(HAS_PROBE_OFFSET_WIZARD_XY_POS, goto_probe_offset_wizard, probe_offset_wizard_menu));
175
+    if (all_axes_homed()) {
176
+      SET_SOFT_ENDSTOP_LOOSE(true); // Disable soft endstops for free Z movement
177
+      z_offset_ref = 0;             // Set Z Value for Wizard Position to 0
178
+      ui.goto_screen(prepare_for_probe_offset_wizard);
179
+      ui.defer_status_screen();
180
+    }
150 181
   });
182
+
151 183
 }
152 184
 
153 185
 #endif // PROBE_OFFSET_WIZARD

Loading…
Cancel
Save