Browse Source

Fix MIN_PROBE_EDGE bug in default ABL G29 (#16367)

Jason Smith 5 years ago
parent
commit
3cade6245e

+ 37
- 28
Marlin/src/core/utility.cpp View File

81
     );
81
     );
82
 
82
 
83
     #if HAS_BED_PROBE
83
     #if HAS_BED_PROBE
84
-      SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
85
-      if (probe_offset.x > 0)
86
-        SERIAL_ECHOPGM(" (Right");
87
-      else if (probe_offset.x < 0)
88
-        SERIAL_ECHOPGM(" (Left");
89
-      else if (probe_offset.y != 0)
90
-        SERIAL_ECHOPGM(" (Middle");
91
-      else
92
-        SERIAL_ECHOPGM(" (Aligned With");
93
 
84
 
94
-      if (probe_offset.y > 0) {
95
-        #if IS_SCARA
96
-          SERIAL_ECHOPGM("-Distal");
97
-        #else
98
-          SERIAL_ECHOPGM("-Back");
99
-        #endif
100
-      }
101
-      else if (probe_offset.y < 0) {
102
-        #if IS_SCARA
103
-          SERIAL_ECHOPGM("-Proximal");
104
-        #else
105
-          SERIAL_ECHOPGM("-Front");
106
-        #endif
107
-      }
108
-      else if (probe_offset.x != 0)
109
-        SERIAL_ECHOPGM("-Center");
85
+      #if !HAS_PROBE_XY_OFFSET
86
+        SERIAL_ECHOPAIR("Probe Offset X0 Y0 Z", probe_offset.z, " (");
87
+      #else
88
+        SERIAL_ECHOPAIR_P(PSTR("Probe Offset X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
89
+        if (probe_offset.x > 0)
90
+          SERIAL_ECHOPGM(" (Right");
91
+        else if (probe_offset.x < 0)
92
+          SERIAL_ECHOPGM(" (Left");
93
+        else if (probe_offset.y != 0)
94
+          SERIAL_ECHOPGM(" (Middle");
95
+        else
96
+          SERIAL_ECHOPGM(" (Aligned With");
97
+
98
+        if (probe_offset.y > 0) {
99
+          #if IS_SCARA
100
+            SERIAL_ECHOPGM("-Distal");
101
+          #else
102
+            SERIAL_ECHOPGM("-Back");
103
+          #endif
104
+        }
105
+        else if (probe_offset.y < 0) {
106
+          #if IS_SCARA
107
+            SERIAL_ECHOPGM("-Proximal");
108
+          #else
109
+            SERIAL_ECHOPGM("-Front");
110
+          #endif
111
+        }
112
+        else if (probe_offset.x != 0)
113
+          SERIAL_ECHOPGM("-Center");
114
+
115
+        SERIAL_ECHOPGM(" & ");
116
+
117
+      #endif
110
 
118
 
111
       if (probe_offset.z < 0)
119
       if (probe_offset.z < 0)
112
-        SERIAL_ECHOPGM(" & Below");
120
+        SERIAL_ECHOPGM("Below");
113
       else if (probe_offset.z > 0)
121
       else if (probe_offset.z > 0)
114
-        SERIAL_ECHOPGM(" & Above");
122
+        SERIAL_ECHOPGM("Above");
115
       else
123
       else
116
-        SERIAL_ECHOPGM(" & Same Z as");
124
+        SERIAL_ECHOPGM("Same Z as");
117
       SERIAL_ECHOLNPGM(" Nozzle)");
125
       SERIAL_ECHOLNPGM(" Nozzle)");
126
+
118
     #endif
127
     #endif
119
 
128
 
120
     #if HAS_ABL_OR_UBL
129
     #if HAS_ABL_OR_UBL

+ 1
- 1
Marlin/src/feature/bedlevel/ubl/ubl.cpp View File

176
     // Add XY probe offset from extruder because probe_at_point() subtracts them when
176
     // Add XY probe offset from extruder because probe_at_point() subtracts them when
177
     // moving to the XY position to be measured. This ensures better agreement between
177
     // moving to the XY position to be measured. This ensures better agreement between
178
     // the current Z position after G28 and the mesh values.
178
     // the current Z position after G28 and the mesh values.
179
-    const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + xy_pos_t(probe_offset));
179
+    const xy_int8_t curr = closest_indexes(xy_pos_t(current_position) + probe_offset_xy);
180
 
180
 
181
     if (!lcd) SERIAL_EOL();
181
     if (!lcd) SERIAL_EOL();
182
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {
182
     for (int8_t j = GRID_MAX_POINTS_Y - 1; j >= 0; j--) {

+ 7
- 6
Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp View File

450
               SERIAL_ECHO(g29_pos.y);
450
               SERIAL_ECHO(g29_pos.y);
451
               SERIAL_ECHOLNPGM(").\n");
451
               SERIAL_ECHOLNPGM(").\n");
452
             }
452
             }
453
-            const xy_pos_t near = g29_pos + probe_offset;
453
+            const xy_pos_t near = g29_pos + probe_offset_xy;
454
             probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
454
             probe_entire_mesh(near, parser.seen('T'), parser.seen('E'), parser.seen('U'));
455
 
455
 
456
             report_current_position();
456
             report_current_position();
468
             do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
468
             do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES);
