Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow each Z axis stepper to move a different direction, if needed #20678

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,14 @@
#define NUM_Z_STEPPER_DRIVERS 1 // (1-4) Z options change based on how many

#if NUM_Z_STEPPER_DRIVERS > 1
#define INVERT_Z2_VS_Z_DIR false // Set 'true' if Z2 motor should rotate in opposite direction from Z
#if NUM_Z_STEPPER_DRIVERS > 2
#define INVERT_Z3_VS_Z_DIR false // Set 'true' if Z3 motor should rotate in opposite direction from Z
#if NUM_Z_STEPPER_DRIVERS > 3
#define INVERT_Z3_VS_Z_DIR false // Set 'true' if Z4 motor should rotate in opposite direction from Z
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
#endif
#endif

//#define Z_MULTI_ENDSTOPS
#if ENABLED(Z_MULTI_ENDSTOPS)
#define Z2_USE_ENDSTOP _XMAX_
Expand Down
4 changes: 3 additions & 1 deletion Marlin/src/libs/L64XX/L64XX_Marlin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = {
#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_Z_DIR ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2
, INVERT_Z_DIR ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3
, INVERT_Z_DIR ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4

, INVERT_E0_DIR, INVERT_E1_DIR, INVERT_E2_DIR, INVERT_E3_DIR
, INVERT_E4_DIR, INVERT_E5_DIR, INVERT_E6_DIR, INVERT_E7_DIR
Expand Down
11 changes: 8 additions & 3 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,10 @@ xyze_int8_t Stepper::count_direction{0};
#endif

#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)
#define Z_APPLY_STEP(v,Q) QUAD_ENDSTOP_APPLY_STEP(Z,v)
#elif ENABLED(Z_STEPPER_AUTO_ALIGN)
Expand All @@ -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)
#endif
#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)
#define Z_APPLY_STEP(v,Q) TRIPLE_ENDSTOP_APPLY_STEP(Z,v)
#elif ENABLED(Z_STEPPER_AUTO_ALIGN)
Expand All @@ -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)
#endif
#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)
#define Z_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Z,v)
#elif ENABLED(Z_STEPPER_AUTO_ALIGN)
Expand Down