Browse Source

Merge pull request #4308 from thinkyhead/rc_debug_gcode_t

Added logging related to gcode_T
Scott Lahteine 8 years ago
parent
commit
cec7110409
1 changed files with 130 additions and 52 deletions
  1. 130
    52
      Marlin/Marlin_main.cpp

+ 130
- 52
Marlin/Marlin_main.cpp View File

1435
     sw_endstop_min[axis] = base_min_pos(axis) + offs;
1435
     sw_endstop_min[axis] = base_min_pos(axis) + offs;
1436
     sw_endstop_max[axis] = base_max_pos(axis) + offs;
1436
     sw_endstop_max[axis] = base_max_pos(axis) + offs;
1437
   }
1437
   }
1438
-
1438
+  #if ENABLED(DEBUG_LEVELING_FEATURE)
1439
+    if (DEBUGGING(LEVELING)) {
1440
+      SERIAL_ECHOPAIR("For ", axis_codes[axis]);
1441
+      SERIAL_ECHOPAIR(" axis:\n home_offset = ", home_offset[axis]);
1442
+      SERIAL_ECHOPAIR("\n position_shift = ", position_shift[axis]);
1443
+      SERIAL_ECHOPAIR("\n sw_endstop_min = ", sw_endstop_min[axis]);
1444
+      SERIAL_ECHOPAIR("\n sw_endstop_max = ", sw_endstop_max[axis]);
1445
+      SERIAL_EOL;
1446
+    }
1447
+  #endif
1439
 }
1448
 }
1440
 
1449
 
