Merge pull request #4963 from esenapaj/Fix-for-advance-algorithm
Move routine of direction signal of ADVANCE and LIN_ADVANCE from Stepper::isr() to Stepper::advance_isr()
This commit is contained in:
commit
3c97fa6e29
1 changed files with 26 additions and 10 deletions
|
@ -91,7 +91,7 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
|
||||||
|
|
||||||
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
#if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
|
||||||
|
|
||||||
unsigned char Stepper::old_OCR0A;
|
unsigned char Stepper::old_OCR0A = 0;
|
||||||
volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
|
volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
|
||||||
|
|
||||||
#if ENABLED(LIN_ADVANCE)
|
#if ENABLED(LIN_ADVANCE)
|
||||||
|
@ -299,14 +299,16 @@ void Stepper::set_directions() {
|
||||||
SET_STEP_DIR(Z); // C
|
SET_STEP_DIR(Z); // C
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (motor_direction(E_AXIS)) {
|
#if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
|
||||||
REV_E_DIR();
|
if (motor_direction(E_AXIS)) {
|
||||||
count_direction[E_AXIS] = -1;
|
REV_E_DIR();
|
||||||
}
|
count_direction[E_AXIS] = -1;
|
||||||
else {
|
}
|
||||||
NORM_E_DIR();
|
else {
|
||||||
count_direction[E_AXIS] = 1;
|
NORM_E_DIR();
|
||||||
}
|
count_direction[E_AXIS] = 1;
|
||||||
|
}
|
||||||
|
#endif // !ADVANCE && !LIN_ADVANCE
|
||||||
}
|
}
|
||||||
|
|
||||||
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
// "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
|
||||||
|
@ -680,15 +682,29 @@ void Stepper::isr() {
|
||||||
old_OCR0A += eISR_Rate;
|
old_OCR0A += eISR_Rate;
|
||||||
OCR0A = old_OCR0A;
|
OCR0A = old_OCR0A;
|
||||||
|
|
||||||
|
#define SET_E_STEP_DIR(INDEX) \
|
||||||
|
if (e_steps[INDEX]) E## INDEX ##_DIR_WRITE(e_steps[INDEX] < 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR)
|
||||||
|
|
||||||
#define START_E_PULSE(INDEX) \
|
#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) \
|
#define STOP_E_PULSE(INDEX) \
|
||||||
if (e_steps[INDEX]) { \
|
if (e_steps[INDEX]) { \
|
||||||
e_steps[INDEX] <= 0 ? ++e_steps[INDEX] : --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
|
||||||
|
|
||||||
#define CYCLES_EATEN_BY_E 60
|
#define CYCLES_EATEN_BY_E 60
|
||||||
|
|
||||||
// Step all E steppers that have steps
|
// Step all E steppers that have steps
|
||||||
|
|
Reference in a new issue