Browse Source

Improvement - G29 Option for Not Retracting Servo

This change introduces an improvement to G29 command on Marlin.

Auto bed leveling operation's reliability is based on the repeatability of the Z-probe switch and the servo. This change introduces an option to G29 command. When the G29 command is sent with an "e" option, during auto bed levelling the servo is not retracted between probes which decreases the bias on auto bed levelling resulting from servo.

G29 command does the auto bed probing as it is.

G29 E command engages the servo on first probing point, probes all points and retracts the servo after probing the last point.

Please comment your opinions, test on your printer and check the code on a programmer's perspective. (I am not a good programmer.)
msutas 10 years ago
parent
commit
e0beb98fd3
1 changed files with 45 additions and 13 deletions
  1. 45
    13
      Marlin/Marlin_main.cpp

+ 45
- 13
Marlin/Marlin_main.cpp View File

1150
 }
1150
 }
1151
 
1151
 
1152
 /// Probe bed height at position (x,y), returns the measured z value
1152
 /// Probe bed height at position (x,y), returns the measured z value
1153
-static float probe_pt(float x, float y, float z_before) {
1153
+static float probe_pt(float x, float y, float z_before, int retract_action=0) {
1154
   // move to right place
1154
   // move to right place
1155
   do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
1155
   do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before);
1156
   do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1156
   do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]);
1157
 
1157
 
1158
 #ifndef Z_PROBE_SLED
1158
 #ifndef Z_PROBE_SLED
1159
-  engage_z_probe();   // Engage Z Servo endstop if available
1159
+   if ((retract_action==0) || (retract_action==1)) 
1160
+     engage_z_probe();   // Engage Z Servo endstop if available
1160
 #endif // Z_PROBE_SLED
1161
 #endif // Z_PROBE_SLED
1161
   run_z_probe();
1162
   run_z_probe();
1162
   float measured_z = current_position[Z_AXIS];
1163
   float measured_z = current_position[Z_AXIS];
1163
 #ifndef Z_PROBE_SLED
1164
 #ifndef Z_PROBE_SLED
1164
-  retract_z_probe();
1165
+  if ((retract_action==0) || (retract_action==3)) 
1166
+     retract_z_probe();
1165
 #endif // Z_PROBE_SLED
1167
 #endif // Z_PROBE_SLED
1166
 
1168
 
1167
   SERIAL_PROTOCOLPGM(MSG_BED);
1169
   SERIAL_PROTOCOLPGM(MSG_BED);
1750
                   z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
1752
                   z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS;
1751
                 }
1753
                 }
1752
 
1754
 
1753
-                float measured_z = probe_pt(xProbe, yProbe, z_before);
1755
+                float measured_z;
1756
+                //Enhanced G29 - Do not retract servo between probes
1757
+                if (code_seen('E') || code_seen('e') )
1758
+                   {
1759
+                   if ((yProbe==FRONT_PROBE_BED_POSITION) && (xCount==0))
1760
+                       {
1761
+                        measured_z = probe_pt(xProbe, yProbe, z_before,1);
1762
+                       } else if ((yProbe==BACK_PROBE_BED_POSITION) && (xCount == AUTO_BED_LEVELING_GRID_POINTS-1))
1763
+                         {
1764
+                         measured_z = probe_pt(xProbe, yProbe, z_before,3);
1765
+                         } else {
1766
+                           measured_z = probe_pt(xProbe, yProbe, z_before,2);
1767
+                         }
1768
+                    } else {
1769
+                    measured_z = probe_pt(xProbe, yProbe, z_before);
1770
+                    }
1754
 
1771
 
1755
                 eqnBVector[probePointCounter] = measured_z;
1772
                 eqnBVector[probePointCounter] = measured_z;
1756
 
1773
 
1781
 #else // AUTO_BED_LEVELING_GRID not defined
1798
 #else // AUTO_BED_LEVELING_GRID not defined
1782
 
1799
 
1783
             // Probe at 3 arbitrary points
1800
             // Probe at 3 arbitrary points
1784
-            // probe 1
1785
-            float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
1786
-
1787
-            // probe 2
1788
-            float z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1789
-
1790
-            // probe 3
1791
-            float z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1792
-
1801
+            // Enhanced G29
1802
+            
1803
+            float z_at_pt_1,z_at_pt_2,z_at_pt_3;
1804
+            
1805
+            if (code_seen('E') || code_seen('e') )
1806
+               {
1807
+               // probe 1               
1808
+                z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING,1);
1809
+               // probe 2
1810
+                z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,2);
1811
+               // probe 3
1812
+                z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS,3); 
1813
+               }
1814
+               else 
1815
+               {
1816
+	        // probe 1
1817
+	        float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
1818
+
1819
+                // probe 2
1820
+                float z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1821
+
1822
+                // probe 3
1823
+                float z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1824
+               }
1793
             clean_up_after_endstop_move();
1825
             clean_up_after_endstop_move();
1794
 
1826
 
1795
             set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
1827
             set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);

Loading…
Cancel
Save