Kaynağa Gözat

Improve MINIMUM_STEPPER_PULSE

Scott Lahteine 8 yıl önce
ebeveyn
işleme
eabff30e75
3 değiştirilmiş dosya ile 16 ekleme ve 8 silme
  1. 3
    0
      Marlin/Conditionals_post.h
  2. 3
    0
      Marlin/macros.h
  3. 10
    8
      Marlin/stepper.cpp

+ 3
- 0
Marlin/Conditionals_post.h Dosyayı Görüntüle

@@ -708,4 +708,7 @@
708 708
     #define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
709 709
   #endif
710 710
 
711
+  // Stepper pulse duration, in cycles
712
+  #define STEP_PULSE_CYCLES ((MINIMUM_STEPPER_PULSE) * CYCLES_PER_MICROSECOND)
713
+
711 714
 #endif // CONDITIONALS_POST_H

+ 3
- 0
Marlin/macros.h Dosyayı Görüntüle

@@ -36,6 +36,9 @@
36 36
   #define CRITICAL_SECTION_END    SREG = _sreg;
37 37
 #endif
38 38
 
39
+// Clock speed factor
40
+#define CYCLES_PER_MICROSECOND (F_CPU / 1000000UL) // 16 or 20
41
+
39 42
 // Remove compiler warning on an unused variable
40 43
 #define UNUSED(x) (void) (x)
41 44
 

+ 10
- 8
Marlin/stepper.cpp Dosyayı Görüntüle

@@ -460,8 +460,10 @@ void Stepper::isr() {
460 460
         _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
461 461
       }
462 462
 
463
+    #define CYCLES_EATEN_BY_CODE 240
464
+
463 465
     // If a minimum pulse time was specified get the CPU clock
464
-    #if MINIMUM_STEPPER_PULSE > 0
466
+    #if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_CODE
465 467
       static uint32_t pulse_start;
466 468
       pulse_start = TCNT0;
467 469
     #endif
@@ -494,9 +496,8 @@ void Stepper::isr() {
494 496
     #endif // !ADVANCE && !LIN_ADVANCE
495 497
 
496 498
     // For a minimum pulse time wait before stopping pulses
497
-    #if MINIMUM_STEPPER_PULSE > 0
498
-      #define CYCLES_EATEN_BY_CODE 10
499
-      while ((uint32_t)(TCNT0 - pulse_start) < (MINIMUM_STEPPER_PULSE * (F_CPU / 1000000UL)) - CYCLES_EATEN_BY_CODE) { /* nada */ }
499
+    #if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_CODE
500
+      while ((uint32_t)(TCNT0 - pulse_start) < STEP_PULSE_CYCLES - CYCLES_EATEN_BY_CODE) { /* nada */ }
500 501
     #endif
501 502
 
502 503
     #if HAS_X_STEP
@@ -688,10 +689,12 @@ void Stepper::isr() {
688 689
         E## INDEX ##_STEP_WRITE(INVERT_E_STEP_PIN); \
689 690
       }
690 691
 
692
+    #define CYCLES_EATEN_BY_E 60
693
+
691 694
     // Step all E steppers that have steps
692 695
     for (uint8_t i = 0; i < step_loops; i++) {
693 696
 
694
-      #if MINIMUM_STEPPER_PULSE > 0
697
+      #if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_E
695 698
         static uint32_t pulse_start;
696 699
         pulse_start = TCNT0;
697 700
       #endif
@@ -708,9 +711,8 @@ void Stepper::isr() {
708 711
       #endif
709 712
 
710 713
       // For a minimum pulse time wait before stopping pulses
711
-      #if MINIMUM_STEPPER_PULSE > 0
712
-        #define CYCLES_EATEN_BY_E 10
713
-        while ((uint32_t)(TCNT0 - pulse_start) < (MINIMUM_STEPPER_PULSE * (F_CPU / 1000000UL)) - CYCLES_EATEN_BY_E) { /* nada */ }
714
+      #if STEP_PULSE_CYCLES > CYCLES_EATEN_BY_E
715
+        while ((uint32_t)(TCNT0 - pulse_start) < STEP_PULSE_CYCLES - CYCLES_EATEN_BY_E) { /* nada */ }
714 716
       #endif
715 717
 
716 718
       STOP_E_PULSE(0);

Loading…
İptal
Kaydet