Browse Source

Patch and cleanup run_z_probe

Scott Lahteine 9 years ago
parent
commit
b78590e63d
1 changed files with 15 additions and 18 deletions
  1. 15
    18
      Marlin/Marlin_main.cpp

+ 15
- 18
Marlin/Marlin_main.cpp View File

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