Merge pull request #4852 from esenapaj/Fix-for-advance-extrusion-algorithms

Fix for advance extrusion algorithms
This commit is contained in:
Scott Lahteine 2016-09-20 11:33:14 -05:00 committed by GitHub
commit ba94c89e21
2 changed files with 23 additions and 39 deletions

View file

@ -95,7 +95,7 @@ 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],
@ -299,7 +299,6 @@ 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;
@ -308,7 +307,6 @@ void Stepper::set_directions() {
NORM_E_DIR();
count_direction[E_AXIS] = 1;
}
#endif //!ADVANCE
}
// "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++) {

View file

@ -113,7 +113,7 @@ 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]