Browse Source

Merge pull request #208 from Enchiridion/Marlin_v1

Added support for dual Z axis stepper drivers
ErikZalm 12 years ago
parent
commit
f062794a0d
4 changed files with 57 additions and 2 deletions
  1. 12
    0
      Marlin/Configuration_adv.h
  2. 7
    2
      Marlin/Marlin.h
  3. 4
    0
      Marlin/pins.h
  4. 34
    0
      Marlin/stepper.cpp

+ 12
- 0
Marlin/Configuration_adv.h View File

78
 
78
 
79
 //#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats.
79
 //#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats.
80
 
80
 
81
+// A single Z stepper driver is usually used to drive 2 stepper motors.
82
+// Uncomment this define to utilize a separate stepper driver for each Z axis motor.
83
+// Only a few motherboards support this, like RAMPS, which have dual extruder support (the 2nd, often unused, extruder driver is used
84
+// to control the 2nd Z axis stepper motor). The pins are currently only defined for a RAMPS motherboards.
85
+// On a RAMPS (or other 5 driver) motherboard, using this feature will limit you to using 1 extruder.
86
+//#define Z_DUAL_STEPPER_DRIVERS
87
+
88
+#ifdef Z_DUAL_STEPPER_DRIVERS
89
+  #undef EXTRUDERS
90
+  #define EXTRUDERS 1
91
+#endif
92
+
81
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
93
 //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
82
 #define X_HOME_RETRACT_MM 5 
94
 #define X_HOME_RETRACT_MM 5 
83
 #define Y_HOME_RETRACT_MM 5 
95
 #define Y_HOME_RETRACT_MM 5 

+ 7
- 2
Marlin/Marlin.h View File

126
 #endif
126
 #endif
127
 
127
 
128
 #if Z_ENABLE_PIN > -1
128
 #if Z_ENABLE_PIN > -1
129
-  #define  enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
130
-  #define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON)
129
+  #ifdef Z_DUAL_STEPPER_DRIVERS
130
+    #define  enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); }
131
+    #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); }
132
+  #else
133
+    #define  enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON)
134
+    #define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON)
135
+  #endif
131
 #else
136
 #else
132
   #define enable_z() ;
137
   #define enable_z() ;
133
   #define disable_z() ;
138
   #define disable_z() ;

+ 4
- 0
Marlin/pins.h View File

267
 #define Z_MIN_PIN          18
267
 #define Z_MIN_PIN          18
268
 #define Z_MAX_PIN          19
268
 #define Z_MAX_PIN          19
269
 
269
 
270
+#define Z2_STEP_PIN        36
271
+#define Z2_DIR_PIN         34
272
+#define Z2_ENABLE_PIN      30
273
+
270
 #define E0_STEP_PIN        26
274
 #define E0_STEP_PIN        26
271
 #define E0_DIR_PIN         28
275
 #define E0_DIR_PIN         28
272
 #define E0_ENABLE_PIN      24
276
 #define E0_ENABLE_PIN      24

+ 34
- 0
Marlin/stepper.cpp View File

421
     
421
     
422
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
422
     if ((out_bits & (1<<Z_AXIS)) != 0) {   // -direction
423
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
423
       WRITE(Z_DIR_PIN,INVERT_Z_DIR);
424
+      
425
+	  #ifdef Z_DUAL_STEPPER_DRIVERS
426
+        WRITE(Z2_DIR_PIN,INVERT_Z_DIR);
427
+      #endif
428
+      
424
       count_direction[Z_AXIS]=-1;
429
       count_direction[Z_AXIS]=-1;
425
       CHECK_ENDSTOPS
430
       CHECK_ENDSTOPS
426
       {
431
       {
437
     }
442
     }
438
     else { // +direction
443
     else { // +direction
439
       WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
444
       WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
445
+
446
+	  #ifdef Z_DUAL_STEPPER_DRIVERS
447
+        WRITE(Z2_DIR_PIN,!INVERT_Z_DIR);
448
+      #endif
449
+
440
       count_direction[Z_AXIS]=1;
450
       count_direction[Z_AXIS]=1;
441
       CHECK_ENDSTOPS
451
       CHECK_ENDSTOPS
442
       {
452
       {
552
       counter_z += current_block->steps_z;
562
       counter_z += current_block->steps_z;
553
       if (counter_z > 0) {
563
       if (counter_z > 0) {
554
         WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
564
         WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN);
565
+        
566
+		#ifdef Z_DUAL_STEPPER_DRIVERS
567
+          WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN);
568
+        #endif
569
+        
555
         counter_z -= current_block->step_event_count;
570
         counter_z -= current_block->step_event_count;
556
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
571
         count_position[Z_AXIS]+=count_direction[Z_AXIS];
557
         WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
572
         WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN);
573
+        
574
+		#ifdef Z_DUAL_STEPPER_DRIVERS
575
+          WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN);
576
+        #endif
558
       }
577
       }
559
 
578
 
560
       #ifndef ADVANCE
579
       #ifndef ADVANCE
704
   #endif
723
   #endif
705
   #if Z_DIR_PIN > -1 
724
   #if Z_DIR_PIN > -1 
706
     SET_OUTPUT(Z_DIR_PIN);
725
     SET_OUTPUT(Z_DIR_PIN);
726
+
727
+    #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_DIR_PIN > -1)
728
+      SET_OUTPUT(Z2_DIR_PIN);
729
+    #endif
707
   #endif
730
   #endif
708
   #if E0_DIR_PIN > -1 
731
   #if E0_DIR_PIN > -1 
709
     SET_OUTPUT(E0_DIR_PIN);
732
     SET_OUTPUT(E0_DIR_PIN);
728
   #if (Z_ENABLE_PIN > -1)
751
   #if (Z_ENABLE_PIN > -1)
729
     SET_OUTPUT(Z_ENABLE_PIN);
752
     SET_OUTPUT(Z_ENABLE_PIN);
730
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
753
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
754
+    
755
+    #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_ENABLE_PIN > -1)
756
+      SET_OUTPUT(Z2_ENABLE_PIN);
757
+      if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
758
+    #endif
731
   #endif
759
   #endif
732
   #if (E0_ENABLE_PIN > -1)
760
   #if (E0_ENABLE_PIN > -1)
733
     SET_OUTPUT(E0_ENABLE_PIN);
761
     SET_OUTPUT(E0_ENABLE_PIN);
802
     SET_OUTPUT(Z_STEP_PIN);
830
     SET_OUTPUT(Z_STEP_PIN);
803
     WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
831
     WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN);
804
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
832
     if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH);
833
+    
834
+    #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_STEP_PIN > -1)
835
+      SET_OUTPUT(Z2_STEP_PIN);
836
+      WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
837
+      if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH);
838
+    #endif
805
   #endif  
839
   #endif  
806
   #if (E0_STEP_PIN > -1) 
840
   #if (E0_STEP_PIN > -1) 
807
     SET_OUTPUT(E0_STEP_PIN);
841
     SET_OUTPUT(E0_STEP_PIN);

Loading…
Cancel
Save