Browse Source

Remove extra Z raises in tool change (#13782)

chai-md 6 years ago
parent
commit
78d7349fd7
1 changed files with 48 additions and 77 deletions
  1. 48
    77
      Marlin/src/module/tool_change.cpp

+ 48
- 77
Marlin/src/module/tool_change.cpp View File

@@ -280,47 +280,37 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
280 280
                   grabpos = parkingposx[tmp_extruder] + (tmp_extruder ? PARKING_EXTRUDER_GRAB_DISTANCE : -(PARKING_EXTRUDER_GRAB_DISTANCE)) + x_offset;
281 281
 
282 282
       /**
283
-       * 1. Raise Z-Axis to give enough clearance
284
-       * 2. Move to park position of old extruder
285
-       * 3. Disengage magnetic field, wait for delay
286
-       * 4. Move near new extruder
287
-       * 5. Engage magnetic field for new extruder
288
-       * 6. Move to parking incl. offset of new extruder
289
-       * 7. Lower Z-Axis
283
+       * 1. Move to park position of old extruder
284
+       * 2. Disengage magnetic field, wait for delay
285
+       * 3. Move near new extruder
286
+       * 4. Engage magnetic field for new extruder
287
+       * 5. Move to parking incl. offset of new extruder
288
+       * 6. Lower Z-Axis
290 289
        */
291 290
 
292 291
       // STEP 1
293 292
 
294 293
       if (DEBUGGING(LEVELING)) DEBUG_POS("Start Autopark", current_position);
295 294
 
296
-      current_position[Z_AXIS] += toolchange_settings.z_raise;
297
-
298
-      if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
299
-
300
-      fast_line_to_current(Z_AXIS);
301
-      planner.synchronize();
302
-
303
-      // STEP 2
304
-
305 295
       current_position[X_AXIS] = parkingposx[active_extruder] + x_offset;
306 296
 
307 297
       if (DEBUGGING(LEVELING)) {
308
-        DEBUG_ECHOLNPAIR("(2) Park extruder ", int(active_extruder));
298
+        DEBUG_ECHOLNPAIR("(1) Park extruder ", int(active_extruder));
309 299
         DEBUG_POS("Moving ParkPos", current_position);
310 300
       }
311 301
 
312 302
       fast_line_to_current(X_AXIS);
313 303
       planner.synchronize();
314 304
 
315
-      // STEP 3
305
+      // STEP 2
316 306
 
317
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Disengage magnet ");
307
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Disengage magnet ");
318 308
 
319 309
       pe_deactivate_solenoid(active_extruder);
320 310
 
321
-      // STEP 4
311
+      // STEP 3
322 312
 
323
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to position near new extruder");
313
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Move to position near new extruder");
324 314
 
325 315
       current_position[X_AXIS] += active_extruder ? -10 : 10; // move 10mm away from parked extruder
326 316
 
@@ -329,8 +319,8 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
329 319
       fast_line_to_current(X_AXIS);
330 320
       planner.synchronize();
331 321
 
332
-      // STEP 5
333
-      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Engage magnetic field");
322
+      // STEP 4
323
+      if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Engage magnetic field");
334 324
 
335 325
       #if ENABLED(PARKING_EXTRUDER_SOLENOIDS_INVERT)
336 326
         pe_activate_solenoid(active_extruder); //just save power for inverted magnets
@@ -338,16 +328,16 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
338 328
 
339 329
       pe_activate_solenoid(tmp_extruder);
340 330
 
341
-      // STEP 6
331
+      // STEP 5
342 332
 
343 333
       current_position[X_AXIS] = grabpos + (tmp_extruder ? -10 : 10);
344 334
       fast_line_to_current(X_AXIS);
345 335
       current_position[X_AXIS] = grabpos;
346
-      if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Unpark extruder", current_position);
336
+      if (DEBUGGING(LEVELING)) DEBUG_POS("(5) Unpark extruder", current_position);
347 337
       planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.5, active_extruder);
348 338
       planner.synchronize();
349 339
 
350
-      // STEP 7
340
+      // STEP 6
351 341
 
352 342
       current_position[X_AXIS] = midpos
