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
   float Planner::position_float[NUM_AXIS] = { 0 };
141
   float Planner::position_float[NUM_AXIS] = { 0 };
142
 #endif
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
  * Class and Instance Methods
149
  * Class and Instance Methods
146
  */
150
  */
988
       segment_time = (MIN_BLOCK_TIME) * 1000UL;
992
       segment_time = (MIN_BLOCK_TIME) * 1000UL;
989
     }
993
     }
990
     block->segment_time = segment_time;
994
     block->segment_time = segment_time;
995
+    block_buffer_runtime_us += segment_time;
991
   #endif
996
   #endif
992
 
997
 
993
   block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0
998
   block->nominal_speed = block->millimeters * inverse_mm_s; // (mm/sec) Always > 0

+ 12
- 1
Marlin/planner.h View File

210
       static float extruder_advance_k;
210
       static float extruder_advance_k;
211
     #endif
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
   public:
217
   public:
214
 
218
 
215
     /**
219
     /**
367
     static block_t* get_current_block() {
371
     static block_t* get_current_block() {
368
       if (blocks_queued()) {
372
       if (blocks_queued()) {
369
         block_t* block = &block_buffer[block_buffer_tail];
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
         SBI(block->flag, BLOCK_BIT_BUSY);
377
         SBI(block->flag, BLOCK_BIT_BUSY);
371
         return block;
378
         return block;
372
       }
379
       }
378
       static bool long_move() {
385
       static bool long_move() {
379
         if (blocks_queued()) {
386
         if (blocks_queued()) {
380
           block_t* block = &block_buffer[block_buffer_tail];
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
         else
390
         else
384
           return true;
391
           return true;
385
       }
392
       }
393
+      
394
+      static void clear_block_buffer_runtime(){
395
+        block_buffer_runtime_us = 0;
396
+      }
386
     #endif
397
     #endif
387
 
398
 
388
     #if ENABLED(AUTOTEMP)
399
     #if ENABLED(AUTOTEMP)

+ 3
- 0
Marlin/stepper.cpp View File

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

Loading…
Cancel
Save