Skip to content

Commit

Permalink
✨ MARKFORGED_INVERSE (#26516)
Browse files Browse the repository at this point in the history
  • Loading branch information
jesterhead82 authored Dec 13, 2023
1 parent 775c6bb commit fef7439
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
10 changes: 9 additions & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,16 @@
//#define COREYX
//#define COREZX
//#define COREZY
//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042

//
// MarkForged Kinematics
// See https://reprap.org/forum/read.php?152,504042
//
//#define MARKFORGED_XY
//#define MARKFORGED_YX
#if ANY(MARKFORGED_XY, MARKFORGED_YX)
//#define MARKFORGED_INVERSE // Enable for an inverted Markforged kinematics belt path
#endif

// Enable for a belt style printer with endless "Z" motion
//#define BELTPRINTER
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1990,11 +1990,11 @@ bool Planner::_populate_block(
dm.c = (CORESIGN(dist.b - dist.c) > 0); // Motor C direction
#endif
#elif ENABLED(MARKFORGED_XY)
dm.a = (dist.a + dist.b > 0); // Motor A direction
dm.a = (dist.a TERN(MARKFORGED_INVERSE, -, +) dist.b > 0); // Motor A direction
dm.b = (dist.b > 0); // Motor B direction
#elif ENABLED(MARKFORGED_YX)
dm.a = (dist.a > 0); // Motor A direction
dm.b = (dist.b + dist.a > 0); // Motor B direction
dm.b = (dist.b TERN(MARKFORGED_INVERSE, -, +) dist.a > 0); // Motor B direction
#else
XYZ_CODE(
dm.x = (dist.a > 0),
Expand Down Expand Up @@ -2062,9 +2062,9 @@ bool Planner::_populate_block(
#elif CORE_IS_YZ
ABS(dist.a), ABS(dist.b + dist.c), ABS(dist.b - dist.c)
#elif ENABLED(MARKFORGED_XY)
ABS(dist.a + dist.b), ABS(dist.b), ABS(dist.c)
ABS(dist.a TERN(MARKFORGED_INVERSE, -, +) dist.b), ABS(dist.b), ABS(dist.c)
#elif ENABLED(MARKFORGED_YX)
ABS(dist.a), ABS(dist.b + dist.a), ABS(dist.c)
ABS(dist.a), ABS(dist.b TERN(MARKFORGED_INVERSE, -, +) dist.a), ABS(dist.c)
#elif IS_SCARA
ABS(dist.a), ABS(dist.b), ABS(dist.c)
#else // default non-h-bot planning
Expand Down Expand Up @@ -2110,11 +2110,11 @@ bool Planner::_populate_block(
dist_mm.c = CORESIGN(dist.b - dist.c) * mm_per_step[C_AXIS];
#endif
#elif ENABLED(MARKFORGED_XY)
dist_mm.a = (dist.a - dist.b) * mm_per_step[A_AXIS];
dist_mm.a = (dist.a TERN(MARKFORGED_INVERSE, +, -) dist.b) * mm_per_step[A_AXIS];
dist_mm.b = dist.b * mm_per_step[B_AXIS];
#elif ENABLED(MARKFORGED_YX)
dist_mm.a = dist.a * mm_per_step[A_AXIS];
dist_mm.b = (dist.b - dist.a) * mm_per_step[B_AXIS];
dist_mm.b = (dist.b TERN(MARKFORGED_INVERSE, +, -) dist.a) * mm_per_step[B_AXIS];
#else
XYZ_CODE(
dist_mm.a = dist.a * mm_per_step[A_AXIS],
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3287,9 +3287,9 @@ void Stepper::_set_position(const abce_long_t &spos) {
// coreyz planning
count_position.set(spos.a, spos.b + spos.c, CORESIGN(spos.b - spos.c));
#elif ENABLED(MARKFORGED_XY)
count_position.set(spos.a - spos.b, spos.b, spos.c);
count_position.set(spos.a TERN(MARKFORGED_INVERSE, +, -) spos.b, spos.b, spos.c);
#elif ENABLED(MARKFORGED_YX)
count_position.set(spos.a, spos.b - spos.a, spos.c);
count_position.set(spos.a, spos.b TERN(MARKFORGED_INVERSE, +, -) spos.a, spos.c);
#endif
SECONDARY_AXIS_CODE(
count_position.i = spos.i,
Expand Down Expand Up @@ -3382,12 +3382,12 @@ void Stepper::endstop_triggered(const AxisEnum axis) {
) * double(0.5)
#elif ENABLED(MARKFORGED_XY)
axis == CORE_AXIS_1
? count_position[CORE_AXIS_1] - count_position[CORE_AXIS_2]
? count_position[CORE_AXIS_1] ENABLED(MARKFORGED_INVERSE, +, -) count_position[CORE_AXIS_2]
: count_position[CORE_AXIS_2]
#elif ENABLED(MARKFORGED_YX)
axis == CORE_AXIS_1
? count_position[CORE_AXIS_1]
: count_position[CORE_AXIS_2] - count_position[CORE_AXIS_1]
: count_position[CORE_AXIS_2] ENABLED(MARKFORGED_INVERSE, +, -) count_position[CORE_AXIS_1]
#else // !IS_CORE
count_position[axis]
#endif
Expand Down
1 change: 1 addition & 0 deletions buildroot/tests/mks_robin_mini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ set -e

use_example_configs Mks/Robin
opt_set MOTHERBOARD BOARD_MKS_ROBIN_MINI EXTRUDERS 1 TEMP_SENSOR_1 0
opt_enable MARKFORGED_XY MARKFORGED_INVERSE
exec_test $1 $2 "MKS Robin mini" "$3"

# cleanup
Expand Down

0 comments on commit fef7439

Please sign in to comment.