Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Misc. updates for extra axes (MarlinFirmware#23521)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and mh-dm committed May 15, 2022
1 parent 1f7431e commit 03c5cb8
Show file tree
Hide file tree
Showing 27 changed files with 289 additions and 205 deletions.
6 changes: 3 additions & 3 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3224,7 +3224,7 @@
#define Z4_SLEW_RATE 1
#endif

#if AXIS_DRIVER_TYPE_I(L6470)
#if AXIS_IS_L64XX(I)
#define I_MICROSTEPS 128
#define I_OVERCURRENT 2000
#define I_STALLCURRENT 1500
Expand All @@ -3233,7 +3233,7 @@
#define I_SLEW_RATE 1
#endif

#if AXIS_DRIVER_TYPE_J(L6470)
#if AXIS_IS_L64XX(J)
#define J_MICROSTEPS 128
#define J_OVERCURRENT 2000
#define J_STALLCURRENT 1500
Expand All @@ -3242,7 +3242,7 @@
#define J_SLEW_RATE 1
#endif

#if AXIS_DRIVER_TYPE_K(L6470)
#if AXIS_IS_L64XX(K)
#define K_MICROSTEPS 128
#define K_OVERCURRENT 2000
#define K_STALLCURRENT 1500
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/HAL/AVR/endstop_interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,5 +301,6 @@ void setup_endstop_interrupts() {
pciSetup(Z_MIN_PROBE_PIN);
#endif
#endif

// If we arrive here without raising an assertion, each pin has either an EXT-interrupt or a PCI.
}
28 changes: 5 additions & 23 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,14 @@
#define STR_I_MIN "w_min"
#define STR_I_MAX "w_max"
#else
#define STR_I "A"
#define STR_I_MIN "a_min"
#define STR_I_MAX "a_max"
#error "AXIS4_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'."
#endif
#else
#define STR_I ""
#endif

#if HAS_J_AXIS
#if AXIS5_NAME == 'A'
#define STR_J "A"
#define STR_J_MIN "a_min"
#define STR_J_MAX "a_max"
#elif AXIS5_NAME == 'B'
#if AXIS5_NAME == 'B'
#define STR_J "B"
#define STR_J_MIN "b_min"
#define STR_J_MAX "b_max"
Expand All @@ -418,24 +412,14 @@
#define STR_J_MIN "w_min"
#define STR_J_MAX "w_max"
#else
#define STR_J "B"
#define STR_J_MIN "b_min"
#define STR_J_MAX "b_max"
#error "AXIS5_NAME can only be one of 'B', 'C', 'U', 'V', or 'W'."
#endif
#else
#define STR_J ""
#endif

#if HAS_K_AXIS
#if AXIS6_NAME == 'A'
#define STR_K "A"
#define STR_K_MIN "a_min"
#define STR_K_MAX "a_max"
#elif AXIS6_NAME == 'B'
#define STR_K "B"
#define STR_K_MIN "b_min"
#define STR_K_MAX "b_max"
#elif AXIS6_NAME == 'C'
#if AXIS6_NAME == 'C'
#define STR_K "C"
#define STR_K_MIN "c_min"
#define STR_K_MAX "c_max"
Expand All @@ -452,9 +436,7 @@
#define STR_K_MIN "w_min"
#define STR_K_MAX "w_max"
#else
#define STR_K "C"
#define STR_K_MIN "c_min"
#define STR_K_MAX "c_max"
#error "AXIS6_NAME can only be one of 'C', 'U', 'V', or 'W'."
#endif
#else
#define STR_K ""
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/feature/direct_stepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ namespace DirectStepping {
volatile bool SerialPageManager<Cfg>::fatal_error;

template<typename Cfg>
volatile PageState SerialPageManager<Cfg>::page_states[Cfg::NUM_PAGES];
volatile PageState SerialPageManager<Cfg>::page_states[Cfg::PAGE_COUNT];

template<typename Cfg>
volatile bool SerialPageManager<Cfg>::page_states_dirty;

template<typename Cfg>
uint8_t SerialPageManager<Cfg>::pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE];
uint8_t SerialPageManager<Cfg>::pages[Cfg::PAGE_COUNT][Cfg::PAGE_SIZE];

template<typename Cfg>
uint8_t SerialPageManager<Cfg>::checksum;
Expand All @@ -74,7 +74,7 @@ namespace DirectStepping {

template <typename Cfg>
void SerialPageManager<Cfg>::init() {
for (int i = 0 ; i < Cfg::NUM_PAGES ; i++)
for (int i = 0 ; i < Cfg::PAGE_COUNT ; i++)
page_states[i] = PageState::FREE;

fatal_error = false;
Expand Down Expand Up @@ -183,10 +183,10 @@ namespace DirectStepping {

SERIAL_CHAR(Cfg::CONTROL_CHAR);
constexpr int state_bits = 2;
constexpr int n_bytes = Cfg::NUM_PAGES >> state_bits;
constexpr int n_bytes = Cfg::PAGE_COUNT >> state_bits;
volatile uint8_t bits_b[n_bytes] = { 0 };

for (page_idx_t i = 0 ; i < Cfg::NUM_PAGES ; i++) {
for (page_idx_t i = 0 ; i < Cfg::PAGE_COUNT ; i++) {
bits_b[i >> state_bits] |= page_states[i] << ((i * state_bits) & 0x7);
}

Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/feature/direct_stepping.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ namespace DirectStepping {
static State state;
static volatile bool fatal_error;

static volatile PageState page_states[Cfg::NUM_PAGES];
static volatile PageState page_states[Cfg::PAGE_COUNT];
static volatile bool page_states_dirty;

static uint8_t pages[Cfg::NUM_PAGES][Cfg::PAGE_SIZE];
static uint8_t pages[Cfg::PAGE_COUNT][Cfg::PAGE_SIZE];
static uint8_t checksum;
static write_byte_idx_t write_byte_idx;
static page_idx_t write_page_idx;
Expand All @@ -87,19 +87,19 @@ namespace DirectStepping {
struct config_t {
static constexpr char CONTROL_CHAR = '!';

static constexpr int NUM_PAGES = num_pages;
static constexpr int NUM_AXES = num_axes;
static constexpr int PAGE_COUNT = num_pages;
static constexpr int AXIS_COUNT = num_axes;
static constexpr int BITS_SEGMENT = bits_segment;
static constexpr int DIRECTIONAL = dir ? 1 : 0;
static constexpr int SEGMENTS = segments;

static constexpr int NUM_SEGMENTS = _BV(BITS_SEGMENT);
static constexpr int SEGMENT_STEPS = _BV(BITS_SEGMENT - DIRECTIONAL) - 1;
static constexpr int TOTAL_STEPS = SEGMENT_STEPS * SEGMENTS;
static constexpr int PAGE_SIZE = (NUM_AXES * BITS_SEGMENT * SEGMENTS) / 8;
static constexpr int PAGE_SIZE = (AXIS_COUNT * BITS_SEGMENT * SEGMENTS) / 8;

typedef typename TypeSelector<(PAGE_SIZE>256), uint16_t, uint8_t>::type write_byte_idx_t;
typedef typename TypeSelector<(NUM_PAGES>256), uint16_t, uint8_t>::type page_idx_t;
typedef typename TypeSelector<(PAGE_COUNT>256), uint16_t, uint8_t>::type page_idx_t;
};

template <uint8_t num_pages>
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/feature/tmc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,12 +421,10 @@
if (monitor_tmc_driver(stepperI, need_update_error_counters, need_debug_reporting))
step_current_down(stepperI);
#endif

#if AXIS_IS_TMC(J)
if (monitor_tmc_driver(stepperJ, need_update_error_counters, need_debug_reporting))
step_current_down(stepperJ);
#endif

#if AXIS_IS_TMC(K)
if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting))
step_current_down(stepperK);
Expand Down
29 changes: 22 additions & 7 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void GcodeSuite::G28() {
reset_stepper_timeout();

#define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
#if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z))
#if HAS_CURRENT_HOME(X) || HAS_CURRENT_HOME(X2) || HAS_CURRENT_HOME(Y) || HAS_CURRENT_HOME(Y2) || (ENABLED(DELTA) && HAS_CURRENT_HOME(Z)) || HAS_CURRENT_HOME(I) || HAS_CURRENT_HOME(J) || HAS_CURRENT_HOME(K)
#define HAS_HOMING_CURRENT 1
#endif

Expand All @@ -273,22 +273,22 @@ void GcodeSuite::G28() {
#if HAS_CURRENT_HOME(X)
const int16_t tmc_save_current_X = stepperX.getMilliamps();
stepperX.rms_current(X_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F("X"), tmc_save_current_X, X_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_X), tmc_save_current_X, X_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(X2)
const int16_t tmc_save_current_X2 = stepperX2.getMilliamps();
stepperX2.rms_current(X2_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F("X2"), tmc_save_current_X2, X2_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_X2), tmc_save_current_X2, X2_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(Y)
const int16_t tmc_save_current_Y = stepperY.getMilliamps();
stepperY.rms_current(Y_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F("Y"), tmc_save_current_Y, Y_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_Y), tmc_save_current_Y, Y_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(Y2)
const int16_t tmc_save_current_Y2 = stepperY2.getMilliamps();
stepperY2.rms_current(Y2_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F("Y2"), tmc_save_current_Y2, Y2_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_Y2), tmc_save_current_Y2, Y2_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(I)
const int16_t tmc_save_current_I = stepperI.getMilliamps();
Expand All @@ -308,7 +308,22 @@ void GcodeSuite::G28() {
#if HAS_CURRENT_HOME(Z) && ENABLED(DELTA)
const int16_t tmc_save_current_Z = stepperZ.getMilliamps();
stepperZ.rms_current(Z_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F("Z"), tmc_save_current_Z, Z_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_Z), tmc_save_current_Z, Z_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(I)
const int16_t tmc_save_current_I = stepperI.getMilliamps();
stepperI.rms_current(I_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_I), tmc_save_current_I, I_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(J)
const int16_t tmc_save_current_J = stepperJ.getMilliamps();
stepperJ.rms_current(J_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_J), tmc_save_current_J, J_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(K)
const int16_t tmc_save_current_K = stepperK.getMilliamps();
stepperK.rms_current(K_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_K), tmc_save_current_K, K_CURRENT_HOME);
#endif
#endif

Expand Down Expand Up @@ -361,7 +376,7 @@ void GcodeSuite::G28() {
homeX = needX || parser.seen_test('X'),
homeY = needY || parser.seen_test('Y'),
homeZZ = homeZ,
homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME),
homeI = needI || parser.seen_test(AXIS4_NAME), homeJ = needJ || parser.seen_test(AXIS5_NAME), homeK = needK || parser.seen_test(AXIS6_NAME)
),
home_all = LINEAR_AXIS_GANG( // Home-all if all or none are flagged
homeX == homeX, && homeY == homeX, && homeZ == homeX,
Expand Down
18 changes: 8 additions & 10 deletions Marlin/src/gcode/calibrate/G425.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,15 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t

park_above_object(m, uncertainty);

#define _ACASE(N,A,B) case A: dir = -1; case B: axis = N##_AXIS; break
#define _PCASE(N) _ACASE(N, N##MINIMUM, N##MAXIMUM)

switch (side) {
#if AXIS_CAN_CALIBRATE(X)
case RIGHT: dir = -1;
case LEFT: axis = X_AXIS; break;
_ACASE(X, RIGHT, LEFT);
#endif
#if HAS_Y_AXIS && AXIS_CAN_CALIBRATE(Y)
case BACK: dir = -1;
case FRONT: axis = Y_AXIS; break;
_ACASE(Y, BACK, FRONT);
#endif
#if HAS_Z_AXIS && AXIS_CAN_CALIBRATE(Z)
case TOP: {
Expand All @@ -259,16 +260,13 @@ inline void probe_side(measurements_t &m, const float uncertainty, const side_t
}
#endif
#if HAS_I_AXIS && AXIS_CAN_CALIBRATE(I)
case IMINIMUM: dir = -1;
case IMAXIMUM: axis = I_AXIS; break;
_PCASE(I);
#endif
#if HAS_J_AXIS && AXIS_CAN_CALIBRATE(J)
case JMINIMUM: dir = -1;
case JMAXIMUM: axis = J_AXIS; break;
_PCASE(J);
#endif
#if HAS_K_AXIS && AXIS_CAN_CALIBRATE(K)
case KMINIMUM: dir = -1;
case KMAXIMUM: axis = K_AXIS; break;
_PCASE(K);
#endif
default: return;
}
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/calibrate/M425.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void GcodeSuite::M425() {
case Z_AXIS: return AXIS_CAN_CALIBRATE(Z),
case I_AXIS: return AXIS_CAN_CALIBRATE(I),
case J_AXIS: return AXIS_CAN_CALIBRATE(J),
case K_AXIS: return AXIS_CAN_CALIBRATE(K),
case K_AXIS: return AXIS_CAN_CALIBRATE(K)
);
}
};
Expand Down
9 changes: 7 additions & 2 deletions Marlin/src/gcode/config/M200-M205.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,13 @@ void GcodeSuite::M205_report(const bool forReplay/*=true*/) {
report_heading_etc(forReplay, F(
"Advanced (B<min_segment_time_us> S<min_feedrate> T<min_travel_feedrate>"
TERN_(HAS_JUNCTION_DEVIATION, " J<junc_dev>")
TERN_(HAS_CLASSIC_JERK, " X<max_x_jerk> Y<max_y_jerk> Z<max_z_jerk>")
TERN_(HAS_CLASSIC_E_JERK, " E<max_e_jerk>")
#if HAS_CLASSIC_JERK
LINEAR_AXIS_GANG(
" X<max_jerk>", " Y<max_jerk>", " Z<max_jerk>",
" " STR_I "<max_jerk>", " " STR_J "<max_jerk>", " " STR_K "<max_jerk>"
)
#endif
TERN_(HAS_CLASSIC_E_JERK, " E<max_jerk>")
")"
));
SERIAL_ECHOLNPGM_P(
Expand Down
39 changes: 35 additions & 4 deletions Marlin/src/gcode/config/M217.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
* W[linear] 0/1 Enable park & Z Raise
* X[linear] Park X (Requires TOOLCHANGE_PARK)
* Y[linear] Park Y (Requires TOOLCHANGE_PARK)
* I[linear] Park I (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 4)
* J[linear] Park J (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 5)
* K[linear] Park K (Requires TOOLCHANGE_PARK and LINEAR_AXES >= 6)
* Z[linear] Z Raise
* F[linear] Fan Speed 0-255
* G[linear/s] Fan time
Expand Down Expand Up @@ -88,10 +91,23 @@ void GcodeSuite::M217() {
#if ENABLED(TOOLCHANGE_PARK)
if (parser.seenval('W')) { toolchange_settings.enable_park = parser.value_linear_units(); }
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 HAS_Y_AXIS
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); }
#endif
#if HAS_I_AXIS
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); }
#endif
#if HAS_J_AXIS
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
#if HAS_K_AXIS
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 (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); }
#if HAS_Z_AXIS
if (parser.seenval('Z')) { toolchange_settings.z_raise = parser.value_linear_units(); }
#endif

#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
migration.target = 0; // 0 = disabled
Expand Down Expand Up @@ -151,9 +167,24 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) {
#endif

#if ENABLED(TOOLCHANGE_PARK)
{
SERIAL_ECHOPGM(" W", LINEAR_UNIT(toolchange_settings.enable_park));
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));
SERIAL_ECHOPGM_P(
SP_X_STR, LINEAR_UNIT(toolchange_settings.change_point.x)
#if HAS_Y_AXIS
, SP_Y_STR, LINEAR_UNIT(toolchange_settings.change_point.y)
#endif
#if HAS_I_AXIS
, SP_I_STR, LINEAR_UNIT(toolchange_settings.change_point.i)
#endif
#if HAS_J_AXIS
, SP_J_STR, LINEAR_UNIT(toolchange_settings.change_point.j)
#endif
#if HAS_K_AXIS
, SP_K_STR, LINEAR_UNIT(toolchange_settings.change_point.k)
#endif
);
}
#endif

#if ENABLED(TOOLCHANGE_FS_PRIME_FIRST_USED)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/config/M92.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "../../module/planner.h"

/**
* M92: Set axis steps-per-unit for one or more axes, X, Y, Z, and E.
* M92: Set axis steps-per-unit for one or more axes, X, Y, Z, [I, [J, [K]]] and E.
* (Follows the same syntax as G92)
*
* With multiple extruders use T to specify which one.
Expand Down
Loading

0 comments on commit 03c5cb8

Please sign in to comment.