Skip to content

Commit fef7439

Browse files
authored
✨ MARKFORGED_INVERSE (MarlinFirmware#26516)
1 parent 775c6bb commit fef7439

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

Marlin/Configuration.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -892,8 +892,16 @@
892892
//#define COREYX
893893
//#define COREZX
894894
//#define COREZY
895-
//#define MARKFORGED_XY // MarkForged. See https://reprap.org/forum/read.php?152,504042
895+
896+
//
897+
// MarkForged Kinematics
898+
// See https://reprap.org/forum/read.php?152,504042
899+
//
900+
//#define MARKFORGED_XY
896901
//#define MARKFORGED_YX
902+
#if ANY(MARKFORGED_XY, MARKFORGED_YX)
903+
//#define MARKFORGED_INVERSE // Enable for an inverted Markforged kinematics belt path
904+
#endif
897905

898906
// Enable for a belt style printer with endless "Z" motion
899907
//#define BELTPRINTER

Marlin/src/module/planner.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -1990,11 +1990,11 @@ bool Planner::_populate_block(
19901990
dm.c = (CORESIGN(dist.b - dist.c) > 0); // Motor C direction
19911991
#endif
19921992
#elif ENABLED(MARKFORGED_XY)
1993-
dm.a = (dist.a + dist.b > 0); // Motor A direction
1993+
dm.a = (dist.a TERN(MARKFORGED_INVERSE, -, +) dist.b > 0); // Motor A direction
19941994
dm.b = (dist.b > 0); // Motor B direction
19951995
#elif ENABLED(MARKFORGED_YX)
19961996
dm.a = (dist.a > 0); // Motor A direction
1997-
dm.b = (dist.b + dist.a > 0); // Motor B direction
1997+
dm.b = (dist.b TERN(MARKFORGED_INVERSE, -, +) dist.a > 0); // Motor B direction
19981998
#else
19991999
XYZ_CODE(
20002000
dm.x = (dist.a > 0),
@@ -2062,9 +2062,9 @@ bool Planner::_populate_block(
20622062
#elif CORE_IS_YZ
20632063
ABS(dist.a), ABS(dist.b + dist.c), ABS(dist.b - dist.c)
20642064
#elif ENABLED(MARKFORGED_XY)
2065-
ABS(dist.a + dist.b), ABS(dist.b), ABS(dist.c)
2065+
ABS(dist.a TERN(MARKFORGED_INVERSE, -, +) dist.b), ABS(dist.b), ABS(dist.c)
20662066
#elif ENABLED(MARKFORGED_YX)
2067-
ABS(dist.a), ABS(dist.b + dist.a), ABS(dist.c)
2067+
ABS(dist.a), ABS(dist.b TERN(MARKFORGED_INVERSE, -, +) dist.a), ABS(dist.c)
20682068
#elif IS_SCARA
20692069
ABS(dist.a), ABS(dist.b), ABS(dist.c)
20702070
#else // default non-h-bot planning
@@ -2110,11 +2110,11 @@ bool Planner::_populate_block(
21102110
dist_mm.c = CORESIGN(dist.b - dist.c) * mm_per_step[C_AXIS];
21112111
#endif
21122112
#elif ENABLED(MARKFORGED_XY)
2113-
dist_mm.a = (dist.a - dist.b) * mm_per_step[A_AXIS];
2113+
dist_mm.a = (dist.a TERN(MARKFORGED_INVERSE, +, -) dist.b) * mm_per_step[A_AXIS];
21142114
dist_mm.b = dist.b * mm_per_step[B_AXIS];
21152115
#elif ENABLED(MARKFORGED_YX)
21162116
dist_mm.a = dist.a * mm_per_step[A_AXIS];
2117-
dist_mm.b = (dist.b - dist.a) * mm_per_step[B_AXIS];
2117+
dist_mm.b = (dist.b TERN(MARKFORGED_INVERSE, +, -) dist.a) * mm_per_step[B_AXIS];
21182118
#else
21192119
XYZ_CODE(
21202120
dist_mm.a = dist.a * mm_per_step[A_AXIS],

Marlin/src/module/stepper.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3287,9 +3287,9 @@ void Stepper::_set_position(const abce_long_t &spos) {
32873287
// coreyz planning
32883288
count_position.set(spos.a, spos.b + spos.c, CORESIGN(spos.b - spos.c));
32893289
#elif ENABLED(MARKFORGED_XY)
3290-
count_position.set(spos.a - spos.b, spos.b, spos.c);
3290+
count_position.set(spos.a TERN(MARKFORGED_INVERSE, +, -) spos.b, spos.b, spos.c);
32913291
#elif ENABLED(MARKFORGED_YX)
3292-
count_position.set(spos.a, spos.b - spos.a, spos.c);
3292+
count_position.set(spos.a, spos.b TERN(MARKFORGED_INVERSE, +, -) spos.a, spos.c);
32933293
#endif
32943294
SECONDARY_AXIS_CODE(
32953295
count_position.i = spos.i,
@@ -3382,12 +3382,12 @@ void Stepper::endstop_triggered(const AxisEnum axis) {
33823382
) * double(0.5)
33833383
#elif ENABLED(MARKFORGED_XY)
33843384
axis == CORE_AXIS_1
3385-
? count_position[CORE_AXIS_1] - count_position[CORE_AXIS_2]
3385+
? count_position[CORE_AXIS_1] ENABLED(MARKFORGED_INVERSE, +, -) count_position[CORE_AXIS_2]
33863386
: count_position[CORE_AXIS_2]
33873387
#elif ENABLED(MARKFORGED_YX)
33883388
axis == CORE_AXIS_1
33893389
? count_position[CORE_AXIS_1]
3390-
: count_position[CORE_AXIS_2] - count_position[CORE_AXIS_1]
3390+
: count_position[CORE_AXIS_2] ENABLED(MARKFORGED_INVERSE, +, -) count_position[CORE_AXIS_1]
33913391
#else // !IS_CORE
33923392
count_position[axis]
33933393
#endif

buildroot/tests/mks_robin_mini

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set -e
99

1010
use_example_configs Mks/Robin
1111
opt_set MOTHERBOARD BOARD_MKS_ROBIN_MINI EXTRUDERS 1 TEMP_SENSOR_1 0
12+
opt_enable MARKFORGED_XY MARKFORGED_INVERSE
1213
exec_test $1 $2 "MKS Robin mini" "$3"
1314

1415
# cleanup

0 commit comments

Comments
 (0)