Przeglądaj źródła

Revert "Improved Core-compatible jerk code"

Reverting commit 3cd7659
Scott Lahteine 7 lat temu
rodzic
commit
97d509d4d2
1 zmienionych plików z 28 dodań i 12 usunięć
  1. 28
    12
      Marlin/src/module/planner.cpp

+ 28
- 12
Marlin/src/module/planner.cpp Wyświetl plik

1110
     }
1110
     }
1111
   #endif
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
   float current_speed[NUM_AXIS], speed_factor = 1.0; // factor <1 decreases speed
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
   LOOP_XYZE(i) {
1115
   LOOP_XYZE(i) {
1117
     const float cs = FABS((current_speed[i] = delta_mm[i] * inverse_secs));
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
     #if ENABLED(DISTINCT_E_FACTORS)
1117
     #if ENABLED(DISTINCT_E_FACTORS)
1122
       if (i == E_AXIS) i += extruder;
1118
       if (i == E_AXIS) i += extruder;
1123
     #endif
1119
     #endif
1162
     }
1158
     }
1163
   #endif // XY_FREQUENCY_LIMIT
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
   // Correct the speed
1161
   // Correct the speed
1169
   if (speed_factor < 1.0) {
1162
   if (speed_factor < 1.0) {
1170
     LOOP_XYZE(i) current_speed[i] *= speed_factor;
1163
     LOOP_XYZE(i) current_speed[i] *= speed_factor;
1172
     block->nominal_rate *= speed_factor;
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
   // Compute and limit the acceleration rate for the trapezoid generator.
1168
   // Compute and limit the acceleration rate for the trapezoid generator.
1179
   const float steps_per_mm = block->step_event_count * inverse_millimeters;
1169
   const float steps_per_mm = block->step_event_count * inverse_millimeters;
1180
   uint32_t accel;
1170
   uint32_t accel;
1276
     }
1266
     }
1277
   #endif
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
   if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) {
1295
   if (moves_queued && !UNEAR_ZERO(previous_nominal_speed)) {
1280
     // Estimate a maximum velocity allowed at a joint of two successive segments.
1296
     // Estimate a maximum velocity allowed at a joint of two successive segments.
1281
     // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
1297
     // If this maximum velocity allowed is lower than the minimum of the entry / exit safe velocities,
1287
 
1303
 
1288
     // Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
1304
     // Factor to multiply the previous / current nominal velocities to get componentwise limited velocities.
1289
     float v_factor = 1;
1305
     float v_factor = 1;
1290
-    uint8_t limited = 0;
1306
+    limited = 0;
1291
 
1307
 
1292
     // Now limit the jerk in all axes.
1308
     // Now limit the jerk in all axes.
1293
     const float smaller_speed_factor = vmax_junction / previous_nominal_speed;
1309
     const float smaller_speed_factor = vmax_junction / previous_nominal_speed;

Ładowanie…
Anuluj
Zapisz