Browse Source

Improvements for junction_deviation_mm

- Drop `max_jerk` with `JUNCTION_DEVIATION`
- Add `max_e_jerk_factor` for use by `LIN_ADVANCE`
- Recalculate `max_e_jerk_factor` when `junction_deviation_mm` changes
- Fix LCD editing of `junction_deviation_mm`
pull/1/head
Scott Lahteine 7 years ago
parent
commit
9d04f47d98
  1. 6
      Marlin/src/gcode/config/M200-M205.cpp
  2. 2
      Marlin/src/gcode/config/M92.cpp
  3. 4
      Marlin/src/lcd/ultralcd.cpp
  4. 20
      Marlin/src/module/configuration_store.cpp
  5. 24
      Marlin/src/module/planner.cpp
  6. 38
      Marlin/src/module/planner.h

6
Marlin/src/gcode/config/M200-M205.cpp

@ -134,8 +134,10 @@ void GcodeSuite::M205() {
#if ENABLED(JUNCTION_DEVIATION)
if (parser.seen('J')) {
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.recalculate_max_e_jerk_factor();
}
else {
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM("?J out of range (0.01 to 0.3)");
@ -151,8 +153,6 @@ void GcodeSuite::M205() {
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
}

2
Marlin/src/gcode/config/M92.cpp

@ -39,7 +39,9 @@ void GcodeSuite::M92() {
const float value = parser.value_per_axis_unit((AxisEnum)(E_AXIS + TARGET_EXTRUDER));
if (value < 20.0) {
float factor = planner.axis_steps_per_mm[E_AXIS + TARGET_EXTRUDER] / value; // increase e constants if M92 E14 is given for netfab.
#if DISABLED(JUNCTION_DEVIATION)
planner.max_jerk[E_AXIS] *= factor;
#endif
planner.max_feedrate_mm_s[E_AXIS + TARGET_EXTRUDER] *= factor;
planner.max_acceleration_steps_per_s2[E_AXIS + TARGET_EXTRUDER] *= factor;
}

4
Marlin/src/lcd/ultralcd.cpp

@ -3752,7 +3752,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
MENU_BACK(MSG_MOTION);
#if ENABLED(JUNCTION_DEVIATION)
MENU_ITEM_EDIT(float3, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01, 0.3);
MENU_ITEM_EDIT_CALLBACK(float43, MSG_JUNCTION_DEVIATION, &planner.junction_deviation_mm, 0.01, 0.3, planner.recalculate_max_e_jerk_factor);
#else
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);
@ -3761,8 +3761,8 @@ void lcd_quick_feedback(const bool clear_buttons) {
#else
MENU_MULTIPLIER_ITEM_EDIT(float52sign, MSG_VC_JERK, &planner.max_jerk[C_AXIS], 0.1, 990);
#endif
#endif
MENU_MULTIPLIER_ITEM_EDIT(float3, MSG_VE_JERK, &planner.max_jerk[E_AXIS], 1, 990);
#endif
END_MENU();
}

20
Marlin/src/module/configuration_store.cpp

@ -330,6 +330,10 @@ void MarlinSettings::postprocess() {
fwretract.refresh_autoretract();
#endif
#if ENABLED(JUNCTION_DEVIATION) && ENABLED(LIN_ADVANCE)
planner.recalculate_max_e_jerk_factor();
#endif
// Refresh steps_to_mm with the reciprocal of axis_steps_per_mm
// and init stepper.count[], planner.position[] with current_position
planner.refresh_positioning();
@ -411,11 +415,13 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(planner.travel_acceleration);
EEPROM_WRITE(planner.min_feedrate_mm_s);
EEPROM_WRITE(planner.min_travel_feedrate_mm_s);
EEPROM_WRITE(planner.max_jerk);
#if ENABLED(JUNCTION_DEVIATION)
const float planner_max_jerk[] = { DEFAULT_XJERK, DEFAULT_YJERK, DEFAULT_ZJERK, DEFAULT_EJERK };
EEPROM_WRITE(planner_max_jerk);
EEPROM_WRITE(planner.junction_deviation_mm);
#else
EEPROM_WRITE(planner.max_jerk);
dummy = 0.02;
EEPROM_WRITE(dummy);
#endif
@ -1008,11 +1014,12 @@ 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.max_jerk);
#if ENABLED(JUNCTION_DEVIATION)
for (uint8_t q = 4; q--;) EEPROM_READ(dummy);
EEPROM_READ(planner.junction_deviation_mm);
#else
EEPROM_READ(planner.max_jerk);
EEPROM_READ(dummy);
#endif
@ -1724,13 +1731,14 @@ void MarlinSettings::reset(PORTARG_SOLO) {
planner.travel_acceleration = DEFAULT_TRAVEL_ACCELERATION;
planner.min_feedrate_mm_s = DEFAULT_MINIMUMFEEDRATE;
planner.min_travel_feedrate_mm_s = DEFAULT_MINTRAVELFEEDRATE;
#if ENABLED(JUNCTION_DEVIATION)
planner.junction_deviation_mm = JUNCTION_DEVIATION_MM;
#else
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
@ -2135,8 +2143,6 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOPAIR_P(port, " X", LINEAR_UNIT(planner.max_jerk[X_AXIS]));
SERIAL_ECHOPAIR_P(port, " Y", LINEAR_UNIT(planner.max_jerk[Y_AXIS]));
SERIAL_ECHOPAIR_P(port, " Z", LINEAR_UNIT(planner.max_jerk[Z_AXIS]));
#endif
#if DISABLED(JUNCTION_DEVIATION) || ENABLED(LIN_ADVANCE)
SERIAL_ECHOPAIR_P(port, " E", LINEAR_UNIT(planner.max_jerk[E_AXIS]));
#endif

24
Marlin/src/module/planner.cpp

@ -121,11 +121,15 @@ float Planner::max_feedrate_mm_s[XYZE_N], // (mm/s) M203 XYZE - Max speeds
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
#if ENABLED(LIN_ADVANCE)
float Planner::max_e_jerk_factor; // Calculated from junction_deviation_mm
#endif
#else
float Planner::max_jerk[XYZE]; // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration.
#endif
#if ENABLED(ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
@ -134,6 +138,9 @@ float Planner::max_feedrate_mm_s[XYZE_N], // (mm/s) M203 XYZE - Max speeds
#if ENABLED(DISTINCT_E_FACTORS)
uint8_t Planner::last_extruder = 0; // Respond to extruder change
#define _EINDEX (E_AXIS + active_extruder)
#else
#define _EINDEX E_AXIS
#endif
int16_t Planner::flow_percentage[EXTRUDERS] = ARRAY_BY_EXTRUDERS1(100); // Extrusion factor for each extruder
@ -2021,6 +2028,13 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
accel = CEIL((esteps ? acceleration : travel_acceleration) * steps_per_mm);
#if ENABLED(LIN_ADVANCE)
#if ENABLED(JUNCTION_DEVIATION)
#define MAX_E_JERK (max_e_jerk_factor * max_acceleration_mm_per_s2[_EINDEX])
#else
#define MAX_E_JERK max_jerk[E_AXIS]
#endif
/**
*
* Use LIN_ADVANCE for blocks if all these are true:
@ -2051,10 +2065,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
if (block->e_D_ratio > 3.0)
block->use_advance_lead = false;
else {
const uint32_t max_accel_steps_per_s2 = max_jerk[E_AXIS] / (extruder_advance_K * block->e_D_ratio) * steps_per_mm;
const uint32_t max_accel_steps_per_s2 = MAX_E_JERK / (extruder_advance_K * block->e_D_ratio) * steps_per_mm;
#if ENABLED(LA_DEBUG)
if (accel > max_accel_steps_per_s2)
SERIAL_ECHOLNPGM("Acceleration limited.");
if (accel > max_accel_steps_per_s2) SERIAL_ECHOLNPGM("Acceleration limited.");
#endif
NOMORE(accel, max_accel_steps_per_s2);
}
@ -2459,10 +2472,7 @@ bool Planner::buffer_segment(const float &a, const float &b, const float &c, con
void Planner::_set_position_mm(const float &a, const float &b, const float &c, const float &e) {
#if ENABLED(DISTINCT_E_FACTORS)
#define _EINDEX (E_AXIS + active_extruder)
last_extruder = active_extruder;
#else
#define _EINDEX E_AXIS
#endif
position[A_AXIS] = LROUND(a * axis_steps_per_mm[A_AXIS]),
position[B_AXIS] = LROUND(b * axis_steps_per_mm[B_AXIS]),

38
Marlin/src/module/planner.h

@ -195,21 +195,25 @@ 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],
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;
static uint32_t max_acceleration_mm_per_s2[XYZE_N], // (mm/s^2) M201 XYZE
max_acceleration_steps_per_s2[XYZE_N], // (steps/s^2) Derived from mm_per_s2
min_segment_time_us; // (µs) M205 B
static float max_feedrate_mm_s[XYZE_N], // (mm/s) M203 XYZE - Max speeds
axis_steps_per_mm[XYZE_N], // (steps) M92 XYZE - Steps per millimeter
steps_to_mm[XYZE_N], // (mm) Millimeters per step
min_feedrate_mm_s, // (mm/s) M205 S - Minimum linear feedrate
acceleration, // (mm/s^2) M204 S - Normal acceleration. DEFAULT ACCELERATION for all printing moves.
retract_acceleration, // (mm/s^2) M204 R - Retract acceleration. Filament pull-back and push-forward while standing still in the other axes
travel_acceleration, // (mm/s^2) M204 T - Travel acceleration. DEFAULT ACCELERATION for all NON printing moves.
min_travel_feedrate_mm_s; // (mm/s) M205 T - Minimum travel feedrate
#if ENABLED(JUNCTION_DEVIATION)
static float junction_deviation_mm; // Initialized by EEPROM
static float junction_deviation_mm; // (mm) M205 J
#if ENABLED(LIN_ADVANCE)
static float max_e_jerk_factor; // Calculated from junction_deviation_mm
#endif
#else
static float max_jerk[XYZE]; // (mm/s^2) M205 XYZE - The largest speed change requiring no acceleration.
#endif
#if HAS_LEVELING
@ -745,6 +749,14 @@ class Planner {
static void autotemp_M104_M109();
#endif
#if ENABLED(JUNCTION_DEVIATION)
FORCE_INLINE static void recalculate_max_e_jerk_factor() {
#if ENABLED(LIN_ADVANCE)
max_e_jerk_factor = SQRT(SQRT(0.5) * junction_deviation_mm) * RECIPROCAL(1.0 - SQRT(0.5));
#endif
}
#endif
private:
/**

Loading…
Cancel
Save