469
 
469
 
470
             if (parser.seen('C') && !xy_seen) {
470
             if (parser.seen('C') && !xy_seen) {
471
+
471
               /**
472
               /**
472
                * Use a good default location for the path.
473
                * Use a good default location for the path.
473
                * The flipped > and < operators in these comparisons is intentional.
474
                * The flipped > and < operators in these comparisons is intentional.
479
                 #if IS_KINEMATIC
480
                 #if IS_KINEMATIC
480
                   X_HOME_POS, Y_HOME_POS
481
                   X_HOME_POS, Y_HOME_POS
481
                 #else
482
                 #else
482
-                  probe_offset.x > 0 ? X_BED_SIZE : 0,
483
-                  probe_offset.y < 0 ? Y_BED_SIZE : 0
483
+                  probe_offset_xy.x > 0 ? X_BED_SIZE : 0,
484
+                  probe_offset_xy.y < 0 ? Y_BED_SIZE : 0
484
                 #endif
485
                 #endif
485
               );
486
               );
486
             }
487
             }
805
       restore_ubl_active_state_and_leave();
806
       restore_ubl_active_state_and_leave();
806
 
807
 
807
       do_blocking_move_to_xy(
808
       do_blocking_move_to_xy(
808
-        constrain(near.x - probe_offset.x, MESH_MIN_X, MESH_MAX_X),
809
-        constrain(near.y - probe_offset.y, MESH_MIN_Y, MESH_MAX_Y)
809
+        constrain(near.x - probe_offset_xy.x, MESH_MIN_X, MESH_MAX_X),
810
+        constrain(near.y - probe_offset_xy.y, MESH_MIN_Y, MESH_MAX_Y)
810
       );
811
       );
811
     }
812
     }
812
 
813
 
1293
     closest.distance = -99999.9f;
1294
     closest.distance = -99999.9f;
1294
 
1295
 
1295
     // Get the reference position, either nozzle or probe
1296
     // Get the reference position, either nozzle or probe
1296
-    const xy_pos_t ref = probe_relative ? pos + probe_offset : pos;
1297
+    const xy_pos_t ref = probe_relative ? pos + probe_offset_xy : pos;
1297
 
1298
 
1298
     float best_so_far = 99999.99f;
1299
     float best_so_far = 99999.99f;
1299
 
1300
 

+ 5
- 4
Marlin/src/gcode/bedlevel/G42.cpp View File

45
       return;
45
       return;
46
     }
46
     }
47
 
47
 
48
+    // Move to current_position, as modified by I, J, P parameters
48
     destination = current_position;
49
     destination = current_position;
49
 
50
 
50
     if (hasI) destination.x = _GET_MESH_X(ix);
51
     if (hasI) destination.x = _GET_MESH_X(ix);
51
     if (hasJ) destination.y = _GET_MESH_Y(iy);
52
     if (hasJ) destination.y = _GET_MESH_Y(iy);
52
 
53
 
53
-    #if HAS_BED_PROBE
54
+    #if HAS_PROBE_XY_OFFSET
54
       if (parser.boolval('P')) {
55
       if (parser.boolval('P')) {
55
-        if (hasI) destination.x -= probe_offset.x;
56
-        if (hasJ) destination.y -= probe_offset.y;
56
+        if (hasI) destination.x -= probe_offset_xy.x;
57
+        if (hasJ) destination.y -= probe_offset_xy.y;
57
       }
58
       }
58
     #endif
59
     #endif
59
 
60
 
60
     const feedRate_t fval = parser.linearval('F'),
61
     const feedRate_t fval = parser.linearval('F'),
61
-                     fr_mm_s = fval > 0 ? MMM_TO_MMS(fval) : 0.0f;
62
+                     fr_mm_s = MMM_TO_MMS(fval > 0 ? fval : 0.0f);
62
 
63
 
63
     // SCARA kinematic has "safe" XY raw moves
64
     // SCARA kinematic has "safe" XY raw moves
64
     #if IS_SCARA
65
     #if IS_SCARA

+ 7
- 8
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

228
       ABL_VAR xy_int8_t meshCount;
228
       ABL_VAR xy_int8_t meshCount;
229
     #endif
229
     #endif
230
 
230
 
231
-    ABL_VAR xy_float_t probe_position_lf, probe_position_rb;
231
+    ABL_VAR xy_pos_t probe_position_lf, probe_position_rb;
232
     ABL_VAR xy_float_t gridSpacing = { 0, 0 };
232
     ABL_VAR xy_float_t gridSpacing = { 0, 0 };
233
 
233
 
234
     #if ENABLED(AUTO_BED_LEVELING_LINEAR)
234
     #if ENABLED(AUTO_BED_LEVELING_LINEAR)
403
       }
403
       }
404
       else {
404
       else {
405
         probe_position_lf.set(
405
         probe_position_lf.set(
406
-          parser.seenval('L') ? (int)RAW_X_POSITION(parser.value_linear_units()) : (_MAX(x_min, X_CENTER - (X_BED_SIZE) / 2)      + MIN_PROBE_EDGE_LEFT),
407
-          parser.seenval('F') ? (int)RAW_Y_POSITION(parser.value_linear_units()) : (_MAX(y_min, Y_CENTER - (Y_BED_SIZE) / 2)      + MIN_PROBE_EDGE_FRONT)
406
+          parser.seenval('L') ? RAW_X_POSITION(parser.value_linear_units()) : x_min,
407
+          parser.seenval('F') ? RAW_Y_POSITION(parser.value_linear_units()) : y_min
408
         );
408
         );
409
         probe_position_rb.set(
409
         probe_position_rb.set(
410
-          parser.seenval('R') ? (int)RAW_X_POSITION(parser.value_linear_units()) : (_MIN(x_max, probe_position_lf.x + X_BED_SIZE) - MIN_PROBE_EDGE_RIGHT),
411
-          parser.seenval('B') ? (int)RAW_Y_POSITION(parser.value_linear_units()) : (_MIN(y_max, probe_position_lf.y + Y_BED_SIZE) - MIN_PROBE_EDGE_BACK)
410
+          parser.seenval('R') ? RAW_X_POSITION(parser.value_linear_units()) : x_max,
411
+          parser.seenval('B') ? RAW_Y_POSITION(parser.value_linear_units()) : y_max
412
         );
412
         );
413
-        SERIAL_ECHOLN("Set Trail 1");
414
       }
413
       }
415
 
414
 
416
       if (
415
       if (
911
         planner.force_unapply_leveling(converted); // use conversion machinery
910
         planner.force_unapply_leveling(converted); // use conversion machinery
912
 
911
 
913
         // Use the last measured distance to the bed, if possible
912
         // Use the last measured distance to the bed, if possible
914
-        if ( NEAR(current_position.x, probePos.x - probe_offset.x)
915
-          && NEAR(current_position.y, probePos.y - probe_offset.y)
913
+        if ( NEAR(current_position.x, probePos.x - probe_offset_xy.x)
914
+          && NEAR(current_position.y, probePos.y - probe_offset_xy.y)
916
         ) {
915
         ) {
917
           const float simple_z = current_position.z - measured_z;
916
           const float simple_z = current_position.z - measured_z;
918
           if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, "  Matrix Z", converted.z, "  Discrepancy ", simple_z - converted.z);
917
           if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, "  Matrix Z", converted.z, "  Discrepancy ", simple_z - converted.z);

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

133
     destination.set(safe_homing_xy, current_position.z);
133
     destination.set(safe_homing_xy, current_position.z);
134
 
134
 
135
     #if HOMING_Z_WITH_PROBE
135
     #if HOMING_Z_WITH_PROBE
136
-      destination -= probe_offset;
136
+      destination -= probe_offset_xy;
137
     #endif
137
     #endif
138
 
138
 
139
     if (position_is_reachable(destination)) {
139
     if (position_is_reachable(destination)) {

+ 5
- 4
Marlin/src/gcode/calibrate/M48.cpp View File

77
   xy_float_t next_pos = current_position;
77
   xy_float_t next_pos = current_position;
78
 
78
 
79
   const xy_pos_t probe_pos = {
79
   const xy_pos_t probe_pos = {
80
-    parser.linearval('X', next_pos.x + probe_offset.x),
81
-    parser.linearval('Y', next_pos.y + probe_offset.y)
80
+    parser.linearval('X', next_pos.x + probe_offset_xy.x),
81
+    parser.linearval('Y', next_pos.y + probe_offset_xy.y)
82
   };
82
   };
83
 
83
 
84
   if (!position_is_reachable_by_probe(probe_pos)) {
84
   if (!position_is_reachable_by_probe(probe_pos)) {
166
           while (angle < 0.0) angle += 360.0;   // outside of this range.   It looks like they behave correctly with
166
           while (angle < 0.0) angle += 360.0;   // outside of this range.   It looks like they behave correctly with
167
                                                 // numbers outside of the range, but just to be safe we clamp them.
167
                                                 // numbers outside of the range, but just to be safe we clamp them.
168
 
168
 
169
-          next_pos.set(probe_pos.x - probe_offset.x + cos(RADIANS(angle)) * radius,
170
-                       probe_pos.y - probe_offset.y + sin(RADIANS(angle)) * radius);
169
+          const xy_pos_t noz_pos = probe_pos - probe_offset_xy;
170
+          next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius,
171
+                       noz_pos.y + sin(RADIANS(angle)) * radius);
171
 
172
 
172
           #if DISABLED(DELTA)
173
           #if DISABLED(DELTA)
173
             LIMIT(next_pos.x, X_MIN_POS, X_MAX_POS);
174
             LIMIT(next_pos.x, X_MIN_POS, X_MAX_POS);

+ 3
- 2
Marlin/src/gcode/probe/G30.cpp View File

39
  *   E   Engage the probe for each probe (default 1)
39
  *   E   Engage the probe for each probe (default 1)
40
  */
40
  */
41
 void GcodeSuite::G30() {
41
 void GcodeSuite::G30() {
42
-  const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset.x),
43
-                         parser.linearval('Y', current_position.y + probe_offset.y) };
42
+
43
+  const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset_xy.x),
44
+                         parser.linearval('Y', current_position.y + probe_offset_xy.y) };
44
 
