Merge pull request #4852 from esenapaj/Fix-for-advance-extrusion-algorithms
Fix for advance extrusion algorithms
This commit is contained in:
commit
ba94c89e21
@ -82,10 +82,10 @@ unsigned int Stepper::cleaning_buffer_counter = 0;
|
||||
bool Stepper::locked_z2_motor = false;
|
||||
#endif
|
||||
|
||||
long Stepper::counter_X = 0,
|
||||
Stepper::counter_Y = 0,
|
||||
Stepper::counter_Z = 0,
|
||||
Stepper::counter_E = 0;
|
||||
long Stepper::counter_X = 0,
|
||||
Stepper::counter_Y = 0,
|
||||
Stepper::counter_Z = 0,
|
||||
Stepper::counter_E = 0;
|
||||
|
||||
volatile uint32_t Stepper::step_events_completed = 0; // The number of step events executed in the current block
|
||||
|
||||
@ -95,17 +95,17 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
|
||||
volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
|
||||
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
volatile int Stepper::e_steps[E_STEPPERS];
|
||||
volatile long Stepper::e_steps[E_STEPPERS];
|
||||
int Stepper::extruder_advance_k = LIN_ADVANCE_K,
|
||||
Stepper::final_estep_rate,
|
||||
Stepper::current_estep_rate[E_STEPPERS],
|
||||
Stepper::current_adv_steps[E_STEPPERS];
|
||||
#else
|
||||
long Stepper::e_steps[E_STEPPERS],
|
||||
Stepper::final_advance = 0,
|
||||
Stepper::old_advance = 0,
|
||||
Stepper::advance_rate,
|
||||
Stepper::advance;
|
||||
long Stepper::e_steps[E_STEPPERS],
|
||||
Stepper::final_advance = 0,
|
||||
Stepper::old_advance = 0,
|
||||
Stepper::advance_rate,
|
||||
Stepper::advance;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -299,16 +299,14 @@ void Stepper::set_directions() {
|
||||
SET_STEP_DIR(Z); // C
|
||||
#endif
|
||||
|
||||
#if DISABLED(ADVANCE)
|
||||
if (motor_direction(E_AXIS)) {
|
||||
REV_E_DIR();
|
||||
count_direction[E_AXIS] = -1;
|
||||
}
|
||||
else {
|
||||
NORM_E_DIR();
|
||||
count_direction[E_AXIS] = 1;
|
||||
}
|
||||
#endif //!ADVANCE
|
||||
if (motor_direction(E_AXIS)) {
|
||||
REV_E_DIR();
|
||||
count_direction[E_AXIS] = -1;
|
||||
}
|
||||
else {
|
||||
NORM_E_DIR();
|
||||
count_direction[E_AXIS] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
||||
@ -683,29 +681,15 @@ void Stepper::isr() {
|
||||
old_OCR0A += eISR_Rate;
|
||||
OCR0A = old_OCR0A;
|
||||
|
||||
#define SET_E_STEP_DIR(INDEX) \
|
||||
E## INDEX ##_DIR_WRITE(e_steps[INDEX] <= 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR)
|
||||
|
||||
#define START_E_PULSE(INDEX) \
|
||||
if (e_steps[INDEX]) E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN)
|
||||
if (e_steps[INDEX]) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN)
|
||||
|
||||
#define STOP_E_PULSE(INDEX) \
|
||||
if (e_steps[INDEX]) { \
|
||||
e_steps[INDEX] <= 0 ? ++e_steps[INDEX] : --e_steps[INDEX]; \
|
||||
E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN); \
|
||||
E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \
|
||||
}
|
||||
|
||||
SET_E_STEP_DIR(0);
|
||||
#if E_STEPPERS > 1
|
||||
SET_E_STEP_DIR(1);
|
||||
#if E_STEPPERS > 2
|
||||
SET_E_STEP_DIR(2);
|
||||
#if E_STEPPERS > 3
|
||||
SET_E_STEP_DIR(3);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Step all E steppers that have steps
|
||||
for (uint8_t i = 0; i < step_loops; i++) {
|
||||
|
||||
|
@ -113,13 +113,13 @@ class Stepper {
|
||||
static unsigned char old_OCR0A;
|
||||
static volatile unsigned char eISR_Rate;
|
||||
#if ENABLED(LIN_ADVANCE)
|
||||
static volatile int e_steps[E_STEPPERS];
|
||||
static volatile long e_steps[E_STEPPERS];
|
||||
static int extruder_advance_k;
|
||||
static int final_estep_rate;
|
||||
static int current_estep_rate[E_STEPPERS]; // Actual extruder speed [steps/s]
|
||||
static int current_adv_steps[E_STEPPERS]; // The amount of current added esteps due to advance.
|
||||
// i.e., the current amount of pressure applied
|
||||
// to the spring (=filament).
|
||||
// i.e., the current amount of pressure applied
|
||||
// to the spring (=filament).
|
||||
#else
|
||||
static long e_steps[E_STEPPERS];
|
||||
static long advance_rate, advance, final_advance;
|
||||
|
Loading…
Reference in New Issue
Block a user