Skip to content

Commit 31d0c6d

Browse files
committed
feedrate interpretation like NIST RS274 NGC interpreter V3
1 parent 4a135d0 commit 31d0c6d

11 files changed

+237
-150
lines changed

Marlin/Configuration.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"
151151

152152
/**
153-
* Define the number of coordinated linear axes.
153+
* Define the number of coordinated axes.
154154
* See https://github.com/DerAndere1/Marlin/wiki
155155
* Each linear axis gets its own stepper control and endstop:
156156
*
@@ -182,19 +182,19 @@
182182
#define AXIS4_NAME 'A' // :['A', 'B', 'C', 'U', 'V', 'W']
183183
#endif
184184
#if LINEAR_AXES >= 5
185-
#define AXIS5_NAME 'B' // :['A', 'B', 'C', 'U', 'V', 'W']
185+
#define AXIS5_NAME 'B' // :['B', 'C', 'U', 'V', 'W']
186186
#endif
187187
#if LINEAR_AXES >= 6
188-
#define AXIS6_NAME 'C' // :['A', 'B', 'C', 'U', 'V', 'W']
188+
#define AXIS6_NAME 'C' // :['C', 'U', 'V', 'W']
189189
#endif
190190
#if LINEAR_AXES >= 7
191-
#define AXIS7_NAME 'U' // :['A', 'B', 'C', 'U', 'V', 'W']
191+
#define AXIS7_NAME 'U' // :['U', 'V', 'W']
192192
#endif
193193
#if LINEAR_AXES >= 8
194-
#define AXIS8_NAME 'V' // :['A', 'B', 'C', 'U', 'V', 'W']
194+
#define AXIS8_NAME 'V' // :['V', 'W']
195195
#endif
196196
#if LINEAR_AXES >= 9
197-
#define AXIS9_NAME 'W' // :['A', 'B', 'C', 'U', 'V', 'W']
197+
#define AXIS9_NAME 'W' // :['W']
198198
#endif
199199

200200
// @section extruder
@@ -958,14 +958,14 @@
958958
//#define DISTINCT_E_FACTORS
959959

960960
/**
961-
* Default Axis Steps Per Unit (steps/mm)
961+
* Default Axis Steps Per Unit (steps/mm for linear axes, steps/° for rotational axes)
962962
* Override with M92
963963
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
964964
*/
965965
#define DEFAULT_AXIS_STEPS_PER_UNIT { 80, 80, 400, 500 }
966966

967967
/**
968-
* Default Max Feed Rate (mm/s)
968+
* Default Max Feed Rate (mm/s for linear axes, °/s for rotational axes)
969969
* Override with M203
970970
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
971971
*/
@@ -977,7 +977,7 @@
977977
#endif
978978

979979
/**
980-
* Default Max Acceleration (change/s) change = mm/s
980+
* Default Max Acceleration (speed change with time) (mm/(s^2) for linear axes, °/(s^2) for rotational axes)
981981
* (Maximum start speed for accelerated moves)
982982
* Override with M201
983983
* X, Y, Z [, I [, J [, K...]]], E0 [, E1[, E2...]]
@@ -990,7 +990,7 @@
990990
#endif
991991

992992
/**
993-
* Default Acceleration (change/s) change = mm/s
993+
* Default Acceleration (speed change with time) (mm/(s^2) for linear axes, °/(s^2) for rotational axes)
994994
* Override with M204
995995
*
996996
* M204 P Acceleration
@@ -1002,7 +1002,7 @@
10021002
#define DEFAULT_TRAVEL_ACCELERATION 3000 // X, Y, Z acceleration for travel (non printing) moves
10031003

10041004
/**
1005-
* Default Jerk limits (mm/s)
1005+
* Default Jerk limits (mm/(s^2))
10061006
* Override with M205 X Y Z E
10071007
*
10081008
* "Jerk" specifies the minimum speed change that requires acceleration.
@@ -1431,7 +1431,7 @@
14311431
#define X_BED_SIZE 200
14321432
#define Y_BED_SIZE 200
14331433

1434-
// Travel limits (mm) after homing, corresponding to endstop positions.
1434+
// Travel limits (mm for linear axes, ° for rotational axes) after homing, corresponding to endstop positions.
14351435
#define X_MIN_POS 0
14361436
#define Y_MIN_POS 0
14371437
#define Z_MIN_POS 0
@@ -1818,7 +1818,7 @@
18181818
#define Z_SAFE_HOMING_Y_POINT Y_CENTER // Y point for Z homing
18191819
#endif
18201820

1821-
// Homing speeds (mm/min)
1821+
// Homing speeds (mm/min for linear axes, °/min for rotational axes)
18221822
#define HOMING_FEEDRATE_MM_M { (50*60), (50*60), (4*60) }
18231823

18241824
// Validate that endstops are triggered on homing moves

Marlin/Configuration_adv.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -784,12 +784,12 @@
784784
* the position of the toolhead relative to the workspace.
785785
*/
786786