45
 
45
   if (!position_is_reachable_by_probe(pos)) return;
46
   if (!position_is_reachable_by_probe(pos)) return;
46
 
47
 

+ 30
- 13
Marlin/src/gcode/probe/M851.cpp View File

37
 
37
 
38
   // Show usage with no parameters
38
   // Show usage with no parameters
39
   if (!parser.seen("XYZ")) {
39
   if (!parser.seen("XYZ")) {
40
-    SERIAL_ECHOLNPAIR_P(PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
40
+    SERIAL_ECHOLNPAIR_P(
41
+      #if HAS_PROBE_XY_OFFSET
42
+        PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR
43
+      #else
44
+        PSTR(MSG_PROBE_OFFSET " X0 Y0 Z")
45
+      #endif
46
+      , probe_offset.z
47
+    );
41
     return;
48
     return;
42
   }
49
   }
43
 
50
 
51
+  // Start with current offsets and modify
44
   xyz_pos_t offs = probe_offset;
52
   xyz_pos_t offs = probe_offset;
45
 
53
 
54
+  // Assume no errors
46
   bool ok = true;
55
   bool ok = true;
47
 
56
 
48
   if (parser.seenval('X')) {
57
   if (parser.seenval('X')) {
49
     const float x = parser.value_float();
58
     const float x = parser.value_float();
50
-    if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
51
-      offs.x = x;
52
-    else {
53
-      SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
54
-      ok = false;
55
-    }
59
+    #if HAS_PROBE_XY_OFFSET
60
+      if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
61
+        offs.x = x;
62
+      else {
63
+        SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
64
+        ok = false;
65
+      }
66
+    #else
67
+      if (x) SERIAL_ECHOLNPAIR("?X must be 0 (NOZZLE_AS_PROBE)."); // ...but let 'ok' stay true
68
+    #endif
56
   }
69
   }
57
 
70
 
58
   if (parser.seenval('Y')) {
71
   if (parser.seenval('Y')) {
59
     const float y = parser.value_float();
72
     const float y = parser.value_float();
60
-    if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
61
-      offs.y = y;
62
-    else {
63
-      SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
64
-      ok = false;
65
-    }
73
+    #if HAS_PROBE_XY_OFFSET
74
+      if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
75
+        offs.y = y;
76
+      else {
77
+        SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
78
+        ok = false;
79
+      }
80
+    #else
81
+      if (y) SERIAL_ECHOLNPAIR("?Y must be 0 (NOZZLE_AS_PROBE)."); // ...but let 'ok' stay true
82
+    #endif
66
   }
83
   }
67
 
84
 
68
   if (parser.seenval('Z')) {
85
   if (parser.seenval('Z')) {

+ 1
- 0
Marlin/src/inc/Conditionals_LCD.h View File

500
 #define PROBE_SELECTED (HAS_BED_PROBE || EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
500
 #define PROBE_SELECTED (HAS_BED_PROBE || EITHER(PROBE_MANUALLY, MESH_BED_LEVELING))
501
 
501
 
502
 #if HAS_BED_PROBE
502
 #if HAS_BED_PROBE
503
+  #define HAS_PROBE_XY_OFFSET   DISABLED(NOZZLE_AS_PROBE)
503
   #define HAS_CUSTOM_PROBE_PIN  DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
504
   #define HAS_CUSTOM_PROBE_PIN  DISABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
504
   #define HOMING_Z_WITH_PROBE   (Z_HOME_DIR < 0 && !HAS_CUSTOM_PROBE_PIN)
505
   #define HOMING_Z_WITH_PROBE   (Z_HOME_DIR < 0 && !HAS_CUSTOM_PROBE_PIN)
505
   #ifndef Z_PROBE_LOW_POINT
506
   #ifndef Z_PROBE_LOW_POINT

+ 14
- 0
Marlin/src/inc/SanityCheck.h View File

1149
     #error "Z_MIN_PROBE_PIN must be defined if Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN is not enabled."
1149
     #error "Z_MIN_PROBE_PIN must be defined if Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN is not enabled."
1150
   #endif
1150
   #endif
1151
 
1151
 
1152
+  #if ENABLED(NOZZLE_AS_PROBE)
1153
+    constexpr float sanity_nozzle_to_probe_offset[] = NOZZLE_TO_PROBE_OFFSET;
1154
+    static_assert(sanity_nozzle_to_probe_offset[0] == 0.0 && sanity_nozzle_to_probe_offset[1] == 0.0,
1155
+                  "NOZZLE_AS_PROBE requires the X,Y offsets in NOZZLE_TO_PROBE_OFFSET to be 0,0.");
1156
+  #endif
1157
+
1158
+  #if DISABLED(NOZZLE_AS_PROBE)
1159
+    static_assert(MIN_PROBE_EDGE >= 0, "MIN_PROBE_EDGE must be >= 0.");
1160
+    static_assert(MIN_PROBE_EDGE_BACK >= 0, "MIN_PROBE_EDGE_BACK must be >= 0.");
1161
+    static_assert(MIN_PROBE_EDGE_FRONT >= 0, "MIN_PROBE_EDGE_FRONT must be >= 0.");
1162
+    static_assert(MIN_PROBE_EDGE_LEFT >= 0, "MIN_PROBE_EDGE_LEFT must be >= 0.");
1163
+    static_assert(MIN_PROBE_EDGE_RIGHT >= 0, "MIN_PROBE_EDGE_RIGHT must be >= 0.");
1164
+  #endif
1165
+
1152
   /**
1166
   /**
1153
    * Make sure Z raise values are set
1167
    * Make sure Z raise values are set
1154
    */
1168
    */

+ 16
- 4
Marlin/src/module/configuration_store.cpp View File

2354
   #if HAS_BED_PROBE
2354
   #if HAS_BED_PROBE
2355
     constexpr float dpo[XYZ] = NOZZLE_TO_PROBE_OFFSET;
2355
     constexpr float dpo[XYZ] = NOZZLE_TO_PROBE_OFFSET;
2356
     static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
2356
     static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
2357
-    LOOP_XYZ(a) probe_offset[a] = dpo[a];
2357
+    #if HAS_PROBE_XY_OFFSET
2358
+      LOOP_XYZ(a) probe_offset[a] = dpo[a];
2359
+    #else
2360
+      probe_offset.x = probe_offset.y = 0;
2361
+      probe_offset.z = dpo[Z_AXIS];
2362
+    #endif
2358
   #endif
2363
   #endif
2359
 
2364
 
2360
   //
2365
   //
3102
         say_units(true);
3107
         say_units(true);
3103
       }
3108
       }
3104
       CONFIG_ECHO_START();
3109
       CONFIG_ECHO_START();
3105
-      SERIAL_ECHOLNPAIR_P(PSTR("  M851 X"), LINEAR_UNIT(probe_offset.x),
3106
-                                  SP_Y_STR, LINEAR_UNIT(probe_offset.y),
3107
-                                  SP_Z_STR, LINEAR_UNIT(probe_offset.z));
3110
+      SERIAL_ECHOLNPAIR_P(
3111
+        #if HAS_PROBE_XY_OFFSET
3112
+          PSTR("  M851 X"), LINEAR_UNIT(probe_offset_xy.x),
3113
+                  SP_Y_STR, LINEAR_UNIT(probe_offset_xy.y),
3114
+                  SP_Z_STR
3115
+        #else
3116
+          PSTR("  M851 X0 Y0 Z")
3117
+        #endif
3118
+        , LINEAR_UNIT(probe_offset.z)
3119
+      );
3108
     #endif
3120
     #endif
3109
 
3121
 
3110
     /**
3122
     /**

+ 1
- 7
Marlin/src/module/delta.cpp View File

91
 #endif
91
 #endif
92
 
92
 
93
 float delta_calibration_radius() {
93
 float delta_calibration_radius() {
94
-  return FLOOR((DELTA_PRINTABLE_RADIUS - (
95
-    #if HAS_BED_PROBE
96
-      _MAX(HYPOT(probe_offset.x, probe_offset.y), MIN_PROBE_EDGE)
97
-    #else
98
-      MIN_PROBE_EDGE
99
-    #endif
100
-  )) * calibration_radius_factor);
94
+  return FLOOR((DELTA_PRINTABLE_RADIUS - _MAX(HYPOT(probe_offset_xy.x, probe_offset_xy.y), MIN_PROBE_EDGE)) * calibration_radius_factor);
101
 }
95
 }
102
 
96
 
103
 /**
97
 /**

+ 24
- 9
Marlin/src/module/motion.h View File

291
  */
291
  */
292
 
292
 
293
 #if IS_KINEMATIC // (DELTA or SCARA)
293
 #if IS_KINEMATIC // (DELTA or SCARA)
294
+
294
   #if HAS_SCARA_OFFSET
295
   #if HAS_SCARA_OFFSET
295
     extern abc_pos_t scara_home_offset; // A and B angular offsets, Z mm offset
296
     extern abc_pos_t scara_home_offset; // A and B angular offsets, Z mm offset
296
   #endif
297
   #endif
315
   }