353 343
         #if HAS_HOTEND_OFFSET
@@ -355,7 +345,7 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
355 345
         #endif
356 346
       ;
357 347
 
358
-      if (DEBUGGING(LEVELING)) DEBUG_POS("(7) Move midway between hotends", current_position);
348
+      if (DEBUGGING(LEVELING)) DEBUG_POS("(6) Move midway between hotends", current_position);
359 349
 
360 350
       fast_line_to_current(X_AXIS);
361 351
       planner.synchronize();
@@ -385,30 +375,20 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
385 375
                 grabxpos = toolheadposx[tmp_extruder];
386 376
 
387 377
     /**
388
-     * 1. Raise Z to give enough clearance
389
-     * 2. Move to switch position of current toolhead
390
-     * 3. Unlock tool and drop it in the dock
391
-     * 4. Move to the new toolhead
392
-     * 5. Grab and lock the new toolhead
378
+     * 1. Move to switch position of current toolhead
379
+     * 2. Unlock tool and drop it in the dock
380
+     * 3. Move to the new toolhead
381
+     * 4. Grab and lock the new toolhead
393 382
      */
394 383
 
395
-    // 1. Raise Z to give enough clearance
384
+    // 1. Move to switch position of current toolhead
396 385
 
397 386
     if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
398 387
 
399
-    current_position[Z_AXIS] += toolchange_settings.z_raise;
400
-
401
-    if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
402
-
403
-    fast_line_to_current(Z_AXIS);
404
-    planner.synchronize();
405
-
406
-    // 2. Move to switch position of current toolhead
407
-
408 388
     current_position[X_AXIS] = placexpos;
409 389
 
410 390
     if (DEBUGGING(LEVELING)) {
411
-      DEBUG_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
391
+      DEBUG_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
412 392
       DEBUG_POS("Move X SwitchPos", current_position);
413 393
     }
414 394
 
@@ -422,9 +402,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
422 402
     fast_line_to_current(Y_AXIS);
423 403
     planner.synchronize();
424 404
 
425
-    // 3. Unlock tool and drop it in the dock
405
+    // 2. Unlock tool and drop it in the dock
426 406
 
427
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Unlock and Place Toolhead");
407
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(2) Unlock and Place Toolhead");
428 408
 
429 409
     MOVE_SERVO(SWITCHING_TOOLHEAD_SERVO_NR, angles[1]);
430 410
     safe_delay(500);
@@ -443,9 +423,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
443 423
     fast_line_to_current(Y_AXIS); // move away from docked toolhead
444 424
     planner.synchronize();
445 425
 
446
-    // 4. Move to the new toolhead
426
+    // 3. Move to the new toolhead
447 427
 
448
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Move to new toolhead position");
428
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(3) Move to new toolhead position");
449 429
 
450 430
     current_position[X_AXIS] = grabxpos;
451 431
 
@@ -460,9 +440,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
460 440
     fast_line_to_current(Y_AXIS);
461 441
     planner.synchronize();
462 442
 
463
-    // 5. Grab and lock the new toolhead
443
+    // 4. Grab and lock the new toolhead
464 444
 
465
-    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(5) Grab and lock new toolhead ");
445
+    if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("(4) Grab and lock new toolhead ");
466 446
 
467 447
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
468 448
 
@@ -497,30 +477,20 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
497 477
                 grabxpos = toolheadposx[tmp_extruder];
498 478
 
499 479
     /**
500
-     * 1. Raise Z to give enough clearance
501
-     * 2. Move to switch position of current toolhead
502
-     * 3. Release and place toolhead in the dock
503
-     * 4. Move to the new toolhead
504
-     * 5. Grab the new toolhead and move to security position
480
+     * 1. Move to switch position of current toolhead
481
+     * 2. Release and place toolhead in the dock
482
+     * 3. Move to the new toolhead
483
+     * 4. Grab the new toolhead and move to security position
505 484
      */
506 485
 
507 486
     if (DEBUGGING(LEVELING)) DEBUG_POS("Starting Toolhead change", current_position);
508 487
 
