From e46898f8e5eec9a2a7f2d5e313b86196372eaffa Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Mar 2017 06:30:22 -0500 Subject: [PATCH 1/3] Remove kinematic optimizations --- Marlin/Marlin_main.cpp | 73 ++++++++++++------------------------------ 1 file changed, 21 insertions(+), 52 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index c560a076d0..386058b672 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -9201,7 +9201,7 @@ void ok_to_send() { ) \ ) - #define DELTA_RAW_IK() do { \ + #define DELTA_RAW_IK() do { \ delta[A_AXIS] = DELTA_Z(A_AXIS); \ delta[B_AXIS] = DELTA_Z(B_AXIS); \ delta[C_AXIS] = DELTA_Z(C_AXIS); \ @@ -9568,54 +9568,19 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { // If there's only 1 segment, loops will be skipped entirely. --segments; - // Using "raw" coordinates saves 6 float subtractions - // per segment, saving valuable CPU cycles - - #if ENABLED(USE_RAW_KINEMATICS) - - // Get the raw current position as starting point - float raw[XYZE] = { - RAW_CURRENT_POSITION(X_AXIS), - RAW_CURRENT_POSITION(Y_AXIS), - RAW_CURRENT_POSITION(Z_AXIS), - current_position[E_AXIS] - }; - - #define DELTA_VAR raw - - // Delta can inline its kinematics - #if ENABLED(DELTA) - #define DELTA_IK() DELTA_RAW_IK() - #else - #define DELTA_IK() inverse_kinematics(raw) - #endif - - #else - - // Get the logical current position as starting point - float logical[XYZE]; - COPY(logical, current_position); - - #define DELTA_VAR logical - - // Delta can inline its kinematics - #if ENABLED(DELTA) - #define DELTA_IK() DELTA_LOGICAL_IK() - #else - #define DELTA_IK() inverse_kinematics(logical) - #endif - - #endif + // Get the logical current position as starting point + float logical[XYZE]; + COPY(logical, current_position); #if ENABLED(USE_DELTA_IK_INTERPOLATION) // Only interpolate XYZ. Advance E normally. - #define DELTA_NEXT(ADDEND) LOOP_XYZ(i) DELTA_VAR[i] += ADDEND; + #define DELTA_NEXT(ADDEND) LOOP_XYZ(i) logical[i] += ADDEND; // Get the starting delta if interpolation is possible if (segments >= 2) { DELTA_IK(); - ADJUST_DELTA(DELTA_VAR); // Adjust Z if bed leveling is enabled + ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled } // Loop using decrement @@ -9629,22 +9594,22 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { DELTA_NEXT(segment_distance[i] + segment_distance[i]); // Advance E normally - DELTA_VAR[E_AXIS] += segment_distance[E_AXIS]; + logical[E_AXIS] += segment_distance[E_AXIS]; // Get the exact delta for the move after this DELTA_IK(); - ADJUST_DELTA(DELTA_VAR); // Adjust Z if bed leveling is enabled + ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled // Move to the interpolated delta position first planner.buffer_line( (prev_delta[A_AXIS] + delta[A_AXIS]) * 0.5, (prev_delta[B_AXIS] + delta[B_AXIS]) * 0.5, (prev_delta[C_AXIS] + delta[C_AXIS]) * 0.5, - DELTA_VAR[E_AXIS], _feedrate_mm_s, active_extruder + logical[E_AXIS], _feedrate_mm_s, active_extruder ); // Advance E once more for the next move - DELTA_VAR[E_AXIS] += segment_distance[E_AXIS]; + logical[E_AXIS] += segment_distance[E_AXIS]; // Do an extra decrement of the loop --s; @@ -9652,25 +9617,29 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { else { // Get the last segment delta. (Used when segments is odd) DELTA_NEXT(segment_distance[i]); - DELTA_VAR[E_AXIS] += segment_distance[E_AXIS]; + logical[E_AXIS] += segment_distance[E_AXIS]; DELTA_IK(); - ADJUST_DELTA(DELTA_VAR); // Adjust Z if bed leveling is enabled + ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled } // Move to the non-interpolated position - planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], DELTA_VAR[E_AXIS], _feedrate_mm_s, active_extruder); + planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], _feedrate_mm_s, active_extruder); } #else - #define DELTA_NEXT(ADDEND) LOOP_XYZE(i) DELTA_VAR[i] += ADDEND; + #define DELTA_NEXT(ADDEND) LOOP_XYZE(i) logical[i] += ADDEND; // For non-interpolated delta calculate every segment for (uint16_t s = segments + 1; --s;) { DELTA_NEXT(segment_distance[i]); - DELTA_IK(); - ADJUST_DELTA(DELTA_VAR); // Adjust Z if bed leveling is enabled - planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], DELTA_VAR[E_AXIS], _feedrate_mm_s, active_extruder); + #if ENABLED(DELTA) + DELTA_LOGICAL_IK(); // Delta can inline its kinematics + #else + inverse_kinematics(logical); + #endif + ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled + planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], _feedrate_mm_s, active_extruder); } #endif From 1e57b0c26915cc3648e40e258a6c6634ebc54ae9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Mar 2017 06:32:11 -0500 Subject: [PATCH 2/3] Remove delta interpolation concept --- Marlin/Marlin_main.cpp | 82 ++++++------------------------------------ 1 file changed, 11 insertions(+), 71 deletions(-) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 386058b672..704bd3be58 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -9572,77 +9572,17 @@ void set_current_from_steppers_for_axis(const AxisEnum axis) { float logical[XYZE]; COPY(logical, current_position); - #if ENABLED(USE_DELTA_IK_INTERPOLATION) - - // Only interpolate XYZ. Advance E normally. - #define DELTA_NEXT(ADDEND) LOOP_XYZ(i) logical[i] += ADDEND; - - // Get the starting delta if interpolation is possible - if (segments >= 2) { - DELTA_IK(); - ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled - } - - // Loop using decrement - for (uint16_t s = segments + 1; --s;) { - // Are there at least 2 moves left? - if (s >= 2) { - // Save the previous delta for interpolation - float prev_delta[ABC] = { delta[A_AXIS], delta[B_AXIS], delta[C_AXIS] }; - - // Get the delta 2 segments ahead (rather than the next) - DELTA_NEXT(segment_distance[i] + segment_distance[i]); - - // Advance E normally - logical[E_AXIS] += segment_distance[E_AXIS]; - - // Get the exact delta for the move after this - DELTA_IK(); - ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled - - // Move to the interpolated delta position first - planner.buffer_line( - (prev_delta[A_AXIS] + delta[A_AXIS]) * 0.5, - (prev_delta[B_AXIS] + delta[B_AXIS]) * 0.5, - (prev_delta[C_AXIS] + delta[C_AXIS]) * 0.5, - logical[E_AXIS], _feedrate_mm_s, active_extruder - ); - - // Advance E once more for the next move - logical[E_AXIS] += segment_distance[E_AXIS]; - - // Do an extra decrement of the loop - --s; - } - else { - // Get the last segment delta. (Used when segments is odd) - DELTA_NEXT(segment_distance[i]); - logical[E_AXIS] += segment_distance[E_AXIS]; - DELTA_IK(); - ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled - } - - // Move to the non-interpolated position - planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], _feedrate_mm_s, active_extruder); - } - - #else - - #define DELTA_NEXT(ADDEND) LOOP_XYZE(i) logical[i] += ADDEND; - - // For non-interpolated delta calculate every segment - for (uint16_t s = segments + 1; --s;) { - DELTA_NEXT(segment_distance[i]); - #if ENABLED(DELTA) - DELTA_LOGICAL_IK(); // Delta can inline its kinematics - #else - inverse_kinematics(logical); - #endif - ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled - planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], _feedrate_mm_s, active_extruder); - } - - #endif + // Calculate and execute the segments + for (uint16_t s = segments + 1; --s;) { + LOOP_XYZE(i) logical[i] += segment_distance[i]; + #if ENABLED(DELTA) + DELTA_LOGICAL_IK(); // Delta can inline its kinematics + #else + inverse_kinematics(logical); + #endif + ADJUST_DELTA(logical); // Adjust Z if bed leveling is enabled + planner.buffer_line(delta[A_AXIS], delta[B_AXIS], delta[C_AXIS], logical[E_AXIS], _feedrate_mm_s, active_extruder); + } // Since segment_distance is only approximate, // the final move must be to the exact destination. From b865b21d32c6e7c95d0bee58a7ec4c0a4fea8ef1 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 17 Mar 2017 06:52:52 -0500 Subject: [PATCH 3/3] Can't use Z fade height with DELTA --- Marlin/SanityCheck.h | 2 ++ .../delta/flsun_kossel_mini/Configuration.h | 2 +- Marlin/example_configurations/delta/generic/Configuration.h | 2 +- Marlin/example_configurations/delta/kossel_pro/Configuration.h | 2 +- Marlin/example_configurations/delta/kossel_xl/Configuration.h | 2 +- 5 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index b39e837e57..52e532549d 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -228,6 +228,8 @@ #if ENABLED(DELTA) #if DISABLED(USE_XMAX_PLUG) && DISABLED(USE_YMAX_PLUG) && DISABLED(USE_ZMAX_PLUG) #error "You probably want to use Max Endstops for DELTA!" + #elif ENABLED(ENABLE_LEVELING_FADE_HEIGHT) + #error "DELTA is incompatible with ENABLE_LEVELING_FADE_HEIGHT. Please disable it." #endif #if ABL_GRID #if (ABL_GRID_MAX_POINTS_X & 1) == 0 || (ABL_GRID_MAX_POINTS_Y & 1) == 0 diff --git a/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration.h b/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration.h index e6e36ea10a..0bdde3b706 100644 --- a/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/flsun_kossel_mini/Configuration.h @@ -931,7 +931,7 @@ // Gradually reduce leveling correction until a set height is reached, // at which point movement will be level to the machine's XY plane. // The height can be set with M420 Z - #define ENABLE_LEVELING_FADE_HEIGHT + //#define ENABLE_LEVELING_FADE_HEIGHT // // Experimental Subdivision of the grid by Catmull-Rom method. diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 98b17324c3..0e654bb440 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -915,7 +915,7 @@ // Gradually reduce leveling correction until a set height is reached, // at which point movement will be level to the machine's XY plane. // The height can be set with M420 Z - #define ENABLE_LEVELING_FADE_HEIGHT + //#define ENABLE_LEVELING_FADE_HEIGHT // // Experimental Subdivision of the grid by Catmull-Rom method. diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index 437b9bcfe2..a4f23dcba3 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -917,7 +917,7 @@ // Gradually reduce leveling correction until a set height is reached, // at which point movement will be level to the machine's XY plane. // The height can be set with M420 Z - #define ENABLE_LEVELING_FADE_HEIGHT + //#define ENABLE_LEVELING_FADE_HEIGHT // // Experimental Subdivision of the grid by Catmull-Rom method. diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index c8a28c42dd..2fc609f741 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -921,7 +921,7 @@ // Gradually reduce leveling correction until a set height is reached, // at which point movement will be level to the machine's XY plane. // The height can be set with M420 Z - #define ENABLE_LEVELING_FADE_HEIGHT + //#define ENABLE_LEVELING_FADE_HEIGHT // // Experimental Subdivision of the grid by Catmull-Rom method.