Browse Source

Merge G29 Ending Position (PR#2498)

Richard Wackerbarth 10 years ago
parent
commit
53d9c9ff23
1 changed files with 32 additions and 14 deletions
  1. 32
    14
      Marlin/Marlin_main.cpp

+ 32
- 14
Marlin/Marlin_main.cpp View File

1300
     feedrate = oldFeedRate;
1300
     feedrate = oldFeedRate;
1301
   }
1301
   }
1302
 
1302
 
1303
+  inline void do_blocking_move_to_xy(float x, float y) { do_blocking_move_to(x, y, current_position[Z_AXIS]); }
1304
+  inline void do_blocking_move_to_x(float x) { do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]); }
1305
+  inline void do_blocking_move_to_z(float z) { do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z); }
1306
+
1303
   static void clean_up_after_endstop_move() {
1307
   static void clean_up_after_endstop_move() {
1304
     #ifdef ENDSTOPS_ONLY_FOR_HOMING
1308
     #ifdef ENDSTOPS_ONLY_FOR_HOMING
1305
       enable_endstops(false);
1309
       enable_endstops(false);
1408
 
1412
 
1409
         #if Z_RAISE_AFTER_PROBING > 0
1413
         #if Z_RAISE_AFTER_PROBING > 0
1410
           if (doRaise) {
1414
           if (doRaise) {
1411
-            do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // this also updates current_position
1415
+            do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // this also updates current_position
1412
             st_synchronize();
1416
             st_synchronize();
1413
           }
1417
           }
1414
         #endif
1418
         #endif
1494
   // Probe bed height at position (x,y), returns the measured z value
1498
   // Probe bed height at position (x,y), returns the measured z value
1495
   static float probe_pt(float x, float y, float z_before, ProbeAction probe_action=ProbeDeployAndStow, int verbose_level=1) {
1499
   static float probe_pt(float x, float y, float z_before, ProbeAction probe_action=ProbeDeployAndStow, int verbose_level=1) {
1496
     // Move Z up to the z_before height, then move the probe to the given XY
1500
     // Move Z up to the z_before height, then move the probe to the given XY
1497
-    do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); // this also updates current_position
1498
-    do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); // this also updates current_position
1501
+    do_blocking_move_to_z(z_before); // this also updates current_position
1502
+    do_blocking_move_to_xy(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER); // this also updates current_position
1499
 
1503
 
1500
     #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
1504
     #if !defined(Z_PROBE_SLED) && !defined(Z_PROBE_ALLEN_KEY)
1501
       if (probe_action & ProbeDeploy) deploy_z_probe();
1505
       if (probe_action & ProbeDeploy) deploy_z_probe();
1604
       return;
1608
       return;
1605
     }
1609
     }
1606
 
1610
 
1611
+    float oldXpos = current_position[X_AXIS]; // save x position
1607
     if (dock) {
1612
     if (dock) {
1608
-      float oldXpos = current_position[X_AXIS]; // save x position
1609
-      do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // rise Z   
1610
-      do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1, current_position[Y_AXIS], current_position[Z_AXIS]);  // Dock sled a bit closer to ensure proper capturing                                                                                                                           
1613
+      do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // raise Z   
1614
+      do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);  // Dock sled a bit closer to ensure proper capturing
1611
       digitalWrite(SLED_PIN, LOW); // turn off magnet
1615
       digitalWrite(SLED_PIN, LOW); // turn off magnet
1612
-      do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking
1613
     } else {
1616
     } else {
1614
-      float oldXpos = current_position[X_AXIS]; // save x position
1615
       float z_loc = current_position[Z_AXIS];
1617
       float z_loc = current_position[Z_AXIS];
1616
       if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
1618
       if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
1617
       do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
1619
       do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
1618
       digitalWrite(SLED_PIN, HIGH); // turn on magnet
1620
       digitalWrite(SLED_PIN, HIGH); // turn on magnet
1619
-      do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking
1620
     }
1621
     }
1622
+    do_blocking_move_to_x(oldXpos); // return to position before docking
1621
   }
1623
   }
1622
 
1624
 
1623
 #endif // Z_PROBE_SLED
1625
 #endif // Z_PROBE_SLED
2744
         float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
2746
         float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
2745
               y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
2747
               y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
2746
               z_tmp = current_position[Z_AXIS],
2748
               z_tmp = current_position[Z_AXIS],
2747
-              real_z = st_get_position_mm(Z_AXIS);  //get the real Z (since the auto bed leveling is already correcting the plane)
2749
+              real_z = st_get_position_mm(Z_AXIS);  //get the real Z (since plan_get_position is now correcting the plane)
2748
 
2750
 
2749
         apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); // Apply the correction sending the probe offset
2751
         apply_rotation_xyz(plan_bed_level_matrix, x_tmp, y_tmp, z_tmp); // Apply the correction sending the probe offset
2750
-        //line below controls z probe offset, zprobe_zoffset is the actual offset that can be modified via m851 or is read from EEPROM
2751
-        current_position[Z_AXIS] = z_tmp - real_z - zprobe_zoffset; // The difference is added to current position and sent to planner.
2752
+
2753
+        // Get the current Z position and send it to the planner.
2754
+        //
2755
+        // >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z (most recent plan_set_position/sync_plan_position)
2756
+        //
2757
+        // >> zprobe_zoffset : Z distance from nozzle to probe (set by default, M851, EEPROM, or Menu)
2758
+        //
2759
+        // >> Z_RAISE_AFTER_PROBING : The distance the probe will have lifted after the last probe
2760
+        //
2761
+        // >> Should home_offset[Z_AXIS] be included?
2762
+        //
2763
+        //      Discussion: home_offset[Z_AXIS] was applied in G28 to set the starting Z.
2764
+        //      If Z is not tweaked in G29 -and- the Z probe in G29 is not actually "homing" Z...
2765
+        //      then perhaps it should not be included here. The purpose of home_offset[] is to
2766
+        //      adjust for inaccurate endstops, not for reasonably accurate probes. If it were
2767
+        //      added here, it could be seen as a compensating factor for the Z probe.
2768
+        //
2769
+        current_position[Z_AXIS] = -zprobe_zoffset + Z_RAISE_AFTER_PROBING + (z_tmp - real_z);
2770
+        // current_position[Z_AXIS] += home_offset[Z_AXIS]; // The probe determines Z=0, not "Z home"
2752
         sync_plan_position();
2771
         sync_plan_position();
2753
       }
2772
       }
2754
     #endif // !DELTA
2773
     #endif // !DELTA
4542
     void raise_z_for_servo() {
4561
     void raise_z_for_servo() {
4543
       float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_HOMING;
4562
       float zpos = current_position[Z_AXIS], z_dest = Z_RAISE_BEFORE_HOMING;
4544
       z_dest += axis_known_position[Z_AXIS] ? zprobe_zoffset : zpos;
4563
       z_dest += axis_known_position[Z_AXIS] ? zprobe_zoffset : zpos;
4545
-      if (zpos < z_dest)
4546
-        do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_dest); // also updates current_position
4564
+      if (zpos < z_dest) do_blocking_move_to_z(z_dest); // also updates current_position
4547
     }
4565
     }
4548
   #endif
4566
   #endif
4549
 
4567
 

Loading…
Cancel
Save