X_DUAL_STEPPER_DRIVERS implementation

master
Scott Lahteine 8 years ago
parent 91bd6eade7
commit 4b4a582c4f

@ -134,73 +134,69 @@ void manage_inactivity(bool ignore_stepper_queue = false);
extern bool extruder_duplication_enabled; extern bool extruder_duplication_enabled;
#endif #endif
#if ENABLED(DUAL_X_CARRIAGE) && HAS_X_ENABLE && HAS_X2_ENABLE #if HAS_X2_ENABLE
#define enable_x() do { X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); } while (0) #define enable_x() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0)
#define disable_x() do { X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } while (0) #define disable_x() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
#elif HAS_X_ENABLE #elif HAS_X_ENABLE
#define enable_x() X_ENABLE_WRITE( X_ENABLE_ON) #define enable_x() X_ENABLE_WRITE( X_ENABLE_ON)
#define disable_x() { X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; } #define disable_x() do{ X_ENABLE_WRITE(!X_ENABLE_ON); axis_known_position[X_AXIS] = false; }while(0)
#else #else
#define enable_x() ; #define enable_x() NOOP
#define disable_x() ; #define disable_x() NOOP
#endif #endif
#if HAS_Y_ENABLE #if HAS_Y2_ENABLE
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) #define enable_y() do{ Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }while(0)
#define enable_y() { Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); } #define disable_y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
#define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; } #elif HAS_Y_ENABLE
#else #define enable_y() Y_ENABLE_WRITE( Y_ENABLE_ON)
#define enable_y() Y_ENABLE_WRITE( Y_ENABLE_ON) #define disable_y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }while(0)
#define disable_y() { Y_ENABLE_WRITE(!Y_ENABLE_ON); axis_known_position[Y_AXIS] = false; }
#endif
#else #else
#define enable_y() ; #define enable_y() NOOP
#define disable_y() ; #define disable_y() NOOP
#endif #endif
#if HAS_Z_ENABLE #if HAS_Z2_ENABLE
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) #define enable_z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }while(0)
#define enable_z() { Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); } #define disable_z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
#define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #elif HAS_Z_ENABLE
#else #define enable_z() Z_ENABLE_WRITE( Z_ENABLE_ON)
#define enable_z() Z_ENABLE_WRITE( Z_ENABLE_ON) #define disable_z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }while(0)
#define disable_z() { Z_ENABLE_WRITE(!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; }
#endif
#else #else
#define enable_z() ; #define enable_z() NOOP
#define disable_z() ; #define disable_z() NOOP
#endif #endif
#if HAS_E0_ENABLE #if HAS_E0_ENABLE
#define enable_e0() E0_ENABLE_WRITE( E_ENABLE_ON) #define enable_e0() E0_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON) #define disable_e0() E0_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e0() /* nothing */ #define enable_e0() NOOP
#define disable_e0() /* nothing */ #define disable_e0() NOOP
#endif #endif
#if (EXTRUDERS > 1) && HAS_E1_ENABLE #if (EXTRUDERS > 1) && HAS_E1_ENABLE
#define enable_e1() E1_ENABLE_WRITE( E_ENABLE_ON) #define enable_e1() E1_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON) #define disable_e1() E1_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e1() /* nothing */ #define enable_e1() NOOP
#define disable_e1() /* nothing */ #define disable_e1() NOOP
#endif #endif
#if (EXTRUDERS > 2) && HAS_E2_ENABLE #if (EXTRUDERS > 2) && HAS_E2_ENABLE
#define enable_e2() E2_ENABLE_WRITE( E_ENABLE_ON) #define enable_e2() E2_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON) #define disable_e2() E2_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e2() /* nothing */ #define enable_e2() NOOP
#define disable_e2() /* nothing */ #define disable_e2() NOOP
#endif #endif
#if (EXTRUDERS > 3) && HAS_E3_ENABLE #if (EXTRUDERS > 3) && HAS_E3_ENABLE
#define enable_e3() E3_ENABLE_WRITE( E_ENABLE_ON) #define enable_e3() E3_ENABLE_WRITE( E_ENABLE_ON)
#define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON) #define disable_e3() E3_ENABLE_WRITE(!E_ENABLE_ON)
#else #else
#define enable_e3() /* nothing */ #define enable_e3() NOOP
#define disable_e3() /* nothing */ #define disable_e3() NOOP
#endif #endif
/** /**

@ -369,8 +369,8 @@
#define __EPIN(p,q) E##p##_##q##_PIN #define __EPIN(p,q) E##p##_##q##_PIN
#define _EPIN(p,q) __EPIN(p,q) #define _EPIN(p,q) __EPIN(p,q)
#if ENABLED(DUAL_X_CARRIAGE) // The X2 axis, if any, should be the next open extruder port
// The X2 axis, if any, should be the next open extruder port #if ENABLED(DUAL_X_CARRIAGE) || ENABLED(X_DUAL_STEPPER_DRIVERS)
#ifndef X2_STEP_PIN #ifndef X2_STEP_PIN
#define X2_STEP_PIN _EPIN(EXTRUDERS, STEP) #define X2_STEP_PIN _EPIN(EXTRUDERS, STEP)
#define X2_DIR_PIN _EPIN(EXTRUDERS, DIR) #define X2_DIR_PIN _EPIN(EXTRUDERS, DIR)
@ -378,25 +378,32 @@
#endif #endif
#undef _X2_PINS #undef _X2_PINS
#define _X2_PINS X2_STEP_PIN, X2_DIR_PIN, X2_ENABLE_PIN, #define _X2_PINS X2_STEP_PIN, X2_DIR_PIN, X2_ENABLE_PIN,
#define Y2_Z2_E_INDEX INCREMENT(EXTRUDERS) #define Y2_E_INDEX INCREMENT(EXTRUDERS)
#else #else
#define Y2_Z2_E_INDEX EXTRUDERS #define Y2_E_INDEX EXTRUDERS
#endif #endif
// The Y2 axis, if any, should be the next open extruder port // The Y2 axis, if any, should be the next open extruder port
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && !defined(Y2_STEP_PIN) #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#define Y2_STEP_PIN _EPIN(Y2_Z2_E_INDEX, STEP) #ifndef Y2_STEP_PIN
#define Y2_DIR_PIN _EPIN(Y2_Z2_E_INDEX, DIR) #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
#define Y2_ENABLE_PIN _EPIN(Y2_Z2_E_INDEX, ENABLE) #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
#define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
#endif
#undef _Y2_PINS #undef _Y2_PINS
#define _Y2_PINS Y2_STEP_PIN, Y2_DIR_PIN, Y2_ENABLE_PIN, #define _Y2_PINS Y2_STEP_PIN, Y2_DIR_PIN, Y2_ENABLE_PIN,
#define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
#else
#define Z2_E_INDEX Y2_E_INDEX
#endif #endif
// The Z2 axis, if any, should be the next open extruder port // The Z2 axis, if any, should be the next open extruder port
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && !defined(Z2_STEP_PIN) #if ENABLED(Z_DUAL_STEPPER_DRIVERS)
#define Z2_STEP_PIN _EPIN(Y2_Z2_E_INDEX, STEP) #ifndef Z2_STEP_PIN
#define Z2_DIR_PIN _EPIN(Y2_Z2_E_INDEX, DIR) #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
#define Z2_ENABLE_PIN _EPIN(Y2_Z2_E_INDEX, ENABLE) #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
#define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
#endif
#undef _Z2_PINS #undef _Z2_PINS
#define _Z2_PINS Z2_STEP_PIN, Z2_DIR_PIN, Z2_ENABLE_PIN, #define _Z2_PINS Z2_STEP_PIN, Z2_DIR_PIN, Z2_ENABLE_PIN,
#endif #endif

@ -120,7 +120,10 @@ unsigned short Stepper::OCR1A_nominal;
volatile long Stepper::endstops_trigsteps[3]; volatile long Stepper::endstops_trigsteps[3];
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(X_DUAL_STEPPER_DRIVERS)
#define X_APPLY_DIR(v,Q) do{ X_DIR_WRITE(v); X2_DIR_WRITE((v) != INVERT_X2_VS_X_DIR); }while(0)
#define X_APPLY_STEP(v,Q) do{ X_STEP_WRITE(v); X2_STEP_WRITE(v); }while(0)
#elif ENABLED(DUAL_X_CARRIAGE)
#define X_APPLY_DIR(v,ALWAYS) \ #define X_APPLY_DIR(v,ALWAYS) \
if (extruder_duplication_enabled || ALWAYS) { \ if (extruder_duplication_enabled || ALWAYS) { \
X_DIR_WRITE(v); \ X_DIR_WRITE(v); \
@ -143,15 +146,15 @@ volatile long Stepper::endstops_trigsteps[3];
#endif #endif
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#define Y_APPLY_DIR(v,Q) { Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); } #define Y_APPLY_DIR(v,Q) do{ Y_DIR_WRITE(v); Y2_DIR_WRITE((v) != INVERT_Y2_VS_Y_DIR); }while(0)
#define Y_APPLY_STEP(v,Q) { Y_STEP_WRITE(v); Y2_STEP_WRITE(v); } #define Y_APPLY_STEP(v,Q) do{ Y_STEP_WRITE(v); Y2_STEP_WRITE(v); }while(0)
#else #else
#define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v) #define Y_APPLY_DIR(v,Q) Y_DIR_WRITE(v)
#define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v) #define Y_APPLY_STEP(v,Q) Y_STEP_WRITE(v)
#endif #endif
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) #if ENABLED(Z_DUAL_STEPPER_DRIVERS)
#define Z_APPLY_DIR(v,Q) { Z_DIR_WRITE(v); Z2_DIR_WRITE(v); } #define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }while(0)
#if ENABLED(Z_DUAL_ENDSTOPS) #if ENABLED(Z_DUAL_ENDSTOPS)
#define Z_APPLY_STEP(v,Q) \ #define Z_APPLY_STEP(v,Q) \
if (performing_homing) { \ if (performing_homing) { \
@ -169,7 +172,7 @@ volatile long Stepper::endstops_trigsteps[3];
Z2_STEP_WRITE(v); \ Z2_STEP_WRITE(v); \
} }
#else #else
#define Z_APPLY_STEP(v,Q) { Z_STEP_WRITE(v); Z2_STEP_WRITE(v); } #define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); }while(0)
#endif #endif
#else #else
#define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v) #define Z_APPLY_DIR(v,Q) Z_DIR_WRITE(v)
@ -669,14 +672,15 @@ void Stepper::init() {
// Initialize Step Pins // Initialize Step Pins
#if HAS_X_STEP #if HAS_X_STEP
AXIS_INIT(x, X, X); #if ENABLED(X_DUAL_STEPPER_DRIVERS) || ENABLED(DUAL_X_CARRIAGE)
#if ENABLED(DUAL_X_CARRIAGE) && HAS_X2_STEP X2_STEP_INIT;
AXIS_INIT(x, X2, X); X2_STEP_WRITE(INVERT_X_STEP_PIN);
#endif #endif
AXIS_INIT(x, X, X);
#endif #endif
#if HAS_Y_STEP #if HAS_Y_STEP
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) && HAS_Y2_STEP #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
Y2_STEP_INIT; Y2_STEP_INIT;
Y2_STEP_WRITE(INVERT_Y_STEP_PIN); Y2_STEP_WRITE(INVERT_Y_STEP_PIN);
#endif #endif
@ -684,7 +688,7 @@ void Stepper::init() {
#endif #endif
#if HAS_Z_STEP #if HAS_Z_STEP
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) && HAS_Z2_STEP #if ENABLED(Z_DUAL_STEPPER_DRIVERS)
Z2_STEP_INIT; Z2_STEP_INIT;
Z2_STEP_WRITE(INVERT_Z_STEP_PIN); Z2_STEP_WRITE(INVERT_Z_STEP_PIN);
#endif #endif

@ -60,7 +60,7 @@
#define X_ENABLE_READ READ(X_ENABLE_PIN) #define X_ENABLE_READ READ(X_ENABLE_PIN)
// X2 motor // X2 motor
#if ENABLED(DUAL_X_CARRIAGE) #if HAS_X2_ENABLE
#define X2_STEP_INIT SET_OUTPUT(X2_STEP_PIN) #define X2_STEP_INIT SET_OUTPUT(X2_STEP_PIN)
#define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE) #define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE)
#define X2_STEP_READ READ(X2_STEP_PIN) #define X2_STEP_READ READ(X2_STEP_PIN)
@ -88,7 +88,7 @@
#define Y_ENABLE_READ READ(Y_ENABLE_PIN) #define Y_ENABLE_READ READ(Y_ENABLE_PIN)
// Y2 motor // Y2 motor
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) #if HAS_Y2_ENABLE
#define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN) #define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN)
#define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE) #define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE)
#define Y2_STEP_READ READ(Y2_STEP_PIN) #define Y2_STEP_READ READ(Y2_STEP_PIN)
@ -116,7 +116,7 @@
#define Z_ENABLE_READ READ(Z_ENABLE_PIN) #define Z_ENABLE_READ READ(Z_ENABLE_PIN)
// Z2 motor // Z2 motor
#if ENABLED(Z_DUAL_STEPPER_DRIVERS) #if HAS_Z2_ENABLE
#define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN) #define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN)
#define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE) #define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE)
#define Z2_STEP_READ READ(Z2_STEP_PIN) #define Z2_STEP_READ READ(Z2_STEP_PIN)

Loading…
Cancel
Save