316
   }
316
 
317
 
317
   #if HAS_BED_PROBE
318
   #if HAS_BED_PROBE
318
-    // Return true if the both nozzle and the probe can reach the given point.
319
-    // Note: This won't work on SCARA since the probe offset rotates with the arm.
320
-    inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
321
-      return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y)
322
-             && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
323
-    }
324
-  #endif
319
+
320
+    #if HAS_PROBE_XY_OFFSET
321
+
322
+      // Return true if the both nozzle and the probe can reach the given point.
323
+      // Note: This won't work on SCARA since the probe offset rotates with the arm.
324
+      inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
325
+        return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y)
326
+               && position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
327
+      }
328
+
329
+    #else
330
+
331
+      FORCE_INLINE bool position_is_reachable_by_probe(const float &rx, const float &ry) {
332
+        return position_is_reachable(rx, ry, MIN_PROBE_EDGE);
333
+      }
334
+
335
+    #endif
336
+
337
+  #endif // HAS_BED_PROBE
325
 
338
 
326
 #else // CARTESIAN
339
 #else // CARTESIAN
327
 
340
 
340
   inline bool position_is_reachable(const xy_pos_t &pos) { return position_is_reachable(pos.x, pos.y); }
353
   inline bool position_is_reachable(const xy_pos_t &pos) { return position_is_reachable(pos.x, pos.y); }
