Browse Source

Clean up tool-change syncs (#14666)

Scott Lahteine 6 years ago
parent
commit
fac0e63058
No account linked to committer's email address
1 changed files with 35 additions and 41 deletions
  1. 35
    41
      Marlin/src/module/tool_change.cpp

+ 35
- 41
Marlin/src/module/tool_change.cpp View File

486
     // 1. Move to switch position current toolhead
486
     // 1. Move to switch position current toolhead
487
 
487
 
488
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;
488
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_CLEAR;
489
-
490
     if (DEBUGGING(LEVELING)) {
489
     if (DEBUGGING(LEVELING)) {
491
       SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
490
       SERIAL_ECHOLNPAIR("(1) Place old tool ", int(active_extruder));
492
       DEBUG_POS("Move Y SwitchPos + Security", current_position);
491
       DEBUG_POS("Move Y SwitchPos + Security", current_position);
493
     }
492
     }
494
-
495
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
493
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
496
-    planner.synchronize();
497
 
494
 
498
     current_position[X_AXIS] = placexpos + SWITCHING_TOOLHEAD_X_SECURITY;
495
     current_position[X_AXIS] = placexpos + SWITCHING_TOOLHEAD_X_SECURITY;
499
-
500
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move X SwitchPos + Security", current_position);
501
-
496
+    if (DEBUGGING(LEVELING)) {
497
+      planner.synchronize();
498
+      DEBUG_POS("Move X SwitchPos + Security", current_position);
499
+    }
502
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
500
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
503
-    planner.synchronize();
504
 
501
 
505
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
502
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
506
-
507
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
508
-
503
+    if (DEBUGGING(LEVELING)) {
504
+      planner.synchronize();
505
+      DEBUG_POS("Move Y SwitchPos", current_position);
506
+    }
509
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
507
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder);
510
-    planner.synchronize();
511
 
508
 
512
     current_position[X_AXIS] = placexpos;
509
     current_position[X_AXIS] = placexpos;
513
-
514
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move X SwitchPos", current_position);
515
-
510
+    if (DEBUGGING(LEVELING)) {
511
+      planner.synchronize();
512
+      DEBUG_POS("Move X SwitchPos", current_position);
513
+    }
516
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25), active_extruder);
514
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[X_AXIS] * 0.25), active_extruder);
517
-    planner.synchronize();
518
 
515
 
519
     // 2. Release and place toolhead in the dock
516
     // 2. Release and place toolhead in the dock
520
 
517
 
521
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(2) Release and Place Toolhead");
518
+    if (DEBUGGING(LEVELING)) {
519
+      planner.synchronize();
520
+      SERIAL_ECHOLNPGM("(2) Release and Place Toolhead");
521
+    }
522
 
522
 
523
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
523
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
524
-
525
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
524
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
526
-
527
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.1), active_extruder);
525
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.1), active_extruder);
528
-    planner.synchronize();
529
 
526
 
530
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_SECURITY;
527
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_SECURITY;
531
-
532
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Security", current_position);
533
-
528
+    if (DEBUGGING(LEVELING)) {
529
+      planner.synchronize();
530
+      DEBUG_POS("Move Y SwitchPos + Security", current_position);
531
+    }
534
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
532
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
535
-    planner.synchronize();
536
 
533
 
537
     // 3. Move to new toolhead position
534
     // 3. Move to new toolhead position
538
 
535
 
539
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(3) Move to new toolhead position");
536
+    if (DEBUGGING(LEVELING)) {
537
+      planner.synchronize();
538
+      SERIAL_ECHOLNPGM("(3) Move to new toolhead position");
539
+    }
540
 
540
 
541
     current_position[X_AXIS] = grabxpos;
541
     current_position[X_AXIS] = grabxpos;
542
-
543
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
542
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X", current_position);
544
-
545
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
543
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS], active_extruder);
546
-    planner.synchronize();
547
 
544
 
548
     // 4. Grab the new toolhead and move to security position
545
     // 4. Grab the new toolhead and move to security position
549
 
546
 
550
-    if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("(4) Grab new toolhead and move to security position");
547
+    if (DEBUGGING(LEVELING)) {
548
+      planner.synchronize();
549
+      SERIAL_ECHOLNPGM("(4) Grab new toolhead and move to security position");
550
+    }
551
 
551
 
552
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
552
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS + SWITCHING_TOOLHEAD_Y_RELEASE;
553
-
554
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
553
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos + Release", current_position);
555
-
556
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
554
     planner.buffer_line(current_position, (planner.settings.max_feedrate_mm_s[Y_AXIS]), active_extruder);
557
-    planner.synchronize();
558
 
555
 
559
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
556
     current_position[Y_AXIS] = SWITCHING_TOOLHEAD_Y_POS;
560
-
561
-    if (DEBUGGING(LEVELING)) DEBUG_POS("Move Y SwitchPos", current_position);
562
-
557
+    if (DEBUGGING(LEVELING)) {
558
+      planner.synchronize();
559
+      DEBUG_POS("Move Y SwitchPos", current_position);
560
+    }
563
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.2, active_extruder);
561
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS] * 0.2, active_extruder);
564
     planner.synchronize();
562
     planner.synchronize();
565
-    safe_delay(100);
563
+    safe_delay(100); // Give switch time to settle
566
 
564
 
567
     current_position[X_AXIS] = grabxpos + SWITCHING_TOOLHEAD_X_SECURITY;
565
     current_position[X_AXIS] = grabxpos + SWITCHING_TOOLHEAD_X_SECURITY;
568
-
569
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X + Security", current_position);
566
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move to new toolhead X + Security", current_position);
570
-
571
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.1, active_extruder);
567
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[X_AXIS] * 0.1, active_extruder);
572
     planner.synchronize();
568
     planner.synchronize();
573
-    safe_delay(100);
569
+    safe_delay(100); // Give switch time to settle
574
 
570
 
575
     current_position[Y_AXIS] += SWITCHING_TOOLHEAD_Y_CLEAR;
571
     current_position[Y_AXIS] += SWITCHING_TOOLHEAD_Y_CLEAR;
576
-
577
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
572
     if (DEBUGGING(LEVELING)) DEBUG_POS("Move back Y clear", current_position);
578
-
579
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
573
     planner.buffer_line(current_position, planner.settings.max_feedrate_mm_s[Y_AXIS], active_extruder); // move away from docked toolhead
580
-    planner.synchronize();
574
+    planner.synchronize(); // Always sync last tool-change move
581
   }
575
   }
582
 
576
 
583
 #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
577
 #elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)

Loading…
Cancel
Save