509
-    // 1. Raise Z to give enough clearance
510
-
511
-    current_position[Z_AXIS] += toolchange_settings.z_raise;
512
-
513
-    if (DEBUGGING(LEVELING)) DEBUG_POS("(1) Raise Z-Axis", current_position);
514
-
515
-    planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Z_AXIS], active_extruder);
516
-    planner.synchronize();
517
-
518
-    // 2. Move to switch position current toolhead
488
+    // 1. Move to switch position current toolhead
519 489
 
520 490
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;
521 491
 
522 492
     if (DEBUGGING(LEVELING)) {
523
-      SERIAL_ECHOLNPAIR("(2) Place old tool ", int(active_extruder));
493
+      SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
524 494
       DEBUG_POS("Move Y SwitchPos + Security", current_position);
525 495
     }
526 496
 
@@ -548,9 +518,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
548 518
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25), active_extruder);
549 519
     planner.synchronize();
550 520
 
551
-    // 3. Release and place toolhead in the dock
521
+    // 2. Release and place toolhead in the dock
552 522
 
553
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Release and Place Toolhead");
523
+    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(2) Release and Place Toolhead");
554 524
 
555 525
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
556 526
 
@@ -566,9 +536,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
566 536
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
567 537
     planner.synchronize();
568 538
 
569
-    // 4. Move to new toolhead position
539
+    // 3. Move to new toolhead position
570 540
 
571
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Move to new toolhead position");
541
+    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Move to new toolhead position");
572 542
 
573 543
     current_position[X_AXIS] = grabxpos;
574 544
 
@@ -577,9 +547,9 @@ inline void fast_line_to_current(const AxisEnum fr_axis) {
577 547
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
578 548
     planner.synchronize();
579 549
 
580
-    // 5. Grab the new toolhead and move to security position
550
+    // 4. Grab the new toolhead and move to security position
581 551
 
582
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(5) Grab new toolhead and move to security position");
552
+    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Grab new toolhead and move to security position");
583 553
 
584 554
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
585 555
 
@@ -785,14 +755,15 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
785 755
       if (!no_move) {
786 756
         #if DISABLED(SWITCHING_NOZZLE)
787 757
           // Do a small lift to avoid the workpiece in the move back (below)
788
-          #if ENABLED(TOOLCHANGE_PARK)
789
-            current_position[X_AXIS] = toolchange_settings.change_point.x;
790
-            current_position[Y_AXIS] = toolchange_settings.change_point.y;
791
-          #endif
792 758
           current_position[Z_AXIS] += toolchange_settings.z_raise;
793 759
           #if HAS_SOFTWARE_ENDSTOPS
794 760
             NOMORE(current_position[Z_AXIS], soft_endstop[Z_AXIS].max);
795 761
           #endif
762
+          fast_line_to_current(Z_AXIS);
763
+          #if ENABLED(TOOLCHANGE_PARK)
764
+            current_position[X_AXIS] = toolchange_settings.change_point.x;
765
+            current_position[Y_AXIS] = toolchange_settings.change_point.y;
766
+          #endif
796 767
           planner.buffer_line(current_position, feedrate_mm_s, active_extruder);
797 768
         #endif
798 769
         planner.synchronize();
@@ -875,10 +846,10 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
875 846
         #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
876 847
           if (should_swap && !too_cold) {
877 848
             #if ENABLED(ADVANCED_PAUSE_FEATURE)
878
-              do_pause_e_move(toolchange_settings.swap_length + TOOLCHANGE_FIL_EXTRA_PRIME, toolchange_settings.prime_speed);
849
+              do_pause_e_move(toolchange_settings.swap_length + TOOLCHANGE_FIL_EXTRA_PRIME, MMM_TO_MMS(toolchange_settings.prime_speed));
879 850
             #else
880 851
               current_position[E_AXIS] += (toolchange_settings.swap_length + TOOLCHANGE_FIL_EXTRA_PRIME) / planner.e_factor[tmp_extruder];
881
-              planner.buffer_line(current_position, toolchange_settings.prime_speed, tmp_extruder);
852
+              planner.buffer_line(current_position, MMM_TO_MMS(toolchange_settings.prime_speed), tmp_extruder);
882 853
             #endif
883 854
             planner.synchronize();
884 855
 

Loading…
Cancel
Save