1441
 /**
1450
 /**
1524
         current_position[Z_AXIS] -= zprobe_zoffset;
1533
         current_position[Z_AXIS] -= zprobe_zoffset;
1525
         #if ENABLED(DEBUG_LEVELING_FEATURE)
1534
         #if ENABLED(DEBUG_LEVELING_FEATURE)
1526
           if (DEBUGGING(LEVELING)) {
1535
           if (DEBUGGING(LEVELING)) {
1527
-            SERIAL_ECHOPAIR("> zprobe_zoffset==", zprobe_zoffset);
1536
+            SERIAL_ECHOPAIR("> zprobe_zoffset = ", zprobe_zoffset);
1528
             SERIAL_EOL;
1537
             SERIAL_EOL;
1529
           }
1538
           }
1530
         #endif
1539
         #endif
1533
 
1542
 
1534
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1543
     #if ENABLED(DEBUG_LEVELING_FEATURE)
1535
       if (DEBUGGING(LEVELING)) {
1544
       if (DEBUGGING(LEVELING)) {
1536
-        SERIAL_ECHOPAIR("> home_offset[axis]==", home_offset[axis]);
1545
+        SERIAL_ECHOPAIR("> home_offset[", axis_codes[axis]);
1546
+        SERIAL_ECHOPAIR("] = ", home_offset[axis]);
1537
         SERIAL_EOL;
1547
         SERIAL_EOL;
1538
         DEBUG_POS("", current_position);
1548
         DEBUG_POS("", current_position);
1539
       }
1549
       }
1725
 
1735
 
1726
 #endif //HAS_BED_PROBE
1736
 #endif //HAS_BED_PROBE
1727
 
1737
 
1728
-#if ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE
1738
+#if ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE || HOTENDS > 1
1729
   static bool axis_unhomed_error(const bool x, const bool y, const bool z) {
1739
   static bool axis_unhomed_error(const bool x, const bool y, const bool z) {
1730
     const bool xx = x && !axis_homed[X_AXIS],
1740
     const bool xx = x && !axis_homed[X_AXIS],
1731
                yy = y && !axis_homed[Y_AXIS],
1741
                yy = y && !axis_homed[Y_AXIS],
6541
 
6551
 
6542
     if (tmp_extruder != active_extruder) {
6552
     if (tmp_extruder != active_extruder) {
6543
       bool no_move = code_seen('S') && code_value_bool();
6553
       bool no_move = code_seen('S') && code_value_bool();
6544
-      // Save current position to return to after applying extruder offset
6545
-      if (!no_move) set_destination_to_current();
6554
+      if (!no_move && axis_unhomed_error(true, true, true)) {
6555
+        SERIAL_ECHOLNPGM("No move on toolchange");
6556
+        no_move = true;
6557
+      }
6558
+
6559
+      // Save current position to destination, for use later
6560
+      set_destination_to_current();
6561
+
6546
       #if ENABLED(DUAL_X_CARRIAGE)
6562
       #if ENABLED(DUAL_X_CARRIAGE)
6547
-        if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && IsRunning() &&
6548
-            (delayed_move_time || current_position[X_AXIS] != x_home_pos(active_extruder))) {
6563
+
6564
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
6565
+          if (DEBUGGING(LEVELING)) {
6566
+            SERIAL_ECHOPGM("Dual X Carriage Mode ");
6567
+            switch (dual_x_carriage_mode) {
6568
+              case DXC_DUPLICATION_MODE: SERIAL_ECHOLNPGM("DXC_DUPLICATION_MODE"); break;
6569
+              case DXC_AUTO_PARK_MODE: SERIAL_ECHOLNPGM("DXC_AUTO_PARK_MODE"); break;
6570
+              case DXC_FULL_CONTROL_MODE: SERIAL_ECHOLNPGM("DXC_FULL_CONTROL_MODE"); break;
6571
+            }
6572
+          }
6573
+        #endif
6574
+
6575
+        if (dual_x_carriage_mode == DXC_AUTO_PARK_MODE && IsRunning()
6576
+             && (delayed_move_time || current_position[X_AXIS] != x_home_pos(active_extruder))
6577
+           ) {
6578
+          #if ENABLED(DEBUG_LEVELING_FEATURE)
6579
+            if (DEBUGGING(LEVELING)) {
6580
+              SERIAL_ECHOPAIR("Raise to ", current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT); SERIAL_EOL;
6581
+              SERIAL_ECHOPAIR("MoveX to ", x_home_pos(active_extruder)); SERIAL_EOL;
6582
+              SERIAL_ECHOPAIR("Lower to ", current_position[Z_AXIS]); SERIAL_EOL;
6583
+            }
6584
+          #endif
6549
           // Park old head: 1) raise 2) move to park position 3) lower
6585
           // Park old head: 1) raise 2) move to park position 3) lower
6550
           planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
6586
           planner.buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + TOOLCHANGE_PARK_ZLIFT,
6551
                            current_position[E_AXIS], planner.max_feedrate[Z_AXIS], active_extruder);
6587
                            current_position[E_AXIS], planner.max_feedrate[Z_AXIS], active_extruder);
6564
         // This function resets the max/min values - the current position may be overwritten below.
6600
         // This function resets the max/min values - the current position may be overwritten below.
6565
         set_axis_is_at_home(X_AXIS);
6601
         set_axis_is_at_home(X_AXIS);
6566
 
6602
 
6567
-        if (dual_x_carriage_mode == DXC_FULL_CONTROL_MODE) {
6568
-          current_position[X_AXIS] = inactive_extruder_x_pos;
6569
-          inactive_extruder_x_pos = destination[X_AXIS];
6570
-        }
6571
-        else if (dual_x_carriage_mode == DXC_DUPLICATION_MODE) {
6572
-          active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
6573
-          if (active_extruder_parked)
6603
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
6604
+          if (DEBUGGING(LEVELING)) DEBUG_POS("New Extruder", current_position);
6605
+        #endif
6606
+
6607
+        switch (dual_x_carriage_mode) {
6608
+          case DXC_FULL_CONTROL_MODE:
6574
             current_position[X_AXIS] = inactive_extruder_x_pos;
6609
             current_position[X_AXIS] = inactive_extruder_x_pos;
6575
-          else
6576
-            current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
6577
-          inactive_extruder_x_pos = destination[X_AXIS];
6578
-          extruder_duplication_enabled = false;
6579
-        }
6580
-        else {
6581
-          // record raised toolhead position for use by unpark
6582
-          memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
6583
-          raised_parked_position[Z_AXIS] += TOOLCHANGE_UNPARK_ZLIFT;
6584
-          active_extruder_parked = true;
6585
-          delayed_move_time = 0;
6610
+            inactive_extruder_x_pos = destination[X_AXIS];
6611
+            break;
6612
+          case DXC_DUPLICATION_MODE:
6613
+            active_extruder_parked = (active_extruder == 0); // this triggers the second extruder to move into the duplication position
6614
+            if (active_extruder_parked)
6615
+              current_position[X_AXIS] = inactive_extruder_x_pos;
6616
+            else
6617
+              current_position[X_AXIS] = destination[X_AXIS] + duplicate_extruder_x_offset;
6618
+            inactive_extruder_x_pos = destination[X_AXIS];
6619
+            extruder_duplication_enabled = false;
6620
+            break;
6621
+          default:
6622
+            // record raised toolhead position for use by unpark
6623
+            memcpy(raised_parked_position, current_position, sizeof(raised_parked_position));
6624
+            raised_parked_position[Z_AXIS] += TOOLCHANGE_UNPARK_ZLIFT;
6625
+            active_extruder_parked = true;
6626
+            delayed_move_time = 0;
6627
+            break;
6586
         }
6628
         }
6587
-        // No extra case for AUTO_BED_LEVELING_FEATURE in DUAL_X_CARRIAGE. Does that mean they don't work together?
6629
+ 
6630
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
6631
+          if (DEBUGGING(LEVELING)) {
6632
+            SERIAL_ECHOPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");
6633
+            SERIAL_EOL;
6634
+            DEBUG_POS("New extruder (parked)", current_position);
6635
+          }
6636
+        #endif
6637
+
6638
+       // No extra case for AUTO_BED_LEVELING_FEATURE in DUAL_X_CARRIAGE. Does that mean they don't work together?
6588
       #else // !DUAL_X_CARRIAGE
6639
       #else // !DUAL_X_CARRIAGE
6589
 
6640
 
6590
-        //
6591
-        // Set current_position to the position of the new nozzle.
6592
-        // Offsets are based on linear distance, so we need to get
6593
-        // the resulting position in coordinate space.
6594
-        //
6595
-        // - With grid or 3-point leveling, offset XYZ by a tilted vector
6596
-        // - With mesh leveling, update Z for the new position
6597
-        // - Otherwise, just use the raw linear distance
6598
-        //
6599
-        // Software endstops are altered here too. Consider a case where:
6600
-        //   E0 at X=0 ... E1 at X=10
6601
-        // When we switch to E1 now X=10, but E1 can't move left.
6602
-        // To express this we apply the change in XY to the software endstops.
6603
-        // E1 can move farther right than E0, so the right limit is extended.
6604
-        //
6605
-        // Note that we don't adjust the Z software endstops. Why not?
6606
-        // Consider a case where Z=0 (here) and switching to E1 makes Z=1
6607
-        // because the bed is 1mm lower at the new position. As long as
6608
-        // the first nozzle is out of the way, the carriage should be
6609
-        // allowed to move 1mm lower. This technically "breaks" the
6610
-        // Z software endstop. But this is technically correct (and
6611
-        // there is no viable alternative).
6612
-        //
6641
+        /**
6642
+         * Set current_position to the position of the new nozzle.
6643
+         * Offsets are based on linear distance, so we need to get
6644
+         * the resulting position in coordinate space.
6645
+         *
6646
+         * - With grid or 3-point leveling, offset XYZ by a tilted vector
6647
+         * - With mesh leveling, update Z for the new position
6648
+         * - Otherwise, just use the raw linear distance
6649
+         *
6650
+         * Software endstops are altered here too. Consider a case where:
6651
+         *   E0 at X=0 ... E1 at X=10
6652
+         * When we switch to E1 now X=10, but E1 can't move left.
6653
+         * To express this we apply the change in XY to the software endstops.
6654
+         * E1 can move farther right than E0, so the right limit is extended.
6655
+         *
6656
+         * Note that we don't adjust the Z software endstops. Why not?
6657
+         * Consider a case where Z=0 (here) and switching to E1 makes Z=1
6658
+         * because the bed is 1mm lower at the new position. As long as
6659
+         * the first nozzle is out of the way, the carriage should be
6660
+         * allowed to move 1mm lower. This technically "breaks" the
6661
+         * Z software endstop. But this is technically correct (and
6662
+         * there is no viable alternative).
6663
+         */
6613
         #if ENABLED(AUTO_BED_LEVELING_FEATURE)
