Browse Source

Merge git://github.com/daid/Marlin into Marlin_v1

Added invert step pins to corexy code
Erik van der Zalm 12 years ago
parent
commit
cd57bf305b
2 changed files with 46 additions and 34 deletions
  1. 6
    0
      Marlin/Configuration_adv.h
  2. 40
    34
      Marlin/stepper.cpp

+ 6
- 0
Marlin/Configuration_adv.h View File

88
 
88
 
89
 #define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
89
 #define MAX_STEP_FREQUENCY 40000 // Max step frequency for Ultimaker (5000 pps / half step)
90
 
90
 
91
+//By default pololu step drivers require an active high signal. However, some high power drivers require an active low signal as step.
92
+#define INVERT_X_STEP_PIN false
93
+#define INVERT_Y_STEP_PIN false
94
+#define INVERT_Z_STEP_PIN false
95
+#define INVERT_E_STEP_PIN false
96
+
91
 //default stepper release if idle
97
 //default stepper release if idle
92
 #define DEFAULT_STEPPER_DEACTIVE_TIME 60
98
 #define DEFAULT_STEPPER_DEACTIVE_TIME 60
93
 
99
 

+ 40
- 34
Marlin/stepper.cpp View File

486
       #if !defined COREXY      
486
       #if !defined COREXY      
487
         counter_x += current_block->steps_x;
487
         counter_x += current_block->steps_x;
488
         if (counter_x > 0) {
488
         if (counter_x > 0) {
489
-          WRITE(X_STEP_PIN, HIGH);
489
+          WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
490
           counter_x -= current_block->step_event_count;
490
           counter_x -= current_block->step_event_count;
491
           count_position[X_AXIS]+=count_direction[X_AXIS];   
491
           count_position[X_AXIS]+=count_direction[X_AXIS];   
492
-          WRITE(X_STEP_PIN, LOW);
492
+          WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
493
         }
493
         }
494
   
494
   
495
         counter_y += current_block->steps_y;
495
         counter_y += current_block->steps_y;
496
         if (counter_y > 0) {
496
         if (counter_y > 0) {
497
-          WRITE(Y_STEP_PIN, HIGH);
497
+          WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
498
           counter_y -= current_block->step_event_count; 
498
           counter_y -= current_block->step_event_count; 
499
-          count_position[Y_AXIS]+=count_direction[Y_AXIS];         
500
-          WRITE(Y_STEP_PIN, LOW);
499
+          count_position[Y_AXIS]+=count_direction[Y_AXIS]; 
500
+          WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
501
         }
501
         }
502
       #endif
502
       #endif
503
   
503
   
506
         counter_y += current_block->steps_y;
506
         counter_y += current_block->steps_y;
507
         
507
         
508
         if ((counter_x > 0)&&!(counter_y>0)){  //X step only
508
         if ((counter_x > 0)&&!(counter_y>0)){  //X step only
509
-          WRITE(X_STEP_PIN, HIGH);
510
-          WRITE(Y_STEP_PIN, HIGH);
509
+          WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
510
+          WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
511
           counter_x -= current_block->step_event_count; 
511
           counter_x -= current_block->step_event_count; 
512
           count_position[X_AXIS]+=count_direction[X_AXIS];         
512
           count_position[X_AXIS]+=count_direction[X_AXIS];         
513
-          WRITE(X_STEP_PIN, LOW);
514
-          WRITE(Y_STEP_PIN, LOW);
513
+          WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
514
+          WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
515
         }
515
         }
516
         
516
         
517
         if (!(counter_x > 0)&&(counter_y>0)){  //Y step only
517
         if (!(counter_x > 0)&&(counter_y>0)){  //Y step only
518
-          WRITE(X_STEP_PIN, HIGH);
519
-          WRITE(Y_STEP_PIN, HIGH);
518
+          WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
519
+          WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
520
           counter_y -= current_block->step_event_count; 
520
           counter_y -= current_block->step_event_count; 
521
           count_position[Y_AXIS]+=count_direction[Y_AXIS];
521
           count_position[Y_AXIS]+=count_direction[Y_AXIS];
522
-          WRITE(X_STEP_PIN, LOW);
523
-          WRITE(Y_STEP_PIN, LOW);
522
+          WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
523
+          WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
524
         }        
524
         }        
525
         
525
         