787-
//#define SENSORLESS_BACKOFF_MM { 2, 2, 0 } // (mm) Backoff from endstops before sensorless homing
787+
//#define SENSORLESS_BACKOFF_MM { 2, 2, 0 } // (mm for linear axes, ° for rotational axes) Backoff from endstops before sensorless homing
788788

789-
#define HOMING_BUMP_MM { 5, 5, 2 } // (mm) Backoff from endstops after first bump
789+
#define HOMING_BUMP_MM { 5, 5, 2 } // (mm for linear axes, ° for rotational axes) Backoff from endstops after first bump
790790
#define HOMING_BUMP_DIVISOR { 2, 2, 4 } // Re-Bump Speed Divisor (Divides the Homing Feedrate)
791791

792-
//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm) Backoff from endstops after homing
792+
//#define HOMING_BACKOFF_POST_MM { 2, 2, 2 } // (mm for linear axes, ° for rotational axes) Backoff from endstops after homing
793793

794794
//#define QUICK_HOME // If G28 contains XY do a diagonal move first
795795
//#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X
@@ -994,8 +994,8 @@
994994
#define DISABLE_INACTIVE_E true
995995

996996
// Default Minimum Feedrates for printing and travel moves
997-
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s) Minimum feedrate. Set with M205 S.
998-
#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s) Minimum travel feedrate. Set with M205 T.
997+
#define DEFAULT_MINIMUMFEEDRATE 0.0 // (mm/s. °/s for moves involving only rotational axes) Minimum feedrate. Set with M205 S.
998+
#define DEFAULT_MINTRAVELFEEDRATE 0.0 // (mm/s. °/s for moves involving only rotational axes) Minimum travel feedrate. Set with M205 T.
999999

10001000
// Minimum time that a segment needs to take as the buffer gets emptied
10011001
#define DEFAULT_MINSEGMENTTIME 20000 // (µs) Set with M205 B.
@@ -1031,7 +1031,7 @@
10311031
#if ENABLED(BACKLASH_COMPENSATION)
10321032
// Define values for backlash distance and correction.
10331033
// If BACKLASH_GCODE is enabled these values are the defaults.
1034-
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm) One value for each linear axis
1034+
#define BACKLASH_DISTANCE_MM { 0, 0, 0 } // (mm for linear axes, ° for rotational axes) One value for each linear axis
10351035
#define BACKLASH_CORRECTION 0.0 // 0.0 = no correction; 1.0 = full correction
10361036

