[2.0.x] Extruder-Distinct Linear Advance K Factors (#11789)

This commit is contained in:
Sam Lane
2018-09-11 04:37:32 +01:00
committed by Scott Lahteine
parent fe9f088d60
commit 4f883d5971
5 changed files with 82 additions and 26 deletions

View File

@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V56"
#define EEPROM_VERSION "V57"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -254,7 +254,7 @@ typedef struct SettingsDataStruct {
//
// LIN_ADVANCE
//
float planner_extruder_advance_K; // M900 K planner.extruder_advance_K
float planner_extruder_advance_K[EXTRUDERS]; // M900 K planner.extruder_advance_K
//
// HAS_MOTOR_CURRENT_PWM
@ -871,14 +871,13 @@ void MarlinSettings::postprocess() {
//
// Linear Advance
//
_FIELD_TEST(planner_extruder_advance_K);
#if ENABLED(LIN_ADVANCE)
EEPROM_WRITE(planner.extruder_advance_K);
LOOP_L_N(i, EXTRUDERS) EEPROM_WRITE(planner.extruder_advance_K[i]);
#else
dummy = 0;
EEPROM_WRITE(dummy);
LOOP_L_N(i, EXTRUDERS) EEPROM_WRITE(dummy);
#endif
_FIELD_TEST(motor_current_setting);
@ -1471,14 +1470,15 @@ void MarlinSettings::postprocess() {
//
// Linear Advance
//
_FIELD_TEST(planner_extruder_advance_K);
#if ENABLED(LIN_ADVANCE)
EEPROM_READ(planner.extruder_advance_K);
#else
EEPROM_READ(dummy);
#endif
LOOP_L_N(i, EXTRUDERS) {
#if ENABLED(LIN_ADVANCE)
EEPROM_READ(planner.extruder_advance_K[i]);
#else
EEPROM_READ(dummy);
#endif
}
//
// Motor Current PWM
@ -1957,7 +1957,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
reset_stepper_drivers();
#if ENABLED(LIN_ADVANCE)
planner.extruder_advance_K = LIN_ADVANCE_K;
LOOP_L_N(i, EXTRUDERS) planner.extruder_advance_K[i] = LIN_ADVANCE_K;
#endif
#if HAS_MOTOR_CURRENT_PWM
@ -2720,8 +2720,16 @@ void MarlinSettings::reset(PORTARG_SOLO) {
CONFIG_ECHO_START;
SERIAL_ECHOLNPGM_P(port, "Linear Advance:");
}
CONFIG_ECHO_START;
SERIAL_ECHOLNPAIR_P(port, " M900 K", planner.extruder_advance_K);
#if EXTRUDERS < 2
SERIAL_ECHOLNPAIR_P(port, " M900 K", planner.extruder_advance_K[0]);
#else
LOOP_L_N(i, EXTRUDERS) {
SERIAL_ECHOPAIR_P(port, " M900 T", int(i));
SERIAL_ECHOLNPAIR_P(port, " K", planner.extruder_advance_K[i]);
}
#endif
#endif
#if HAS_MOTOR_CURRENT_PWM

View File

@ -213,7 +213,7 @@ float Planner::previous_speed[NUM_AXIS],
#endif
#if ENABLED(LIN_ADVANCE)
float Planner::extruder_advance_K; // Initialized by settings.load()
float Planner::extruder_advance_K[EXTRUDERS]; // Initialized by settings.load()
#endif
#if HAS_POSITION_FLOAT
@ -1082,7 +1082,7 @@ void Planner::recalculate_trapezoids() {
calculate_trapezoid_for_block(current, current_entry_speed * nomr, next_entry_speed * nomr);
#if ENABLED(LIN_ADVANCE)
if (current->use_advance_lead) {
const float comp = current->e_D_ratio * extruder_advance_K * axis_steps_per_mm[E_AXIS];
const float comp = current->e_D_ratio * extruder_advance_K[active_extruder] * axis_steps_per_mm[E_AXIS];
current->max_adv_steps = current_nominal_speed * comp;
current->final_adv_steps = next_entry_speed * comp;
}
@ -1121,7 +1121,7 @@ void Planner::recalculate_trapezoids() {
calculate_trapezoid_for_block(next, next_entry_speed * nomr, float(MINIMUM_PLANNER_SPEED) * nomr);
#if ENABLED(LIN_ADVANCE)
if (next->use_advance_lead) {
const float comp = next->e_D_ratio * extruder_advance_K * axis_steps_per_mm[E_AXIS];
const float comp = next->e_D_ratio * extruder_advance_K[active_extruder] * axis_steps_per_mm[E_AXIS];
next->max_adv_steps = next_nominal_speed * comp;
next->final_adv_steps = (MINIMUM_PLANNER_SPEED) * comp;
}
@ -2130,12 +2130,12 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
*
* esteps : This is a print move, because we checked for A, B, C steps before.
*
* extruder_advance_K : There is an advance factor set.
* extruder_advance_K[active_extruder] : There is an advance factor set for this extruder.
*
* de > 0 : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
*/
block->use_advance_lead = esteps
&& extruder_advance_K
&& extruder_advance_K[active_extruder]
&& de > 0;
if (block->use_advance_lead) {
@ -2154,7 +2154,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
if (block->e_D_ratio > 3.0f)
block->use_advance_lead = false;
else {
const uint32_t max_accel_steps_per_s2 = MAX_E_JERK / (extruder_advance_K * block->e_D_ratio) * steps_per_mm;
const uint32_t max_accel_steps_per_s2 = MAX_E_JERK / (extruder_advance_K[active_extruder] * block->e_D_ratio) * steps_per_mm;
#if ENABLED(LA_DEBUG)
if (accel > max_accel_steps_per_s2) SERIAL_ECHOLNPGM("Acceleration limited.");
#endif
@ -2190,9 +2190,9 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
#endif
#if ENABLED(LIN_ADVANCE)
if (block->use_advance_lead) {
block->advance_speed = (STEPPER_TIMER_RATE) / (extruder_advance_K * block->e_D_ratio * block->acceleration * axis_steps_per_mm[E_AXIS_N]);
block->advance_speed = (STEPPER_TIMER_RATE) / (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * axis_steps_per_mm[E_AXIS_N]);
#if ENABLED(LA_DEBUG)
if (extruder_advance_K * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio)
if (extruder_advance_K[active_extruder] * block->e_D_ratio * block->acceleration * 2 < SQRT(block->nominal_speed_sqr) * block->e_D_ratio)
SERIAL_ECHOLNPGM("More than 2 steps per eISR loop executed.");
if (block->advance_speed < 200)
SERIAL_ECHOLNPGM("eISR running at > 10kHz.");

View File

@ -231,7 +231,7 @@ class Planner {
#endif
#if ENABLED(LIN_ADVANCE)
static float extruder_advance_K;
static float extruder_advance_K[EXTRUDERS];
#endif
#if HAS_POSITION_FLOAT