526
         if ((counter_x > 0)&&(counter_y>0)){  //step in both axes
526
         if ((counter_x > 0)&&(counter_y>0)){  //step in both axes
527
           if (((out_bits & (1<<X_AXIS)) == 0)^((out_bits & (1<<Y_AXIS)) == 0)){  //X and Y in different directions
527
           if (((out_bits & (1<<X_AXIS)) == 0)^((out_bits & (1<<Y_AXIS)) == 0)){  //X and Y in different directions
528
-            WRITE(Y_STEP_PIN, HIGH);
528
+            WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
529
             counter_x -= current_block->step_event_count;             
529
             counter_x -= current_block->step_event_count;             
530
-            WRITE(Y_STEP_PIN, LOW);
530
+            WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
531
             step_wait();
531
             step_wait();
532
             count_position[X_AXIS]+=count_direction[X_AXIS];
532
             count_position[X_AXIS]+=count_direction[X_AXIS];
533
             count_position[Y_AXIS]+=count_direction[Y_AXIS];
533
             count_position[Y_AXIS]+=count_direction[Y_AXIS];
534
-            WRITE(Y_STEP_PIN, HIGH);
534
+            WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
535
             counter_y -= current_block->step_event_count;
535
             counter_y -= current_block->step_event_count;
536
-            WRITE(Y_STEP_PIN, LOW);
536
+            WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
537
           }
537
           }
538
           else{  //X and Y in same direction
538
           else{  //X and Y in same direction
539
-            WRITE(X_STEP_PIN, HIGH);
539
+            WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
540
             counter_x -= current_block->step_event_count;             
540
             counter_x -= current_block->step_event_count;             
541
-            WRITE(X_STEP_PIN, LOW) ;
541
+            WRITE(X_STEP_PIN, INVERT_X_STEP_PIN) ;
542
             step_wait();
542
             step_wait();
543
             count_position[X_AXIS]+=count_direction[X_AXIS];
543
             count_position[X_AXIS]+=count_direction[X_AXIS];
544
             count_position[Y_AXIS]+=count_direction[Y_AXIS];
544
             count_position[Y_AXIS]+=count_direction[Y_AXIS];
545
-            WRITE(X_STEP_PIN, HIGH); 
545
+            WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); 
546
             counter_y -= current_block->step_event_count;    
546
             counter_y -= current_block->step_event_count;    
547
-            WRITE(X_STEP_PIN, LOW);        
547
+            WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);        
548
           }
548
           }
549
         }
549
         }
550
       #endif //corexy
550
       #endif //corexy
551
       
551
       
552
       counter_z += current_block->steps_z;
552
       counter_z += current_block->steps_z;
553
       if (counter_z > 0) {
553
       if (counter_z > 0) {
554
-        WRITE(Z_STEP_PIN, HIGH);
554
+        WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
555
         counter_z -= current_block->step_event_count;
555
         counter_z -= current_block->step_event_count;
556
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
556
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
557
-        WRITE(Z_STEP_PIN, LOW);
557
+        WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
558
       }
558
       }
559
 
559
 
560
       #ifndef ADVANCE
560
       #ifndef ADVANCE
561
         counter_e += current_block->steps_e;
561
         counter_e += current_block->steps_e;
562
         if (counter_e > 0) {
562
         if (counter_e > 0) {
563
-          WRITE_E_STEP(HIGH);
563
+          WRITE_E_STEP(!INVERT_E_STEP_PIN);
564
           counter_e -= current_block->step_event_count;
564
           counter_e -= current_block->step_event_count;
565
           count_position[E_AXIS]+=count_direction[E_AXIS];
565
           count_position[E_AXIS]+=count_direction[E_AXIS];
566
-          WRITE_E_STEP(LOW);
566
+          WRITE(E_STEP_PIN, INVERT_E_STEP_PIN);
567
         }
567
         }
568
       #endif //!ADVANCE
568
       #endif //!ADVANCE
569
       step_events_completed += 1;  
569
       step_events_completed += 1;  
647
     // Set E direction (Depends on E direction + advance)
647
     // Set E direction (Depends on E direction + advance)
648
     for(unsigned char i=0; i<4;i++) {
648
     for(unsigned char i=0; i<4;i++) {
649
       if (e_steps[0] != 0) {
649
       if (e_steps[0] != 0) {
650
-        WRITE(E0_STEP_PIN, LOW);
650
+        WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN);
651
         if (e_steps[0] < 0) {
651
         if (e_steps[0] < 0) {
652
           WRITE(E0_DIR_PIN, INVERT_E0_DIR);
652
           WRITE(E0_DIR_PIN, INVERT_E0_DIR);
653
           e_steps[0]++;
653
           e_steps[0]++;
654
-          WRITE(E0_STEP_PIN, HIGH);
654
+          WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
655
         } 
655
         } 
656
         else if (e_steps[0] > 0) {
656
         else if (e_steps[0] > 0) {
657
           WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
657
           WRITE(E0_DIR_PIN, !INVERT_E0_DIR);
658
           e_steps[0]--;
658
           e_steps[0]--;
659
-          WRITE(E0_STEP_PIN, HIGH);
659
+          WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN);
660
         }
660
         }
661
       }
661
       }
662
  #if EXTRUDERS > 1
662
  #if EXTRUDERS > 1
