Browse Source

Merge pull request #5931 from thinkyhead/rc_core_endstop_fix

Fix CoreYX / YZ / ZX endstop logic
pull/1/head
Scott Lahteine 7 years ago
committed by GitHub
parent
commit
8a4e9d08a3
  1. 4
      .travis.yml
  2. 46
      Marlin/endstops.cpp

4
.travis.yml

@ -226,10 +226,10 @@ script:
- opt_enable COREXY - opt_enable COREXY
- build_marlin - build_marlin
# #
# Enable COREXZ # Enable COREYX (swapped)
# #
- restore_configs - restore_configs
- opt_enable COREXZ - opt_enable COREYX
- build_marlin - build_marlin
# #
# Enable Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS # Enable Z_DUAL_STEPPER_DRIVERS, Z_DUAL_ENDSTOPS

46
Marlin/endstops.cpp

@ -273,17 +273,26 @@ void Endstops::update() {
#endif #endif
#if CORE_IS_XY || CORE_IS_XZ #if CORE_IS_XY || CORE_IS_XZ
#if ENABLED(COREYX) || ENABLED(COREZX)
#define CORE_X_CMP !=
#define CORE_X_NOT !
#else
#define CORE_X_CMP ==
#define CORE_X_NOT
#endif
// Head direction in -X axis for CoreXY and CoreXZ bots. // Head direction in -X axis for CoreXY and CoreXZ bots.
// If DeltaA == -DeltaB, the movement is only in Y or Z axis // If steps differ, both axes are moving.
if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) == stepper.motor_direction(CORE_AXIS_2))) { // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z, handled below)
if (stepper.motor_direction(X_HEAD)) // If DeltaA == DeltaB, the movement is only in the 1st axis (X)
if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_X_CMP stepper.motor_direction(CORE_AXIS_2)) {
if (CORE_X_NOT stepper.motor_direction(X_HEAD))
#else #else
if (stepper.motor_direction(X_AXIS)) // stepping along -X axis (regular Cartesian bot) if (stepper.motor_direction(X_AXIS)) // stepping along -X axis (regular Cartesian bot)
#endif #endif
{ // -direction { // -direction
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR == -1) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR == -1)) if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR < 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR < 0))
#endif #endif
{ {
#if HAS_X_MIN #if HAS_X_MIN
@ -294,7 +303,7 @@ void Endstops::update() {
else { // +direction else { // +direction
#if ENABLED(DUAL_X_CARRIAGE) #if ENABLED(DUAL_X_CARRIAGE)
// with 2 x-carriages, endstops are only checked in the homing direction for the active extruder // with 2 x-carriages, endstops are only checked in the homing direction for the active extruder
if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR == 1) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR == 1)) if ((stepper.current_block->active_extruder == 0 && X_HOME_DIR > 0) || (stepper.current_block->active_extruder != 0 && X2_HOME_DIR > 0))
#endif #endif
{ {
#if HAS_X_MAX #if HAS_X_MAX
@ -306,11 +315,22 @@ void Endstops::update() {
} }
#endif #endif
// Handle swapped vs. typical Core axis order
#if ENABLED(COREYX) || ENABLED(COREZY) || ENABLED(COREZX)
#define CORE_YZ_CMP ==
#define CORE_YZ_NOT !
#elif CORE_IS_XY || CORE_IS_YZ || CORE_IS_XZ
#define CORE_YZ_CMP !=
#define CORE_YZ_NOT
#endif
#if CORE_IS_XY || CORE_IS_YZ #if CORE_IS_XY || CORE_IS_YZ
// Head direction in -Y axis for CoreXY / CoreYZ bots. // Head direction in -Y axis for CoreXY / CoreYZ bots.
// If DeltaA == DeltaB, the movement is only in X or Y axis // If steps differ, both axes are moving
if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) { // If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y)
if (stepper.motor_direction(Y_HEAD)) // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Y or Z)
if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)) {
if (CORE_YZ_NOT stepper.motor_direction(Y_HEAD))
#else #else
if (stepper.motor_direction(Y_AXIS)) // -direction if (stepper.motor_direction(Y_AXIS)) // -direction
#endif #endif
@ -330,9 +350,11 @@ void Endstops::update() {
#if CORE_IS_XZ || CORE_IS_YZ #if CORE_IS_XZ || CORE_IS_YZ
// Head direction in -Z axis for CoreXZ or CoreYZ bots. // Head direction in -Z axis for CoreXZ or CoreYZ bots.
// If DeltaA == DeltaB, the movement is only in X or Y axis // If steps differ, both axes are moving
if ((stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2]) || (stepper.motor_direction(CORE_AXIS_1) != stepper.motor_direction(CORE_AXIS_2))) { // If DeltaA == DeltaB, the movement is only in the 1st axis (X or Y, already handled above)
if (stepper.motor_direction(Z_HEAD)) // If DeltaA == -DeltaB, the movement is only in the 2nd axis (Z)
if (stepper.current_block->steps[CORE_AXIS_1] != stepper.current_block->steps[CORE_AXIS_2] || stepper.motor_direction(CORE_AXIS_1) CORE_YZ_CMP stepper.motor_direction(CORE_AXIS_2)) {
if (CORE_YZ_NOT stepper.motor_direction(Z_HEAD))
#else #else
if (stepper.motor_direction(Z_AXIS)) if (stepper.motor_direction(Z_AXIS))
#endif #endif

Loading…
Cancel
Save