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 12 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
   #define EXTRUDERS 1
152
   #define EXTRUDERS 1
153
 #endif
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
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
170
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
156
 #define X_HOME_RETRACT_MM 5 
171
 #define X_HOME_RETRACT_MM 5 
157
 #define Y_HOME_RETRACT_MM 5 
172
 #define Y_HOME_RETRACT_MM 5 

+ 7
- 2
Marlin/Marlin.h View File

105
 #endif
105
 #endif
106
 
106
 
107
 #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
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
 #else
115
 #else
111
   #define enable_y() ;
116
   #define enable_y() ;
112
   #define disable_y() ;
117
   #define disable_y() ;

+ 32
- 0
Marlin/stepper.cpp View File

357
     }
357
     }
358
     if((out_bits & (1<<Y_AXIS))!=0){
358
     if((out_bits & (1<<Y_AXIS))!=0){
359
       WRITE(Y_DIR_PIN, INVERT_Y_DIR);
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
       count_direction[Y_AXIS]=-1;
365
       count_direction[Y_AXIS]=-1;
361
     }
366
     }
362
     else{
367
     else{
363
       WRITE(Y_DIR_PIN, !INVERT_Y_DIR);
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
       count_direction[Y_AXIS]=1;
374
       count_direction[Y_AXIS]=1;
365
     }
375
     }
366
     
376
     
516
         counter_y += current_block->steps_y;
526
         counter_y += current_block->steps_y;
517
         if (counter_y > 0) {
527
         if (counter_y > 0) {
518
           WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
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
           counter_y -= current_block->step_event_count; 
534
           counter_y -= current_block->step_event_count; 
520
           count_position[Y_AXIS]+=count_direction[Y_AXIS]; 
535
           count_position[Y_AXIS]+=count_direction[Y_AXIS]; 
521
           WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
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
       counter_z += current_block->steps_z;
543
       counter_z += current_block->steps_z;
687
   #endif
706
   #endif
688
   #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 
707
   #if defined(Y_DIR_PIN) && Y_DIR_PIN > -1 
689
     SET_OUTPUT(Y_DIR_PIN);
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
   #endif
713
   #endif
691
   #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1 
714
   #if defined(Z_DIR_PIN) && Z_DIR_PIN > -1 
692
     SET_OUTPUT(Z_DIR_PIN);
715
     SET_OUTPUT(Z_DIR_PIN);
714
   #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
737
   #if defined(Y_ENABLE_PIN) && Y_ENABLE_PIN > -1
715
     SET_OUTPUT(Y_ENABLE_PIN);
738
     SET_OUTPUT(Y_ENABLE_PIN);
716
     if(!Y_ENABLE_ON) WRITE(Y_ENABLE_PIN,HIGH);
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
   #endif
745
   #endif
718
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
746
   #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1
719
     SET_OUTPUT(Z_ENABLE_PIN);
747
     SET_OUTPUT(Z_ENABLE_PIN);
791
   #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1) 
819
   #if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1) 
792
     SET_OUTPUT(Y_STEP_PIN);
820
     SET_OUTPUT(Y_STEP_PIN);
793
     WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
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
     disable_y();
826
     disable_y();
795
   #endif  
827
   #endif  
796
   #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1) 
828
   #if defined(Z_STEP_PIN) && (Z_STEP_PIN > -1) 

Loading…
Cancel
Save