10371037
// Add steps for motor direction changes on CORE kinematics
@@ -3006,10 +3006,10 @@
30063006
#define Z2_HYBRID_THRESHOLD 3
30073007
#define Z3_HYBRID_THRESHOLD 3
30083008
#define Z4_HYBRID_THRESHOLD 3
3009-
#define I_HYBRID_THRESHOLD 3
3010-
#define J_HYBRID_THRESHOLD 3
3011-
#define K_HYBRID_THRESHOLD 3
3012-
#define U_HYBRID_THRESHOLD 3
3009+
#define I_HYBRID_THRESHOLD 3 // [mm/s for linear axis, °/s for rotational axis]
3010+
#define J_HYBRID_THRESHOLD 3 // [mm/s for linear axis, °/s for rotational axis]
3011+
#define K_HYBRID_THRESHOLD 3 // [mm/s for linear axis, °/s for rotational axis]
3012+
#define U_HYBRID_THRESHOLD 3 // [mm/s]
30133013
#define V_HYBRID_THRESHOLD 3
30143014
#define W_HYBRID_THRESHOLD 3
30153015
#define E0_HYBRID_THRESHOLD 30

Marlin/src/core/language.h

+5-65
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,7 @@
408408
#endif
409409

410410
#if LINEAR_AXES >= 5
411-
#if AXIS5_NAME == 'A'
412-
#define AXIS5_STR "A"
413-
#define STR_J_MIN "a_min"
414-
#define STR_J_MAX "a_max"
415-
#elif AXIS5_NAME == 'B'
411+
#if AXIS5_NAME == 'B'
416412
#define AXIS5_STR "B"
417413
#define STR_J_MIN "b_min"
418414
#define STR_J_MAX "b_max"
@@ -442,15 +438,7 @@
442438
#endif
443439

444440
#if LINEAR_AXES >= 6
445-
#if AXIS6_NAME == 'A'
446-
#define AXIS6_STR "A"
447-
#define STR_K_MIN "a_min"
448-
#define STR_K_MAX "a_max"
449-
#elif AXIS6_NAME == 'B'
450-
#define AXIS6_STR "B"
451-
#define STR_K_MIN "b_min"
452-
#define STR_K_MAX "b_max"
453-
#elif AXIS6_NAME == 'C'
441+
#if AXIS6_NAME == 'C'
454442
#define AXIS6_STR "C"
455443
#define STR_K_MIN "c_min"
456444
#define STR_K_MAX "c_max"
@@ -476,19 +464,7 @@
476464
#endif
477465

478466
#if LINEAR_AXES >= 7
479-
#if AXIS7_NAME == 'A'
480-
#define AXIS7_STR "A"
481-
#define STR_U_MIN "a_min"
482-
#define STR_U_MAX "a_max"
483-
#elif AXIS7_NAME == 'B'
484-
#define AXIS7_STR "B"
485-
#define STR_U_MIN "b_min"
486-
#define STR_U_MAX "b_max"
487-
#elif AXIS7_NAME == 'C'
488-
#define AXIS7_STR "C"
489-
#define STR_U_MIN "c_min"
490-
#define STR_U_MAX "c_max"
491-
#elif AXIS7_NAME == 'U'
467+
#if AXIS7_NAME == 'U'
492468
#define AXIS7_STR "U"
493469
#define STR_U_MIN "u_min"
494470
#define STR_U_MAX "u_max"
@@ -510,23 +486,7 @@
510486
#endif
511487

512488
#if LINEAR_AXES >= 8
513-
#if AXIS8_NAME == 'A'
514-
#define AXIS8_STR "A"
515-
#define STR_V_MIN "a_min"
516-
#define STR_V_MAX "a_max"
517-
#elif AXIS8_NAME == 'B'
518-
#define AXIS8_STR "B"
519-
#define STR_V_MIN "b_min"
520-
#define STR_V_MAX "b_max"
521-
#elif AXIS8_NAME == 'C'
522-
#define AXIS8_STR "C"
523-
#define STR_V_MIN "c_min"
524-
#define STR_V_MAX "c_max"
525-
#elif AXIS8_NAME == 'U'
526-
#define AXIS8_STR "U"
527-
#define STR_V_MIN "u_min"
528-
#define STR_V_MAX "u_max"
529-
#elif AXIS8_NAME == 'V'
489+
#if AXIS8_NAME == 'V'
530490
#define AXIS8_STR "V"
531491
#define STR_V_MIN "v_min"
532492
#define STR_V_MAX "v_max"
@@ -544,27 +504,7 @@
544504
#endif
545505

