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
   float Planner::position_float[NUM_AXIS] = { 0 };
136
   float Planner::position_float[NUM_AXIS] = { 0 };
137
 #endif
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
  * Class and Instance Methods
144
  * Class and Instance Methods
141
  */
145
  */
954
       segment_time = (MIN_BLOCK_TIME) * 1000UL;
958
       segment_time = (MIN_BLOCK_TIME) * 1000UL;
955
     }
959
     }
956
     block->segment_time = segment_time;
960
     block->segment_time = segment_time;
961
+    block_buffer_runtime_us += segment_time;
957
   #endif
962
   #endif
958
 
963
 
959
   block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0
964
   block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0

+ 12
- 1
Marlin/planner.h View File

206
       static float extruder_advance_k;
206
       static float extruder_advance_k;
207
     #endif
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
   public:
213
   public:
210
 
214
 
211
     /**
215
     /**
363
     static block_t* get_current_block() {
367
     static block_t* get_current_block() {
364
       if (blocks_queued()) {
368
       if (blocks_queued()) {
365
         block_t* block = &block_buffer[block_buffer_tail];
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
         SBI(block->flag, BLOCK_BIT_BUSY);
373
         SBI(block->flag, BLOCK_BIT_BUSY);
367
         return block;
374
         return block;
368
       }
375
       }
374
       static bool long_move() {
381
       static bool long_move() {
375
         if (blocks_queued()) {
382
         if (blocks_queued()) {
376
           block_t* block = &block_buffer[block_buffer_tail];
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
         else
386
         else
380
           return true;
387
           return true;
381
       }
388
       }
389
+      
390
+      static void clear_block_buffer_runtime(){
391
+        block_buffer_runtime_us = 0;
392
+      }
382
     #endif
393
     #endif
383
 
394
 
384
     #if ENABLED(AUTOTEMP)
395
     #if ENABLED(AUTOTEMP)

+ 3
- 0
Marlin/stepper.cpp View File

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

Loading…
Cancel
Save