6664
         #if ENABLED(AUTO_BED_LEVELING_FEATURE)
6614
           // Offset extruder, make sure to apply the bed level rotation matrix
6665
           // Offset extruder, make sure to apply the bed level rotation matrix
6615
           vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
6666
           vector_3 tmp_offset_vec = vector_3(hotend_offset[X_AXIS][tmp_extruder],
6648
           #if ENABLED(MESH_BED_LEVELING)
6699
           #if ENABLED(MESH_BED_LEVELING)
6649
 
6700
 
6650
             if (mbl.active()) {
6701
             if (mbl.active()) {
6702
+              #if ENABLED(DEBUG_LEVELING_FEATURE)
6703
+                if (DEBUGGING(LEVELING)) SERIAL_ECHOPAIR("Z before MBL: ", current_position[Z_AXIS]);
6704
+              #endif
6651
               float xpos = RAW_CURRENT_POSITION(X_AXIS),
6705
               float xpos = RAW_CURRENT_POSITION(X_AXIS),
6652
                     ypos = RAW_CURRENT_POSITION(Y_AXIS);
6706
                     ypos = RAW_CURRENT_POSITION(Y_AXIS);
6653
               current_position[Z_AXIS] += mbl.get_z(xpos + xydiff[X_AXIS], ypos + xydiff[Y_AXIS]) - mbl.get_z(xpos, ypos);
6707
               current_position[Z_AXIS] += mbl.get_z(xpos + xydiff[X_AXIS], ypos + xydiff[Y_AXIS]) - mbl.get_z(xpos, ypos);
6708
+              #if ENABLED(DEBUG_LEVELING_FEATURE)
6709
+                if (DEBUGGING(LEVELING)) {
6710
+                  SERIAL_ECHOPAIR(" after: ", current_position[Z_AXIS]);
6711
+                  SERIAL_EOL;
6712
+                }
6713
+              #endif
6654
             }
6714
             }
6655
 
6715
 
6656
           #endif // MESH_BED_LEVELING
6716
           #endif // MESH_BED_LEVELING
6657
 
6717
 
6658
         #endif // !AUTO_BED_LEVELING_FEATURE
6718
         #endif // !AUTO_BED_LEVELING_FEATURE
6659
 
6719
 
6720
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
6721
+          if (DEBUGGING(LEVELING)) {
6722
+            SERIAL_ECHOPAIR("Offset Tool XY by { ", xydiff[X_AXIS]);
6723
+            SERIAL_ECHOPAIR(", ", xydiff[X_AXIS]);
6724
+            SERIAL_ECHOLNPGM(" }");
6725
+          }
6726
+        #endif
6727
+
6660
         // The newly-selected extruder XY is actually at...
6728
         // The newly-selected extruder XY is actually at...
6661
         current_position[X_AXIS] += xydiff[X_AXIS];
6729
         current_position[X_AXIS] += xydiff[X_AXIS];
6662
         current_position[Y_AXIS] += xydiff[Y_AXIS];
6730
         current_position[Y_AXIS] += xydiff[Y_AXIS];
6670
 
6738
 
6671
       #endif // !DUAL_X_CARRIAGE
6739
       #endif // !DUAL_X_CARRIAGE
6672
 
6740
 
6741
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
6742
+        if (DEBUGGING(LEVELING)) DEBUG_POS("Sync After Toolchange", current_position);
6743
+      #endif
6744
+
6673
       // Tell the planner the new "current position"
6745
       // Tell the planner the new "current position"
6674
       SYNC_PLAN_POSITION_KINEMATIC();
6746
       SYNC_PLAN_POSITION_KINEMATIC();
6675
 
6747
 
6676
       // Move to the "old position" (move the extruder into place)
6748
       // Move to the "old position" (move the extruder into place)
6677
-      if (!no_move && IsRunning()) prepare_move_to_destination();
6749
+      if (!no_move && IsRunning()) {
6750
+        #if ENABLED(DEBUG_LEVELING_FEATURE)
6751
+          if (DEBUGGING(LEVELING)) DEBUG_POS("Move back", destination);
6752
+        #endif
6753
+        prepare_move_to_destination();
6754
+      }
6678
 
6755
 
6679
     } // (tmp_extruder != active_extruder)
6756
     } // (tmp_extruder != active_extruder)
6680
 
6757
 
6758
+    stepper.synchronize();
6759
+
6681
     #if ENABLED(EXT_SOLENOID)
6760
     #if ENABLED(EXT_SOLENOID)
6682
-      stepper.synchronize();
6683
       disable_all_solenoids();
6761
       disable_all_solenoids();
6684
       enable_solenoid_on_active_extruder();
6762
       enable_solenoid_on_active_extruder();
6685
     #endif // EXT_SOLENOID
6763
     #endif // EXT_SOLENOID

Loading…
Cancel
Save