Browse Source

Merge pull request #4722 from thinkyhead/rc_minimum_stepper_pulse

MINIMUM_STEPPER_PULSE option
Scott Lahteine 8 years ago
parent
commit
a82a89bc58

+ 4
- 0
Marlin/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/Cartesio/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/Felix/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/Hephestos_2/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/K8200/Configuration_adv.h View File

@@ -539,6 +539,10 @@
539 539
 // Moves (or segments) with fewer steps than this will be joined with the next move
540 540
 #define MIN_STEPS_PER_SEGMENT 3
541 541
 
542
+// The minimum pulse width (in µs) for stepping a stepper.
543
+// Set this if you find stepping unreliable, or if using a very fast CPU.
544
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
545
+
542 546
 // @section temperature
543 547
 
544 548
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/K8400/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/SCARA/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

@@ -541,6 +541,10 @@
541 541
 // Moves (or segments) with fewer steps than this will be joined with the next move
542 542
 #define MIN_STEPS_PER_SEGMENT 6
543 543
 
544
+// The minimum pulse width (in µs) for stepping a stepper.
545
+// Set this if you find stepping unreliable, or if using a very fast CPU.
546
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
547
+
544 548
 // @section temperature
545 549
 
546 550
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

@@ -535,6 +535,10 @@
535 535
 // Moves (or segments) with fewer steps than this will be joined with the next move
536 536
 #define MIN_STEPS_PER_SEGMENT 6
537 537
 
538
+// The minimum pulse width (in µs) for stepping a stepper.
539
+// Set this if you find stepping unreliable, or if using a very fast CPU.
540
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
541
+
538 542
 // @section temperature
539 543
 
540 544
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

@@ -535,6 +535,10 @@
535 535
 // Moves (or segments) with fewer steps than this will be joined with the next move
536 536
 #define MIN_STEPS_PER_SEGMENT 6
537 537
 
538
+// The minimum pulse width (in µs) for stepping a stepper.
539
+// Set this if you find stepping unreliable, or if using a very fast CPU.
540
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
541
+
538 542
 // @section temperature
539 543
 
540 544
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

@@ -534,6 +534,10 @@
534 534
 // Moves (or segments) with fewer steps than this will be joined with the next move
535 535
 #define MIN_STEPS_PER_SEGMENT 6
536 536
 
537
+// The minimum pulse width (in µs) for stepping a stepper.
538
+// Set this if you find stepping unreliable, or if using a very fast CPU.
539
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
540
+
537 541
 // @section temperature
538 542
 
539 543
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

@@ -539,6 +539,10 @@
539 539
 // Moves (or segments) with fewer steps than this will be joined with the next move
540 540
 #define MIN_STEPS_PER_SEGMENT 6
541 541
 
542
+// The minimum pulse width (in µs) for stepping a stepper.
543
+// Set this if you find stepping unreliable, or if using a very fast CPU.
544
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
545
+
542 546
 // @section temperature
543 547
 
544 548
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration_adv.h View File

@@ -535,6 +535,10 @@
535 535
 // Moves (or segments) with fewer steps than this will be joined with the next move
536 536
 #define MIN_STEPS_PER_SEGMENT 6
537 537
 
538
+// The minimum pulse width (in µs) for stepping a stepper.
539
+// Set this if you find stepping unreliable, or if using a very fast CPU.
540
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
541
+
538 542
 // @section temperature
539 543
 
540 544
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/makibox/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 4
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

@@ -533,6 +533,10 @@
533 533
 // Moves (or segments) with fewer steps than this will be joined with the next move
534 534
 #define MIN_STEPS_PER_SEGMENT 6
535 535
 
536
+// The minimum pulse width (in µs) for stepping a stepper.
537
+// Set this if you find stepping unreliable, or if using a very fast CPU.
538
+#define MINIMUM_STEPPER_PULSE 0 // (µs) The smallest stepper pulse allowed
539
+
536 540
 // @section temperature
537 541
 
538 542
 // Control heater 0 and heater 1 in parallel.

+ 25
- 15
Marlin/stepper.cpp View File

@@ -449,18 +449,30 @@ void Stepper::isr() {
449 449
       #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
450 450
       #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
451 451
 
452
-      #define STEP_ADD(AXIS) \
452
+      #define PULSE_START(AXIS) \
453 453
         _COUNTER(AXIS) += current_block->steps[_AXIS(AXIS)]; \
454 454
         if (_COUNTER(AXIS) > 0) { _APPLY_STEP(AXIS)(!_INVERT_STEP_PIN(AXIS),0); }
455 455
 
456
+      #define PULSE_STOP(AXIS) \
457
+        if (_COUNTER(AXIS) > 0) { \
458
+          _COUNTER(AXIS) -= current_block->step_event_count; \
459
+          count_position[_AXIS(AXIS)] += count_direction[_AXIS(AXIS)]; \
460
+          _APPLY_STEP(AXIS)(_INVERT_STEP_PIN(AXIS),0); \
461
+        }
462
+
463
+      #if MINIMUM_STEPPER_PULSE > 0
464
+        static uint32_t pulse_start;
465
+        pulse_start = TCNT0;
466
+      #endif
467
+
456 468
       #if HAS_X_STEP
457
-        STEP_ADD(X);
469
+        PULSE_START(X);
458 470
       #endif
459 471
       #if HAS_Y_STEP
460
-        STEP_ADD(Y);
472
+        PULSE_START(Y);
461 473
       #endif
462 474
       #if HAS_Z_STEP
463
-        STEP_ADD(Z);
475
+        PULSE_START(Z);
464 476
       #endif
465 477
 
466 478
       #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
@@ -475,25 +487,23 @@ void Stepper::isr() {
475 487
             if (counter_M[j] > 0) En_STEP_WRITE(j, !INVERT_E_STEP_PIN);
476 488
           }
477 489
         #else // !MIXING_EXTRUDER
478
-          STEP_ADD(E);
490
+          PULSE_START(E);
479 491
         #endif
480 492
       #endif // !ADVANCE && !LIN_ADVANCE
481 493
 
482
-      #define STEP_IF_COUNTER(AXIS) \
483
-        if (_COUNTER(AXIS) > 0) { \
484
-          _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
-        }
494
+      #if MINIMUM_STEPPER_PULSE > 0
495
+        #define CYCLES_EATEN_BY_CODE 10
496
+        while ((uint32_t)(TCNT0 - pulse_start) < (MINIMUM_STEPPER_PULSE * (F_CPU / 1000000UL)) - CYCLES_EATEN_BY_CODE) { /* nada */ }
497
+      #endif
488 498
 
489 499
       #if HAS_X_STEP
490
-        STEP_IF_COUNTER(X);
500
+        PULSE_STOP(X);
491 501
       #endif
492 502
       #if HAS_Y_STEP
493
-        STEP_IF_COUNTER(Y);
503
+        PULSE_STOP(Y);
494 504
       #endif
495 505
       #if HAS_Z_STEP
496
-        STEP_IF_COUNTER(Z);
506
+        PULSE_STOP(Z);
497 507
       #endif
498 508
 
499 509
       #if DISABLED(ADVANCE) && DISABLED(LIN_ADVANCE)
@@ -510,7 +520,7 @@ void Stepper::isr() {
510 520
             }
511 521
           }
512 522
         #else // !MIXING_EXTRUDER
513
-          STEP_IF_COUNTER(E);
523
+          PULSE_STOP(E);
514 524
         #endif
515 525
       #endif // !ADVANCE && !LIN_ADVANCE
516 526
 

Loading…
Cancel
Save