Bläddra i källkod

[bugfix-1.1.x] COREXY stutter moves (planner.cpp changes) (#8697)

Bob-the-Kuhn 6 år sedan
förälder
incheckning
86b65e52c4
1 ändrade filer med 10 tillägg och 31 borttagningar
  1. 10
    31
      Marlin/planner.cpp

+ 10
- 31
Marlin/planner.cpp Visa fil

@@ -1042,9 +1042,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1042 1042
     CRITICAL_SECTION_END
1043 1043
   #endif
1044 1044
 
1045
-  block->nominal_speed = block->millimeters * inverse_secs;           //   (mm/sec) Always > 0
1046
-  block->nominal_rate = CEIL(block->step_event_count * inverse_secs); // (step/sec) Always > 0
1047
-
1048 1045
   #if ENABLED(FILAMENT_WIDTH_SENSOR)
1049 1046
     static float filwidth_e_count = 0, filwidth_delay_dist = 0;
1050 1047
 
@@ -1079,10 +1076,13 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1079 1076
     }
1080 1077
   #endif
1081 1078
 
1082
-  // Calculate and limit speed in mm/sec for each axis
1079
+  // Calculate and limit speed in mm/sec for each axis, calculate minimum acceleration ratio
1083 1080
   float current_speed[NUM_AXIS], speed_factor = 1.0; // factor <1 decreases speed
1081
+  float max_stepper_speed = 0, min_axis_accel_ratio = 1; // ratio < 1 means acceleration ramp needed
1084 1082
   LOOP_XYZE(i) {
1085 1083
     const float cs = FABS((current_speed[i] = delta_mm[i] * inverse_secs));
1084
+    NOMORE(min_axis_accel_ratio, max_jerk[i] / cs);
1085
+    NOLESS(max_stepper_speed, cs);
1086 1086
     #if ENABLED(DISTINCT_E_FACTORS)
1087 1087
       if (i == E_AXIS) i += extruder;
1088 1088
     #endif
@@ -1127,6 +1127,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1127 1127
     }
1128 1128
   #endif // XY_FREQUENCY_LIMIT
1129 1129
 
1130
+  block->nominal_speed = max_stepper_speed; // (mm/sec) Always > 0
1131
+  block->nominal_rate = CEIL(block->step_event_count * inverse_secs); // (step/sec) Always > 0
1132
+
1130 1133
   // Correct the speed
1131 1134
   if (speed_factor < 1.0) {
1132 1135
     LOOP_XYZE(i) current_speed[i] *= speed_factor;
@@ -1134,6 +1137,8 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1134 1137
     block->nominal_rate *= speed_factor;
1135 1138
   }
1136 1139
 
1140
+  float safe_speed = block->nominal_speed * min_axis_accel_ratio;
1141
+  static float previous_safe_speed;
1137 1142
   // Compute and limit the acceleration rate for the trapezoid generator.
1138 1143
   const float steps_per_mm = block->step_event_count * inverse_millimeters;
1139 1144
   uint32_t accel;
@@ -1235,32 +1240,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1235 1240
     }
1236 1241
   #endif
1237 1242
 
1238
-  /**
1239
-   * Adapted from Průša MKS firmware
1240
-   * https://github.com/prusa3d/Prusa-Firmware
1241
-   *
1242
-   * Start with a safe speed (from which the machine may halt to stop immediately).
1243
-   */
1244
-
1245
-  // Exit speed limited by a jerk to full halt of a previous last segment
1246
-  static float previous_safe_speed;
1247
-
1248
-  float safe_speed = block->nominal_speed;
1249
-  uint8_t limited = 0;
1250
-  LOOP_XYZE(i) {
1251
-    const float jerk = FABS(current_speed[i]), maxj = max_jerk[i];
1252
-    if (jerk > maxj) {
1253
-      if (limited) {
1254
-        const float mjerk = maxj * block->nominal_speed;
1255
-        if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk;
1256
-      }
1257
-      else {
1258
-        ++limited;
1259
-        safe_speed = maxj;
1260
-      }
1261
-    }
1262
-  }
1263
-
1264 1243
   if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) {
1265 1244
     // Estimate a maximum velocity allowed at a joint of two successive segments.
1266 1245
     // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
@@ -1272,7 +1251,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1272 1251
 
1273 1252
     // Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
1274 1253
     float v_factor = 1;
1275
-    limited = 0;
1254
+    uint8_t limited = 0;
1276 1255
 
1277 1256
     // Now limit the jerk in all axes.
1278 1257
     const float smaller_speed_factor = vmax_junction / previous_nominal_speed;

Laddar…
Avbryt
Spara