|
@@ -1110,14 +1110,10 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
|
1110
|
1110
|
}
|
1111
|
1111
|
#endif
|
1112
|
1112
|
|
1113
|
|
- // Calculate and limit speed in mm/sec for each axis, calculate minimum acceleration ratio
|
|
1113
|
+ // Calculate and limit speed in mm/sec for each axis
|
1114
|
1114
|
float current_speed[NUM_AXIS], speed_factor = 1.0; // factor <1 decreases speed
|
1115
|
|
- float max_stepper_speed = 0, min_axis_accel_ratio = 1; // ratio < 1 means acceleration ramp needed
|
1116
|
1115
|
LOOP_XYZE(i) {
|
1117
|
1116
|
const float cs = FABS((current_speed[i] = delta_mm[i] * inverse_secs));
|
1118
|
|
- if (cs > max_jerk[i])
|
1119
|
|
- NOMORE(min_axis_accel_ratio, max_jerk[i] / cs);
|
1120
|
|
- NOLESS(max_stepper_speed, cs);
|
1121
|
1117
|
#if ENABLED(DISTINCT_E_FACTORS)
|
1122
|
1118
|
if (i == E_AXIS) i += extruder;
|
1123
|
1119
|
#endif
|
|
@@ -1162,9 +1158,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
|
1162
|
1158
|
}
|
1163
|
1159
|
#endif // XY_FREQUENCY_LIMIT
|
1164
|
1160
|
|
1165
|
|
- block->nominal_speed = max_stepper_speed; // (mm/sec) Always > 0
|
1166
|
|
- block->nominal_rate = CEIL(block->step_event_count * inverse_secs); // (step/sec) Always > 0
|
1167
|
|
-
|
1168
|
1161
|
// Correct the speed
|
1169
|
1162
|
if (speed_factor < 1.0) {
|
1170
|
1163
|
LOOP_XYZE(i) current_speed[i] *= speed_factor;
|
|
@@ -1172,9 +1165,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
|
1172
|
1165
|
block->nominal_rate *= speed_factor;
|
1173
|
1166
|
}
|
1174
|
1167
|
|
1175
|
|
- float safe_speed = block->nominal_speed * min_axis_accel_ratio;
|
1176
|
|
- static float previous_safe_speed;
|
1177
|
|
-
|
1178
|
1168
|
// Compute and limit the acceleration rate for the trapezoid generator.
|
1179
|
1169
|
const float steps_per_mm = block->step_event_count * inverse_millimeters;
|
1180
|
1170
|
uint32_t accel;
|
|
@@ -1276,6 +1266,32 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
|
1276
|
1266
|
}
|
1277
|
1267
|
#endif
|
1278
|
1268
|
|
|
1269
|
+ /**
|
|
1270
|
+ * Adapted from Průša MKS firmware
|
|
1271
|
+ * https://github.com/prusa3d/Prusa-Firmware
|
|
1272
|
+ *
|
|
1273
|
+ * Start with a safe speed (from which the machine may halt to stop immediately).
|
|
1274
|
+ */
|
|
1275
|
+
|
|
1276
|
+ // Exit speed limited by a jerk to full halt of a previous last segment
|
|
1277
|
+ static float previous_safe_speed;
|
|
1278
|
+
|
|
1279
|
+ float safe_speed = block->nominal_speed;
|
|
1280
|
+ uint8_t limited = 0;
|
|
1281
|
+ LOOP_XYZE(i) {
|
|
1282
|
+ const float jerk = FABS(current_speed[i]), maxj = max_jerk[i];
|
|
1283
|
+ if (jerk > maxj) {
|
|
1284
|
+ if (limited) {
|
|
1285
|
+ const float mjerk = maxj * block->nominal_speed;
|
|
1286
|
+ if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk;
|
|
1287
|
+ }
|
|
1288
|
+ else {
|
|
1289
|
+ ++limited;
|
|
1290
|
+ safe_speed = maxj;
|
|
1291
|
+ }
|
|
1292
|
+ }
|
|
1293
|
+ }
|
|
1294
|
+
|
1279
|
1295
|
if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) {
|
1280
|
1296
|
// Estimate a maximum velocity allowed at a joint of two successive segments.
|
1281
|
1297
|
// If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
|
|
@@ -1287,7 +1303,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
|
1287
|
1303
|
|
1288
|
1304
|
// Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
|
1289
|
1305
|
float v_factor = 1;
|
1290
|
|
- uint8_t limited = 0;
|
|
1306
|
+ limited = 0;
|
1291
|
1307
|
|
1292
|
1308
|
// Now limit the jerk in all axes.
|
1293
|
1309
|
const float smaller_speed_factor = vmax_junction / previous_nominal_speed;
|