Просмотр исходного кода

Put more code between pulse start and stop (#9959)

Scott Lahteine 7 лет назад
Родитель
Сommit
0dd1c4458d
Аккаунт пользователя с таким Email не найден
1 измененных файлов: 46 добавлений и 39 удалений
  1. 46
    39
      Marlin/src/module/stepper.cpp

+ 46
- 39
Marlin/src/module/stepper.cpp Просмотреть файл

443
   // Take multiple steps per interrupt (For high speed moves)
443
   // Take multiple steps per interrupt (For high speed moves)
444
   bool all_steps_done = false;
444
   bool all_steps_done = false;
445
   for (uint8_t i = step_loops; i--;) {
445
   for (uint8_t i = step_loops; i--;) {
446
-    #if ENABLED(LIN_ADVANCE)
447
-
448
-      counter_E += current_block->steps[E_AXIS];
449
-      if (counter_E > 0) {
450
-        counter_E -= current_block->step_event_count;
451
-        #if DISABLED(MIXING_EXTRUDER)
452
-          // Don't step E here for mixing extruder
453
-          count_position[E_AXIS] += count_direction[E_AXIS];
454
-          motor_direction(E_AXIS) ? --e_steps : ++e_steps;
455
-        #endif
456
-      }
457
-
458
-      #if ENABLED(MIXING_EXTRUDER)
459
-        // Step mixing steppers proportionally
460
-        const bool dir = motor_direction(E_AXIS);
461
-        MIXING_STEPPERS_LOOP(j) {
462
-          counter_m[j] += current_block->steps[E_AXIS];
463
-          if (counter_m[j] > 0) {
464
-            counter_m[j] -= current_block->mix_event_count[j];
465
-            dir ? --e_steps[j] : ++e_steps[j];
466
-          }
467
-        }
468
-      #endif
469
-
470
-    #endif // LIN_ADVANCE
471
 
446
 
472
     #define _COUNTER(AXIS) counter_## AXIS
447
     #define _COUNTER(AXIS) counter_## AXIS
473
     #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
448
     #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
474
     #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
449
     #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
475
 
450
 
476
     // Advance the Bresenham counter; start a pulse if the axis needs a step
451
     // Advance the Bresenham counter; start a pulse if the axis needs a step
477
-    #define PULSE_START(AXIS) \
452
+    #define PULSE_START(AXIS) do{ \
478
       _COUNTER(AXIS) += current_block->steps[_AXIS(AXIS)]; \
453
       _COUNTER(AXIS) += current_block->steps[_AXIS(AXIS)]; \
479
-      if (_COUNTER(AXIS) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
454
+      if (_COUNTER(AXIS) > 0) _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS), 0); }while(0)
480
 
455
 
481
-    // Stop an active pulse, reset the Bresenham counter, update the position
482
-    #define PULSE_STOP(AXIS) \
456
+    // Advance the Bresenham counter; start a pulse if the axis needs a step
457
+    #define STEP_TICK(AXIS) \
483
       if (_COUNTER(AXIS) > 0) { \
458
       if (_COUNTER(AXIS) > 0) { \
484
         _COUNTER(AXIS) -= current_block->step_event_count; \
459
         _COUNTER(AXIS) -= current_block->step_event_count; \
485
-        count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
486
-        _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
487
-      }
460
+        count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; }
461
+
462
+    // Stop an active pulse, if any
463
+    #define PULSE_STOP(AXIS) _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS), 0)
488
 
464
 
489
     /**
465
     /**
490
      * Estimate the number of cycles that the stepper logic already takes
466
      * Estimate the number of cycles that the stepper logic already takes
563
       PULSE_START(Z);
539
       PULSE_START(Z);
564
     #endif
540
     #endif
565
 
541
 
566
-    // For non-advance use linear interpolation for E also
567
-    #if DISABLED(LIN_ADVANCE)
542
+    #if ENABLED(LIN_ADVANCE)
543
+
544
+      counter_E += current_block->steps[E_AXIS];
545
+      if (counter_E > 0) {
546
+        #if DISABLED(MIXING_EXTRUDER)
547
+          // Don't step E here for mixing extruder
548
+          motor_direction(E_AXIS) ? --e_steps : ++e_steps;
549
+        #endif
550
+      }
551
+
552
+      #if ENABLED(MIXING_EXTRUDER)
553
+        // Step mixing steppers proportionally
554
+        const bool dir = motor_direction(E_AXIS);
555
+        MIXING_STEPPERS_LOOP(j) {
556
+          counter_m[j] += current_block->steps[E_AXIS];
557
+          if (counter_m[j] > 0) {
558
+            counter_m[j] -= current_block->mix_event_count[j];
559
+            dir ? --e_steps[j] : ++e_steps[j];
560
+          }
561
+        }
562
+      #endif
563
+
564
+    #else // !LIN_ADVANCE - use linear interpolation for E also
565
+
568
       #if ENABLED(MIXING_EXTRUDER)
566
       #if ENABLED(MIXING_EXTRUDER)
569
         // Keep updating the single E axis
567
         // Keep updating the single E axis
570
         counter_E += current_block->steps[E_AXIS];
568
         counter_E += current_block->steps[E_AXIS];
580
       #endif
578
       #endif
581
     #endif // !LIN_ADVANCE
579
     #endif // !LIN_ADVANCE
582
 
580
 
581
+    #if HAS_X_STEP
582
+      STEP_TICK(X);
583
+    #endif
584
+    #if HAS_Y_STEP
585
+      STEP_TICK(Y);
586
+    #endif
587
+    #if HAS_Z_STEP
588
+      STEP_TICK(Z);
589
+    #endif
590
+
591
+    STEP_TICK(E); // Always tick the single E axis
592
+
583
     // For minimum pulse time wait before stopping pulses
593
     // For minimum pulse time wait before stopping pulses
584
     #if EXTRA_CYCLES_XYZE > 20
594
     #if EXTRA_CYCLES_XYZE > 20
585
       while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
595
       while (EXTRA_CYCLES_XYZE > (uint32_t)(HAL_timer_get_count(PULSE_TIMER_NUM) - pulse_start) * (PULSE_TIMER_PRESCALE)) { /* nada */ }
