From e7dc174f30366570c07677ccf653dd04e2b3c6a3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 2 Oct 2016 01:48:17 -0500 Subject: [PATCH] More detailed debugging of G28 delta --- Marlin/Marlin_main.cpp | 95 ++++++++++++++++++++++++++++-------------- Marlin/planner.cpp | 3 +- Marlin/stepper_dac.cpp | 3 +- 3 files changed, 67 insertions(+), 34 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 849a99986d..1b3c0c2180 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -643,7 +643,7 @@ static void report_current_position(); #endif #define DEBUG_POS(SUFFIX,VAR) do { \ - print_xyz(PSTR(STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0) + print_xyz(PSTR(" " STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0) #endif /** @@ -1349,7 +1349,8 @@ static void set_axis_is_at_home(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR(">>> set_axis_is_at_home(", axis_codes[axis]); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; } #endif @@ -1437,7 +1438,8 @@ static void set_axis_is_at_home(AxisEnum axis) { SERIAL_ECHOLNPAIR("] = ", home_offset[axis]); DEBUG_POS("", current_position); SERIAL_ECHOPAIR("<<< set_axis_is_at_home(", axis_codes[axis]); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; } #endif } @@ -1661,7 +1663,8 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR("do_probe_raise(", z_raise); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; } #endif @@ -1718,7 +1721,8 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR("dock_sled(", stow); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; } #endif @@ -1905,6 +1909,13 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(BLTOUCH) FORCE_INLINE void set_bltouch_deployed(const bool &deploy) { servo[Z_ENDSTOP_SERVO_NR].move(deploy ? BLTOUCH_DEPLOY : BLTOUCH_STOW); + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) { + SERIAL_ECHOPAIR("set_bltouch_deployed(", deploy); + SERIAL_CHAR(')'); + SERIAL_EOL; + } + #endif } #endif @@ -2084,7 +2095,8 @@ static void clean_up_after_endstop_or_probe_move() { SERIAL_ECHOPAIR(">>> probe_pt(", x); SERIAL_ECHOPAIR(", ", y); SERIAL_ECHOPAIR(", ", stow ? "stow" : "no stow"); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; DEBUG_POS("", current_position); } #endif @@ -2094,15 +2106,6 @@ static void clean_up_after_endstop_or_probe_move() { // Ensure a minimum height before moving the probe do_probe_raise(Z_CLEARANCE_BETWEEN_PROBES); - // Move to the XY where we shall probe - #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("> do_blocking_move_to_xy(", x - (X_PROBE_OFFSET_FROM_EXTRUDER)); - SERIAL_ECHOPAIR(", ", y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); - SERIAL_ECHOLNPGM(")"); - } - #endif - feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S; // Move the probe to the given XY @@ -2337,6 +2340,16 @@ static void clean_up_after_endstop_or_probe_move() { */ static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0.0) { + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) { + SERIAL_ECHOPAIR(">>> do_homing_move(", axis_codes[axis]); + SERIAL_ECHOPAIR(", ", distance); + SERIAL_ECHOPAIR(", ", fr_mm_s); + SERIAL_CHAR(')'); + SERIAL_EOL; + } + #endif + #if HOMING_Z_WITH_PROBE && ENABLED(BLTOUCH) bool deploy_bltouch = (axis == Z_AXIS && distance < 0); if (deploy_bltouch) set_bltouch_deployed(true); @@ -2363,6 +2376,14 @@ static void do_homing_move(const AxisEnum axis, float distance, float fr_mm_s=0. #endif endstops.hit_on_purpose(); + + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) { + SERIAL_ECHOPAIR("<<< do_homing_move(", axis_codes[axis]); + SERIAL_CHAR(')'); + SERIAL_EOL; + } + #endif } /** @@ -2392,7 +2413,8 @@ static void homeaxis(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR(">>> homeaxis(", axis_codes[axis]); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; } #endif @@ -2413,6 +2435,9 @@ static void homeaxis(AxisEnum axis) { #endif // Fast move towards endstop until triggered + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 1 Fast:"); + #endif do_homing_move(axis, 1.5 * max_length(axis) * axis_home_dir); // When homing Z with probe respect probe clearance @@ -2426,8 +2451,15 @@ static void homeaxis(AxisEnum axis) { // If a second homing move is configured... if (bump) { // Move away from the endstop by the axis HOME_BUMP_MM + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Move Away:"); + #endif do_homing_move(axis, -bump); + // Slow move towards endstop until triggered + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Home 2 Slow:"); + #endif do_homing_move(axis, 2 * bump, get_homing_bump_feedrate(axis)); } @@ -2466,10 +2498,7 @@ static void homeaxis(AxisEnum axis) { // retrace by the amount specified in endstop_adj if (endstop_adj[axis] * Z_HOME_DIR < 0) { #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) { - SERIAL_ECHOPAIR("> endstop_adj = ", endstop_adj[axis] * Z_HOME_DIR); - DEBUG_POS("", current_position); - } + if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("endstop_adj:"); #endif do_homing_move(axis, endstop_adj[axis]); } @@ -2497,7 +2526,8 @@ static void homeaxis(AxisEnum axis) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR("<<< homeaxis(", axis_codes[axis]); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; } #endif } // homeaxis() @@ -3044,6 +3074,9 @@ inline void gcode_G4() { * This is like quick_home_xy() but for 3 towers. */ inline void home_delta() { + #if ENABLED(DEBUG_LEVELING_FEATURE) + if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position); + #endif // Init the current position of all carriages to 0,0,0 memset(current_position, 0, sizeof(current_position)); sync_plan_position(); @@ -3055,11 +3088,8 @@ inline void gcode_G4() { stepper.synchronize(); endstops.hit_on_purpose(); // clear endstop hit flags - // Probably not needed. Double-check this line: - memset(current_position, 0, sizeof(current_position)); - // At least one carriage has reached the top. - // Now back off and re-home each carriage separately. + // Now re-home each carriage separately. HOMEAXIS(A); HOMEAXIS(B); HOMEAXIS(C); @@ -3073,7 +3103,7 @@ inline void gcode_G4() { SYNC_PLAN_POSITION_KINEMATIC(); #if ENABLED(DEBUG_LEVELING_FEATURE) - if (DEBUGGING(LEVELING)) DEBUG_POS("(DELTA)", current_position); + if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position); #endif } @@ -3313,6 +3343,11 @@ inline void gcode_G28() { endstops.not_homing(); + #if ENABLED(DELTA) + // move to a height where we can use the full xy-area + do_blocking_move_to_z(delta_clip_start_height); + #endif + // Enable mesh leveling again #if ENABLED(MESH_BED_LEVELING) if (mbl.has_mesh()) { @@ -3357,11 +3392,6 @@ inline void gcode_G28() { } #endif - #if ENABLED(DELTA) - // move to a height where we can use the full xy-area - do_blocking_move_to_z(delta_clip_start_height); - #endif - clean_up_after_endstop_or_probe_move(); #if ENABLED(DEBUG_LEVELING_FEATURE) @@ -7314,7 +7344,8 @@ inline void gcode_T(uint8_t tmp_extruder) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) { SERIAL_ECHOPAIR(">>> gcode_T(", tmp_extruder); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; DEBUG_POS("BEFORE", current_position); } #endif diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index 5d54f14fad..2d4cd107ed 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -658,7 +658,8 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co SERIAL_ECHOPAIR(") Z:", lz); #endif SERIAL_ECHOPAIR(" (", dz); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; //*/ // DRYRUN ignores all temperature constraints and assures that the extruder is instantly satisfied diff --git a/Marlin/stepper_dac.cpp b/Marlin/stepper_dac.cpp index 25cd7e6ee9..440bd787d3 100644 --- a/Marlin/stepper_dac.cpp +++ b/Marlin/stepper_dac.cpp @@ -102,7 +102,8 @@ SERIAL_ECHOPAIR(" (", dac_amps(2)); SERIAL_ECHOPAIR(") E:", dac_perc(3)); SERIAL_ECHOPAIR(" (", dac_amps(3)); - SERIAL_ECHOLNPGM(")"); + SERIAL_CHAR(')'); + SERIAL_EOL; } void dac_commit_eeprom() {