Skip to content

Commit

Permalink
feedrate interpretation like NIST RS274 NGC interpreter V3
Browse files Browse the repository at this point in the history
  • Loading branch information
DerAndere1 committed Dec 5, 2021
1 parent 4a135d0 commit 31d0c6d
Show file tree
Hide file tree
Showing 11 changed files with 237 additions and 150 deletions.
26 changes: 13 additions & 13 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
//#define MACHINE_UUID "00000000-0000-0000-0000-000000000000"

/**
* Define the number of coordinated linear axes.
* Define the number of coordinated axes.
* See /~https://github.com/DerAndere1/Marlin/wiki
* Each linear axis gets its own stepper control and endstop:
*
Expand Down Expand Up @@ -182,19 +182,19 @@
#define AXIS4_NAME 'A' // :['A', 'B', 'C', 'U', 'V', 'W']
#endif
#if LINEAR_AXES >= 5
#define AXIS5_NAME 'B' // :['A', 'B', 'C', 'U', 'V', 'W']
#define AXIS5_NAME 'B' // :['B', 'C', 'U', 'V', 'W']
#endif
#if LINEAR_AXES >= 6
#define AXIS6_NAME 'C' // :['A', 'B', 'C', 'U', 'V', 'W']
#define AXIS6_NAME 'C' // :['C', 'U', 'V', 'W']
#endif
#if LINEAR_AXES >= 7
#define AXIS7_NAME 'U' // :['A', 'B', 'C', 'U', 'V', 'W']
#define AXIS7_NAME 'U' // :['U', 'V', 'W']
#endif
#if LINEAR_AXES >= 8
#define AXIS8_NAME 'V' // :['A', 'B', 'C', 'U', 'V', 'W']
#define AXIS8_NAME 'V' // :['V', 'W']
#endif
#if LINEAR_AXES >= 9
#define AXIS9_NAME 'W' // :['A', 'B', 'C', 'U', 'V', 'W']
#define AXIS9_NAME 'W' // :['W']
#endif

// @section extruder
Expand Down Expand Up @@ -958,14 +958,14 @@
//#define DISTINCT_E_FACTORS

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

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

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

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

/**
* Default Jerk limits (mm/s)
* Default Jerk limits (mm/(s^2))
* Override with M205 X Y Z E
*
* "Jerk" specifies the minimum speed change that requires acceleration.
Expand Down Expand Up @@ -1431,7 +1431,7 @@
#define X_BED_SIZE 200
#define Y_BED_SIZE 200

// Travel limits (mm) after homing, corresponding to endstop positions.
// Travel limits (mm for linear axes, ° for rotational axes) after homing, corresponding to endstop positions.
#define X_MIN_POS 0
#define Y_MIN_POS 0
#define Z_MIN_POS 0
Expand Down Expand Up @@ -1818,7 +1818,7 @@
#define Z_SAFE_HOMING_Y_POINT Y_CENTER // Y point for Z homing
#endif

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

// Validate that endstops are triggered on homing moves
Expand Down
20 changes: 10 additions & 10 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,12 +784,12 @@
* the position of the toolhead relative to the workspace.
*/

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

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

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

//#define QUICK_HOME // If G28 contains XY do a diagonal move first
//#define HOME_Y_BEFORE_X // If G28 contains XY home Y before X
Expand Down Expand Up @@ -994,8 +994,8 @@
#define DISABLE_INACTIVE_E true

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

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

// Add steps for motor direction changes on CORE kinematics
Expand Down Expand Up @@ -3006,10 +3006,10 @@
#define Z2_HYBRID_THRESHOLD 3
#define Z3_HYBRID_THRESHOLD 3
#define Z4_HYBRID_THRESHOLD 3
#define I_HYBRID_THRESHOLD 3
#define J_HYBRID_THRESHOLD 3
#define K_HYBRID_THRESHOLD 3
#define U_HYBRID_THRESHOLD 3
#define I_HYBRID_THRESHOLD 3 // [mm/s for linear axis, °/s for rotational axis]
#define J_HYBRID_THRESHOLD 3 // [mm/s for linear axis, °/s for rotational axis]
#define K_HYBRID_THRESHOLD 3 // [mm/s for linear axis, °/s for rotational axis]
#define U_HYBRID_THRESHOLD 3 // [mm/s]
#define V_HYBRID_THRESHOLD 3
#define W_HYBRID_THRESHOLD 3
#define E0_HYBRID_THRESHOLD 30
Expand Down
70 changes: 5 additions & 65 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,7 @@
#endif

#if LINEAR_AXES >= 5
#if AXIS5_NAME == 'A'
#define AXIS5_STR "A"
#define STR_J_MIN "a_min"
#define STR_J_MAX "a_max"
#elif AXIS5_NAME == 'B'
#if AXIS5_NAME == 'B'
#define AXIS5_STR "B"
#define STR_J_MIN "b_min"
#define STR_J_MAX "b_max"
Expand Down Expand Up @@ -442,15 +438,7 @@
#endif

