Browse Source

Merge pull request #4373 from thinkyhead/rc_homing_leveling_wtf

Fix, cleanup DELTA G28 / G29 support functions
Scott Lahteine 9 years ago
parent
commit
5655f8b331
1 changed files with 30 additions and 33 deletions
  1. 30
    33
      Marlin/Marlin_main.cpp

+ 30
- 33
Marlin/Marlin_main.cpp View File

1679
 
1679
 
1680
     feedrate_mm_m = (fr_mm_m != 0.0) ? fr_mm_m : XY_PROBE_FEEDRATE_MM_M;
1680
     feedrate_mm_m = (fr_mm_m != 0.0) ? fr_mm_m : XY_PROBE_FEEDRATE_MM_M;
1681
 
1681
 
1682
+    set_destination_to_current();          // sync destination at the start
1683
+
1682
     // when in the danger zone
1684
     // when in the danger zone
1683
     if (current_position[Z_AXIS] > delta_clip_start_height) {
1685
     if (current_position[Z_AXIS] > delta_clip_start_height) {
1684
-      if (delta_clip_start_height < z) { // staying in the danger zone
1685
-        destination[X_AXIS] = x;         // move directly
1686
+      if (z > delta_clip_start_height) {   // staying in the danger zone
1687
+        destination[X_AXIS] = x;           // move directly (uninterpolated)
1686
         destination[Y_AXIS] = y;
1688
         destination[Y_AXIS] = y;
1687
         destination[Z_AXIS] = z;
1689
         destination[Z_AXIS] = z;
1688
-        prepare_move_to_destination_raw(); // this will also set_current_to_destination
1690
+        prepare_move_to_destination_raw(); // set_current_to_destination
1689
         return;
1691
         return;
1690
-      } else {                           // leave the danger zone
1691
-        destination[X_AXIS] = current_position[X_AXIS];
1692
-        destination[Y_AXIS] = current_position[Y_AXIS];
1692
+      }
1693
+      else {
1693
         destination[Z_AXIS] = delta_clip_start_height;
1694
         destination[Z_AXIS] = delta_clip_start_height;
1694
-        prepare_move_to_destination_raw(); // this will also set_current_to_destination
1695
+        prepare_move_to_destination_raw(); // set_current_to_destination
1695
       }
1696
       }
1696
     }
1697
     }
1697
-    if (current_position[Z_AXIS] < z) {  // raise
1698
-      destination[X_AXIS] = current_position[X_AXIS];
1699
-      destination[Y_AXIS] = current_position[Y_AXIS];
1698
+
1699
+    if (z > current_position[Z_AXIS]) {    // raising?
1700
       destination[Z_AXIS] = z;
1700
       destination[Z_AXIS] = z;
1701
-      prepare_move_to_destination_raw(); // this will also set_current_to_destination
1701
+      prepare_move_to_destination_raw();   // set_current_to_destination
1702
     }
1702
     }
1703
+
1703
     destination[X_AXIS] = x;
1704
     destination[X_AXIS] = x;
1704
     destination[Y_AXIS] = y;
1705
     destination[Y_AXIS] = y;
1705
-    destination[Z_AXIS] = current_position[Z_AXIS];
1706
-    prepare_move_to_destination(); // this will also set_current_to_destination
1706
+    prepare_move_to_destination();         // set_current_to_destination
1707
 
1707
 
1708
-    if (current_position[Z_AXIS] > z) { // lower
1708
+    if (z < current_position[Z_AXIS]) {    // lowering?
1709
       destination[Z_AXIS] = z;
1709
       destination[Z_AXIS] = z;
1710
-      prepare_move_to_destination_raw(); // this will also set_current_to_destination
1710
+      prepare_move_to_destination_raw();   // set_current_to_destination
1711
     }
1711
     }
1712
 
1712
 
1713
   #else
1713
   #else
2087
   }
2087
   }
2088
 
2088
 
2089
   #if ENABLED(DELTA)
2089
   #if ENABLED(DELTA)