341
 
354
 
342
   #if HAS_BED_PROBE
355
   #if HAS_BED_PROBE
356
+
343
     /**
357
     /**
344
      * Return whether the given position is within the bed, and whether the nozzle
358
      * Return whether the given position is within the bed, and whether the nozzle
345
      * can reach the position required to put the probe at the given position.
359
      * can reach the position required to put the probe at the given position.
348
      *          nozzle must be be able to reach +10,-10.
362
      *          nozzle must be be able to reach +10,-10.
349
      */
363
      */
350
     inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
364
     inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
351
-      return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y)
365
+      return position_is_reachable(rx - probe_offset_xy.x, ry - probe_offset_xy.y)
352
           && WITHIN(rx, probe_min_x() - slop, probe_max_x() + slop)
366
           && WITHIN(rx, probe_min_x() - slop, probe_max_x() + slop)
353
           && WITHIN(ry, probe_min_y() - slop, probe_max_y() + slop);
367
           && WITHIN(ry, probe_min_y() - slop, probe_max_y() + slop);
354
     }
368
     }
355
-  #endif
369
+
370
+  #endif // HAS_BED_PROBE
356
 
371
 
357
 #endif // CARTESIAN
372
 #endif // CARTESIAN
358
 
373
 

+ 9
- 3
Marlin/src/module/probe.cpp View File