#if LINEAR_AXES >= 6
#if AXIS6_NAME == 'A'
#define AXIS6_STR "A"
#define STR_K_MIN "a_min"
#define STR_K_MAX "a_max"
#elif AXIS6_NAME == 'B'
#define AXIS6_STR "B"
#define STR_K_MIN "b_min"
#define STR_K_MAX "b_max"
#elif AXIS6_NAME == 'C'
#if AXIS6_NAME == 'C'
#define AXIS6_STR "C"
#define STR_K_MIN "c_min"
#define STR_K_MAX "c_max"
Expand All @@ -476,19 +464,7 @@
#endif

#if LINEAR_AXES >= 7
#if AXIS7_NAME == 'A'
#define AXIS7_STR "A"
#define STR_U_MIN "a_min"
#define STR_U_MAX "a_max"
#elif AXIS7_NAME == 'B'
#define AXIS7_STR "B"
#define STR_U_MIN "b_min"
#define STR_U_MAX "b_max"
#elif AXIS7_NAME == 'C'
#define AXIS7_STR "C"
#define STR_U_MIN "c_min"
#define STR_U_MAX "c_max"
#elif AXIS7_NAME == 'U'
#if AXIS7_NAME == 'U'
#define AXIS7_STR "U"
#define STR_U_MIN "u_min"
#define STR_U_MAX "u_max"
Expand All @@ -510,23 +486,7 @@
#endif

#if LINEAR_AXES >= 8
#if AXIS8_NAME == 'A'
#define AXIS8_STR "A"
#define STR_V_MIN "a_min"
#define STR_V_MAX "a_max"
#elif AXIS8_NAME == 'B'
#define AXIS8_STR "B"
#define STR_V_MIN "b_min"
#define STR_V_MAX "b_max"
#elif AXIS8_NAME == 'C'
#define AXIS8_STR "C"
#define STR_V_MIN "c_min"
#define STR_V_MAX "c_max"
#elif AXIS8_NAME == 'U'
#define AXIS8_STR "U"
#define STR_V_MIN "u_min"
#define STR_V_MAX "u_max"
#elif AXIS8_NAME == 'V'
#if AXIS8_NAME == 'V'
#define AXIS8_STR "V"
#define STR_V_MIN "v_min"
#define STR_V_MAX "v_max"
Expand All @@ -544,27 +504,7 @@
#endif

