Skip to content

Commit

Permalink
rotational axes in degrees, feedrate interpretation like LinuxCNC.
Browse files Browse the repository at this point in the history
The time a move with feedrate F takes is now as follows:
if any of X, Y, Z move (whether other axes are moved or not)
  t = sqrt(dX^2 + dY^2 + dZ^2)/F
else, if none of XYZ move but any secondary linear axes move (wether
rotational axes are moved or not):
  t = sqrt(dU^2 + dV^2 + dW^2)/F
else, if only rotary axes are moved:
  t = sqrt(dA^2 + dB^2 + dC^2)/F
  • Loading branch information
DerAndere1 committed Dec 18, 2021
1 parent 3236df3 commit 1988c2e
Show file tree
Hide file tree
Showing 11 changed files with 325 additions and 147 deletions.
32 changes: 19 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 @@ -179,22 +179,28 @@
* I (AXIS4), J (AXIS5), K (AXIS6), U (AXIS7), V (AXIS8), W (AXIS9).
*/
#if LINEAR_AXES >= 4
#define HAS_ROTATIONAL_AXIS4 0
#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 HAS_ROTATIONAL_AXIS5 0
#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 HAS_ROTATIONAL_AXIS6 1
#define AXIS6_NAME 'C' // :['C', 'U', 'V', 'W']
#endif
#if LINEAR_AXES >= 7
#define AXIS7_NAME 'U' // :['A', 'B', 'C', 'U', 'V', 'W']
#define HAS_ROTATIONAL_AXIS7 0
#define AXIS7_NAME 'U' // :['U', 'V', 'W']
#endif
#if LINEAR_AXES >= 8
#define AXIS8_NAME 'V' // :['A', 'B', 'C', 'U', 'V', 'W']
#define HAS_ROTATIONAL_AXIS8 0
#define AXIS8_NAME 'V' // :['V', 'W']
#endif
#if LINEAR_AXES >= 9
#define AXIS9_NAME 'W' // :['A', 'B', 'C', 'U', 'V', 'W']
#define HAS_ROTATIONAL_AXIS9 0
#define AXIS9_NAME 'W' // :['W']
#endif

// @section extruder
Expand Down Expand Up @@ -959,14 +965,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 @@ -978,7 +984,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 @@ -991,7 +997,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 @@ -1003,7 +1009,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 @@ -1432,7 +1438,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 @@ -1819,7 +1825,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 @@ -828,12 +828,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 @@ -1038,8 +1038,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 @@ -1075,7 +1075,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 @@ -3067,10 +3067,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 @@ -407,11 +407,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 @@ -439,15 +435,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 @@ -471,19 +459,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 @@ -503,23 +479,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 @@ -535,27 +495,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 @@ -281,7 +282,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
72 changes: 60 additions & 12 deletions Marlin/src/gcode/config/M217.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,22 +96,46 @@ 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); }
#if HAS_ROTATIONAL_AXIS7
if (parser.seenval('C')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.u = constrain(v, U_MIN_POS, U_MAX_POS); }
#else
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); }
#endif
#endif
#if LINEAR_AXES >= 8
if (parser.seenval('H')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.v = constrain(v, V_MIN_POS, V_MAX_POS); }
#if HAS_ROTATIONAL_AXIS8
if (parser.seenval('H')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.v = constrain(v, V_MIN_POS, V_MAX_POS); }
#else
if (parser.seenval('H')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.v = constrain(v, V_MIN_POS, V_MAX_POS); }
#endif
#endif
#if LINEAR_AXES >= 9
if (parser.seenval('O')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.w = constrain(v, W_MIN_POS, W_MAX_POS); }
#if HAS_ROTATIONAL_AXIS9
if (parser.seenval('O')) { const int16_t v = parser.value_int(); toolchange_settings.change_point.w = constrain(v, W_MIN_POS, W_MAX_POS); }
#else
if (parser.seenval('O')) { const int16_t v = parser.value_linear_units(); toolchange_settings.change_point.w = constrain(v, W_MIN_POS, W_MAX_POS); }
#endif
#endif
#endif

Expand Down Expand Up @@ -179,22 +203,46 @@ 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));
#if HAS_ROTATIONAL_AXIS7
SERIAL_ECHOPGM_P(" C", toolchange_settings.change_point.u);
#else
SERIAL_ECHOPGM_P(" C", LINEAR_UNIT(toolchange_settings.change_point.u));
#endif
#endif
#if LINEAR_AXES >= 8
SERIAL_ECHOPGM_P(" H", LINEAR_UNIT(toolchange_settings.change_point.v));
#if HAS_ROTATIONAL_AXIS8
SERIAL_ECHOPGM_P(" H", toolchange_settings.change_point.v);
#else
SERIAL_ECHOPGM_P(" H", LINEAR_UNIT(toolchange_settings.change_point.v));
#endif
#endif
#if LINEAR_AXES >= 9
SERIAL_ECHOPGM_P(" O", LINEAR_UNIT(toolchange_settings.change_point.w));
#if HAS_ROTATIONAL_AXIS9
SERIAL_ECHOPGM_P(" O", toolchange_settings.change_point.w);
#else
SERIAL_ECHOPGM_P(" O", LINEAR_UNIT(toolchange_settings.change_point.w));
#endif
#endif
#endif

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
Loading

0 comments on commit 1988c2e

Please sign in to comment.