Browse Source

🚸 G33 R and O options (#22707)

Luc Van Daele 3 years ago
parent
commit
37c488fda1
No account linked to committer's email address

+ 38
- 27
Marlin/src/gcode/calibrate/G33.cpp View File

69
 
69
 
70
 float lcd_probe_pt(const xy_pos_t &xy);
70
 float lcd_probe_pt(const xy_pos_t &xy);
71
 
71
 
72
+float dcr;
73
+
72
 void ac_home() {
74
 void ac_home() {
73
   endstops.enable(true);
75
   endstops.enable(true);
74
   TERN_(SENSORLESS_HOMING, probe.set_homing_current(true));
76
   TERN_(SENSORLESS_HOMING, probe.set_homing_current(true));
175
 /**
177
 /**
176
  *  - Probe a point
178
  *  - Probe a point
177
  */
179
  */
178
-static float calibration_probe(const xy_pos_t &xy, const bool stow) {
180
+static float calibration_probe(const xy_pos_t &xy, const bool stow, const bool probe_at_offset) {
179
   #if HAS_BED_PROBE
181
   #if HAS_BED_PROBE
180
-    return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true, false);
182
+    return probe.probe_at_point(xy, stow ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true, probe_at_offset);
181
   #else
183
   #else
182
     UNUSED(stow);
184
     UNUSED(stow);
183
     return lcd_probe_pt(xy);
185
     return lcd_probe_pt(xy);
187
 /**
189
 /**
188
  *  - Probe a grid
190
  *  - Probe a grid
189
  */
191
  */
190
-static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_points, const bool towers_set, const bool stow_after_each) {
192
+static bool probe_calibration_points(float z_pt[NPP + 1], const int8_t probe_points, const bool towers_set, const bool stow_after_each, const bool probe_at_offset) {
191
   const bool _0p_calibration      = probe_points == 0,
193
   const bool _0p_calibration      = probe_points == 0,
192
              _1p_calibration      = probe_points == 1 || probe_points == -1,
194
              _1p_calibration      = probe_points == 1 || probe_points == -1,
193
              _4p_calibration      = probe_points == 2,
195
              _4p_calibration      = probe_points == 2,
209
 
211
 
210
   if (!_0p_calibration) {
212
   if (!_0p_calibration) {
211
 
213
 
212
-    const float dcr = delta_calibration_radius();
213
-
214
     if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
214
     if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
215
       const xy_pos_t center{0};
215
       const xy_pos_t center{0};
216
-      z_pt[CEN] += calibration_probe(center, stow_after_each);
216
+      z_pt[CEN] += calibration_probe(center, stow_after_each, probe_at_offset);
217
       if (isnan(z_pt[CEN])) return false;
217
       if (isnan(z_pt[CEN])) return false;
218
     }
218
     }
219
 
219
 
224
         const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
224
         const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
225
                     r = dcr * 0.1;
225
                     r = dcr * 0.1;
226
         const xy_pos_t vec = { cos(a), sin(a) };
226
         const xy_pos_t vec = { cos(a), sin(a) };
227
-        z_pt[CEN] += calibration_probe(vec * r, stow_after_each);
227
+        z_pt[CEN] += calibration_probe(vec * r, stow_after_each, probe_at_offset);
228
         if (isnan(z_pt[CEN])) return false;
228
         if (isnan(z_pt[CEN])) return false;
229
      }
229
      }
230
       z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
230
       z_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
249
                       r = dcr * (1 - 0.1 * (zig_zag ? offset - circle : circle)),
249
                       r = dcr * (1 - 0.1 * (zig_zag ? offset - circle : circle)),
250
                       interpol = FMOD(rad, 1);
250
                       interpol = FMOD(rad, 1);
251
           const xy_pos_t vec = { cos(a), sin(a) };
251
           const xy_pos_t vec = { cos(a), sin(a) };
252
-          const float z_temp = calibration_probe(vec * r, stow_after_each);
252
+          const float z_temp = calibration_probe(vec * r, stow_after_each, probe_at_offset);
253
           if (isnan(z_temp)) return false;
253
           if (isnan(z_temp)) return false;
254
           // split probe point to neighbouring calibration points
254
           // split probe point to neighbouring calibration points
255
           z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
255
           z_pt[uint8_t(LROUND(rad - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
276
 static void reverse_kinematics_probe_points(float z_pt[NPP + 1], abc_float_t mm_at_pt_axis[NPP + 1]) {
276
 static void reverse_kinematics_probe_points(float z_pt[NPP + 1], abc_float_t mm_at_pt_axis[NPP + 1]) {
277
   xyz_pos_t pos{0};
277
   xyz_pos_t pos{0};
278
 
278
 
279
-  const float dcr = delta_calibration_radius();
280
   LOOP_CAL_ALL(rad) {
279
   LOOP_CAL_ALL(rad) {
281
     const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
280
     const float a = RADIANS(210 + (360 / NPP) *  (rad - 1)),
282
                 r = (rad == CEN ? 0.0f : dcr);
281
                 r = (rad == CEN ? 0.0f : dcr);
287
 }
286
 }
288
 
287
 
289
 static void forward_kinematics_probe_points(abc_float_t mm_at_pt_axis[NPP + 1], float z_pt[NPP + 1]) {
288
 static void forward_kinematics_probe_points(abc_float_t mm_at_pt_axis[NPP + 1], float z_pt[NPP + 1]) {
290
-  const float r_quot = delta_calibration_radius() / delta_radius;
289
+  const float r_quot = dcr / delta_radius;
291
 
290
 
292
   #define ZPP(N,I,A) (((1.0f + r_quot * (N)) / 3.0f) * mm_at_pt_axis[I].A)
291
   #define ZPP(N,I,A) (((1.0f + r_quot * (N)) / 3.0f) * mm_at_pt_axis[I].A)
293
   #define Z00(I, A) ZPP( 0, I, A)
292
   #define Z00(I, A) ZPP( 0, I, A)
328
 }
327
 }
329
 
328
 
330
 static float auto_tune_h() {
329
 static float auto_tune_h() {
331
-  const float r_quot = delta_calibration_radius() / delta_radius;
330
+  const float r_quot = dcr / delta_radius;
332
   return RECIPROCAL(r_quot / (2.0f / 3.0f));  // (2/3)/CR
331
   return RECIPROCAL(r_quot / (2.0f / 3.0f));  // (2/3)/CR
333
 }
332
 }
334
 
333
 
373
  *      P3       Probe all positions: center, towers and opposite towers. Calibrate all.
372
  *      P3       Probe all positions: center, towers and opposite towers. Calibrate all.
374
  *      P4-P10   Probe all positions at different intermediate locations and average them.
373
  *      P4-P10   Probe all positions at different intermediate locations and average them.
375
  *
374
  *
375
+ *   Rn.nn  override default calibration Radius
376
+ *
376
  *   T   Don't calibrate tower angle corrections
377
  *   T   Don't calibrate tower angle corrections
377
  *
378
  *
378
  *   Cn.nn  Calibration precision; when omitted calibrates to maximum precision
379
  *   Cn.nn  Calibration precision; when omitted calibrates to maximum precision
387
  *
388
  *
388
  *   E   Engage the probe for each point
389
  *   E   Engage the probe for each point
389
  *
390
  *
391
+ *   O   Probe at offset points (this is wrong but it seems to work)
392
+ *
390
  * With SENSORLESS_PROBING:
393
  * With SENSORLESS_PROBING:
391
  *   Use these flags to calibrate stall sensitivity: (e.g., `G33 P1 Y Z` to calibrate X only.)
394
  *   Use these flags to calibrate stall sensitivity: (e.g., `G33 P1 Y Z` to calibrate X only.)
392
  *   X   Don't activate stallguard on X.
395
  *   X   Don't activate stallguard on X.
403
     return;
406
     return;
404
   }
407
   }
405
 
408
 
406
-  const bool towers_set = !parser.seen_test('T');
409
+  const bool probe_at_offset = TERN0(HAS_PROBE_XY_OFFSET, parser.boolval('O')),
410
+                  towers_set = !parser.seen_test('T');
411
+
412
+  float max_dcr = dcr = DELTA_PRINTABLE_RADIUS;
413
+  #if HAS_PROBE_XY_OFFSET
414
+    // For offset probes the calibration radius is set to a safe but non-optimal value
415
+    dcr -= HYPOT(probe.offset_xy.x, probe.offset_xy.y);
416
+    if (probe_at_offset) {
417
+      // With probe positions both probe and nozzle need to be within the printable area
418
+      max_dcr = dcr;
419
+    }
420
+    // else with nozzle positions there is a risk of the probe being outside the bed
421
+    // but as long the nozzle stays within the printable area there is no risk of
422
+    // the effector crashing into the towers.
423
+  #endif
424
+
425
+  if (parser.seenval('R')) dcr = parser.value_float();
426
+  if (!WITHIN(dcr, 0, max_dcr)) {
427
+    SERIAL_ECHOLNPGM("?calibration (R)adius implausible.");
428
+    return;
429
+  }
407
 
430
 
408
   const float calibration_precision = parser.floatval('C', 0.0f);
431
   const float calibration_precision = parser.floatval('C', 0.0f);
409
   if (calibration_precision < 0) {
432
   if (calibration_precision < 0) {
453
 
476
 
454
   SERIAL_ECHOLNPGM("G33 Auto Calibrate");
477
   SERIAL_ECHOLNPGM("G33 Auto Calibrate");
455
 
478
 
456
-  const float dcr = delta_calibration_radius();
457
-
458
-  if (!_1p_calibration && !_0p_calibration) { // test if the outer radius is reachable
459
-    LOOP_CAL_RAD(axis) {
460
-      const float a = RADIANS(210 + (360 / NPP) *  (axis - 1));
461
-      if (!position_is_reachable(cos(a) * dcr, sin(a) * dcr)) {
462
-        SERIAL_ECHOLNPGM("?Bed calibration radius implausible.");
463
-        return;
464
-      }
465
-    }
466
-  }
467
-
468
   // Report settings
479
   // Report settings
469
   PGM_P const checkingac = PSTR("Checking... AC");
480
   PGM_P const checkingac = PSTR("Checking... AC");
470
   SERIAL_ECHOPGM_P(checkingac);
481
   SERIAL_ECHOPGM_P(checkingac);
487
 
498
 
488
     // Probe the points
499
     // Probe the points
489
     zero_std_dev_old = zero_std_dev;
500
     zero_std_dev_old = zero_std_dev;
490
-    if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each)) {
501
+    if (!probe_calibration_points(z_at_pt, probe_points, towers_set, stow_after_each, probe_at_offset)) {
491
       SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666");
502
       SERIAL_ECHOLNPGM("Correct delta settings with M665 and M666");
492
       return ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
503
       return ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));
493
     }
504
     }
526
       #define Z0(I) ZP(0, I)
537
       #define Z0(I) ZP(0, I)
527
 
538
 
528
       // calculate factors
539
       // calculate factors
529
-      if (_7p_9_center) calibration_radius_factor = 0.9f;
540
+      if (_7p_9_center) dcr *= 0.9f;
530
       h_factor = auto_tune_h();
541
       h_factor = auto_tune_h();
531
       r_factor = auto_tune_r();
542
       r_factor = auto_tune_r();
532
       a_factor = auto_tune_a();
543
       a_factor = auto_tune_a();
533
-      calibration_radius_factor = 1.0f;
544
+      dcr /= 0.9f;
534
 
545
 
535
       switch (probe_points) {
546
       switch (probe_points) {
536
         case 0:
547
         case 0:

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

88
   }
88
   }
89
 
89
 
90
   void _goto_tower_a(const_float_t a) {
90
   void _goto_tower_a(const_float_t a) {
91
+    constexpr float dcr = DELTA_PRINTABLE_RADIUS;
91
     xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
92
     xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
92
-    _man_probe_pt(tower_vec * delta_calibration_radius());
93
+    _man_probe_pt(tower_vec * dcr);
93
   }
94
   }
94
   void _goto_tower_x() { _goto_tower_a(210); }
95
   void _goto_tower_x() { _goto_tower_a(210); }
95
   void _goto_tower_y() { _goto_tower_a(330); }
96
   void _goto_tower_y() { _goto_tower_a(330); }

+ 0
- 22
Marlin/src/module/delta.cpp View File

83
 }
83
 }
84
 
84
 
85
 /**
85
 /**
86
- * Get a safe radius for calibration
87
- */
88
-
89
-#if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU)
90
-
91
-  #if ENABLED(DELTA_AUTO_CALIBRATION)
92
-    float calibration_radius_factor = 1;
93
-  #endif
94
-
95
-  float delta_calibration_radius() {
96
-    return calibration_radius_factor * (
97
-      #if HAS_BED_PROBE
98
-        FLOOR((DELTA_PRINTABLE_RADIUS) - _MAX(HYPOT(probe.offset_xy.x, probe.offset_xy.y), PROBING_MARGIN))
99
-      #else
100
-        DELTA_PRINTABLE_RADIUS
101
-      #endif
102
-    );
103
-  }
104
-
105
-#endif
106
-
107
-/**
108
  * Delta Inverse Kinematics
86
  * Delta Inverse Kinematics
109
  *
87
  *
110
  * Calculate the tower positions for a given machine
88
  * Calculate the tower positions for a given machine

+ 0
- 13
Marlin/src/module/delta.h View File

46
 void recalc_delta_settings();
46
 void recalc_delta_settings();
47
 
47
 
48
 /**
48
 /**
49
- * Get a safe radius for calibration
50
- */
51
-#if ENABLED(DELTA_AUTO_CALIBRATION)
52
-  extern float calibration_radius_factor;
53
-#else
54
-  constexpr float calibration_radius_factor = 1;
55
-#endif
56
-
57
-#if EITHER(DELTA_AUTO_CALIBRATION, DELTA_CALIBRATION_MENU)
58
-  float delta_calibration_radius();
59
-#endif
60
-
61
-/**
62
  * Delta Inverse Kinematics
49
  * Delta Inverse Kinematics
63
  *
50
  *
64
  * Calculate the tower positions for a given machine
51
  * Calculate the tower positions for a given machine

Loading…
Cancel
Save