Browse Source

Added Y_DUAL_STEPPER_DRIVERS

Enables two stepper drivers to be used for the Y axis (useful for
Shapeoko style machines)
Each Y driver can be stepped in either the same way or in opposite
directions, accounting for different hardware setups (leadscrew vs. belt
driven)
Richard Miles 11 years ago
parent
commit
ed1ab42186
3 changed files with 54 additions and 2 deletions
  1. 15
    0
      Marlin/Configuration_adv.h
  2. 7
    2
      Marlin/Marlin.h
  3. 32
    0
      Marlin/stepper.cpp

+ 15
- 0
Marlin/Configuration_adv.h View File

@@ -152,6 +152,21 @@
152 152
   #define EXTRUDERS 1
153 153
 #endif
154 154
 
155
+// Same again but for Y Axis.
156
+#define Y_DUAL_STEPPER_DRIVERS
157
+
158
+// Define if the two Y drives need to rotate in opposite directions
159
+#define INVERT_Y2_VS_Y_DIR true
160
+
161
+#ifdef Y_DUAL_STEPPER_DRIVERS
162
+  #undef EXTRUDERS
163
+  #define EXTRUDERS 1
164
+#endif
165
+
166
+#ifdef Z_DUAL_STEPPER_DRIVERS && Y_DUAL_STEPPER_DRIVERS
167
+  #error "You cannot have dual drivers for both Y and Z"
168
+#endif 
169
+
155 170
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
156 171
 #define X_HOME_RETRACT_MM 5 
157 172
 #define Y_HOME_RETRACT_MM 5 

+ 7
- 2
Marlin/Marlin.h View File

@@ -105,8 +105,13 @@ void manage_inactivity();
105 105
 #endif
106 106
 
107 107
 #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
108
-  #define  enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
109
-  #define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
108
+  #ifdef Y_DUAL_STEPPER_DRIVERS
109
+    #define  enable_y() { WRITE(Y_ENABLE_PIN, Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN,  Y_ENABLE_ON); }
110
+    #define disable_y() { WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON); WRITE(Y2_ENABLE_PIN, !Y_ENABLE_ON); }
111
+  #else
112
+    #define  enable_y() WRITE(Y_ENABLE_PIN, Y_ENABLE_ON)
113
+    #define disable_y() WRITE(Y_ENABLE_PIN,!Y_ENABLE_ON)
114
+  #endif
110 115
 #else
111 116
   #define enable_y() ;
112 117
   #define disable_y() ;

+ 32
- 0
Marlin/stepper.cpp View File

@@ -357,10 +357,20 @@ ISR(TIMER1_COMPA_vect)
357 357
     }
358 358
     if((out_bits & (1<<Y_AXIS))!=0){
359 359
       WRITE(Y_DIR_PIN, INVERT_Y_DIR);
360
+	  
361
+	  #ifdef Y_DUAL_STEPPER_DRIVERS
362
+	    WRITE(Y2_DIR_PIN, !(INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
363
+	  #endif
364
+	  
360 365
       count_direction[Y_AXIS]=-1;
361 366
     }
362 367
     else{
363 368
       WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
369
+	  
370
+	  #ifdef Y_DUAL_STEPPER_DRIVERS
371
+	    WRITE(Y2_DIR_PIN, (INVERT_Y_DIR == INVERT_Y2_VS_Y_DIR));
372
+	  #endif
373
+	  
364 374
       count_direction[Y_AXIS]=1;
365 375
     }
366 376
     
@@ -516,9 +526,18 @@ ISR(TIMER1_COMPA_vect)
516 526
         counter_y += current_block->steps_y;
517 527
         if (counter_y > 0) {
518 528
           WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
529
+		  
530
+		  #ifdef Y_DUAL_STEPPER_DRIVERS
531
+			WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
532
+		  #endif
533
+		  
519 534
           counter_y -= current_block->step_event_count; 
520 535
           count_position[Y_AXIS]+=count_direction[Y_AXIS]; 
521 536
           WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
537
+		  
538
+		  #ifdef Y_DUAL_STEPPER_DRIVERS
539
+			WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
540
+		  #endif
522 541
         }
523 542
   
524 543
       counter_z += current_block->steps_z;
@@ -687,6 +706,10 @@ void st_init()
687 706
   #endif
688 707
   #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 
689 708
     SET_OUTPUT(Y_DIR_PIN);
709
+		
710
+	#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_DIR_PIN) && (Y2_DIR_PIN > -1)
711
+	  SET_OUTPUT(Y2_DIR_PIN);
712
+	#endif
690 713
   #endif
691 714
   #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1 
692 715
     SET_OUTPUT(Z_DIR_PIN);
@@ -714,6 +737,11 @@ void st_init()
714 737
   #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
715 738
     SET_OUTPUT(Y_ENABLE_PIN);
716 739
     if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
740
+	
741
+	#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_ENABLE_PIN) && (Y2_ENABLE_PIN > -1)
742
+	  SET_OUTPUT(Y2_ENABLE_PIN);
743
+	  if(!Y_ENABLE_ON) WRITE(Y2_ENABLE_PIN,HIGH);
744
+	#endif
717 745
   #endif
718 746
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
719 747
     SET_OUTPUT(Z_ENABLE_PIN);
@@ -791,6 +819,10 @@ void st_init()
791 819
   #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1) 
792 820
     SET_OUTPUT(Y_STEP_PIN);
793 821
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
822
+    #if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
823
+      SET_OUTPUT(Y2_STEP_PIN);
824
+      WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
825
+    #endif
794 826
     disable_y();
795 827
   #endif  
796 828
   #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1) 

Loading…
Cancel
Save