Browse Source

Calculate dm and e-steps earlier in planner

Scott Lahteine 8 years ago
parent
commit
1cf878fdb1
1 changed files with 40 additions and 36 deletions
  1. 40
    36
      Marlin/planner.cpp

+ 40
- 36
Marlin/planner.cpp View File

@@ -656,6 +656,35 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
656 656
     }
657 657
   #endif
658 658
 
659
+  // Compute direction bit-mask for this block
660
+  uint8_t dm = 0;
661
+  #if ENABLED(COREXY)
662
+    if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
663
+    if (db < 0) SBI(dm, Y_HEAD); // ...and Y
664
+    if (dc < 0) SBI(dm, Z_AXIS);
665
+    if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction
666
+    if (da - db < 0) SBI(dm, B_AXIS); // Motor B direction
667
+  #elif ENABLED(COREXZ)
668
+    if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
669
+    if (db < 0) SBI(dm, Y_AXIS);
670
+    if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
671
+    if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction
672
+    if (da - dc < 0) SBI(dm, C_AXIS); // Motor C direction
673
+  #elif ENABLED(COREYZ)
674
+    if (da < 0) SBI(dm, X_AXIS);
675
+    if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
676
+    if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
677
+    if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction
678
+    if (db - dc < 0) SBI(dm, C_AXIS); // Motor C direction
679
+  #else
680
+    if (da < 0) SBI(dm, X_AXIS);
681
+    if (db < 0) SBI(dm, Y_AXIS);
682
+    if (dc < 0) SBI(dm, Z_AXIS);
683
+  #endif
684
+  if (de < 0) SBI(dm, E_AXIS);
685
+
686
+  int32_t esteps = labs(de) * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01 + 0.5;
687
+
659 688
   // Calculate the buffer head after we push this byte
660 689
   int next_buffer_head = next_block_index(block_buffer_head);
661 690
 
@@ -669,6 +698,9 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
669 698
   // Clear all flags, including the "busy" bit
670 699
   block->flag = 0;
671 700
 
701
+  // Set direction bits
702
+  block->direction_bits = dm;
703
+
672 704
   // Number of steps for each axis
673 705
   #if ENABLED(COREXY)
674 706
     // corexy planning
@@ -693,8 +725,8 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
693 725
     block->steps[Z_AXIS] = labs(dc);
694 726
   #endif
695 727
 
696
-  block->steps[E_AXIS] = labs(de) * volumetric_multiplier[extruder] * flow_percentage[extruder] * 0.01 + 0.5;
697
-  block->step_event_count = MAX4(block->steps[X_AXIS], block->steps[Y_AXIS], block->steps[Z_AXIS], block->steps[E_AXIS]);
728
+  block->steps[E_AXIS] = esteps;
729
+  block->step_event_count = MAX4(block->steps[X_AXIS], block->steps[Y_AXIS], block->steps[Z_AXIS], esteps);
698 730
 
699 731
   // Bail if this is a zero-length block
700 732
   if (block->step_event_count < MIN_STEPS_PER_SEGMENT) return;
@@ -714,34 +746,6 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
714 746
     block->e_to_p_pressure = baricuda_e_to_p_pressure;
715 747
   #endif
716 748
 
