Browse Source

Revert the planner acceleration logic somewhat

Scott Lahteine 8 years ago
parent
commit
4226f56f53
1 changed files with 17 additions and 20 deletions
  1. 17
    20
      Marlin/planner.cpp

+ 17
- 20
Marlin/planner.cpp View File

@@ -946,26 +946,23 @@ void Planner::check_axes_activity() {
946 946
 
947 947
   // Compute and limit the acceleration rate for the trapezoid generator.
948 948
   float steps_per_mm = block->step_event_count / block->millimeters;
949
-  block->acceleration_steps_per_s2 = ceil((
950
-    (block->steps[X_AXIS] == 0 && block->steps[Y_AXIS] == 0 && block->steps[Z_AXIS] == 0) ?
951
-      retract_acceleration : block->steps[E_AXIS] == 0 ?
952
-      travel_acceleration :
953
-      acceleration
954
-    ) * steps_per_mm
955
-  );
956
-  // Limit acceleration per axis
957
-  long acc_st = block->acceleration_steps_per_s2;
958
-  if (max_acceleration_steps_per_s2[X_AXIS] < (acc_st * block->steps[X_AXIS]) / block->step_event_count)
959
-    acc_st = (max_acceleration_steps_per_s2[X_AXIS] * block->step_event_count) / block->steps[X_AXIS];
960
-  if (max_acceleration_steps_per_s2[Y_AXIS] < (acc_st * block->steps[Y_AXIS]) / block->step_event_count)
961
-    acc_st = (max_acceleration_steps_per_s2[Y_AXIS] * block->step_event_count) / block->steps[Y_AXIS];
962
-  if (max_acceleration_steps_per_s2[Z_AXIS] < (acc_st * block->steps[Z_AXIS]) / block->step_event_count)
963
-    acc_st = (max_acceleration_steps_per_s2[Z_AXIS] * block->step_event_count) / block->steps[Z_AXIS];
964
-  if (max_acceleration_steps_per_s2[E_AXIS] < (acc_st * block->steps[E_AXIS]) / block->step_event_count)
965
-    acc_st = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
966
-  block->acceleration_steps_per_s2 = acc_st;
967
-  block->acceleration = acc_st / steps_per_mm;
968
-  block->acceleration_rate = (long)(acc_st * 16777216.0 / (F_CPU / 8.0));
949
+  if (!block->steps[X_AXIS] && !block->steps[Y_AXIS] && !block->steps[Z_AXIS]) {
950
+    block->acceleration_steps_per_s2 = ceil(retract_acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
951
+  }
952
+  else {
953
+    // Limit acceleration per axis
954
+    block->acceleration_steps_per_s2 = ceil((block->steps[E_AXIS] ? acceleration : travel_acceleration) * steps_per_mm);
955
+    if (max_acceleration_steps_per_s2[X_AXIS] < (block->acceleration_steps_per_s2 * block->steps[X_AXIS]) / block->step_event_count)
956
+      block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[X_AXIS] * block->step_event_count) / block->steps[X_AXIS];
957
+    if (max_acceleration_steps_per_s2[Y_AXIS] < (block->acceleration_steps_per_s2 * block->steps[Y_AXIS]) / block->step_event_count)
958
+      block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[Y_AXIS] * block->step_event_count) / block->steps[Y_AXIS];
959
+    if (max_acceleration_steps_per_s2[Z_AXIS] < (block->acceleration_steps_per_s2 * block->steps[Z_AXIS]) / block->step_event_count)
960
+      block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[Z_AXIS] * block->step_event_count) / block->steps[Z_AXIS];
961
+    if (max_acceleration_steps_per_s2[E_AXIS] < (block->acceleration_steps_per_s2 * block->steps[E_AXIS]) / block->step_event_count)
962
+      block->acceleration_steps_per_s2 = (max_acceleration_steps_per_s2[E_AXIS] * block->step_event_count) / block->steps[E_AXIS];
963
+  }
964
+  block->acceleration = block->acceleration_steps_per_s2 / steps_per_mm;
965
+  block->acceleration_rate = (long)(block->acceleration_steps_per_s2 * 16777216.0 / ((F_CPU) / 8.0));
969 966
 
970 967
   #if 0  // Use old jerk for now
971 968
 

Loading…
Cancel
Save