Browse Source

Apply updated ISR timing code

Scott Lahteine 8 years ago
parent
commit
aad9c0ed8d
2 changed files with 21 additions and 15 deletions
  1. 20
    14
      Marlin/stepper.cpp
  2. 1
    1
      Marlin/stepper.h

+ 20
- 14
Marlin/stepper.cpp View File

@@ -413,6 +413,12 @@ void Stepper::isr() {
413 413
       step_events_completed++;
414 414
       if (step_events_completed >= current_block->step_event_count) break;
415 415
     }
416
+
417
+    #if ENABLED(LIN_ADVANCE)
418
+      // If we have esteps to execute, fire the next ISR "now"
419
+      if (e_steps[current_block->active_extruder]) OCR0A = TCNT0 + 2;
420
+    #endif
421
+
416 422
     // Calculate new timer value
417 423
     unsigned short timer, step_rate;
418 424
     if (step_events_completed <= (unsigned long)current_block->accelerate_until) {
@@ -427,7 +433,7 @@ void Stepper::isr() {
427 433
       timer = calc_timer(acc_step_rate);
428 434
       OCR1A = timer;
429 435
       acceleration_time += timer;
430
-      
436
+
431 437
       #if ENABLED(LIN_ADVANCE)
432 438
 
433 439
         if (current_block->use_advance_lead)
@@ -444,6 +450,9 @@ void Stepper::isr() {
444 450
 
445 451
       #endif // ADVANCE or LIN_ADVANCE
446 452
 
453
+      #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
454
+        eISR_Rate = (timer >> 2) / abs(e_steps[current_block->active_extruder]);
455
+      #endif
447 456
     }
448 457
     else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
449 458
       MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
@@ -476,11 +485,20 @@ void Stepper::isr() {
476 485
         old_advance = advance_whole;
477 486
 
478 487
       #endif // ADVANCE or LIN_ADVANCE
488
+
489
+      #if ENABLED(ADVANCE) || ENABLED(LIN_ADVANCE)
490
+        eISR_Rate = (timer >> 2) / abs(e_steps[current_block->active_extruder]);
491
+      #endif
479 492
     }
480 493
     else {
494
+
481 495
       #if ENABLED(LIN_ADVANCE)
496
+
482 497
         if (current_block->use_advance_lead)
483 498
           current_estep_rate[current_block->active_extruder] = final_estep_rate;
499
+
500
+        eISR_Rate = (OCR1A_nominal >> 2) / abs(e_steps[current_block->active_extruder]);
501
+
484 502
       #endif
485 503
 
486 504
       OCR1A = OCR1A_nominal;
@@ -506,19 +524,7 @@ void Stepper::isr() {
506 524
 
507 525
   void Stepper::advance_isr() {
508 526
 
509
-    byte maxesteps = 0;
510
-    for (uint8_t i = 0; i < EXTRUDERS; i++)
511
-      if (abs(e_steps[i]) > maxesteps) maxesteps = abs(e_steps[i]);
512
-
513
-    if (maxesteps > 3)
514
-      old_OCR0A += 13;  // ~19kHz (250000/13 = 19230 Hz)
515
-    else if (maxesteps > 2)
516
-      old_OCR0A += 17;  // ~15kHz (250000/17 = 14705 Hz)
517
-    else if (maxesteps > 1)
518
-      old_OCR0A += 26;  // ~10kHz (250000/26 =  9615 Hz)
519
-    else
520
-      old_OCR0A += 52;  //  ~5kHz (250000/26 =  4807 Hz)
521
-
527
+    old_OCR0A += eISR_Rate;
522 528
     OCR0A = old_OCR0A;
523 529
 
524 530
     #define STEP_E_ONCE(INDEX) \

+ 1
- 1
Marlin/stepper.h View File

@@ -22,7 +22,7 @@
22 22
 
23 23
 /**
24 24
  * stepper.h - stepper motor driver: executes motion plans of planner.c using the stepper motors
25
- * Part of Grbl
25
+ * Derived from Grbl
26 26
  *
27 27
  * Copyright (c) 2009-2011 Simen Svale Skogsrud
28 28
  *

Loading…
Cancel
Save