2090
-    #define SET_CURRENT_FROM_STEPPERS() current_position[Z_AXIS] = z_before - stepper.get_axis_position_mm(Z_AXIS) + z_mm
2090
+    #define Z_FROM_STEPPERS() z_before + stepper.get_axis_position_mm(Z_AXIS) - z_mm
2091
   #else
2091
   #else
2092
-    #define SET_CURRENT_FROM_STEPPERS() current_position[Z_AXIS] = stepper.get_axis_position_mm(Z_AXIS)
2092
+    #define Z_FROM_STEPPERS() stepper.get_axis_position_mm(Z_AXIS)
2093
   #endif
2093
   #endif
2094
 
2094
 
2095
   // Do a single Z probe and return with current_position[Z_AXIS]
2095
   // Do a single Z probe and return with current_position[Z_AXIS]
2104
     #endif
2104
     #endif
2105
 
2105
 
2106
     #if ENABLED(DELTA)
2106
     #if ENABLED(DELTA)
2107
-      float z_before = current_position[Z_AXIS];
2108
-      float z_mm = stepper.get_axis_position_mm(Z_AXIS);
2107
+      float z_before = current_position[Z_AXIS],         // Current Z
2108
+            z_mm = stepper.get_axis_position_mm(Z_AXIS); // Some tower's current position
2109
     #endif
2109
     #endif
2110
-    current_position[Z_AXIS] = -(Z_MAX_LENGTH + 10);
2111
-    do_blocking_move_to_z(current_position[Z_AXIS], Z_PROBE_SPEED_FAST);
2112
-    endstops.hit_on_purpose(); // clear endstop hit flags
2113
-    // Get the current stepper position after bumping an endstop
2114
-    SET_CURRENT_FROM_STEPPERS();
2115
-    SYNC_PLAN_POSITION_KINEMATIC(); // tell the planner where we are
2110
+
2111
+    do_blocking_move_to_z(-(Z_MAX_LENGTH + 10), Z_PROBE_SPEED_FAST);
2112
+    endstops.hit_on_purpose();
2113
+    current_position[Z_AXIS] = Z_FROM_STEPPERS();
2114
+    SYNC_PLAN_POSITION_KINEMATIC();
2116
 
2115
 
2117
     // move up the retract distance
2116
     // move up the retract distance
2118
-    current_position[Z_AXIS] += home_bump_mm(Z_AXIS);
2119
-    do_blocking_move_to_z(current_position[Z_AXIS], Z_PROBE_SPEED_FAST);
2117
+    do_blocking_move_to_z(current_position[Z_AXIS] + home_bump_mm(Z_AXIS), Z_PROBE_SPEED_FAST);
2120
 
2118
 
2121
     #if ENABLED(DELTA)
2119
     #if ENABLED(DELTA)
2122
       z_before = current_position[Z_AXIS];
2120
       z_before = current_position[Z_AXIS];
2123
       z_mm = stepper.get_axis_position_mm(Z_AXIS);
2121
       z_mm = stepper.get_axis_position_mm(Z_AXIS);
2124
     #endif
2122
     #endif
2123
+
2125
     // move back down slowly to find bed
2124
     // move back down slowly to find bed
2126
-    current_position[Z_AXIS] -= home_bump_mm(Z_AXIS) * 2;
2127
-    do_blocking_move_to_z(current_position[Z_AXIS], Z_PROBE_SPEED_SLOW);
2128
-    endstops.hit_on_purpose(); // clear endstop hit flags
2129
-    // Get the current stepper position after bumping an endstop
2130
-    SET_CURRENT_FROM_STEPPERS();
2131
-    SYNC_PLAN_POSITION_KINEMATIC(); // tell the planner where we are
2125
+    do_blocking_move_to_z(current_position[Z_AXIS] - home_bump_mm(Z_AXIS) * 2, Z_PROBE_SPEED_SLOW);
2126
+    endstops.hit_on_purpose();
2127
+    current_position[Z_AXIS] = Z_FROM_STEPPERS();
2128
+    SYNC_PLAN_POSITION_KINEMATIC();
2132
 
2129
 
2133
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2130
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2134
       if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);
2131
       if (DEBUGGING(LEVELING)) DEBUG_POS("run_z_probe", current_position);

Loading…
Cancel
Save