Make max_e_jerk an array to reduce CPU usage (#11118)

This commit is contained in:
Andy Shaw 2018-06-27 03:38:31 +01:00 committed by Scott Lahteine
parent d13f76b7da
commit 3b3029c4bf
5 changed files with 29 additions and 8 deletions

View file

@ -136,7 +136,7 @@ void GcodeSuite::M205() {
const float junc_dev = parser.value_linear_units(); const float junc_dev = parser.value_linear_units();
if (WITHIN(junc_dev, 0.01, 0.3)) { if (WITHIN(junc_dev, 0.01, 0.3)) {
planner.junction_deviation_mm = junc_dev; planner.junction_deviation_mm = junc_dev;
planner.recalculate_max_e_jerk_factor(); planner.recalculate_max_e_jerk();
} }
else { else {
SERIAL_ERROR_START(); SERIAL_ERROR_START();

View file

@ -3752,7 +3752,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
MENU_BACK(MSG_MOTION); MENU_BACK(MSG_MOTION);
#if ENABLED(JUNCTION_DEVIATION) #if ENABLED(JUNCTION_DEVIATION)
MENU_ITEM_EDIT_CALLBACK(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01, 0.3, planner.recalculate_max_e_jerk_factor); MENU_ITEM_EDIT_CALLBACK(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01, 0.3, planner.recalculate_max_e_jerk);
#else #else
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VA_JERK, &planner.max_jerk[A_AXIS], 1, 990); MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VA_JERK, &planner.max_jerk[A_AXIS], 1, 990);
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VB_JERK, &planner.max_jerk[B_AXIS], 1, 990); MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VB_JERK, &planner.max_jerk[B_AXIS], 1, 990);

View file

@ -331,7 +331,7 @@ void MarlinSettings::postprocess() {
#endif #endif
#if ENABLED(JUNCTION_DEVIATION) && ENABLED(LIN_ADVANCE) #if ENABLED(JUNCTION_DEVIATION) && ENABLED(LIN_ADVANCE)
planner.recalculate_max_e_jerk_factor(); planner.recalculate_max_e_jerk();
#endif #endif
// Refresh steps_to_mm with the reciprocal of axis_steps_per_mm // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm

View file

@ -126,7 +126,11 @@ float Planner::max_feedrate_mm_s[XYZE_N], // (mm/s) M203 XYZE - Max speeds
#if ENABLED(JUNCTION_DEVIATION) #if ENABLED(JUNCTION_DEVIATION)
float Planner::junction_deviation_mm; // (mm) M205 J float Planner::junction_deviation_mm; // (mm) M205 J
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
float Planner::max_e_jerk_factor; // Calculated from junction_deviation_mm #if ENABLED(DISTINCT_E_FACTORS)
float Planner::max_e_jerk[EXTRUDERS]; // Calculated from junction_deviation_mm
#else
float Planner::max_e_jerk;
#endif
#endif #endif
#else #else
float Planner::max_jerk[XYZE]; // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration. float Planner::max_jerk[XYZE]; // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration.
@ -2056,7 +2060,11 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
#if ENABLED(JUNCTION_DEVIATION) #if ENABLED(JUNCTION_DEVIATION)
#define MAX_E_JERK (max_e_jerk_factor * max_acceleration_mm_per_s2[_EINDEX]) #if ENABLED(DISTINCT_E_FACTORS)
#define MAX_E_JERK max_e_jerk[extruder]
#else
#define MAX_E_JERK max_e_jerk
#endif
#else #else
#define MAX_E_JERK max_jerk[E_AXIS] #define MAX_E_JERK max_jerk[E_AXIS]
#endif #endif
@ -2569,6 +2577,9 @@ void Planner::reset_acceleration_rates() {
if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]); if (AXIS_CONDITION) NOLESS(highest_rate, max_acceleration_steps_per_s2[i]);
} }
cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL cutoff_long = 4294967295UL / highest_rate; // 0xFFFFFFFFUL
#if ENABLED(JUNCTION_DEVIATION) && ENABLED(LIN_ADVANCE)
recalculate_max_e_jerk();
#endif
} }
// Recalculate position, steps_to_mm if axis_steps_per_mm changes! // Recalculate position, steps_to_mm if axis_steps_per_mm changes!

View file

@ -210,7 +210,11 @@ class Planner {
#if ENABLED(JUNCTION_DEVIATION) #if ENABLED(JUNCTION_DEVIATION)
static float junction_deviation_mm; // (mm) M205 J static float junction_deviation_mm; // (mm) M205 J
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
static float max_e_jerk_factor; // Calculated from junction_deviation_mm #if ENABLED(DISTINCT_E_FACTORS)
static float max_e_jerk[EXTRUDERS]; // Calculated from junction_deviation_mm
#else
static float max_e_jerk;
#endif
#endif #endif
#else #else
static float max_jerk[XYZE]; // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration. static float max_jerk[XYZE]; // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration.
@ -750,9 +754,15 @@ class Planner {
#endif #endif
#if ENABLED(JUNCTION_DEVIATION) #if ENABLED(JUNCTION_DEVIATION)
FORCE_INLINE static void recalculate_max_e_jerk_factor() { FORCE_INLINE static void recalculate_max_e_jerk() {
#define GET_MAX_E_JERK(N) SQRT(SQRT(0.5) * junction_deviation_mm * (N) * RECIPROCAL(1.0 - SQRT(0.5)))
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
max_e_jerk_factor = SQRT(SQRT(0.5) * junction_deviation_mm * RECIPROCAL(1.0 - SQRT(0.5))); #if ENABLED(DISTINCT_E_FACTORS)
for (uint8_t i = 0; i < EXTRUDERS; i++)
max_e_jerk[i] = GET_MAX_E_JERK(max_acceleration_mm_per_s2[E_AXIS + i]);
#else
max_e_jerk = GET_MAX_E_JERK(max_acceleration_mm_per_s2[E_AXIS]);
#endif
#endif #endif
} }
#endif #endif