600
 
610
 
601
     #if DISABLED(LIN_ADVANCE)
611
     #if DISABLED(LIN_ADVANCE)
602
       #if ENABLED(MIXING_EXTRUDER)
612
       #if ENABLED(MIXING_EXTRUDER)
603
-        // Always step the single E axis
604
-        if (counter_E > 0) {
605
-          counter_E -= current_block->step_event_count;
606
-          count_position[E_AXIS] += count_direction[E_AXIS];
607
-        }
608
         MIXING_STEPPERS_LOOP(j) {
613
         MIXING_STEPPERS_LOOP(j) {
609
           if (counter_m[j] > 0) {
614
           if (counter_m[j] > 0) {
610
             counter_m[j] -= current_block->mix_event_count[j];
615
             counter_m[j] -= current_block->mix_event_count[j];
686
 
691
 
687
     SPLIT(interval);  // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL
692
     SPLIT(interval);  // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL
688
     _NEXT_ISR(ocr_val);
693
     _NEXT_ISR(ocr_val);
694
+
689
     deceleration_time += interval;
695
     deceleration_time += interval;
690
 
696
 
691
     #if ENABLED(LIN_ADVANCE)
697
     #if ENABLED(LIN_ADVANCE)
714
 
720
 
715
     SPLIT(OCR1A_nominal);  // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL
721
     SPLIT(OCR1A_nominal);  // split step into multiple ISRs if larger than ENDSTOP_NOMINAL_OCR_VAL
716
     _NEXT_ISR(ocr_val);
722
     _NEXT_ISR(ocr_val);
723
+
717
     // ensure we're running at the correct step rate, even if we just came off an acceleration
724
     // ensure we're running at the correct step rate, even if we just came off an acceleration
718
     step_loops = step_loops_nominal;
725
     step_loops = step_loops_nominal;
719
   }
726
   }

Загрузка…
Отмена
Сохранить