546506
#if LINEAR_AXES >= 9
547-
#if AXIS9_NAME == 'A'
548-
#define AXIS9_STR "A"
549-
#define STR_W_MIN "a_min"
550-
#define STR_W_MAX "a_max"
551-
#elif AXIS9_NAME == 'B'
552-
#define AXIS9_STR "B"
553-
#define STR_W_MIN "b_min"
554-
#define STR_W_MAX "b_max"
555-
#elif AXIS9_NAME == 'C'
556-
#define AXIS9_STR "C"
557-
#define STR_W_MIN "c_min"
558-
#define STR_W_MAX "c_max"
559-
#elif AXIS9_NAME == 'U'
560-
#define AXIS9_STR "U"
561-
#define STR_W_MIN "u_min"
562-
#define STR_W_MAX "u_max"
563-
#elif AXIS9_NAME == 'V'
564-
#define AXIS9_STR "V"
565-
#define STR_W_MIN "v_min"
566-
#define STR_W_MAX "v_max"
567-
#elif AXIS9_NAME == 'W'
507+
#if AXIS9_NAME == 'W'
568508
#define AXIS9_STR "W"
569509
#define STR_W_MIN "w_min"
570510
#define STR_W_MAX "w_max"

Marlin/src/gcode/config/M200-M205.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ void GcodeSuite::M201() {
134134

135135
void GcodeSuite::M201_report(const bool forReplay/*=true*/) {
136136
report_heading_etc(forReplay, F(STR_MAX_ACCELERATION));
137+
// TODO (DerAndere): Add support for rotational axes with distance in degrees
137138
SERIAL_ECHOLNPGM_P(
138139
LIST_N(DOUBLE(LINEAR_AXES),
139140
PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]),
@@ -279,7 +280,7 @@ void GcodeSuite::M205() {
279280
if (parser.seenval('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units()),
280281
if (parser.seenval('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units()),
281282
if ((seenZ = parser.seenval('Z'))) planner.set_max_jerk(Z_AXIS, parser.value_linear_units()),
282-
if (parser.seenval(AXIS4_NAME)) planner.set_max_jerk(I_AXIS, parser.value_linear_units()),
283+
if (parser.seenval(AXIS4_NAME)) planner.set_max_jerk(I_AXIS, parser.value_linear_units()), // TODO (DerAndere): Rotational axes in degrees
283284
if (parser.seenval(AXIS5_NAME)) planner.set_max_jerk(J_AXIS, parser.value_linear_units()),
284285
if (parser.seenval(AXIS6_NAME)) planner.set_max_jerk(K_AXIS, parser.value_linear_units()),
285286
if (parser.seenval(AXIS7_NAME)) planner.set_max_jerk(U_AXIS, parser.value_linear_units()),

Marlin/src/gcode/config/M217.cpp

+30-6
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,25 @@ void GcodeSuite::M217() {
9696
if (parser.seenval('X')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.x = constrain(v, X_MIN_POS, X_MAX_POS); }
9797
if (parser.seenval('Y')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.y = constrain(v, Y_MIN_POS, Y_MAX_POS); }
9898
#if LINEAR_AXES >= 4
99-
if (parser.seenval('I')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); }
99+
#if HAS_ROTATIONAL_AXIS4
100+
if (parser.seenval('I')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); }
101+
#else
102+
if (parser.seenval('I')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); } // TODO (DerAndere): Rotational axes in degrees
103+
#endif
100104
#endif
101105
#if LINEAR_AXES >= 5
102-
if (parser.seenval('J')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); }
106+
#if HAS_ROTATIONAL_AXIS5
107+
if (parser.seenval('J')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); }
108+
#else
109+
if (parser.seenval('J')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); }
110+
#endif
103111
#endif
104112
#if LINEAR_AXES >= 6
105-
if (parser.seenval('K')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); }
113+
#if HAS_ROTATIONAL_AXIS6
114+
if (parser.seenval('K')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); }
115+
#else
116+
if (parser.seenval('K')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); }
117+
#endif
106118
#endif
107119
#if LINEAR_AXES >= 7
108120
if (parser.seenval('C')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.u = constrain(v, U_MIN_POS, U_MAX_POS); }
@@ -179,13 +191,25 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) {
179191
SERIAL_ECHOPGM_P(SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x));
180192
SERIAL_ECHOPGM_P(SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y));
181193
#if LINEAR_AXES >= 4
182-
SERIAL_ECHOPGM_P(" I", LINEAR_UNIT(toolchange_settings.change_point.i));
194+
#if HAS_ROTATIONAL_AXIS4
195+
SERIAL_ECHOPGM_P(" I", toolchange_settings.change_point.i);
196+
#else
197+
SERIAL_ECHOPGM_P(" I", LINEAR_UNIT(toolchange_settings.change_point.i));
198+
#endif
183199
#endif
184200
#if LINEAR_AXES >= 5
185-
SERIAL_ECHOPGM_P(" J", LINEAR_UNIT(toolchange_settings.change_point.j));
201+
#if HAS_ROTATIONAL_AXIS5
202+
SERIAL_ECHOPGM_P(" J", toolchange_settings.change_point.j);
203+
#else
204+
SERIAL_ECHOPGM_P(" J", LINEAR_UNIT(toolchange_settings.change_point.j));
205+
#endif
186206
#endif
187207
#if LINEAR_AXES >= 6
188-
SERIAL_ECHOPGM_P(" K", LINEAR_UNIT(toolchange_settings.change_point.k));
208+
#if HAS_ROTATIONAL_AXIS6
209+
SERIAL_ECHOPGM_P(" K", toolchange_settings.change_point.k);
210+
#else
211+
SERIAL_ECHOPGM_P(" K", LINEAR_UNIT(toolchange_settings.change_point.k));
212+
#endif
189213
#endif
190214
#if LINEAR_AXES >= 7
191215
SERIAL_ECHOPGM_P(" C", LINEAR_UNIT(toolchange_settings.change_point.u));