56
   #include "../feature/backlash.h"
56
   #include "../feature/backlash.h"
57
 #endif
57
 #endif
58
 
58
 
59
-xyz_pos_t probe_offset; // Initialized by settings.load()
60
-
61
 #if ENABLED(BLTOUCH)
59
 #if ENABLED(BLTOUCH)
62
   #include "../feature/bltouch.h"
60
   #include "../feature/bltouch.h"
63
 #endif
61
 #endif
86
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
84
 #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
87
 #include "../core/debug_out.h"
85
 #include "../core/debug_out.h"
88
 
86
 
87
+
88
+xyz_pos_t probe_offset; // Initialized by settings.load()
89
+
90
+#if HAS_PROBE_XY_OFFSET
91
+  xyz_pos_t &probe_offset_xy = probe_offset;
92
+#endif
93
+
94
+
89
 #if ENABLED(Z_PROBE_SLED)
95
 #if ENABLED(Z_PROBE_SLED)
90
 
96
 
91
   #ifndef SLED_DOCKING_OFFSET
97
   #ifndef SLED_DOCKING_OFFSET
698
   xyz_pos_t npos = { rx, ry };
704
   xyz_pos_t npos = { rx, ry };
699
   if (probe_relative) {
705
   if (probe_relative) {
700
     if (!position_is_reachable_by_probe(npos)) return NAN;  // The given position is in terms of the probe
706
     if (!position_is_reachable_by_probe(npos)) return NAN;  // The given position is in terms of the probe
701
-    npos -= probe_offset;                                   // Get the nozzle position
707
+    npos -= probe_offset_xy;                                // Get the nozzle position
702
   }
708
   }
