From 8692748ecd10e194e9820fea0305de8087670ec3 Mon Sep 17 00:00:00 2001 From: esenapaj Date: Mon, 19 Sep 2016 12:29:59 +0900 Subject: [PATCH 1/4] Fix broken direction signal of ADVANCED and LIN_ADVANCED Remove a setting proccess of E direction in advance_isr() --- Marlin/stepper.cpp | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 158e31dac..4026cc2ed 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -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,9 +681,6 @@ 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) @@ -695,17 +690,6 @@ void Stepper::isr() { 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++) { From b04ed8f9c3c4b8e9031e418095e1418733f662e0 Mon Sep 17 00:00:00 2001 From: esenapaj Date: Mon, 19 Sep 2016 21:05:22 +0900 Subject: [PATCH 2/4] Fix inverted stepper signal of ADVANCED and LIN_ADVANCED --- Marlin/stepper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 4026cc2ed..a25f0c76e 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -682,12 +682,12 @@ void Stepper::isr() { OCR0A = old_OCR0A; #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); \ } // Step all E steppers that have steps From 7e9576dc5b2f5149d27f6223ef28a152351c515b Mon Sep 17 00:00:00 2001 From: esenapaj Date: Tue, 20 Sep 2016 19:14:48 +0900 Subject: [PATCH 3/4] Extend the e_steps[] from int to long for allowing more than 32,767 E steps Probably needed for long straight lines when using high microstepping --- Marlin/stepper.cpp | 2 +- Marlin/stepper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index a25f0c76e..d2f47fd46 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -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], diff --git a/Marlin/stepper.h b/Marlin/stepper.h index d7507aff2..d5de89657 100644 --- a/Marlin/stepper.h +++ b/Marlin/stepper.h @@ -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] From 954563d6033ad2ae267bc899da92572d440418e0 Mon Sep 17 00:00:00 2001 From: esenapaj Date: Tue, 20 Sep 2016 19:16:05 +0900 Subject: [PATCH 4/4] Adjust spacing --- Marlin/stepper.cpp | 18 +++++++++--------- Marlin/stepper.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index d2f47fd46..a7eccd877 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -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 @@ -101,11 +101,11 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even 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 diff --git a/Marlin/stepper.h b/Marlin/stepper.h index d5de89657..b0f0779ea 100644 --- a/Marlin/stepper.h +++ b/Marlin/stepper.h @@ -118,8 +118,8 @@ class Stepper { 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;