From 50cde90324a74d9f5eb88c6cd359e21f5ca1b2b3 Mon Sep 17 00:00:00 2001 From: Enchiridion Date: Sat, 4 Aug 2012 00:32:26 -0600 Subject: [PATCH] Added support for dual Z axis stepper drivers --- Marlin/Configuration_adv.h | 12 ++++++++++++ Marlin/Marlin.h | 9 +++++++-- Marlin/pins.h | 4 ++++ Marlin/stepper.cpp | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 297c9df13..0182c9375 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -78,6 +78,18 @@ //#define Z_LATE_ENABLE // Enable Z the last moment. Needed if your Z driver overheats. +// A single Z stepper driver is usually used to drive 2 stepper motors. +// Uncomment this define to utilize a separate stepper driver for each Z axis motor. +// Only a few motherboards support this, like RAMPS, which have dual extruder support (the 2nd, often unused, extruder driver is used +// to control the 2nd Z axis stepper motor). The pins are currently only defined for a RAMPS motherboards. +// On a RAMPS (or other 5 driver) motherboard, using this feature will limit you to using 1 extruder. +//#define Z_DUAL_STEPPER_DRIVERS + +#ifdef Z_DUAL_STEPPER_DRIVERS + #undef EXTRUDERS + #define EXTRUDERS 1 +#endif + //homing hits the endstop, then retracts by this distance, before it tries to slowly bump again: #define X_HOME_RETRACT_MM 5 #define Y_HOME_RETRACT_MM 5 diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 412363444..943acb012 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -122,8 +122,13 @@ void manage_inactivity(byte debug); #endif #if Z_ENABLE_PIN > -1 - #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) - #define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON) + #ifdef Z_DUAL_STEPPER_DRIVERS + #define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } + #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); } + #else + #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) + #define disable_z() WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON) + #endif #else #define enable_z() ; #define disable_z() ; diff --git a/Marlin/pins.h b/Marlin/pins.h index 419ddb643..8d719375b 100644 --- a/Marlin/pins.h +++ b/Marlin/pins.h @@ -267,6 +267,10 @@ #define Z_MIN_PIN 18 #define Z_MAX_PIN 19 +#define Z2_STEP_PIN 36 +#define Z2_DIR_PIN 34 +#define Z2_ENABLE_PIN 30 + #define E0_STEP_PIN 26 #define E0_DIR_PIN 28 #define E0_ENABLE_PIN 24 diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index aba44e8e1..a222f154a 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -421,6 +421,11 @@ ISR(TIMER1_COMPA_vect) if ((out_bits & (1<steps_z; if (counter_z > 0) { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + + #ifdef Z_DUAL_STEPPER_DRIVERS + WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); + #endif + counter_z -= current_block->step_event_count; count_position[Z_AXIS]+=count_direction[Z_AXIS]; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); + + #ifdef Z_DUAL_STEPPER_DRIVERS + WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); + #endif } #ifndef ADVANCE @@ -704,6 +723,10 @@ void st_init() #endif #if Z_DIR_PIN > -1 SET_OUTPUT(Z_DIR_PIN); + + #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_DIR_PIN > -1) + SET_OUTPUT(Z2_DIR_PIN); + #endif #endif #if E0_DIR_PIN > -1 SET_OUTPUT(E0_DIR_PIN); @@ -728,6 +751,11 @@ void st_init() #if (Z_ENABLE_PIN > -1) SET_OUTPUT(Z_ENABLE_PIN); if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH); + + #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_ENABLE_PIN > -1) + SET_OUTPUT(Z2_ENABLE_PIN); + if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH); + #endif #endif #if (E0_ENABLE_PIN > -1) SET_OUTPUT(E0_ENABLE_PIN); @@ -802,6 +830,12 @@ void st_init() SET_OUTPUT(Z_STEP_PIN); WRITE(Z_STEP_PIN,INVERT_Z_STEP_PIN); if(!Z_ENABLE_ON) WRITE(Z_ENABLE_PIN,HIGH); + + #if defined(Z_DUAL_STEPPER_DRIVERS) && (Z2_STEP_PIN > -1) + SET_OUTPUT(Z2_STEP_PIN); + WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN); + if(!Z_ENABLE_ON) WRITE(Z2_ENABLE_PIN,HIGH); + #endif #endif #if (E0_STEP_PIN > -1) SET_OUTPUT(E0_STEP_PIN);