703
   else if (!position_is_reachable(npos)) return NAN;        // The given position is in terms of the nozzle
709
   else if (!position_is_reachable(npos)) return NAN;        // The given position is in terms of the nozzle
704
 
710
 

+ 12
- 19
Marlin/src/module/probe.h View File

31
 
31
 
32
   extern xyz_pos_t probe_offset;
32
   extern xyz_pos_t probe_offset;
33
 
33
 
34
+  #if HAS_PROBE_XY_OFFSET
35
+    extern xyz_pos_t &probe_offset_xy;
36
+  #else
37
+    constexpr xy_pos_t probe_offset_xy{0};
38
+  #endif
39
+
34
   bool set_probe_deployed(const bool deploy);
40
   bool set_probe_deployed(const bool deploy);
35
   #ifdef Z_AFTER_PROBING
41
   #ifdef Z_AFTER_PROBING
36
     void move_z_after_probing();
42
     void move_z_after_probing();
54
 #else
60
 #else
55
 
61
 
56
   constexpr xyz_pos_t probe_offset{0};
62
   constexpr xyz_pos_t probe_offset{0};
63
+  constexpr xy_pos_t probe_offset_xy{0};
57
 
64
 
58
   #define DEPLOY_PROBE()
65
   #define DEPLOY_PROBE()
