Преглед на файлове

Fix broken reverse planner (#9943)

From #9914 by @Sebastianv650
Scott Lahteine преди 6 години
родител
ревизия
930720bbbb
No account linked to committer's email address
променени са 2 файла, в които са добавени 15 реда и са изтрити 18 реда
  1. 15
    14
      Marlin/src/module/planner.cpp
  2. 0
    4
      Marlin/src/module/planner.h

+ 15
- 14
Marlin/src/module/planner.cpp Целия файл

@@ -289,18 +289,26 @@ void Planner::reverse_pass_kernel(block_t* const current, const block_t * const
289 289
  * Once in reverse and once forward. This implements the reverse pass.
290 290
  */
291 291
 void Planner::reverse_pass() {
292
-  if (movesplanned() > 3) {
293
-    const uint8_t endnr = BLOCK_MOD(block_buffer_tail + 2); // tail is running. tail+1 shouldn't be altered because it's connected to the running block.
294
-                                                            // tail+2 because the index is not yet advanced when checked
292
+  if (movesplanned() > 2) {
293
+    const uint8_t endnr = BLOCK_MOD(block_buffer_tail + 1); // tail is running. tail+1 shouldn't be altered because it's connected to the running block.
295 294
     uint8_t blocknr = prev_block_index(block_buffer_head);
296 295
     block_t* current = &block_buffer[blocknr];
297 296
 
297
+    // Last/newest block in buffer:
298
+    const float max_entry_speed = current->max_entry_speed;
299
+    if (current->entry_speed != max_entry_speed) {
300
+      // If nominal length true, max junction speed is guaranteed to be reached. Only compute
301
+      // for max allowable speed if block is decelerating and nominal length is false.
302
+      current->entry_speed = TEST(current->flag, BLOCK_BIT_NOMINAL_LENGTH)
303
+        ? max_entry_speed
304
+        : min(max_entry_speed, max_allowable_speed(-current->acceleration, MINIMUM_PLANNER_SPEED, current->millimeters));
305
+      SBI(current->flag, BLOCK_BIT_RECALCULATE);
306
+    }
307
+
298 308
     do {
299 309
       const block_t * const next = current;
300 310
       blocknr = prev_block_index(blocknr);
301 311
       current = &block_buffer[blocknr];
302
-      if (TEST(current->flag, BLOCK_BIT_START_FROM_FULL_HALT)) // Up to this every block is already optimized.
303
-        break;
304 312
       reverse_pass_kernel(current, next);
305 313
     } while (blocknr != endnr);
306 314
   }
@@ -920,7 +928,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
920 928
 
921 929
   // Enable extruder(s)
922 930
   if (esteps) {
923
-
924 931
     #if ENABLED(AUTO_POWER_CONTROL)
925 932
       powerManager.power_on();
926 933
     #endif
@@ -1425,17 +1432,11 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE]
1425 1432
     // Now the transition velocity is known, which maximizes the shared exit / entry velocity while
1426 1433
     // respecting the jerk factors, it may be possible, that applying separate safe exit / entry velocities will achieve faster prints.
1427 1434
     const float vmax_junction_threshold = vmax_junction * 0.99f;
1428
-    if (previous_safe_speed > vmax_junction_threshold && safe_speed > vmax_junction_threshold) {
1429
-      // Not coasting. The machine will stop and start the movements anyway,
1430
-      // better to start the segment from start.
1431
-      SBI(block->flag, BLOCK_BIT_START_FROM_FULL_HALT);
1435
+    if (previous_safe_speed > vmax_junction_threshold && safe_speed > vmax_junction_threshold)
1432 1436
       vmax_junction = safe_speed;
1433
-    }
1434 1437
   }
1435
-  else {
1436
-    SBI(block->flag, BLOCK_BIT_START_FROM_FULL_HALT);
1438
+  else
1437 1439
     vmax_junction = safe_speed;
1438
-  }
1439 1440
 
1440 1441
   // Max entry speed of this block equals the max exit speed of the previous block.
1441 1442
   block->max_entry_speed = vmax_junction;

+ 0
- 4
Marlin/src/module/planner.h Целия файл

@@ -53,9 +53,6 @@ enum BlockFlagBit {
53 53
   // from a safe speed (in consideration of jerking from zero speed).
54 54
   BLOCK_BIT_NOMINAL_LENGTH,
55 55
 
56
-  // Start from a halt at the start of this block, respecting the maximum allowed jerk.
57
-  BLOCK_BIT_START_FROM_FULL_HALT,
58
-
59 56
   // The block is busy
60 57
   BLOCK_BIT_BUSY,
61 58
 
@@ -66,7 +63,6 @@ enum BlockFlagBit {
66 63
 enum BlockFlag {
67 64
   BLOCK_FLAG_RECALCULATE          = _BV(BLOCK_BIT_RECALCULATE),
68 65
   BLOCK_FLAG_NOMINAL_LENGTH       = _BV(BLOCK_BIT_NOMINAL_LENGTH),
69
-  BLOCK_FLAG_START_FROM_FULL_HALT = _BV(BLOCK_BIT_START_FROM_FULL_HALT),
70 66
   BLOCK_FLAG_BUSY                 = _BV(BLOCK_BIT_BUSY),
71 67
   BLOCK_FLAG_CONTINUED            = _BV(BLOCK_BIT_CONTINUED)
72 68
 };

Loading…
Отказ
Запис