Browse Source

Planner anti-stutter by Sebastian Popp

Scott Lahteine 7 years ago
parent
commit
4f5e087ff4
2 changed files with 15 additions and 6 deletions
  1. 5
    6
      Marlin/src/module/planner.cpp
  2. 10
    0
      Marlin/src/module/planner.h

+ 5
- 6
Marlin/src/module/planner.cpp View File

@@ -1352,7 +1352,9 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1352 1352
 
1353 1353
   // Initialize block entry speed. Compute based on deceleration to user-defined MINIMUM_PLANNER_SPEED.
1354 1354
   const float v_allowable = max_allowable_speed(-block->acceleration, MINIMUM_PLANNER_SPEED, block->millimeters);
1355
-  block->entry_speed = min(vmax_junction, v_allowable);
1355
+  // If stepper ISR is disabled, this indicates buffer_segment wants to add a split block.
1356
+  // In this case start with the max. allowed speed to avoid an interrupted first move.
1357
+  block->entry_speed = STEPPER_ISR_ENABLED() ? MINIMUM_PLANNER_SPEED : min(vmax_junction, v_allowable);
1356 1358
 
1357 1359
   // Initialize planner efficiency flags
1358 1360
   // Set flag if block will always reach maximum junction speed regardless of entry/exit speeds.
@@ -1362,7 +1364,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1362 1364
   // block nominal speed limits both the current and next maximum junction speeds. Hence, in both
1363 1365
   // the reverse and forward planners, the corresponding block junction speed will always be at the
1364 1366
   // the maximum junction speed and may always be ignored for any speed reduction checks.
1365
-  block->flag |= BLOCK_FLAG_RECALCULATE | (block->nominal_speed <= v_allowable ? BLOCK_FLAG_NOMINAL_LENGTH : 0);
1367
+  block->flag |= block->nominal_speed <= v_allowable ? BLOCK_FLAG_RECALCULATE | BLOCK_FLAG_NOMINAL_LENGTH : BLOCK_FLAG_RECALCULATE;
1366 1368
 
1367 1369
   // Update previous path unit_vector and nominal speed
1368 1370
   COPY(previous_speed, current_speed);
@@ -1382,7 +1384,7 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1382 1384
      *                                      In that case, the retract and move will be executed together.
1383 1385
      *                                      This leads to too many advance steps due to a huge e_acceleration.
1384 1386
      *                                      The math is good, but we must avoid retract moves with advance!
1385
-     * lin_dist_e > 0                     : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
1387
+     * lin_dist_e > 0                       : Extruder is running forward (e.g., for "Wipe while retracting" (Slic3r) or "Combing" (Cura) moves)
1386 1388
      */
1387 1389
     block->use_advance_lead =  esteps && (block->steps[X_AXIS] || block->steps[Y_AXIS])
1388 1390
                             && extruder_advance_k
@@ -1398,9 +1400,6 @@ void Planner::_buffer_steps(const int32_t (&target)[XYZE], float fr_mm_s, const
1398 1400
 
1399 1401
   #endif // LIN_ADVANCE
1400 1402
 
1401
-  const float bnsr = 1.0 / block->nominal_speed;
1402
-  calculate_trapezoid_for_block(block, block->entry_speed * bnsr, safe_speed * bnsr);
1403
-
1404 1403
   // Move buffer head
1405 1404
   block_buffer_head = next_buffer_head;
1406 1405
 

+ 10
- 0
Marlin/src/module/planner.h View File

@@ -534,6 +534,16 @@ class Planner {
534 534
     static block_t* get_current_block() {
535 535
       if (blocks_queued()) {
536 536
         block_t * const block = &block_buffer[block_buffer_tail];
537
+
538
+        // If the block has no trapezoid calculated, it's unsafe to execute.
539
+        if (movesplanned() > 1) {
540
+          const block_t * const next = &block_buffer[next_block_index(block_buffer_tail)];
541
+          if (TEST(block->flag, BLOCK_BIT_RECALCULATE) || TEST(next->flag, BLOCK_BIT_RECALCULATE))
542
+            return NULL;
543
+        }
544
+        else if (TEST(block->flag, BLOCK_BIT_RECALCULATE))
545
+          return NULL;
546
+
537 547
         #if ENABLED(ULTRA_LCD)
538 548
           block_buffer_runtime_us -= block->segment_time_us; // We can't be sure how long an active block will take, so don't count it.
539 549
         #endif

Loading…
Cancel
Save