#if LINEAR_AXES >= 9
#if AXIS9_NAME == 'A'
#define AXIS9_STR "A"
#define STR_W_MIN "a_min"
#define STR_W_MAX "a_max"
#elif AXIS9_NAME == 'B'
#define AXIS9_STR "B"
#define STR_W_MIN "b_min"
#define STR_W_MAX "b_max"
#elif AXIS9_NAME == 'C'
#define AXIS9_STR "C"
#define STR_W_MIN "c_min"
#define STR_W_MAX "c_max"
#elif AXIS9_NAME == 'U'
#define AXIS9_STR "U"
#define STR_W_MIN "u_min"
#define STR_W_MAX "u_max"
#elif AXIS9_NAME == 'V'
#define AXIS9_STR "V"
#define STR_W_MIN "v_min"
#define STR_W_MAX "v_max"
#elif AXIS9_NAME == 'W'
#if AXIS9_NAME == 'W'
#define AXIS9_STR "W"
#define STR_W_MIN "w_min"
#define STR_W_MAX "w_max"
Expand Down
3 changes: 2 additions & 1 deletion Marlin/src/gcode/config/M200-M205.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void GcodeSuite::M201() {

void GcodeSuite::M201_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, F(STR_MAX_ACCELERATION));
// TODO (DerAndere): Add support for rotational axes with distance in degrees
SERIAL_ECHOLNPGM_P(
LIST_N(DOUBLE(LINEAR_AXES),
PSTR(" M201 X"), LINEAR_UNIT(planner.settings.max_acceleration_mm_per_s2[X_AXIS]),
Expand Down Expand Up @@ -279,7 +280,7 @@ void GcodeSuite::M205() {
if (parser.seenval('X')) planner.set_max_jerk(X_AXIS, parser.value_linear_units()),
if (parser.seenval('Y')) planner.set_max_jerk(Y_AXIS, parser.value_linear_units()),
if ((seenZ = parser.seenval('Z'))) planner.set_max_jerk(Z_AXIS, parser.value_linear_units()),
if (parser.seenval(AXIS4_NAME)) planner.set_max_jerk(I_AXIS, parser.value_linear_units()),
if (parser.seenval(AXIS4_NAME)) planner.set_max_jerk(I_AXIS, parser.value_linear_units()), // TODO (DerAndere): Rotational axes in degrees
if (parser.seenval(AXIS5_NAME)) planner.set_max_jerk(J_AXIS, parser.value_linear_units()),
if (parser.seenval(AXIS6_NAME)) planner.set_max_jerk(K_AXIS, parser.value_linear_units()),
if (parser.seenval(AXIS7_NAME)) planner.set_max_jerk(U_AXIS, parser.value_linear_units()),
Expand Down
36 changes: 30 additions & 6 deletions Marlin/src/gcode/config/M217.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,25 @@ void GcodeSuite::M217() {
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); }
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); }
#if LINEAR_AXES >= 4
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); }
#if HAS_ROTATIONAL_AXIS4
if (parser.seenval('I')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.i = constrain(v, I_MIN_POS, I_MAX_POS); }
#else
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
#endif
#endif
#if LINEAR_AXES >= 5
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); }
#if HAS_ROTATIONAL_AXIS5
if (parser.seenval('J')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.j = constrain(v, J_MIN_POS, J_MAX_POS); }
#else
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); }
#endif
#endif
#if LINEAR_AXES >= 6
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); }
#if HAS_ROTATIONAL_AXIS6
if (parser.seenval('K')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.k = constrain(v, K_MIN_POS, K_MAX_POS); }
#else
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); }
#endif
#endif
#if LINEAR_AXES >= 7
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); }
Expand Down Expand Up @@ -179,13 +191,25 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) {
SERIAL_ECHOPGM_P(SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x));
SERIAL_ECHOPGM_P(SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y));
#if LINEAR_AXES >= 4
SERIAL_ECHOPGM_P(" I", LINEAR_UNIT(toolchange_settings.change_point.i));
#if HAS_ROTATIONAL_AXIS4
SERIAL_ECHOPGM_P(" I", toolchange_settings.change_point.i);
#else
SERIAL_ECHOPGM_P(" I", LINEAR_UNIT(toolchange_settings.change_point.i));
#endif
#endif
#if LINEAR_AXES >= 5
SERIAL_ECHOPGM_P(" J", LINEAR_UNIT(toolchange_settings.change_point.j));
#if HAS_ROTATIONAL_AXIS5
SERIAL_ECHOPGM_P(" J", toolchange_settings.change_point.j);
#else
SERIAL_ECHOPGM_P(" J", LINEAR_UNIT(toolchange_settings.change_point.j));
#endif
#endif
#if LINEAR_AXES >= 6
SERIAL_ECHOPGM_P(" K", LINEAR_UNIT(toolchange_settings.change_point.k));
#if HAS_ROTATIONAL_AXIS6
SERIAL_ECHOPGM_P(" K", toolchange_settings.change_point.k);
#else
SERIAL_ECHOPGM_P(" K", LINEAR_UNIT(toolchange_settings.change_point.k));
#endif
#endif
#if LINEAR_AXES >= 7
SERIAL_ECHOPGM_P(" C", LINEAR_UNIT(toolchange_settings.change_point.u));
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/gcode/config/M92.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ void GcodeSuite::M92() {

void GcodeSuite::M92_report(const bool forReplay/*=true*/, const int8_t e/*=-1*/) {
report_heading_etc(forReplay, F(STR_STEPS_PER_UNIT));
// TODO (DerAndere): Add support for rotational axes with distance in degrees
SERIAL_ECHOPGM_P(LIST_N(DOUBLE(LINEAR_AXES),
PSTR(" M92 X"), LINEAR_UNIT(planner.settings.axis_steps_per_mm[X_AXIS]),
SP_Y_STR, LINEAR_UNIT(planner.settings.axis_steps_per_mm[Y_AXIS]),
Expand Down
21 changes: 18 additions & 3 deletions Marlin/src/gcode/geometry/M206_M428.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,24 @@ void GcodeSuite::M206() {
if (!parser.seen_any()) return M206_report();

LOOP_LINEAR_AXES(i)
if (parser.seen(AXIS_CHAR(i)))
set_home_offset((AxisEnum)i, parser.value_linear_units());

if (parser.seen(AXIS_CHAR(i))) {
#if HAS_ROTATIONAL_AXES
if ((HAS_ROTATIONAL_AXIS4 && i == I_AXIS)
#if HAS_ROTATIONAL_AXIS5
|| (i == J_AXIS)
#endif
#if HAS_ROTATIONAL_AXIS6
|| ( && i == K_AXIS))
#endif
) {
set_home_offset((AxisEnum)i, parser.value_float());
}
else
set_home_offset((AxisEnum)i, parser.value_linear_units());
#else
set_home_offset((AxisEnum)i, parser.value_linear_units());
#endif
}
#if ENABLED(MORGAN_SCARA)
if (parser.seen('T')) set_home_offset(A_AXIS, parser.value_float()); // Theta
if (parser.seen('P')) set_home_offset(B_AXIS, parser.value_float()); // Psi
Expand Down
Loading

0 comments on commit 31d0c6d

Please sign in to comment.