|
@@ -135,6 +135,15 @@ static void G33_cleanup(
|
135
|
135
|
#endif
|
136
|
136
|
}
|
137
|
137
|
|
|
138
|
+inline float calibration_probe(const float nx, const float ny, const bool stow) {
|
|
139
|
+ #if HAS_BED_PROBE
|
|
140
|
+ return probe_pt(nx, ny, stow, 0, false);
|
|
141
|
+ #else
|
|
142
|
+ UNUSED(stow);
|
|
143
|
+ return lcd_probe_pt(nx, ny);
|
|
144
|
+ #endif
|
|
145
|
+}
|
|
146
|
+
|
138
|
147
|
static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points, const bool towers_set, const bool stow_after_each) {
|
139
|
148
|
const bool _0p_calibration = probe_points == 0,
|
140
|
149
|
_1p_calibration = probe_points == 1,
|
|
@@ -153,23 +162,13 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
153
|
162
|
_7p_6_centre = probe_points >= 5 && probe_points <= 7,
|
154
|
163
|
_7p_9_centre = probe_points >= 8;
|
155
|
164
|
|
156
|
|
- #if HAS_BED_PROBE
|
157
|
|
- const float dx = (X_PROBE_OFFSET_FROM_EXTRUDER),
|
158
|
|
- dy = (Y_PROBE_OFFSET_FROM_EXTRUDER);
|
159
|
|
- #endif
|
160
|
|
-
|
161
|
165
|
LOOP_CAL_ALL(axis) z_at_pt[axis] = 0.0;
|
162
|
166
|
|
163
|
167
|
if (!_0p_calibration) {
|
164
|
168
|
|
165
|
169
|
if (!_7p_no_intermediates && !_7p_4_intermediates && !_7p_11_intermediates) { // probe the center
|
166
|
|
- z_at_pt[CEN] +=
|
167
|
|
- #if HAS_BED_PROBE
|
168
|
|
- probe_pt(dx, dy, stow_after_each, 1, false)
|
169
|
|
- #else
|
170
|
|
- lcd_probe_pt(0, 0)
|
171
|
|
- #endif
|
172
|
|
- ;
|
|
170
|
+ z_at_pt[CEN] += calibration_probe(0, 0, stow_after_each);
|
|
171
|
+ if (isnan(z_at_pt[CEN])) return NAN;
|
173
|
172
|
}
|
174
|
173
|
|
175
|
174
|
if (_7p_calibration) { // probe extra center points
|
|
@@ -178,14 +177,9 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
178
|
177
|
I_LOOP_CAL_PT(axis, start, steps) {
|
179
|
178
|
const float a = RADIANS(210 + (360 / NPP) * (axis - 1)),
|
180
|
179
|
r = delta_calibration_radius * 0.1;
|
181
|
|
- z_at_pt[CEN] +=
|
182
|
|
- #if HAS_BED_PROBE
|
183
|
|
- probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1, false)
|
184
|
|
- #else
|
185
|
|
- lcd_probe_pt(cos(a) * r, sin(a) * r)
|
186
|
|
- #endif
|
187
|
|
- ;
|
188
|
|
- }
|
|
180
|
+ z_at_pt[CEN] += calibration_probe(cos(a) * r, sin(a) * r, stow_after_each);
|
|
181
|
+ if (isnan(z_at_pt[CEN])) return NAN;
|
|
182
|
+ }
|
189
|
183
|
z_at_pt[CEN] /= float(_7p_2_intermediates ? 7 : probe_points);
|
190
|
184
|
}
|
191
|
185
|
|
|
@@ -206,14 +200,9 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
206
|
200
|
for (int8_t circle = -offset; circle <= offset; circle++) {
|
207
|
201
|
const float a = RADIANS(210 + (360 / NPP) * (axis - 1)),
|
208
|
202
|
r = delta_calibration_radius * (1 + 0.1 * (zig_zag ? circle : - circle)),
|
209
|
|
- interpol = FMOD(axis, 1);
|
210
|
|
- const float z_temp =
|
211
|
|
- #if HAS_BED_PROBE
|
212
|
|
- probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1, false)
|
213
|
|
- #else
|
214
|
|
- lcd_probe_pt(cos(a) * r, sin(a) * r)
|
215
|
|
- #endif
|
216
|
|
- ;
|
|
203
|
+ interpol = fmod(axis, 1);
|
|
204
|
+ const float z_temp = calibration_probe(cos(a) * r, sin(a) * r, stow_after_each);
|
|
205
|
+ if (isnan(z_temp)) return NAN;
|
217
|
206
|
// split probe point to neighbouring calibration points
|
218
|
207
|
z_at_pt[uint8_t(round(axis - interpol + NPP - 1)) % NPP + 1] += z_temp * sq(cos(RADIANS(interpol * 90)));
|
219
|
208
|
z_at_pt[uint8_t(round(axis - interpol)) % NPP + 1] += z_temp * sq(sin(RADIANS(interpol * 90)));
|
|
@@ -243,7 +232,7 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
243
|
232
|
|
244
|
233
|
#if HAS_BED_PROBE
|
245
|
234
|
|
246
|
|
- static void G33_auto_tune() {
|
|
235
|
+ static bool G33_auto_tune() {
|
247
|
236
|
float z_at_pt[NPP + 1] = { 0.0 },
|
248
|
237
|
z_at_pt_base[NPP + 1] = { 0.0 },
|
249
|
238
|
z_temp, h_fac = 0.0, r_fac = 0.0, a_fac = 0.0, norm = 0.8;
|
|
@@ -257,7 +246,7 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
257
|
246
|
|
258
|
247
|
SERIAL_PROTOCOLPGM("AUTO TUNE baseline");
|
259
|
248
|
SERIAL_EOL();
|
260
|
|
- probe_G33_points(z_at_pt_base, 3, true, false);
|
|
249
|
+ if (isnan(probe_G33_points(z_at_pt_base, 3, true, false))) return false;
|
261
|
250
|
print_G33_results(z_at_pt_base, true, true);
|
262
|
251
|
|
263
|
252
|
LOOP_XYZ(axis) {
|
|
@@ -272,7 +261,7 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
272
|
261
|
SERIAL_CHAR(tolower(axis_codes[axis]));
|
273
|
262
|
SERIAL_EOL();
|
274
|
263
|
|
275
|
|
- probe_G33_points(z_at_pt, 3, true, false);
|
|
264
|
+ if (isnan(probe_G33_points(z_at_pt, 3, true, false))) return false;
|
276
|
265
|
LOOP_CAL_ALL(axis) z_at_pt[axis] -= z_at_pt_base[axis];
|
277
|
266
|
print_G33_results(z_at_pt, true, true);
|
278
|
267
|
delta_endstop_adj[axis] += 1.0;
|
|
@@ -303,7 +292,7 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
303
|
292
|
SERIAL_PROTOCOLPGM("Tuning R");
|
304
|
293
|
SERIAL_PROTOCOL(zig_zag == -1 ? "-" : "+");
|
305
|
294
|
SERIAL_EOL();
|
306
|
|
- probe_G33_points(z_at_pt, 3, true, false);
|
|
295
|
+ if (isnan(probe_G33_points(z_at_pt, 3, true, false))) return false;
|
307
|
296
|
LOOP_CAL_ALL(axis) z_at_pt[axis] -= z_at_pt_base[axis];
|
308
|
297
|
print_G33_results(z_at_pt, true, true);
|
309
|
298
|
delta_radius -= 1.0 * zig_zag;
|
|
@@ -330,7 +319,7 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
330
|
319
|
SERIAL_CHAR(tolower(axis_codes[axis]));
|
331
|
320
|
SERIAL_EOL();
|
332
|
321
|
|
333
|
|
- probe_G33_points(z_at_pt, 3, true, false);
|
|
322
|
+ if (isnan(probe_G33_points(z_at_pt, 3, true, false))) return false;
|
334
|
323
|
LOOP_CAL_ALL(axis) z_at_pt[axis] -= z_at_pt_base[axis];
|
335
|
324
|
print_G33_results(z_at_pt, true, true);
|
336
|
325
|
|
|
@@ -365,6 +354,7 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
365
|
354
|
SERIAL_EOL();
|
366
|
355
|
SERIAL_PROTOCOLPGM("Copy these values to Configuration.h");
|
367
|
356
|
SERIAL_EOL();
|
|
357
|
+ return true;
|
368
|
358
|
}
|
369
|
359
|
|
370
|
360
|
#endif // HAS_BED_PROBE
|
|
@@ -392,8 +382,9 @@ static float probe_G33_points(float z_at_pt[NPP + 1], const int8_t probe_points,
|
392
|
382
|
*
|
393
|
383
|
* Vn Verbose level:
|
394
|
384
|
* V0 Dry-run mode. Report settings and probe results. No calibration.
|
395
|
|
- * V1 Report settings
|
396
|
|
- * V2 Report settings and probe results
|
|
385
|
+ * V1 Report start and end settings only
|
|
386
|
+ * V2 Report settings at each iteration
|
|
387
|
+ * V3 Report settings and probe results
|
397
|
388
|
*
|
398
|
389
|
* E Engage the probe for each point
|
399
|
390
|
*/
|
|
@@ -406,12 +397,12 @@ void GcodeSuite::G33() {
|
406
|
397
|
}
|
407
|
398
|
|
408
|
399
|
const int8_t verbose_level = parser.byteval('V', 1);
|
409
|
|
- if (!WITHIN(verbose_level, 0, 2)) {
|
410
|
|
- SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-2).");
|
|
400
|
+ if (!WITHIN(verbose_level, 0, 3)) {
|
|
401
|
+ SERIAL_PROTOCOLLNPGM("?(V)erbose level is implausible (0-3).");
|
411
|
402
|
return;
|
412
|
403
|
}
|
413
|
404
|
|
414
|
|
- const float calibration_precision = parser.floatval('C');
|
|
405
|
+ const float calibration_precision = parser.floatval('C', 0.0);
|
415
|
406
|
if (calibration_precision < 0) {
|
416
|
407
|
SERIAL_PROTOCOLLNPGM("?(C)alibration precision is implausible (>=0).");
|
417
|
408
|
return;
|
|
@@ -519,6 +510,11 @@ void GcodeSuite::G33() {
|
519
|
510
|
// Probe the points
|
520
|
511
|
|
521
|
512
|
zero_std_dev = probe_G33_points(z_at_pt, probe_points, towers_set, stow_after_each);
|
|
513
|
+ if (isnan(zero_std_dev)) {
|
|
514
|
+ SERIAL_PROTOCOLPGM("Correct delta_radius with M665 R or end-stops with M666 X Y Z");
|
|
515
|
+ SERIAL_EOL();
|
|
516
|
+ return G33_CLEANUP();
|
|
517
|
+ }
|
522
|
518
|
|
523
|
519
|
// Solve matrices
|
524
|
520
|
|
|
@@ -632,7 +628,7 @@ void GcodeSuite::G33() {
|
632
|
628
|
|
633
|
629
|
// print report
|
634
|
630
|
|
635
|
|
- if (verbose_level != 1)
|
|
631
|
+ if (verbose_level > 2)
|
636
|
632
|
print_G33_results(z_at_pt, _tower_results, _opposite_results);
|
637
|
633
|
|
638
|
634
|
if (verbose_level != 0) { // !dry run
|
|
@@ -672,7 +668,8 @@ void GcodeSuite::G33() {
|
672
|
668
|
SERIAL_PROTOCOL_F(zero_std_dev, 3);
|
673
|
669
|
SERIAL_EOL();
|
674
|
670
|
lcd_setstatus(mess);
|
675
|
|
- print_G33_settings(_endstop_results, _angle_results);
|
|
671
|
+ if (verbose_level > 1)
|
|
672
|
+ print_G33_settings(_endstop_results, _angle_results);
|
676
|
673
|
}
|
677
|
674
|
}
|
678
|
675
|
else { // dry run
|