Browse Source

Merge pull request #5274 from Sebastianv650/improve_smooth_moves

Improvement for ENSURE_SMOOTH_MOVES
Scott Lahteine 7 years ago
parent
commit
e9e4208ff1
3 changed files with 20 additions and 1 deletions
  1. 5
    0
      Marlin/planner.cpp
  2. 12
    1
      Marlin/planner.h
  3. 3
    0
      Marlin/stepper.cpp

+ 5
- 0
Marlin/planner.cpp View File

@@ -141,6 +141,10 @@ float Planner::previous_speed[NUM_AXIS],
141 141
   float Planner::position_float[NUM_AXIS] = { 0 };
142 142
 #endif
143 143
 
144
+#if ENABLED(ENSURE_SMOOTH_MOVES)
145
+  uint32_t Planner::block_buffer_runtime_us = 0;
146
+#endif
147
+
144 148
 /**
145 149
  * Class and Instance Methods
146 150
  */
@@ -988,6 +992,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
988 992
       segment_time = (MIN_BLOCK_TIME) * 1000UL;
989 993
     }
990 994
     block->segment_time = segment_time;
995
+    block_buffer_runtime_us += segment_time;
991 996
   #endif
992 997
 
993 998
   block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0

+ 12
- 1
Marlin/planner.h View File

@@ -210,6 +210,10 @@ class Planner {
210 210
       static float extruder_advance_k;
211 211
     #endif
212 212
 
213
+    #if ENABLED(ENSURE_SMOOTH_MOVES)
214
+      static uint32_t block_buffer_runtime_us; //Theoretical block buffer runtime in µs
215
+    #endif
216
+
213 217
   public:
214 218
 
215 219
     /**
@@ -367,6 +371,9 @@ class Planner {
367 371
     static block_t* get_current_block() {
368 372
       if (blocks_queued()) {
369 373
         block_t* block = &block_buffer[block_buffer_tail];
374
+        #if ENABLED(ENSURE_SMOOTH_MOVES)
375
+          block_buffer_runtime_us -= block->segment_time; //We can't be sure how long an active block will take, so don't count it.
376
+        #endif
370 377
         SBI(block->flag, BLOCK_BIT_BUSY);
371 378
         return block;
372 379
       }
@@ -378,11 +385,15 @@ class Planner {
378 385
       static bool long_move() {
379 386
         if (blocks_queued()) {
380 387
           block_t* block = &block_buffer[block_buffer_tail];
381
-          return block->segment_time > (LCD_UPDATE_THRESHOLD) * 1000UL;
388
+          return block_buffer_runtime_us > (LCD_UPDATE_THRESHOLD) * 1000UL + (MIN_BLOCK_TIME) * 3000UL;
382 389
         }
383 390
         else
384 391
           return true;
385 392
       }
393
+      
394
+      static void clear_block_buffer_runtime(){
395
+        block_buffer_runtime_us = 0;
396
+      }
386 397
     #endif
387 398
 
388 399
     #if ENABLED(AUTOTEMP)

+ 3
- 0
Marlin/stepper.cpp View File

@@ -1072,6 +1072,9 @@ void Stepper::finish_and_disable() {
1072 1072
 
1073 1073
 void Stepper::quick_stop() {
1074 1074
   cleaning_buffer_counter = 5000;
1075
+  #if ENABLED(ENSURE_SMOOTH_MOVES)
1076
+    planner.clear_block_buffer_runtime();
1077
+  #endif
1075 1078
   DISABLE_STEPPER_DRIVER_INTERRUPT();
1076 1079
   while (planner.blocks_queued()) planner.discard_current_block();
1077 1080
   current_block = NULL;

Loading…
Cancel
Save