663
       if (e_steps[1] != 0) {
663
       if (e_steps[1] != 0) {
664
-        WRITE(E1_STEP_PIN, LOW);
664
+        WRITE(E1_STEP_PIN, INVERT_E_STEP_PIN);
665
         if (e_steps[1] < 0) {
665
         if (e_steps[1] < 0) {
666
           WRITE(E1_DIR_PIN, INVERT_E1_DIR);
666
           WRITE(E1_DIR_PIN, INVERT_E1_DIR);
667
           e_steps[1]++;
667
           e_steps[1]++;
668
-          WRITE(E1_STEP_PIN, HIGH);
668
+          WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
669
         } 
669
         } 
670
         else if (e_steps[1] > 0) {
670
         else if (e_steps[1] > 0) {
671
           WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
671
           WRITE(E1_DIR_PIN, !INVERT_E1_DIR);
672
           e_steps[1]--;
672
           e_steps[1]--;
673
-          WRITE(E1_STEP_PIN, HIGH);
673
+          WRITE(E1_STEP_PIN, !INVERT_E_STEP_PIN);
674
         }
674
         }
675
       }
675
       }
676
  #endif
676
  #endif
677
  #if EXTRUDERS > 2
677
  #if EXTRUDERS > 2
678
       if (e_steps[2] != 0) {
678
       if (e_steps[2] != 0) {
679
-        WRITE(E2_STEP_PIN, LOW);
679
+        WRITE(E2_STEP_PIN, INVERT_E_STEP_PIN);
680
         if (e_steps[2] < 0) {
680
         if (e_steps[2] < 0) {
681
           WRITE(E2_DIR_PIN, INVERT_E2_DIR);
681
           WRITE(E2_DIR_PIN, INVERT_E2_DIR);
682
           e_steps[2]++;
682
           e_steps[2]++;
683
-          WRITE(E2_STEP_PIN, HIGH);
683
+          WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
684
         } 
684
         } 
685
         else if (e_steps[2] > 0) {
685
         else if (e_steps[2] > 0) {
686
           WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
686
           WRITE(E2_DIR_PIN, !INVERT_E2_DIR);
687
           e_steps[2]--;
687
           e_steps[2]--;
688
-          WRITE(E2_STEP_PIN, HIGH);
688
+          WRITE(E2_STEP_PIN, !INVERT_E_STEP_PIN);
689
         }
689
         }
690
       }
690
       }
691
  #endif
691
  #endif
790
   //Initialize Step Pins
790
   //Initialize Step Pins
791
   #if (X_STEP_PIN > -1) 
791
   #if (X_STEP_PIN > -1) 
792
     SET_OUTPUT(X_STEP_PIN);
792
     SET_OUTPUT(X_STEP_PIN);
793
+    WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
793
     if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
794
     if(!X_ENABLE_ON) WRITE(X_ENABLE_PIN,HIGH);
794
   #endif  
795
   #endif  
795
   #if (Y_STEP_PIN > -1) 
796
   #if (Y_STEP_PIN > -1) 
796
     SET_OUTPUT(Y_STEP_PIN);
797
     SET_OUTPUT(Y_STEP_PIN);
798
+    WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
797
     if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
799
     if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
798
   #endif  
800
   #endif  
799
   #if (Z_STEP_PIN > -1) 
801
   #if (Z_STEP_PIN > -1) 
800
     SET_OUTPUT(Z_STEP_PIN);
802
     SET_OUTPUT(Z_STEP_PIN);
803
+    WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
801
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
804
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
802
   #endif  
805
   #endif  
803
   #if (E0_STEP_PIN > -1) 
806
   #if (E0_STEP_PIN > -1) 
804
     SET_OUTPUT(E0_STEP_PIN);
807
     SET_OUTPUT(E0_STEP_PIN);
808
+    WRITE(E0_STEP_PIN,INVERT_E_STEP_PIN);
805
     if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
809
     if(!E_ENABLE_ON) WRITE(E0_ENABLE_PIN,HIGH);
806
   #endif  
810
   #endif  
807
   #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1) 
811
   #if defined(E1_STEP_PIN) && (E1_STEP_PIN > -1) 
808
     SET_OUTPUT(E1_STEP_PIN);
812
     SET_OUTPUT(E1_STEP_PIN);
813
+    WRITE(E1_STEP_PIN,INVERT_E_STEP_PIN);
809
     if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
814
     if(!E_ENABLE_ON) WRITE(E1_ENABLE_PIN,HIGH);
810
   #endif  
815
   #endif  
811
   #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1) 
816
   #if defined(E2_STEP_PIN) && (E2_STEP_PIN > -1) 
812
     SET_OUTPUT(E2_STEP_PIN);
817
     SET_OUTPUT(E2_STEP_PIN);
818
+    WRITE(E2_STEP_PIN,INVERT_E_STEP_PIN);
813
     if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
819
     if(!E_ENABLE_ON) WRITE(E2_ENABLE_PIN,HIGH);
814
   #endif  
820
   #endif  
815
 
821
 

Loading…
Cancel
Save