Browse Source

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

Fix for advance extrusion algorithms
Scott Lahteine 9 years ago
parent
commit
ba94c89e21
2 changed files with 23 additions and 39 deletions
  1. 20
    36
      Marlin/stepper.cpp
  2. 3
    3
      Marlin/stepper.h

+ 20
- 36
Marlin/stepper.cpp View File

@@ -82,10 +82,10 @@ unsigned int Stepper::cleaning_buffer_counter = 0;
82 82
   bool Stepper::locked_z2_motor = false;
83 83
 #endif
84 84
 
85
-long  Stepper::counter_X = 0,
86
-      Stepper::counter_Y = 0,
87
-      Stepper::counter_Z = 0,
88
-      Stepper::counter_E = 0;
85
+long Stepper::counter_X = 0,
86
+     Stepper::counter_Y = 0,
87
+     Stepper::counter_Z = 0,
88
+     Stepper::counter_E = 0;
89 89
 
90 90
 volatile uint32_t Stepper::step_events_completed = 0; // The number of step events executed in the current block
91 91
 
@@ -95,17 +95,17 @@ volatile uint32_t Stepper::step_events_completed = 0; // The number of step even
95 95
   volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
96 96
 
97 97
   #if ENABLED(LIN_ADVANCE)
98
-    volatile int Stepper::e_steps[E_STEPPERS];
98
+    volatile long Stepper::e_steps[E_STEPPERS];
99 99
     int Stepper::extruder_advance_k = LIN_ADVANCE_K,
100 100
         Stepper::final_estep_rate,
101 101
         Stepper::current_estep_rate[E_STEPPERS],
102 102
         Stepper::current_adv_steps[E_STEPPERS];
103 103
   #else
104
-    long  Stepper::e_steps[E_STEPPERS],
105
-          Stepper::final_advance = 0,
106
-          Stepper::old_advance = 0,
107
-          Stepper::advance_rate,
108
-          Stepper::advance;
104
+    long Stepper::e_steps[E_STEPPERS],
105
+         Stepper::final_advance = 0,
106
+         Stepper::old_advance = 0,
107
+         Stepper::advance_rate,
108
+         Stepper::advance;
109 109
   #endif
110 110
 #endif
111 111
 
@@ -299,16 +299,14 @@ void Stepper::set_directions() {
299 299
     SET_STEP_DIR(Z); // C
300 300
   #endif
301 301
 
302
-  #if DISABLED(ADVANCE)
303
-    if (motor_direction(E_AXIS)) {
304
-      REV_E_DIR();
305
-      count_direction[E_AXIS] = -1;
306
-    }
307
-    else {
308
-      NORM_E_DIR();
309
-      count_direction[E_AXIS] = 1;
310
-    }
311
-  #endif //!ADVANCE
302
+  if (motor_direction(E_AXIS)) {
303
+    REV_E_DIR();
304
+    count_direction[E_AXIS] = -1;
305
+  }
306
+  else {
307
+    NORM_E_DIR();
308
+    count_direction[E_AXIS] = 1;
309
+  }
312 310
 }
313 311
 
314 312
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
@@ -683,29 +681,15 @@ void Stepper::isr() {
683 681
     old_OCR0A += eISR_Rate;
684 682
     OCR0A = old_OCR0A;
685 683
 
686
-    #define SET_E_STEP_DIR(INDEX) \
687
-      E## INDEX ##_DIR_WRITE(e_steps[INDEX] <= 0 ? INVERT_E## INDEX ##_DIR : !INVERT_E## INDEX ##_DIR)
688
-
689 684
     #define START_E_PULSE(INDEX) \
690
-      if (e_steps[INDEX]) E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN)
685
+      if (e_steps[INDEX]) E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN)
691 686
 
692 687
     #define STOP_E_PULSE(INDEX) \
693 688
       if (e_steps[INDEX]) { \
694 689
         e_steps[INDEX] <= 0 ? ++e_steps[INDEX] : --e_steps[INDEX]; \
695
-        E## INDEX ##_STEP_WRITE(!INVERT_E_STEP_PIN); \
690
+        E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \
696 691
       }
697 692
 
698
-    SET_E_STEP_DIR(0);
699
-    #if E_STEPPERS > 1
700
-      SET_E_STEP_DIR(1);
701
-      #if E_STEPPERS > 2
702
-        SET_E_STEP_DIR(2);
703
-        #if E_STEPPERS > 3
704
-          SET_E_STEP_DIR(3);
705
-        #endif
706
-      #endif
707
-    #endif
708
-
709 693
     // Step all E steppers that have steps
710 694
     for (uint8_t i = 0; i < step_loops; i++) {
711 695
 

+ 3
- 3
Marlin/stepper.h View File

@@ -113,13 +113,13 @@ class Stepper {
113 113
       static unsigned char old_OCR0A;
114 114
       static volatile unsigned char eISR_Rate;
115 115
       #if ENABLED(LIN_ADVANCE)
116
-        static volatile int e_steps[E_STEPPERS];
116
+        static volatile long e_steps[E_STEPPERS];
117 117
         static int extruder_advance_k;
118 118
         static int final_estep_rate;
119 119
         static int current_estep_rate[E_STEPPERS]; // Actual extruder speed [steps/s]
120 120
         static int current_adv_steps[E_STEPPERS];  // The amount of current added esteps due to advance.
121
-                                                  // i.e., the current amount of pressure applied
122
-                                                  // to the spring (=filament).
121
+                                                   // i.e., the current amount of pressure applied
122
+                                                   // to the spring (=filament).
123 123
       #else
124 124
         static long e_steps[E_STEPPERS];
125 125
         static long advance_rate, advance, final_advance;

Loading…
Cancel
Save