Marlin/src/gcode/config/M92.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ void GcodeSuite::M92() {
9292

9393
void GcodeSuite::M92_report(const bool forReplay/*=true*/, const int8_t e/*=-1*/) {
9494
report_heading_etc(forReplay, F(STR_STEPS_PER_UNIT));
95+
// TODO (DerAndere): Add support for rotational axes with distance in degrees
9596
SERIAL_ECHOPGM_P(LIST_N(DOUBLE(LINEAR_AXES),
9697
PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]),
9798
SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]),

Marlin/src/gcode/geometry/M206_M428.cpp

+18-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,24 @@ void GcodeSuite::M206() {
4141
if (!parser.seen_any()) return M206_report();
4242

4343
LOOP_LINEAR_AXES(i)
44-
if (parser.seen(AXIS_CHAR(i)))
45-
set_home_offset((AxisEnum)i, parser.value_linear_units());
46-
44+
if (parser.seen(AXIS_CHAR(i))) {
45+
#if HAS_ROTATIONAL_AXES
46+
if ((HAS_ROTATIONAL_AXIS4 && i == I_AXIS)
47+
#if HAS_ROTATIONAL_AXIS5
48+
|| (i == J_AXIS)
49+
#endif
50+
#if HAS_ROTATIONAL_AXIS6
51+
|| ( && i == K_AXIS))
52+
#endif
53+
) {
54+
set_home_offset((AxisEnum)i, parser.value_float());
55+
}
56+
else
57+
set_home_offset((AxisEnum)i, parser.value_linear_units());
58+
#else
59+
set_home_offset((AxisEnum)i, parser.value_linear_units());
60+
#endif
61+
}
4762
#if ENABLED(MORGAN_SCARA)
4863
if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta
4964
if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi

0 commit comments

Comments
 (0)