59
   #define STOW_PROBE()
66
   #define STOW_PROBE()
71
     );
78
     );
72
 
79
 
73
     inline float probe_radius() {
80
     inline float probe_radius() {
74
-      return printable_radius - (
75
-        #if HAS_BED_PROBE
76
-          _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset.x, probe_offset.y))
77
-        #else
78
-          MIN_PROBE_EDGE
79
-        #endif
80
-      );
81
+      return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
81
     }
82
     }
82
   #endif
83
   #endif
83
 
84
 
85
     return (
86
     return (
86
       #if IS_KINEMATIC
87
       #if IS_KINEMATIC
87
         (X_CENTER) - probe_radius()
88
         (X_CENTER) - probe_radius()
88
-      #elif ENABLED(NOZZLE_AS_PROBE)
89
-        _MAX(MIN_PROBE_EDGE_LEFT, X_MIN_POS)
90
       #else
89
       #else
91
-        _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset.x)
90
+        _MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset_xy.x)
92
       #endif
91
       #endif
93
     );
92
     );
94
   }
93
   }
96
     return (
95
     return (
97
       #if IS_KINEMATIC
96
       #if IS_KINEMATIC
98
         (X_CENTER) + probe_radius()
97
         (X_CENTER) + probe_radius()
99
-      #elif ENABLED(NOZZLE_AS_PROBE)
100
-        _MAX(MIN_PROBE_EDGE_RIGHT, X_MAX_POS)
101
       #else
98
       #else
102
-        _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset.x)
99
+        _MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset_xy.x)
103
       #endif
100
       #endif
104
     );
101
     );
105
   }
102
   }
107
     return (
104
     return (
108
       #if IS_KINEMATIC
105
       #if IS_KINEMATIC
109
         (Y_CENTER) - probe_radius()
106
         (Y_CENTER) - probe_radius()
110
-      #elif ENABLED(NOZZLE_AS_PROBE)
111
-        _MIN(MIN_PROBE_EDGE_FRONT, Y_MIN_POS)
112
       #else
107
       #else
113
-        _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset.y)
108
+        _MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
114
       #endif
109
       #endif
115
     );
110
     );
116
   }
111
   }
118
     return (
113
     return (
119
       #if IS_KINEMATIC
114
       #if IS_KINEMATIC
120
         (Y_CENTER) + probe_radius()
115
         (Y_CENTER) + probe_radius()
121
-      #elif ENABLED(NOZZLE_AS_PROBE)
122
-        _MAX(MIN_PROBE_EDGE_BACK, Y_MAX_POS)
123
       #else
116
       #else
124
-        _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset.y)
117
+        _MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset_xy.y)
125
       #endif
118
       #endif
126
     );
119
     );
127
   }
120
   }

+ 2
- 1
buildroot/share/tests/LPC1768-tests View File

45
            Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \
45
            Z_SAFE_HOMING ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE \
46
            LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA
46
            LCD_INFO_MENU ARC_SUPPORT BEZIER_CURVE_SUPPORT EXTENDED_CAPABILITIES_REPORT AUTO_REPORT_TEMPERATURES SDCARD_SORT_ALPHA
47
 opt_set GRID_MAX_POINTS_X 16
47
 opt_set GRID_MAX_POINTS_X 16
48
-exec_test $1 $2 "Re-ARM with Many Features"
48
+opt_set NOZZLE_TO_PROBE_OFFSET "{ 0, 0, 0 }"
49
+exec_test $1 $2 "Re-ARM with NOZZLE_AS_PROBE and many features."
49
 
50
 
50
 # clean up
51
 # clean up
51
 restore_configs
52
 restore_configs

Loading…
Cancel
Save