Browse Source

Merge pull request #4450 from thinkyhead/rc_fix_delta_optimization

Fix DELTA speed calculation
Scott Lahteine 8 years ago
parent
commit
256b03598d
1 changed files with 11 additions and 23 deletions
  1. 11
    23
      Marlin/planner.cpp

+ 11
- 23
Marlin/planner.cpp View File

@@ -804,15 +804,9 @@ void Planner::check_axes_activity() {
804 804
     #endif
805 805
   #else
806 806
     float delta_mm[4];
807
-    #if ENABLED(DELTA)
808
-      // On delta all axes (should!) have the same steps-per-mm
809
-      // so calculate distance in steps first, then do one division
810
-      // at the end to get millimeters
811
-    #else
812
-      delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
813
-      delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
814
-      delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
815
-    #endif
807
+    delta_mm[X_AXIS] = dx * steps_to_mm[X_AXIS];
808
+    delta_mm[Y_AXIS] = dy * steps_to_mm[Y_AXIS];
809
+    delta_mm[Z_AXIS] = dz * steps_to_mm[Z_AXIS];
816 810
   #endif
817 811
   delta_mm[E_AXIS] = 0.01 * (de * steps_to_mm[E_AXIS]) * volumetric_multiplier[extruder] * extruder_multiplier[extruder];
818 812
 
@@ -827,21 +821,15 @@ void Planner::check_axes_activity() {
827 821
         sq(delta_mm[X_HEAD]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_HEAD])
828 822
       #elif ENABLED(COREYZ)
829 823
         sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_HEAD]) + sq(delta_mm[Z_HEAD])
830
-      #elif ENABLED(DELTA)
831
-        sq(dx) + sq(dy) + sq(dz)
832 824
       #else
833 825
         sq(delta_mm[X_AXIS]) + sq(delta_mm[Y_AXIS]) + sq(delta_mm[Z_AXIS])
834 826
       #endif
835
-    )
836
-      #if ENABLED(DELTA)
837
-        * steps_to_mm[X_AXIS]
838
-      #endif
839
-    ;
827
+    );
840 828
   }
841 829
   float inverse_millimeters = 1.0 / block->millimeters;  // Inverse millimeters to remove multiple divides
842 830
 
843 831
   // Calculate moves/second for this move. No divide by zero due to previous checks.
844
-  float inverse_second = fr_mm_s * inverse_millimeters;
832
+  float inverse_mm_s = fr_mm_s * inverse_millimeters;
845 833
 
846 834
   int moves_queued = movesplanned();
847 835
 
@@ -853,21 +841,21 @@ void Planner::check_axes_activity() {
853 841
     #endif
854 842
     #if ENABLED(SLOWDOWN)
855 843
       //  segment time im micro seconds
856
-      unsigned long segment_time = lround(1000000.0/inverse_second);
844
+      unsigned long segment_time = lround(1000000.0/inverse_mm_s);
857 845
       if (mq) {
858 846
         if (segment_time < min_segment_time) {
859 847
           // buffer is draining, add extra time.  The amount of time added increases if the buffer is still emptied more.
860
-          inverse_second = 1000000.0 / (segment_time + lround(2 * (min_segment_time - segment_time) / moves_queued));
848
+          inverse_mm_s = 1000000.0 / (segment_time + lround(2 * (min_segment_time - segment_time) / moves_queued));
861 849
           #ifdef XY_FREQUENCY_LIMIT
862
-            segment_time = lround(1000000.0 / inverse_second);
850
+            segment_time = lround(1000000.0 / inverse_mm_s);
863 851
           #endif
864 852
         }
865 853
       }
866 854
     #endif
867 855
   #endif
868 856
 
869
-  block->nominal_speed = block->millimeters * inverse_second; // (mm/sec) Always > 0
870
-  block->nominal_rate = ceil(block->step_event_count * inverse_second); // (step/sec) Always > 0
857
+  block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0
858
+  block->nominal_rate = ceil(block->step_event_count * inverse_mm_s); // (step/sec) Always > 0
871 859
 
872 860
   #if ENABLED(FILAMENT_WIDTH_SENSOR)
873 861
     static float filwidth_e_count = 0, filwidth_delay_dist = 0;
@@ -907,7 +895,7 @@ void Planner::check_axes_activity() {
907 895
   float current_speed[NUM_AXIS];
908 896
   float speed_factor = 1.0; //factor <=1 do decrease speed
909 897
   LOOP_XYZE(i) {
910
-    current_speed[i] = delta_mm[i] * inverse_second;
898
+    current_speed[i] = delta_mm[i] * inverse_mm_s;
911 899
     float cs = fabs(current_speed[i]), mf = max_feedrate_mm_s[i];
912 900
     if (cs > mf) speed_factor = min(speed_factor, mf / cs);
913 901
   }

Loading…
Cancel
Save