Multi-Z stepper inverting (#20678)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
wilbur4321 2021-01-05 15:03:45 -08:00 committed by Scott Lahteine
parent aa5ac6c3b2
commit 5ef0475dc5
5 changed files with 32 additions and 23 deletions

View File

@ -1089,7 +1089,7 @@
//#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing //#define PROBING_STEPPERS_OFF // Turn steppers off (unless needed to hold position) when probing
//#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors //#define DELAY_BEFORE_PROBING 200 // (ms) To prevent vibrations from triggering piezo sensors
// Require minimum nozzle and/or bed temperature for probing. // Require minimum nozzle and/or bed temperature for probing
//#define PREHEAT_BEFORE_PROBING //#define PREHEAT_BEFORE_PROBING
#if ENABLED(PREHEAT_BEFORE_PROBING) #if ENABLED(PREHEAT_BEFORE_PROBING)
#define PROBING_NOZZLE_TEMP 120 // (°C) Only applies to E0 at this time #define PROBING_NOZZLE_TEMP 120 // (°C) Only applies to E0 at this time

View File

@ -552,7 +552,7 @@
//#define X_DUAL_STEPPER_DRIVERS //#define X_DUAL_STEPPER_DRIVERS
#if ENABLED(X_DUAL_STEPPER_DRIVERS) #if ENABLED(X_DUAL_STEPPER_DRIVERS)
#define INVERT_X2_VS_X_DIR true // Set 'true' if X motors should rotate in opposite directions //#define INVERT_X2_VS_X_DIR // Enable if X2 direction signal is opposite to X
//#define X_DUAL_ENDSTOPS //#define X_DUAL_ENDSTOPS
#if ENABLED(X_DUAL_ENDSTOPS) #if ENABLED(X_DUAL_ENDSTOPS)
#define X2_USE_ENDSTOP _XMAX_ #define X2_USE_ENDSTOP _XMAX_
@ -562,7 +562,7 @@
//#define Y_DUAL_STEPPER_DRIVERS //#define Y_DUAL_STEPPER_DRIVERS
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#define INVERT_Y2_VS_Y_DIR true // Set 'true' if Y motors should rotate in opposite directions //#define INVERT_Y2_VS_Y_DIR // Enable if Y2 direction signal is opposite to Y
//#define Y_DUAL_ENDSTOPS //#define Y_DUAL_ENDSTOPS
#if ENABLED(Y_DUAL_ENDSTOPS) #if ENABLED(Y_DUAL_ENDSTOPS)
#define Y2_USE_ENDSTOP _YMAX_ #define Y2_USE_ENDSTOP _YMAX_
@ -576,6 +576,11 @@
#define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many #define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many
#if NUM_Z_STEPPER_DRIVERS > 1 #if NUM_Z_STEPPER_DRIVERS > 1
// Enable if Z motor direction signals are the opposite of Z1
//#define INVERT_Z2_VS_Z_DIR
//#define INVERT_Z3_VS_Z_DIR
//#define INVERT_Z4_VS_Z_DIR
//#define Z_MULTI_ENDSTOPS //#define Z_MULTI_ENDSTOPS
#if ENABLED(Z_MULTI_ENDSTOPS) #if ENABLED(Z_MULTI_ENDSTOPS)
#define Z2_USE_ENDSTOP _XMAX_ #define Z2_USE_ENDSTOP _XMAX_

View File

@ -211,14 +211,18 @@
#if DISABLED(Y_DUAL_STEPPER_DRIVERS) #if DISABLED(Y_DUAL_STEPPER_DRIVERS)
#undef Y2_DRIVER_TYPE #undef Y2_DRIVER_TYPE
#endif #endif
#if NUM_Z_STEPPER_DRIVERS < 2
#undef Z2_DRIVER_TYPE
#endif
#if NUM_Z_STEPPER_DRIVERS < 3
#undef Z3_DRIVER_TYPE
#endif
#if NUM_Z_STEPPER_DRIVERS < 4 #if NUM_Z_STEPPER_DRIVERS < 4
#undef Z4_DRIVER_TYPE #undef Z4_DRIVER_TYPE
#undef INVERT_Z4_VS_Z_DIR
#if NUM_Z_STEPPER_DRIVERS < 3
#undef Z3_DRIVER_TYPE
#undef INVERT_Z3_VS_Z_DIR
#if NUM_Z_STEPPER_DRIVERS < 2
#undef Z2_DRIVER_TYPE
#undef INVERT_Z2_VS_Z_DIR
#endif
#endif
#endif #endif
// //

View File

@ -60,16 +60,11 @@ uint8_t L64XX_Marlin::dir_commands[MAX_L64XX]; // array to hold direction comma
const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = { const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = {
INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR
, (INVERT_X_DIR) // X2 , (INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2
#if ENABLED(X_DUAL_STEPPER_DRIVERS) , (INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2
^ ENABLED(INVERT_X2_VS_X_DIR) , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2
#endif , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3
, (INVERT_Y_DIR) // Y2 , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4
#if ENABLED(Y_DUAL_STEPPER_DRIVERS)
^ ENABLED(INVERT_Y2_VS_Y_DIR)
#endif
, INVERT_Z_DIR, INVERT_Z_DIR, INVERT_Z_DIR // Z2,Z3,Z4
, INVERT_E0_DIR, INVERT_E1_DIR, INVERT_E2_DIR, INVERT_E3_DIR , INVERT_E0_DIR, INVERT_E1_DIR, INVERT_E2_DIR, INVERT_E3_DIR
, INVERT_E4_DIR, INVERT_E5_DIR, INVERT_E6_DIR, INVERT_E7_DIR , INVERT_E4_DIR, INVERT_E5_DIR, INVERT_E6_DIR, INVERT_E7_DIR
}; };

View File

@ -381,7 +381,10 @@ xyze_int8_t Stepper::count_direction{0};
#endif #endif
#if NUM_Z_STEPPER_DRIVERS == 4 #if NUM_Z_STEPPER_DRIVERS == 4
#define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); Z3_DIR_WRITE(v); Z4_DIR_WRITE(v); }while(0) #define Z_APPLY_DIR(v,Q) do{ \
Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); \
Z3_DIR_WRITE((v) ^ ENABLED(INVERT_Z3_VS_Z_DIR)); Z4_DIR_WRITE((v) ^ ENABLED(INVERT_Z4_VS_Z_DIR)); \
}while(0)
#if ENABLED(Z_MULTI_ENDSTOPS) #if ENABLED(Z_MULTI_ENDSTOPS)
#define Z_APPLY_STEP(v,Q) QUAD_ENDSTOP_APPLY_STEP(Z,v) #define Z_APPLY_STEP(v,Q) QUAD_ENDSTOP_APPLY_STEP(Z,v)
#elif ENABLED(Z_STEPPER_AUTO_ALIGN) #elif ENABLED(Z_STEPPER_AUTO_ALIGN)
@ -390,7 +393,9 @@ xyze_int8_t Stepper::count_direction{0};
#define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); Z4_STEP_WRITE(v); }while(0) #define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); Z4_STEP_WRITE(v); }while(0)
#endif #endif
#elif NUM_Z_STEPPER_DRIVERS == 3 #elif NUM_Z_STEPPER_DRIVERS == 3
#define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); Z3_DIR_WRITE(v); }while(0) #define Z_APPLY_DIR(v,Q) do{ \
Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); Z3_DIR_WRITE((v) ^ ENABLED(INVERT_Z3_VS_Z_DIR)); \
}while(0)
#if ENABLED(Z_MULTI_ENDSTOPS) #if ENABLED(Z_MULTI_ENDSTOPS)
#define Z_APPLY_STEP(v,Q) TRIPLE_ENDSTOP_APPLY_STEP(Z,v) #define Z_APPLY_STEP(v,Q) TRIPLE_ENDSTOP_APPLY_STEP(Z,v)
#elif ENABLED(Z_STEPPER_AUTO_ALIGN) #elif ENABLED(Z_STEPPER_AUTO_ALIGN)
@ -399,7 +404,7 @@ xyze_int8_t Stepper::count_direction{0};
#define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); }while(0) #define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); }while(0)
#endif #endif
#elif NUM_Z_STEPPER_DRIVERS == 2 #elif NUM_Z_STEPPER_DRIVERS == 2
#define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }while(0) #define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); }while(0)
#if ENABLED(Z_MULTI_ENDSTOPS) #if ENABLED(Z_MULTI_ENDSTOPS)
#define Z_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Z,v) #define Z_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Z,v)
#elif ENABLED(Z_STEPPER_AUTO_ALIGN) #elif ENABLED(Z_STEPPER_AUTO_ALIGN)