Sfoglia il codice sorgente

Fix initial safe_speed in jerk code (#11417)

Scott Lahteine 7 anni fa
parent
commit
b826bf4194
Nessun account collegato all'indirizzo email del committer
1 ha cambiato i file con 13 aggiunte e 13 eliminazioni
  1. 13
    13
      Marlin/src/module/planner.cpp

+ 13
- 13
Marlin/src/module/planner.cpp Vedi File

@@ -1348,7 +1348,7 @@ void Planner::check_axes_activity() {
1348 1348
 
1349 1349
     volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM] = parser.volumetric_enabled
1350 1350
       ? ratio_2 / CIRCLE_AREA(filament_width_nominal * 0.5f) // Volumetric uses a true volumetric multiplier
1351
-      : ratio_2;                                            // Linear squares the ratio, which scales the volume
1351
+      : ratio_2;                                             // Linear squares the ratio, which scales the volume
1352 1352
 
1353 1353
     refresh_e_factor(FILAMENT_SENSOR_EXTRUDER_NUM);
1354 1354
   }
@@ -1947,7 +1947,7 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
1947 1947
   else
1948 1948
     block->millimeters = millimeters;
1949 1949
 
1950
-  const float inverse_millimeters = 1.0 / block->millimeters;  // Inverse millimeters to remove multiple divides
1950
+  const float inverse_millimeters = 1.0f / block->millimeters;  // Inverse millimeters to remove multiple divides
1951 1951
 
1952 1952
   // Calculate inverse time for this move. No divide by zero due to previous checks.
1953 1953
   // Example: At 120mm/s a 60mm move takes 0.5s. So this will give 2.0.
@@ -2298,27 +2298,27 @@ bool Planner::_populate_block(block_t * const block, bool split_move,
2298 2298
     /**
2299 2299
      * Adapted from Průša MKS firmware
2300 2300
      * https://github.com/prusa3d/Prusa-Firmware
2301
-     *
2302
-     * Start with a safe speed (from which the machine may halt to stop immediately).
2303 2301
      */
2302
+    const float nominal_speed = SQRT(block->nominal_speed_sqr);
2304 2303
 
2305 2304
     // Exit speed limited by a jerk to full halt of a previous last segment
2306 2305
     static float previous_safe_speed;
2307 2306
 
2308
-    const float nominal_speed = SQRT(block->nominal_speed_sqr);
2307
+    // Start with a safe speed (from which the machine may halt to stop immediately).
2309 2308
     float safe_speed = nominal_speed;
2310 2309
 
2311 2310
     uint8_t limited = 0;
2312 2311
     LOOP_XYZE(i) {
2313
-      const float jerk = ABS(current_speed[i]), maxj = max_jerk[i];
2314
-      if (jerk > maxj) {
2315
-        if (limited) {
2316
-          const float mjerk = maxj * nominal_speed;
2317
-          if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk;
2312
+      const float jerk = ABS(current_speed[i]),   // cs : Starting from zero, change in speed for this axis
2313
+                  maxj = max_jerk[i];             // mj : The max jerk setting for this axis
2314
+      if (jerk > maxj) {                          // cs > mj : New current speed too fast?
2315
+        if (limited) {                            // limited already?
2316
+          const float mjerk = nominal_speed * maxj; // ns*mj
2317
+          if (jerk * safe_speed > mjerk) safe_speed = mjerk / jerk; // ns*mj/cs
2318 2318
         }
2319 2319
         else {
2320
-          ++limited;
2321
-          safe_speed = maxj;
2320
+          safe_speed *= maxj / jerk;              // Initial limit: ns*mj/cs
2321
+          ++limited;                              // Initially limited
2322 2322
         }
2323 2323
       }
2324 2324
     }
@@ -2620,7 +2620,7 @@ void Planner::reset_acceleration_rates() {
2620 2620
 
2621 2621
 // Recalculate position, steps_to_mm if axis_steps_per_mm changes!
2622 2622
 void Planner::refresh_positioning() {
2623
-  LOOP_XYZE_N(i) steps_to_mm[i] = 1.0 / axis_steps_per_mm[i];
2623
+  LOOP_XYZE_N(i) steps_to_mm[i] = 1.0f / axis_steps_per_mm[i];
2624 2624
   set_position_mm_kinematic(current_position);
2625 2625
   reset_acceleration_rates();
2626 2626
 }

Loading…
Annulla
Salva