Explorar el Código

Prevent a tool change move out of bounds

Scott Lahteine hace 6 años
padre
commit
bc87e97357
Se han modificado 1 ficheros con 29 adiciones y 23 borrados
  1. 29
    23
      Marlin/src/module/tool_change.cpp

+ 29
- 23
Marlin/src/module/tool_change.cpp Ver fichero

@@ -126,6 +126,10 @@
126 126
 
127 127
 #endif // SWITCHING_NOZZLE
128 128
 
129
+inline void fast_line_to_current(const AxisEnum fr_axis) {
130
+  planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[fr_axis], active_extruder);
131
+}
132
+
129 133
 #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
130 134
 
131 135
   float parkingposx[2] ,           // M951 R L
@@ -308,7 +312,7 @@
308 312
         if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
309 313
       #endif
310 314
 
311
-      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
315
+      fast_line_to_current(Z_AXIS);
312 316
       planner.synchronize();
313 317
 
314 318
       // STEP 2
@@ -322,7 +326,7 @@
322 326
         }
323 327
       #endif
324 328
 
325
-      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
329
+      fast_line_to_current(X_AXIS);
326 330
       planner.synchronize();
327 331
 
328 332
       // STEP 3
@@ -345,7 +349,7 @@
345 349
         if (DEBUGGING(LEVELING)) DEBUG_POS("Move away from parked extruder", current_position);
346 350
       #endif
347 351
 
348
-      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
352
+      fast_line_to_current(X_AXIS);
349 353
       planner.synchronize();
350 354
 
351 355
       // STEP 5
@@ -362,12 +366,12 @@
362 366
       // STEP 6
363 367
 
364 368
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
365
-      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
369
+      fast_line_to_current(X_AXIS);
366 370
       current_position[X_AXIS] = grabpos;
367 371
       #if ENABLED(DEBUG_LEVELING_FEATURE)
368 372
         if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
369 373
       #endif
370
-      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS]/2, active_extruder);
374
+      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
371 375
       planner.synchronize();
372 376
 
373 377
       // STEP 7
@@ -382,7 +386,7 @@
382 386
         if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
383 387
       #endif
384 388
 
385
-      planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
389
+      fast_line_to_current(X_AXIS);
386 390
       planner.synchronize();
387 391
 
388 392
       #if ENABLED(DEBUG_LEVELING_FEATURE)
@@ -428,7 +432,7 @@
428 432
      * 6. Apply the z-offset of the new toolhead
429 433
      */
430 434
 
431
-    // STEP 1
435
+    // 1. Raise Z to give enough clearance
432 436
 
433 437
     #if ENABLED(DEBUG_LEVELING_FEATURE)
434 438
       if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
@@ -440,10 +444,10 @@
440 444
       if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
441 445
     #endif
442 446
 
443
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
447
+    fast_line_to_current(Z_AXIS);
444 448
     planner.synchronize();
445 449
 
446
-    // STEP 2
450
+    // 2. Move to switch position of current toolhead
447 451
 
448 452
     current_position[X_AXIS] = placexpos;
449 453
 
@@ -454,7 +458,7 @@
454 458
       }
455 459
     #endif
456 460
 
457
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
461
+    fast_line_to_current(X_AXIS);
458 462
     planner.synchronize();
459 463
 
460 464
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
@@ -463,10 +467,10 @@
463 467
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
464 468
     #endif
465 469
 
466
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
470
+    fast_line_to_current(Y_AXIS);
467 471
     planner.synchronize();
468 472
 
469
-    // STEP 3
473
+    // 3. Unlock tool and drop it in the dock
470 474
 
471 475
     #if ENABLED(DEBUG_LEVELING_FEATURE)
472 476
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Unlock and Place Toolhead");
@@ -490,10 +494,10 @@
490 494
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
491 495
     #endif
492 496
 
493
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
497
+    fast_line_to_current(Y_AXIS); // move away from docked toolhead
494 498
     planner.synchronize();
495 499
 
496
-    // STEP 4
500
+    // 4. Move to the new toolhead
497 501
 
498 502
     #if ENABLED(DEBUG_LEVELING_FEATURE)
499 503
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
@@ -505,7 +509,7 @@
505 509
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
506 510
     #endif
507 511
 
508
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
512
+    fast_line_to_current(X_AXIS);
509 513
     planner.synchronize();
510 514
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS - SWITCHING_TOOLHEAD_Y_SECURITY;
511 515
 
@@ -513,10 +517,10 @@
513 517
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
514 518
     #endif
515 519
 
516
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
520
+    fast_line_to_current(Y_AXIS);
517 521
     planner.synchronize();
518 522
 
519
-    // STEP 5
523
+    // 5. Grab and lock the new toolhead
520 524
 
521 525
     #if ENABLED(DEBUG_LEVELING_FEATURE)
522 526
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab and lock new toolhead ");
@@ -541,10 +545,10 @@
541 545
       if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
542 546
     #endif
543 547
 
544
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
548
+    fast_line_to_current(Y_AXIS); // move away from docked toolhead
545 549
     planner.synchronize();
546 550
 
547
-    // STEP 6
551
+    // 6. Apply the z-offset of the new toolhead
548 552
 
549 553
     #if HAS_HOTEND_OFFSET
550 554
       current_position[Z_AXIS] += hotend_offset[Z_AXIS][active_extruder] - hotend_offset[Z_AXIS][tmp_extruder];
@@ -589,9 +593,7 @@ inline void invalid_extruder_error(const uint8_t e) {
589 593
     ) {
590 594
 
591 595
       #if ENABLED(DEBUG_LEVELING_FEATURE)
592
-        if (DEBUGGING(LEVELING)) {
593
-          SERIAL_ECHOLNPAIR("MoveX to ", xhome);
594
-        }
596
+        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("MoveX to ", xhome);
595 597
       #endif
596 598
       // Park old head
597 599
       planner.buffer_line(xhome, current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
@@ -797,7 +799,7 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
797 799
         #if HAS_SOFTWARE_ENDSTOPS
798 800
           NOMORE(current_position[Z_AXIS], soft_endstop_max[Z_AXIS]);
799 801
         #endif
800
-        if (!no_move)planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
802
+        if (!no_move) fast_line_to_current(Z_AXIS);
801 803
         move_nozzle_servo(tmp_extruder);
802 804
       #endif
803 805
 
@@ -867,8 +869,12 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
867 869
           }
868 870
         #endif
869 871
 
872
+        // Prevent a move outside physical bounds
873
+        clamp_to_software_endstops(destination);
874
+
870 875
         // Move back to the original (or tweaked) position
871 876
         do_blocking_move_to(destination);
877
+
872 878
         #if ENABLED(DUAL_X_CARRIAGE)
873 879
           active_extruder_parked = false;
874 880
         #endif

Loading…
Cancelar
Guardar