Browse Source

Improvement for ENSURE_SMOOTH_MOVES

Instead of waiting for a single long block, compare the complete block
buffer runtime for the long_move() check.
Sebastianv650 8 years ago
parent
commit
8190483eeb
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

@@ -136,6 +136,10 @@ float Planner::previous_speed[NUM_AXIS],
136 136
   float Planner::position_float[NUM_AXIS] = { 0 };
137 137
 #endif
138 138
 
139
+#if ENABLED(ENSURE_SMOOTH_MOVES)
140
+  uint32_t Planner::block_buffer_runtime_us = 0;
141
+#endif
142
+
139 143
 /**
140 144
  * Class and Instance Methods
141 145
  */
@@ -954,6 +958,7 @@ void Planner::_buffer_line(const float &a, const float &b, const float &c, const
954 958
       segment_time = (MIN_BLOCK_TIME) * 1000UL;
955 959
     }
956 960
     block->segment_time = segment_time;
961
+    block_buffer_runtime_us += segment_time;
957 962
   #endif
958 963
 
959 964
   block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0

+ 12
- 1
Marlin/planner.h View File

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

+ 3
- 0
Marlin/stepper.cpp View File

@@ -1067,6 +1067,9 @@ void Stepper::finish_and_disable() {
1067 1067
 
1068 1068
 void Stepper::quick_stop() {
1069 1069
   cleaning_buffer_counter = 5000;
1070
+  #if ENABLED(ENSURE_SMOOTH_MOVES)
1071
+    planner.clear_block_buffer_runtime();
1072
+  #endif
1070 1073
   DISABLE_STEPPER_DRIVER_INTERRUPT();
1071 1074
   while (planner.blocks_queued()) planner.discard_current_block();
1072 1075
   current_block = NULL;

Loading…
Cancel
Save