From e0beb98fd30e9364e730094c448986da78887d6d Mon Sep 17 00:00:00 2001 From: msutas Date: Sat, 10 Jan 2015 17:25:39 +0200 Subject: [PATCH 1/2] 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.) --- Marlin/Marlin_main.cpp | 54 +++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 11 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 0862e1fe0..331bcc30a 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1150,18 +1150,20 @@ static void retract_z_probe() { } /// Probe bed height at position (x,y), returns the measured z value -static float probe_pt(float x, float y, float z_before) { +static float probe_pt(float x, float y, float z_before, int retract_action=0) { // move to right place do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z_before); do_blocking_move_to(x - X_PROBE_OFFSET_FROM_EXTRUDER, y - Y_PROBE_OFFSET_FROM_EXTRUDER, current_position[Z_AXIS]); #ifndef Z_PROBE_SLED - engage_z_probe(); // Engage Z Servo endstop if available + if ((retract_action==0) || (retract_action==1)) + engage_z_probe(); // Engage Z Servo endstop if available #endif // Z_PROBE_SLED run_z_probe(); float measured_z = current_position[Z_AXIS]; #ifndef Z_PROBE_SLED - retract_z_probe(); + if ((retract_action==0) || (retract_action==3)) + retract_z_probe(); #endif // Z_PROBE_SLED SERIAL_PROTOCOLPGM(MSG_BED); @@ -1750,7 +1752,22 @@ void process_commands() z_before = current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS; } - float measured_z = probe_pt(xProbe, yProbe, z_before); + float measured_z; + //Enhanced G29 - Do not retract servo between probes + if (code_seen('E') || code_seen('e') ) + { + if ((yProbe==FRONT_PROBE_BED_POSITION) && (xCount==0)) + { + measured_z = probe_pt(xProbe, yProbe, z_before,1); + } else if ((yProbe==BACK_PROBE_BED_POSITION) && (xCount == AUTO_BED_LEVELING_GRID_POINTS-1)) + { + measured_z = probe_pt(xProbe, yProbe, z_before,3); + } else { + measured_z = probe_pt(xProbe, yProbe, z_before,2); + } + } else { + measured_z = probe_pt(xProbe, yProbe, z_before); + } eqnBVector[probePointCounter] = measured_z; @@ -1781,15 +1798,30 @@ void process_commands() #else // AUTO_BED_LEVELING_GRID not defined // Probe at 3 arbitrary points - // probe 1 - float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING); + // Enhanced G29 + + float z_at_pt_1,z_at_pt_2,z_at_pt_3; + + if (code_seen('E') || code_seen('e') ) + { + // probe 1 + z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING,1); + // probe 2 + 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); + // probe 3 + 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); + } + else + { + // probe 1 + float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING); - // probe 2 - 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); - - // probe 3 - 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); + // probe 2 + 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); + // probe 3 + 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); + } clean_up_after_endstop_move(); set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3); From 3a5a6f42fb6f76cb8c9643aaa19a02c388f77e1a Mon Sep 17 00:00:00 2001 From: msutas Date: Mon, 12 Jan 2015 11:07:46 +0200 Subject: [PATCH 2/2] Corrected the ABL grid option G29 E was not retracting the probe on the last probe point when used with ABL grid. Corrected. --- Marlin/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 331bcc30a..60752090b 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1759,7 +1759,7 @@ void process_commands() if ((yProbe==FRONT_PROBE_BED_POSITION) && (xCount==0)) { measured_z = probe_pt(xProbe, yProbe, z_before,1); - } else if ((yProbe==BACK_PROBE_BED_POSITION) && (xCount == AUTO_BED_LEVELING_GRID_POINTS-1)) + } else if ((yProbe==FRONT_PROBE_BED_POSITION + (yGridSpacing * (AUTO_BED_LEVELING_GRID_POINTS-1))) && (xCount == AUTO_BED_LEVELING_GRID_POINTS-1)) { measured_z = probe_pt(xProbe, yProbe, z_before,3); } else {