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
   bool Stepper::locked_z2_motor = false;
82
   bool Stepper::locked_z2_motor = false;
83
 #endif
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
 volatile uint32_t Stepper::step_events_completed = 0; // The number of step events executed in the current block
90
 volatile uint32_t Stepper::step_events_completed = 0; // The number of step events executed in the current block
91
 
91
 
95
   volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
95
   volatile unsigned char Stepper::eISR_Rate = 200; // Keep the ISR at a low rate until needed
96
 
96
 
97
   #if ENABLED(LIN_ADVANCE)
97
   #if ENABLED(LIN_ADVANCE)
98
-    volatile int Stepper::e_steps[E_STEPPERS];
98
+    volatile long Stepper::e_steps[E_STEPPERS];
99
     int Stepper::extruder_advance_k = LIN_ADVANCE_K,
99
     int Stepper::extruder_advance_k = LIN_ADVANCE_K,
100
         Stepper::final_estep_rate,
100
         Stepper::final_estep_rate,
101
         Stepper::current_estep_rate[E_STEPPERS],
101
         Stepper::current_estep_rate[E_STEPPERS],
102
         Stepper::current_adv_steps[E_STEPPERS];
102
         Stepper::current_adv_steps[E_STEPPERS];
103
   #else
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
   #endif
109
   #endif
110
 #endif
110
 #endif
111
 
111
 
299
     SET_STEP_DIR(Z); // C
299
     SET_STEP_DIR(Z); // C
300
   #endif
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
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
312
 // "The Stepper Driver Interrupt" - This timer interrupt is the workhorse.
683
     old_OCR0A += eISR_Rate;
681
     old_OCR0A += eISR_Rate;
684
     OCR0A = old_OCR0A;
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
     #define START_E_PULSE(INDEX) \
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
     #define STOP_E_PULSE(INDEX) \
687
     #define STOP_E_PULSE(INDEX) \
693
       if (e_steps[INDEX]) { \
688
       if (e_steps[INDEX]) { \
694
         e_steps[INDEX] <= 0 ? ++e_steps[INDEX] : --e_steps[INDEX]; \
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
     // Step all E steppers that have steps
693
     // Step all E steppers that have steps
710
     for (uint8_t i = 0; i < step_loops; i++) {
694
     for (uint8_t i = 0; i < step_loops; i++) {
711
 
695
 

+ 3
- 3
Marlin/stepper.h View File

113
       static unsigned char old_OCR0A;
113
       static unsigned char old_OCR0A;
114
       static volatile unsigned char eISR_Rate;
114
       static volatile unsigned char eISR_Rate;
115
       #if ENABLED(LIN_ADVANCE)
115
       #if ENABLED(LIN_ADVANCE)
116
-        static volatile int e_steps[E_STEPPERS];
116
+        static volatile long e_steps[E_STEPPERS];
117
         static int extruder_advance_k;
117
         static int extruder_advance_k;
118
         static int final_estep_rate;
118
         static int final_estep_rate;
119
         static int current_estep_rate[E_STEPPERS]; // Actual extruder speed [steps/s]
119
         static int current_estep_rate[E_STEPPERS]; // Actual extruder speed [steps/s]
120
         static int current_adv_steps[E_STEPPERS];  // The amount of current added esteps due to advance.
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
       #else
123
       #else
124
         static long e_steps[E_STEPPERS];
124
         static long e_steps[E_STEPPERS];
125
         static long advance_rate, advance, final_advance;
125
         static long advance_rate, advance, final_advance;

Loading…
Cancel
Save