Pārlūkot izejas kodu

Apply updated ISR timing code

Scott Lahteine 9 gadus atpakaļ
vecāks
revīzija
aad9c0ed8d
2 mainītis faili ar 21 papildinājumiem un 15 dzēšanām
  1. 20
    14
      Marlin/stepper.cpp
  2. 1
    1
      Marlin/stepper.h

+ 20
- 14
Marlin/stepper.cpp Parādīt failu

413
       step_events_completed++;
413
       step_events_completed++;
414
       if (step_events_completed >= current_block->step_event_count) break;
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
     // Calculate new timer value
422
     // Calculate new timer value
417
     unsigned short timer, step_rate;
423
     unsigned short timer, step_rate;
418
     if (step_events_completed <= (unsigned long)current_block->accelerate_until) {
424
     if (step_events_completed <= (unsigned long)current_block->accelerate_until) {
427
       timer = calc_timer(acc_step_rate);
433
       timer = calc_timer(acc_step_rate);
428
       OCR1A = timer;
434
       OCR1A = timer;
429
       acceleration_time += timer;
435
       acceleration_time += timer;
430
-      
436
+
431
       #if ENABLED(LIN_ADVANCE)
437
       #if ENABLED(LIN_ADVANCE)
432
 
438
 
433
         if (current_block->use_advance_lead)
439
         if (current_block->use_advance_lead)
444
 
450
 
445
       #endif // ADVANCE or LIN_ADVANCE
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
     else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
457
     else if (step_events_completed > (unsigned long)current_block->decelerate_after) {
449
       MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
458
       MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
476
         old_advance = advance_whole;
485
         old_advance = advance_whole;
477
 
486
 
478
       #endif // ADVANCE or LIN_ADVANCE
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
     else {
493
     else {
494
+
481
       #if ENABLED(LIN_ADVANCE)
495
       #if ENABLED(LIN_ADVANCE)
496
+
482
         if (current_block->use_advance_lead)
497
         if (current_block->use_advance_lead)
483
           current_estep_rate[current_block->active_extruder] = final_estep_rate;
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
       #endif
502
       #endif
485
 
503
 
486
       OCR1A = OCR1A_nominal;
504
       OCR1A = OCR1A_nominal;
506
 
524
 
507
   void Stepper::advance_isr() {
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
     OCR0A = old_OCR0A;
528
     OCR0A = old_OCR0A;
523
 
529
 
524
     #define STEP_E_ONCE(INDEX) \
530
     #define STEP_E_ONCE(INDEX) \

+ 1
- 1
Marlin/stepper.h Parādīt failu

22
 
22
 
23
 /**
23
 /**
24
  * stepper.h - stepper motor driver: executes motion plans of planner.c using the stepper motors
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
  * Copyright (c) 2009-2011 Simen Svale Skogsrud
27
  * Copyright (c) 2009-2011 Simen Svale Skogsrud
28
  *
28
  *

Notiek ielāde…
Atcelt
Saglabāt