Skip to content

Commit

Permalink
✨ MarkForged YX kinematics (MarlinFirmware#23163)
Browse files Browse the repository at this point in the history
  • Loading branch information
HoverClub authored and mh-dm committed May 15, 2022
1 parent e2b38ff commit 3e6498b
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 76 deletions.
1 change: 1 addition & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -756,6 +756,7 @@
//#define COREZX
//#define COREZY
//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042
//#define MARKFORGED_YX

// Enable for a belt style printer with endless "Z" motion
//#define BELTPRINTER
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ enum AxisEnum : uint8_t {
#undef _EN_ITEM

// Core also keeps toolhead directions
#if EITHER(IS_CORE, MARKFORGED_XY)
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
, X_HEAD, Y_HEAD, Z_HEAD
#endif

Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/core/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ void safe_delay(millis_t ms) {
TERN_(DELTA, "Delta")
TERN_(IS_SCARA, "SCARA")
TERN_(IS_CORE, "Core")
TERN_(MARKFORGED_XY, "MarkForged")
TERN_(MARKFORGED_XY, "MarkForgedXY")
TERN_(MARKFORGED_YX, "MarkForgedYX")
TERN_(IS_CARTESIAN, "Cartesian")
);

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/backlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
static axis_bits_t last_direction_bits;
axis_bits_t changed_dir = last_direction_bits ^ dm;
// Ignore direction change unless steps are taken in that direction
#if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
#if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX)
if (!da) CBI(changed_dir, X_AXIS);
if (!db) CBI(changed_dir, Y_AXIS);
if (!dc) CBI(changed_dir, Z_AXIS);
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/gcode/host/M360.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ void GcodeSuite::M360() {
TERN_(DELTA, "Delta")
TERN_(IS_SCARA, "SCARA")
TERN_(IS_CORE, "Core")
TERN_(MARKFORGED_XY, "MarkForged")
TERN_(MARKFORGED_XY, "MarkForgedXY")
TERN_(MARKFORGED_YX, "MarkForgedYX")
TERN_(IS_CARTESIAN, "Cartesian")
);

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@
#define CORE_AXIS_2 C_AXIS
#endif
#define CORESIGN(n) (ANY(COREYX, COREZX, COREZY) ? (-(n)) : (n))
#elif ENABLED(MARKFORGED_XY)
#elif EITHER(MARKFORGED_XY, MARKFORGED_YX)
// Markforged kinematics
#define CORE_AXIS_1 A_AXIS
#define CORE_AXIS_2 B_AXIS
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@

// Calibration codes only for non-core axes
#if EITHER(BACKLASH_GCODE, CALIBRATION_GCODE)
#if EITHER(IS_CORE, MARKFORGED_XY)
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
#define CAN_CALIBRATE(A,B) (_AXIS(A) == B)
#else
#define CAN_CALIBRATE(A,B) true
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if ENABLED(BABYSTEPPING)
#if ENABLED(SCARA)
#error "BABYSTEPPING is not implemented for SCARA yet."
#elif BOTH(MARKFORGED_XY, BABYSTEP_XY)
#elif ENABLED(BABYSTEP_XY) && EITHER(MARKFORGED_XY, MARKFORGED_YX)
#error "BABYSTEPPING only implemented for Z axis on MarkForged."
#elif BOTH(DELTA, BABYSTEP_XY)
#error "BABYSTEPPING only implemented for Z axis on deltabots."
Expand Down Expand Up @@ -1459,8 +1459,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
/**
* Allow only one kinematic type to be defined
*/
#if MANY(DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, FOAMCUTTER_XYUV)
#error "Please enable only one of DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, or FOAMCUTTER_XYUV."
#if MANY(DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, FOAMCUTTER_XYUV)
#error "Please enable only one of DELTA, MORGAN_SCARA, MP_SCARA, AXEL_TPARA, COREXY, COREXZ, COREYZ, COREYX, COREZX, COREZY, MARKFORGED_XY, MARKFORGED_YX, or FOAMCUTTER_XYUV."
#endif

/**
Expand Down Expand Up @@ -1958,8 +1958,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#if ENABLED(DUAL_X_CARRIAGE)
#if EXTRUDERS < 2
#error "DUAL_X_CARRIAGE requires 2 (or more) extruders."
#elif ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
#error "DUAL_X_CARRIAGE cannot be used with COREXY, COREYX, COREXZ, COREZX, or MARKFORGED_XY."
#elif ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX)
#error "DUAL_X_CARRIAGE cannot be used with COREXY, COREYX, COREXZ, COREZX, MARKFORGED_YX, or MARKFORGED_XY."
#elif !GOOD_AXIS_PINS(X2)
#error "DUAL_X_CARRIAGE requires X2 stepper pins to be defined."
#elif !HAS_X_MAX
Expand Down Expand Up @@ -3201,8 +3201,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "CoreXZ requires both X and Z to use sensorless homing if either one does."
#elif CORE_IS_YZ && Y_SENSORLESS != Z_SENSORLESS && !HOMING_Z_WITH_PROBE
#error "CoreYZ requires both Y and Z to use sensorless homing if either one does."
#elif ENABLED(MARKFORGED_XY) && X_SENSORLESS != Y_SENSORLESS
#error "MARKFORGED_XY requires both X and Y to use sensorless homing if either one does."
#elif EITHER(MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS != Y_SENSORLESS
#error "MARKFORGED requires both X and Y to use sensorless homing if either one does."
#endif

// Other TMC feature requirements
Expand Down Expand Up @@ -3462,7 +3462,7 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#error "BACKLASH_COMPENSATION requires BACKLASH_DISTANCE_MM."
#elif !defined(BACKLASH_CORRECTION)
#error "BACKLASH_COMPENSATION requires BACKLASH_CORRECTION."
#elif ENABLED(MARKFORGED_XY)
#elif EITHER(MARKFORGED_XY, MARKFORGED_YX)
constexpr float backlash_arr[] = BACKLASH_DISTANCE_MM;
static_assert(!backlash_arr[CORE_AXIS_1] && !backlash_arr[CORE_AXIS_2],
"BACKLASH_COMPENSATION can only apply to " STRINGIFY(NORMAL_AXIS) " on a MarkForged system.");
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_backlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void menu_backlash() {

EDIT_ITEM_FAST(percent, MSG_BACKLASH_CORRECTION, &backlash.correction, all_off, all_on);

#if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
#if DISABLED(CORE_BACKLASH) || EITHER(MARKFORGED_XY, MARKFORGED_YX)
#define _CAN_CALI AXIS_CAN_CALIBRATE
#else
#define _CAN_CALI(A) true
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ void Endstops::update() {
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
#define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT))

#if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
#if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_XY)
#define HAS_G38_PROBE 1
// For G38 moves check the probe's pin for ALL movement
if (G38_move) UPDATE_ENDSTOP_BIT(Z, TERN(USES_Z_MIN_PROBE_PIN, MIN_PROBE, MIN));
Expand All @@ -628,12 +628,12 @@ void Endstops::update() {
#define X_MAX_TEST() TERN1(DUAL_X_CARRIAGE, TERN0(X_HOME_TO_MAX, stepper.last_moved_extruder == 0) || TERN0(X2_HOME_TO_MAX, stepper.last_moved_extruder != 0))

// Use HEAD for core axes, AXIS for others
#if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY)
#if ANY(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_XY)
#define X_AXIS_HEAD X_HEAD
#else
#define X_AXIS_HEAD X_AXIS
#endif
#if ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY)
#if ANY(CORE_IS_XY, CORE_IS_YZ, MARKFORGED_XY, MARKFORGED_YX)
#define Y_AXIS_HEAD Y_HEAD
#else
#define Y_AXIS_HEAD Y_AXIS
Expand Down Expand Up @@ -1111,7 +1111,7 @@ void Endstops::update() {
bool hit = false;
#if X_SPI_SENSORLESS
if (tmc_spi_homing.x && (stepperX.test_stall_status()
#if ANY(CORE_IS_XY, MARKFORGED_XY) && Y_SPI_SENSORLESS
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SPI_SENSORLESS
|| stepperY.test_stall_status()
#elif CORE_IS_XZ && Z_SPI_SENSORLESS
|| stepperZ.test_stall_status()
Expand All @@ -1123,7 +1123,7 @@ void Endstops::update() {
#endif
#if Y_SPI_SENSORLESS
if (tmc_spi_homing.y && (stepperY.test_stall_status()
#if ANY(CORE_IS_XY, MARKFORGED_XY) && X_SPI_SENSORLESS
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SPI_SENSORLESS
|| stepperX.test_stall_status()
#elif CORE_IS_YZ && Z_SPI_SENSORLESS
|| stepperZ.test_stall_status()
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ void prepare_line_to_destination() {
#if AXIS_HAS_STALLGUARD(X2)
stealth_states.x2 = tmc_enable_stallguard(stepperX2);
#endif
#if EITHER(CORE_IS_XY, MARKFORGED_XY) && Y_SENSORLESS
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS
stealth_states.y = tmc_enable_stallguard(stepperY);
#elif CORE_IS_XZ && Z_SENSORLESS
stealth_states.z = tmc_enable_stallguard(stepperZ);
Expand All @@ -1380,7 +1380,7 @@ void prepare_line_to_destination() {
#if AXIS_HAS_STALLGUARD(Y2)
stealth_states.y2 = tmc_enable_stallguard(stepperY2);
#endif
#if EITHER(CORE_IS_XY, MARKFORGED_XY) && X_SENSORLESS
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS
stealth_states.x = tmc_enable_stallguard(stepperX);
#elif CORE_IS_YZ && Z_SENSORLESS
stealth_states.z = tmc_enable_stallguard(stepperZ);
Expand Down Expand Up @@ -1444,7 +1444,7 @@ void prepare_line_to_destination() {
#if AXIS_HAS_STALLGUARD(X2)
tmc_disable_stallguard(stepperX2, enable_stealth.x2);
#endif
#if EITHER(CORE_IS_XY, MARKFORGED_XY) && Y_SENSORLESS
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && Y_SENSORLESS
tmc_disable_stallguard(stepperY, enable_stealth.y);
#elif CORE_IS_XZ && Z_SENSORLESS
tmc_disable_stallguard(stepperZ, enable_stealth.z);
Expand All @@ -1457,7 +1457,7 @@ void prepare_line_to_destination() {
#if AXIS_HAS_STALLGUARD(Y2)
tmc_disable_stallguard(stepperY2, enable_stealth.y2);
#endif
#if EITHER(CORE_IS_XY, MARKFORGED_XY) && X_SENSORLESS
#if ANY(CORE_IS_XY, MARKFORGED_XY, MARKFORGED_YX) && X_SENSORLESS
tmc_disable_stallguard(stepperX, enable_stealth.x);
#elif CORE_IS_YZ && Z_SENSORLESS
tmc_disable_stallguard(stepperZ, enable_stealth.z);
Expand Down Expand Up @@ -2011,7 +2011,7 @@ void prepare_line_to_destination() {
do_homing_move(axis, adjDistance, get_homing_bump_feedrate(axis));
}

#else // CARTESIAN / CORE / MARKFORGED_XY
#else // CARTESIAN / CORE / MARKFORGED_XY / MARKFORGED_YX

set_axis_is_at_home(axis);
sync_plan_position();
Expand Down Expand Up @@ -2041,7 +2041,7 @@ void prepare_line_to_destination() {
#if ENABLED(SENSORLESS_HOMING)
planner.synchronize();
if (false
#if EITHER(IS_CORE, MARKFORGED_XY)
#if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX)
|| axis != NORMAL_AXIS
#endif
) safe_delay(200); // Short delay to allow belts to spring back
Expand Down
Loading

0 comments on commit 3e6498b

Please sign in to comment.