717
-  // Compute direction bit-mask for this block
718
-  uint8_t dm = 0;
719
-  #if ENABLED(COREXY)
720
-    if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
721
-    if (db < 0) SBI(dm, Y_HEAD); // ...and Y
722
-    if (dc < 0) SBI(dm, Z_AXIS);
723
-    if (da + db < 0) SBI(dm, A_AXIS); // Motor A direction
724
-    if (da - db < 0) SBI(dm, B_AXIS); // Motor B direction
725
-  #elif ENABLED(COREXZ)
726
-    if (da < 0) SBI(dm, X_HEAD); // Save the real Extruder (head) direction in X Axis
727
-    if (db < 0) SBI(dm, Y_AXIS);
728
-    if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
729
-    if (da + dc < 0) SBI(dm, A_AXIS); // Motor A direction
730
-    if (da - dc < 0) SBI(dm, C_AXIS); // Motor C direction
731
-  #elif ENABLED(COREYZ)
732
-    if (da < 0) SBI(dm, X_AXIS);
733
-    if (db < 0) SBI(dm, Y_HEAD); // Save the real Extruder (head) direction in Y Axis
734
-    if (dc < 0) SBI(dm, Z_HEAD); // ...and Z
735
-    if (db + dc < 0) SBI(dm, B_AXIS); // Motor B direction
736
-    if (db - dc < 0) SBI(dm, C_AXIS); // Motor C direction
737
-  #else
738
-    if (da < 0) SBI(dm, X_AXIS);
739
-    if (db < 0) SBI(dm, Y_AXIS);
740
-    if (dc < 0) SBI(dm, Z_AXIS);
741
-  #endif
742
-  if (de < 0) SBI(dm, E_AXIS);
743
-  block->direction_bits = dm;
744
-
745 749
   block->active_extruder = extruder;
746 750
 
747 751
   //enable active axes
@@ -768,7 +772,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
768 772
   #endif
769 773
 
770 774
   // Enable extruder(s)
771
-  if (block->steps[E_AXIS]) {
775
+  if (esteps) {
772 776
 
773 777
     #if ENABLED(DISABLE_INACTIVE_EXTRUDER) // Enable only the selected extruder
774 778
 
@@ -837,7 +841,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
837 841
     #endif
838 842
   }
839 843
 
840
-  if (block->steps[E_AXIS])
844
+  if (esteps)
841 845
     NOLESS(fr_mm_s, min_feedrate_mm_s);
842 846
   else
843 847
     NOLESS(fr_mm_s, min_travel_feedrate_mm_s);
@@ -1035,7 +1039,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1035 1039
     }while(0)
1036 1040
 
1037 1041
     // Start with print or travel acceleration
1038
-    accel = ceil((block->steps[E_AXIS] ? acceleration : travel_acceleration) * steps_per_mm);
1042
+    accel = ceil((esteps ? acceleration : travel_acceleration) * steps_per_mm);
1039 1043
 
1040 1044
     // Limit acceleration per axis
1041 1045
     if (block->step_event_count <= cutoff_long){
@@ -1222,18 +1226,18 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
1222 1226
     // This leads to an enormous number of advance steps due to a huge e_acceleration.
1223 1227
     // The math is correct, but you don't want a retract move done with advance!
1224 1228
     // So this situation is filtered out here.
1225
-    if (!block->steps[E_AXIS] || (!block->steps[X_AXIS] && !block->steps[Y_AXIS]) || stepper.get_advance_k() == 0 || (uint32_t) block->steps[E_AXIS] == block->step_event_count) {
1229
+    if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS]) || stepper.get_advance_k() == 0 || (uint32_t)esteps == block->step_event_count) {
1226 1230
       block->use_advance_lead = false;
1227 1231
     }
1228 1232
     else {
1229 1233
       block->use_advance_lead = true;
1230
-      block->e_speed_multiplier8 = (block->steps[E_AXIS] << 8) / block->step_event_count;
1234
+      block->e_speed_multiplier8 = (esteps << 8) / block->step_event_count;
1231 1235
     }
1232 1236
 
1233 1237
   #elif ENABLED(ADVANCE)
1234 1238
 
1235 1239
     // Calculate advance rate
1236
-    if (!block->steps[E_AXIS] || (!block->steps[X_AXIS] && !block->steps[Y_AXIS] && !block->steps[Z_AXIS])) {
1240
+    if (!esteps || (!block->steps[X_AXIS] && !block->steps[Y_AXIS] && !block->steps[Z_AXIS])) {
1237 1241
       block->advance_rate = 0;
1238 1242
       block->advance = 0;
1239 1243
     }

Loading…
Cancel
Save