diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index d0aff05bc..571d59f4d 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -9124,28 +9124,35 @@ inline void gcode_M204() { /** * M205: Set Advanced Settings * + * B = Min Segment Time (µs) * S = Min Feed Rate (units/s) * T = Min Travel Feed Rate (units/s) - * B = Min Segment Time (µs) * X = Max X Jerk (units/sec^2) * Y = Max Y Jerk (units/sec^2) * Z = Max Z Jerk (units/sec^2) * E = Max E Jerk (units/sec^2) + * J = Junction Deviation (mm) (Requires JUNCTION_DEVIATION) */ inline void gcode_M205() { + if (parser.seen('B')) planner.min_segment_time_us = parser.value_ulong(); if (parser.seen('S')) planner.min_feedrate_mm_s = parser.value_linear_units(); if (parser.seen('T')) planner.min_travel_feedrate_mm_s = parser.value_linear_units(); - if (parser.seen('B')) planner.min_segment_time_us = parser.value_ulong(); - if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units(); - if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units(); - if (parser.seen('Z')) { - planner.max_jerk[Z_AXIS] = parser.value_linear_units(); - #if HAS_MESH - if (planner.max_jerk[Z_AXIS] <= 0.1) - SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses."); - #endif - } - if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units(); + #if ENABLED(JUNCTION_DEVIATION) + if (parser.seen('J')) planner.junction_deviation_mm = parser.value_linear_units(); + #else + if (parser.seen('X')) planner.max_jerk[X_AXIS] = parser.value_linear_units(); + if (parser.seen('Y')) planner.max_jerk[Y_AXIS] = parser.value_linear_units(); + if (parser.seen('Z')) { + planner.max_jerk[Z_AXIS] = parser.value_linear_units(); + #if HAS_MESH + if (planner.max_jerk[Z_AXIS] <= 0.1) + SERIAL_ECHOLNPGM("WARNING! Low Z Jerk may lead to unwanted pauses."); + #endif + } + #endif + #if DISABLED(JUNCTION_DEVIATION) || ENABLED(LIN_ADVANCE) + if (parser.seen('E')) planner.max_jerk[E_AXIS] = parser.value_linear_units(); + #endif } #if HAS_M206_COMMAND diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 0bd07a4bb..9cb30685e 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -37,7 +37,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V54" +#define EEPROM_VERSION "V55" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -97,16 +97,17 @@ typedef struct SettingsDataStruct { // uint8_t esteppers; // XYZE_N - XYZ + uint32_t planner_max_acceleration_mm_per_s2[XYZE_N], // M201 XYZE planner.max_acceleration_mm_per_s2[XYZE_N] + planner_min_segment_time_us; // M205 B planner.min_segment_time_us float planner_axis_steps_per_mm[XYZE_N], // M92 XYZE planner.axis_steps_per_mm[XYZE_N] - planner_max_feedrate_mm_s[XYZE_N]; // M203 XYZE planner.max_feedrate_mm_s[XYZE_N] - uint32_t planner_max_acceleration_mm_per_s2[XYZE_N]; // M201 XYZE planner.max_acceleration_mm_per_s2[XYZE_N] - float planner_acceleration, // M204 P planner.acceleration + planner_max_feedrate_mm_s[XYZE_N], // M203 XYZE planner.max_feedrate_mm_s[XYZE_N] + planner_acceleration, // M204 P planner.acceleration planner_retract_acceleration, // M204 R planner.retract_acceleration planner_travel_acceleration, // M204 T planner.travel_acceleration planner_min_feedrate_mm_s, // M205 S planner.min_feedrate_mm_s - planner_min_travel_feedrate_mm_s; // M205 T planner.min_travel_feedrate_mm_s - uint32_t planner_min_segment_time_us; // M205 B planner.min_segment_time_us - float planner_max_jerk[XYZE]; // M205 XYZE planner.max_jerk[XYZE] + planner_min_travel_feedrate_mm_s, // M205 T planner.min_travel_feedrate_mm_s + planner_max_jerk[XYZE], // M205 XYZE planner.max_jerk[XYZE] + planner_junction_deviation_mm; // M205 J planner.junction_deviation_mm float home_offset[XYZ]; // M206 XYZ @@ -416,18 +417,24 @@ void MarlinSettings::postprocess() { const uint8_t esteppers = COUNT(planner.axis_steps_per_mm) - XYZ; EEPROM_WRITE(esteppers); + EEPROM_WRITE(planner.max_acceleration_mm_per_s2); + EEPROM_WRITE(planner.min_segment_time_us); EEPROM_WRITE(planner.axis_steps_per_mm); EEPROM_WRITE(planner.max_feedrate_mm_s); - EEPROM_WRITE(planner.max_acceleration_mm_per_s2); - EEPROM_WRITE(planner.acceleration); EEPROM_WRITE(planner.retract_acceleration); EEPROM_WRITE(planner.travel_acceleration); EEPROM_WRITE(planner.min_feedrate_mm_s); EEPROM_WRITE(planner.min_travel_feedrate_mm_s); - EEPROM_WRITE(planner.min_segment_time_us); EEPROM_WRITE(planner.max_jerk); + #if ENABLED(JUNCTION_DEVIATION) + EEPROM_WRITE(planner.junction_deviation_mm); + #else + dummy = 0.02; + EEPROM_WRITE(dummy); + #endif + _FIELD_TEST(home_offset); #if !HAS_HOME_OFFSET @@ -994,17 +1001,20 @@ void MarlinSettings::postprocess() { // Get only the number of E stepper parameters previously stored // Any steppers added later are set to their defaults - const float def1[] = DEFAULT_AXIS_STEPS_PER_UNIT, def2[] = DEFAULT_MAX_FEEDRATE; - const uint32_t def3[] = DEFAULT_MAX_ACCELERATION; - float tmp1[XYZ + esteppers], tmp2[XYZ + esteppers]; - uint32_t tmp3[XYZ + esteppers]; - EEPROM_READ(tmp1); - EEPROM_READ(tmp2); - EEPROM_READ(tmp3); + const uint32_t def1[] = DEFAULT_MAX_ACCELERATION; + const float def2[] = DEFAULT_AXIS_STEPS_PER_UNIT, def3[] = DEFAULT_MAX_FEEDRATE; + + uint32_t tmp1[XYZ + esteppers]; + EEPROM_READ(tmp1); // max_acceleration_mm_per_s2 + EEPROM_READ(planner.min_segment_time_us); + + float tmp2[XYZ + esteppers], tmp3[XYZ + esteppers]; + EEPROM_READ(tmp2); // axis_steps_per_mm + EEPROM_READ(tmp3); // max_feedrate_mm_s if (!validating) LOOP_XYZE_N(i) { - planner.axis_steps_per_mm[i] = i < XYZ + esteppers ? tmp1[i] : def1[i < COUNT(def1) ? i : COUNT(def1) - 1]; - planner.max_feedrate_mm_s[i] = i < XYZ + esteppers ? tmp2[i] : def2[i < COUNT(def2) ? i : COUNT(def2) - 1]; - planner.max_acceleration_mm_per_s2[i] = i < XYZ + esteppers ? tmp3[i] : def3[i < COUNT(def3) ? i : COUNT(def3) - 1]; + planner.max_acceleration_mm_per_s2[i] = i < XYZ + esteppers ? tmp1[i] : def1[i < COUNT(def1) ? i : COUNT(def1) - 1]; + planner.axis_steps_per_mm[i] = i < XYZ + esteppers ? tmp2[i] : def2[i < COUNT(def2) ? i : COUNT(def2) - 1]; + planner.max_feedrate_mm_s[i] = i < XYZ + esteppers ? tmp3[i] : def3[i < COUNT(def3) ? i : COUNT(def3) - 1]; } EEPROM_READ(planner.acceleration); @@ -1012,9 +1022,14 @@ void MarlinSettings::postprocess() { EEPROM_READ(planner.travel_acceleration); EEPROM_READ(planner.min_feedrate_mm_s); EEPROM_READ(planner.min_travel_feedrate_mm_s); - EEPROM_READ(planner.min_segment_time_us); EEPROM_READ(planner.max_jerk); + #if ENABLED(JUNCTION_DEVIATION) + EEPROM_READ(planner.junction_deviation_mm); + #else + EEPROM_READ(dummy); + #endif + // // Home Offset (M206) // @@ -1699,17 +1714,21 @@ void MarlinSettings::reset() { planner.max_acceleration_mm_per_s2[i] = pgm_read_dword_near(&tmp3[i < COUNT(tmp3) ? i : COUNT(tmp3) - 1]); } + planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME; planner.acceleration = DEFAULT_ACCELERATION; planner.retract_acceleration = DEFAULT_RETRACT_ACCELERATION; planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION; planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE; planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE; - planner.min_segment_time_us = DEFAULT_MINSEGMENTTIME; planner.max_jerk[X_AXIS] = DEFAULT_XJERK; planner.max_jerk[Y_AXIS] = DEFAULT_YJERK; planner.max_jerk[Z_AXIS] = DEFAULT_ZJERK; planner.max_jerk[E_AXIS] = DEFAULT_EJERK; + #if ENABLED(JUNCTION_DEVIATION) + planner.junction_deviation_mm = JUNCTION_DEVIATION_MM; + #endif + #if HAS_HOME_OFFSET ZERO(home_offset); #endif @@ -2077,16 +2096,34 @@ void MarlinSettings::reset() { if (!forReplay) { CONFIG_ECHO_START; - SERIAL_ECHOLNPGM("Advanced: S T B X Z E"); + SERIAL_ECHOPGM("Advanced: B S T"); + #if ENABLED(JUNCTION_DEVIATION) + SERIAL_ECHOPGM(" J"); + #else + SERIAL_ECHOPGM(" X Y Z"); + #endif + #if DISABLED(JUNCTION_DEVIATION) || ENABLED(LIN_ADVANCE) + SERIAL_ECHOPGM(" E"); + #endif + SERIAL_EOL(); } CONFIG_ECHO_START; - SERIAL_ECHOPAIR(" M205 S", LINEAR_UNIT(planner.min_feedrate_mm_s)); + SERIAL_ECHOPAIR(" M205 B", LINEAR_UNIT(planner.min_segment_time_us)); + SERIAL_ECHOPAIR(" S", LINEAR_UNIT(planner.min_feedrate_mm_s)); SERIAL_ECHOPAIR(" T", LINEAR_UNIT(planner.min_travel_feedrate_mm_s)); - SERIAL_ECHOPAIR(" B", planner.min_segment_time_us); - SERIAL_ECHOPAIR(" X", LINEAR_UNIT(planner.max_jerk[X_AXIS])); - SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS])); - SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS])); - SERIAL_ECHOLNPAIR(" E", LINEAR_UNIT(planner.max_jerk[E_AXIS])); + + #if ENABLED(JUNCTION_DEVIATION) + SERIAL_ECHOPAIR(" J", LINEAR_UNIT(planner.junction_deviation_mm)); + #else + SERIAL_ECHOPAIR(" X", LINEAR_UNIT(planner.max_jerk[X_AXIS])); + SERIAL_ECHOPAIR(" Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS])); + SERIAL_ECHOPAIR(" Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS])); + #endif + #if DISABLED(JUNCTION_DEVIATION) || ENABLED(LIN_ADVANCE) + SERIAL_ECHOPAIR(" E", LINEAR_UNIT(planner.max_jerk[E_AXIS])); + #endif + + SERIAL_EOL(); #if HAS_M206_COMMAND if (!forReplay) { diff --git a/Marlin/language_en.h b/Marlin/language_en.h index c06a17fa9..1cf356766 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -537,6 +537,9 @@ #ifndef MSG_VE_JERK #define MSG_VE_JERK _UxGT("Ve-jerk") #endif +#ifndef MSG_JUNCTION_DEVIATION + #define MSG_JUNCTION_DEVIATION _UxGT("Junction Dev") +#endif #ifndef MSG_VELOCITY #define MSG_VELOCITY _UxGT("Velocity") #endif diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index b4099a9ca..ccc14f982 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -99,9 +99,23 @@ uint16_t Planner::cleaning_buffer_counter; // A counter to disable queuing of uint8_t Planner::delay_before_delivering, // This counter delays delivery of blocks when queue becomes empty to allow the opportunity of merging blocks Planner::block_buffer_planned; // Index of the optimally planned block -float Planner::max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second - Planner::axis_steps_per_mm[XYZE_N], - Planner::steps_to_mm[XYZE_N]; +uint32_t Planner::max_acceleration_mm_per_s2[XYZE_N], // (mm/s^2) M201 XYZE + Planner::max_acceleration_steps_per_s2[XYZE_N], // (steps/s^2) Derived from mm_per_s2 + Planner::min_segment_time_us; // (µs) M205 B + +float Planner::max_feedrate_mm_s[XYZE_N], // (mm/s) M203 XYZE - Max speeds + Planner::axis_steps_per_mm[XYZE_N], // (steps) M92 XYZE - Steps per millimeter + Planner::steps_to_mm[XYZE_N], // (mm) Millimeters per step + Planner::min_feedrate_mm_s, // (mm/s) M205 S - Minimum linear feedrate + Planner::acceleration, // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves. + Planner::retract_acceleration, // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes + Planner::travel_acceleration, // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves. + Planner::max_jerk[XYZE], // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration. + Planner::min_travel_feedrate_mm_s; // (mm/s) M205 T - Minimum travel feedrate + +#if ENABLED(JUNCTION_DEVIATION) + float Planner::junction_deviation_mm; // (mm) M205 J +#endif #if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED) bool Planner::abort_on_endstop_hit = false; @@ -121,19 +135,6 @@ float Planner::e_factor[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(1.0); // The flow perce Planner::volumetric_multiplier[EXTRUDERS]; // Reciprocal of cross-sectional area of filament (in mm^2). Pre-calculated to reduce computation in the planner #endif -uint32_t Planner::max_acceleration_steps_per_s2[XYZE_N], - Planner::max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override by software - -uint32_t Planner::min_segment_time_us; - -// Initialized by settings.load() -float Planner::min_feedrate_mm_s, - Planner::acceleration, // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all printing moves. M204 SXXXX - Planner::retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX - Planner::travel_acceleration, // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX - Planner::max_jerk[XYZE], // The largest speed change requiring no acceleration - Planner::min_travel_feedrate_mm_s; - #if HAS_LEVELING bool Planner::leveling_active = false; // Flag that auto bed leveling is enabled #if ABL_PLANAR @@ -2169,7 +2170,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move, const float junction_acceleration = limit_value_by_axis_maximum(block->acceleration, junction_unit_vec), sin_theta_d2 = SQRT(0.5 * (1.0 - junction_cos_theta)); // Trig half angle identity. Always positive. - vmax_junction_sqr = (junction_acceleration * JUNCTION_DEVIATION_MM * sin_theta_d2) / (1.0 - sin_theta_d2); + vmax_junction_sqr = (junction_acceleration * junction_deviation_mm * sin_theta_d2) / (1.0 - sin_theta_d2); if (block->millimeters < 1.0) { // Fast acos approximation, minus the error bar to be safe diff --git a/Marlin/planner.h b/Marlin/planner.h index 39b23928c..7060556c1 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -190,20 +190,23 @@ class Planner { // May be auto-adjusted by a filament width sensor #endif + static uint32_t max_acceleration_steps_per_s2[XYZE_N], + max_acceleration_mm_per_s2[XYZE_N], // Use M201 to override + min_segment_time_us; // Use 'M205 B<µs>' to override static float max_feedrate_mm_s[XYZE_N], // Max speeds in mm per second axis_steps_per_mm[XYZE_N], - steps_to_mm[XYZE_N]; - static uint32_t max_acceleration_steps_per_s2[XYZE_N], - max_acceleration_mm_per_s2[XYZE_N]; // Use M201 to override - - static uint32_t min_segment_time_us; // Use 'M205 B<µs>' to override - static float min_feedrate_mm_s, + steps_to_mm[XYZE_N], + min_feedrate_mm_s, acceleration, // Normal acceleration mm/s^2 DEFAULT ACCELERATION for all printing moves. M204 SXXXX retract_acceleration, // Retract acceleration mm/s^2 filament pull-back and push-forward while standing still in the other axes M204 TXXXX travel_acceleration, // Travel acceleration mm/s^2 DEFAULT ACCELERATION for all NON printing moves. M204 MXXXX max_jerk[XYZE], // The largest speed change requiring no acceleration min_travel_feedrate_mm_s; + #if ENABLED(JUNCTION_DEVIATION) + static float junction_deviation_mm; // Initialized by EEPROM + #endif + #if HAS_LEVELING static bool leveling_active; // Flag that bed leveling is enabled #if ABL_PLANAR diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 0519c6f6e..967aa6cbb 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -3742,12 +3742,16 @@ void lcd_quick_feedback(const bool clear_buttons) { START_MENU(); MENU_BACK(MSG_MOTION); - MENU_ITEM_EDIT(float3, MSG_VA_JERK, &planner.max_jerk[A_AXIS], 1, 990); - MENU_ITEM_EDIT(float3, MSG_VB_JERK, &planner.max_jerk[B_AXIS], 1, 990); - #if ENABLED(DELTA) - MENU_ITEM_EDIT(float3, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 1, 990); + #if ENABLED(JUNCTION_DEVIATION) + MENU_ITEM_EDIT(float3, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0, 5); #else - MENU_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1, 990); + MENU_ITEM_EDIT(float3, MSG_VA_JERK, &planner.max_jerk[A_AXIS], 1, 990); + MENU_ITEM_EDIT(float3, MSG_VB_JERK, &planner.max_jerk[B_AXIS], 1, 990); + #if ENABLED(DELTA) + MENU_ITEM_EDIT(float3, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 1, 990); + #else + MENU_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1, 990); + #endif #endif MENU_ITEM_EDIT(float3, MSG_VE_JERK, &planner.max_jerk[E_AXIS], 1, 990);