Support for up to 9 axes (#23112, #24036, #24231)

This commit is contained in:
Scott Lahteine
2022-04-29 15:21:15 -05:00
parent 369542db3b
commit fd13a928c1
103 changed files with 4553 additions and 799 deletions

View File

@ -97,7 +97,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
const float f_corr = float(correction) / all_on;
LOOP_LINEAR_AXES(axis) {
LOOP_NUM_AXES(axis) {
if (distance_mm[axis]) {
const bool reverse = TEST(dm, axis);
@ -145,7 +145,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
}
int32_t Backlash::get_applied_steps(const AxisEnum axis) {
if (axis >= LINEAR_AXES) return 0;
if (axis >= NUM_AXES) return 0;
const bool reverse = TEST(last_direction_bits, axis);
@ -165,11 +165,11 @@ class Backlash::StepAdjuster {
xyz_long_t applied_steps;
public:
StepAdjuster() {
LOOP_LINEAR_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis);
LOOP_NUM_AXES(axis) applied_steps[axis] = backlash.get_applied_steps((AxisEnum)axis);
}
~StepAdjuster() {
// after backlash compensation parameter changes, ensure applied step count does not change
LOOP_LINEAR_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis];
LOOP_NUM_AXES(axis) residual_error[axis] += backlash.get_applied_steps((AxisEnum)axis) - applied_steps[axis];
}
};

View File

@ -317,6 +317,42 @@ void unified_bed_leveling::G29() {
// Send 'N' to force homing before G29 (internal only)
if (axes_should_home() || parser.seen_test('N')) gcode.home_all_axes();
TERN_(HAS_MULTI_HOTEND, if (active_extruder != 0) tool_change(0, true));
// Position bed horizontally and Z probe vertically.
#if defined(SAFE_BED_LEVELING_START_X) || defined(SAFE_BED_LEVELING_START_Y) || defined(SAFE_BED_LEVELING_START_Z) \
|| defined(SAFE_BED_LEVELING_START_I) || defined(SAFE_BED_LEVELING_START_J) || defined(SAFE_BED_LEVELING_START_K) \
|| defined(SAFE_BED_LEVELING_START_U) || defined(SAFE_BED_LEVELING_START_V) || defined(SAFE_BED_LEVELING_START_W)
xyze_pos_t safe_position = current_position;
#ifdef SAFE_BED_LEVELING_START_X
safe_position.x = SAFE_BED_LEVELING_START_X;
#endif
#ifdef SAFE_BED_LEVELING_START_Y
safe_position.y = SAFE_BED_LEVELING_START_Y;
#endif
#ifdef SAFE_BED_LEVELING_START_Z
safe_position.z = SAFE_BED_LEVELING_START_Z;
#endif
#ifdef SAFE_BED_LEVELING_START_I
safe_position.i = SAFE_BED_LEVELING_START_I;
#endif
#ifdef SAFE_BED_LEVELING_START_J
safe_position.j = SAFE_BED_LEVELING_START_J;
#endif
#ifdef SAFE_BED_LEVELING_START_K
safe_position.k = SAFE_BED_LEVELING_START_K;
#endif
#ifdef SAFE_BED_LEVELING_START_U
safe_position.u = SAFE_BED_LEVELING_START_U;
#endif
#ifdef SAFE_BED_LEVELING_START_V
safe_position.v = SAFE_BED_LEVELING_START_V;
#endif
#ifdef SAFE_BED_LEVELING_START_W
safe_position.w = SAFE_BED_LEVELING_START_W;
#endif
do_blocking_move_to(safe_position);
#endif
}
// Invalidate one or more nearby mesh points, possibly all.

View File

@ -337,7 +337,7 @@ bool I2CPositionEncoder::test_axis() {
ec = false;
xyze_pos_t startCoord, endCoord;
LOOP_LINEAR_AXES(a) {
LOOP_NUM_AXES(a) {
startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
}
@ -395,7 +395,7 @@ void I2CPositionEncoder::calibrate_steps_mm(const uint8_t iter) {
travelDistance = endDistance - startDistance;
xyze_pos_t startCoord, endCoord;
LOOP_LINEAR_AXES(a) {
LOOP_NUM_AXES(a) {
startCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
endCoord[a] = planner.get_axis_position_mm((AxisEnum)a);
}

View File

@ -163,7 +163,7 @@ Joystick joystick;
// norm_jog values of [-1 .. 1] maps linearly to [-feedrate .. feedrate]
xyz_float_t move_dist{0};
float hypot2 = 0;
LOOP_LINEAR_AXES(i) if (norm_jog[i]) {
LOOP_NUM_AXES(i) if (norm_jog[i]) {
move_dist[i] = seg_time * norm_jog[i] * TERN(EXTENSIBLE_UI, manual_feedrate_mm_s, planner.settings.max_feedrate_mm_s)[i];
hypot2 += sq(move_dist[i]);
}

View File

@ -567,7 +567,7 @@ void PrintJobRecovery::resume() {
TERN_(HAS_HOME_OFFSET, home_offset = info.home_offset);
TERN_(HAS_POSITION_SHIFT, position_shift = info.position_shift);
#if HAS_HOME_OFFSET || HAS_POSITION_SHIFT
LOOP_LINEAR_AXES(i) update_workspace_offset((AxisEnum)i);
LOOP_NUM_AXES(i) update_workspace_offset((AxisEnum)i);
#endif
// Relative axis modes
@ -617,7 +617,7 @@ void PrintJobRecovery::resume() {
#if HAS_HOME_OFFSET
DEBUG_ECHOPGM("home_offset: ");
LOOP_LINEAR_AXES(i) {
LOOP_NUM_AXES(i) {
if (i) DEBUG_CHAR(',');
DEBUG_DECIMAL(info.home_offset[i]);
}
@ -626,7 +626,7 @@ void PrintJobRecovery::resume() {
#if HAS_POSITION_SHIFT
DEBUG_ECHOPGM("position_shift: ");
LOOP_LINEAR_AXES(i) {
LOOP_NUM_AXES(i) {
if (i) DEBUG_CHAR(',');
DEBUG_DECIMAL(info.position_shift[i]);
}

View File

@ -65,15 +65,18 @@ void stepper_driver_backward_check() {
TEST_BACKWARD(I, 8);
TEST_BACKWARD(J, 9);
TEST_BACKWARD(K, 10);
TEST_BACKWARD(U, 11);
TEST_BACKWARD(V, 12);
TEST_BACKWARD(W, 13);
TEST_BACKWARD(E0, 11);
TEST_BACKWARD(E1, 12);
TEST_BACKWARD(E2, 13);
TEST_BACKWARD(E3, 14);
TEST_BACKWARD(E4, 15);
TEST_BACKWARD(E5, 16);
TEST_BACKWARD(E6, 17);
TEST_BACKWARD(E7, 18);
TEST_BACKWARD(E0, 14);
TEST_BACKWARD(E1, 15);
TEST_BACKWARD(E2, 16);
TEST_BACKWARD(E3, 17);
TEST_BACKWARD(E4, 18);
TEST_BACKWARD(E5, 19);
TEST_BACKWARD(E6, 20);
TEST_BACKWARD(E7, 21);
if (!axis_plug_backward)
WRITE(SAFE_POWER_PIN, HIGH);
@ -103,15 +106,18 @@ void stepper_driver_backward_report() {
REPORT_BACKWARD(I, 8);
REPORT_BACKWARD(J, 9);
REPORT_BACKWARD(K, 10);
REPORT_BACKWARD(U, 11);
REPORT_BACKWARD(V, 12);
REPORT_BACKWARD(W, 13);
REPORT_BACKWARD(E0, 11);
REPORT_BACKWARD(E1, 12);
REPORT_BACKWARD(E2, 13);
REPORT_BACKWARD(E3, 14);
REPORT_BACKWARD(E4, 15);
REPORT_BACKWARD(E5, 16);
REPORT_BACKWARD(E6, 17);
REPORT_BACKWARD(E7, 18);
REPORT_BACKWARD(E0, 14);
REPORT_BACKWARD(E1, 15);
REPORT_BACKWARD(E2, 16);
REPORT_BACKWARD(E3, 17);
REPORT_BACKWARD(E4, 18);
REPORT_BACKWARD(E5, 19);
REPORT_BACKWARD(E6, 20);
REPORT_BACKWARD(E7, 21);
}
#endif // HAS_DRIVER_SAFE_POWER_PROTECT

View File

@ -429,6 +429,18 @@
if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting))
step_current_down(stepperK);
#endif
#if AXIS_IS_TMC(U)
if (monitor_tmc_driver(stepperU, need_update_error_counters, need_debug_reporting))
step_current_down(stepperU);
#endif
#if AXIS_IS_TMC(V)
if (monitor_tmc_driver(stepperV, need_update_error_counters, need_debug_reporting))
step_current_down(stepperV);
#endif
#if AXIS_IS_TMC(W)
if (monitor_tmc_driver(stepperW, need_update_error_counters, need_debug_reporting))
step_current_down(stepperW);
#endif
#if AXIS_IS_TMC(E0)
(void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting);
@ -809,6 +821,15 @@
#if AXIS_IS_TMC(K)
if (k) tmc_status(stepperK, n);
#endif
#if AXIS_IS_TMC(U)
if (u) tmc_status(stepperU, n);
#endif
#if AXIS_IS_TMC(V)
if (v) tmc_status(stepperV, n);
#endif
#if AXIS_IS_TMC(W)
if (w) tmc_status(stepperW, n);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
@ -883,6 +904,15 @@
#if AXIS_IS_TMC(K)
if (k) tmc_parse_drv_status(stepperK, n);
#endif
#if AXIS_IS_TMC(U)
if (u) tmc_parse_drv_status(stepperU, n);
#endif
#if AXIS_IS_TMC(V)
if (v) tmc_parse_drv_status(stepperV, n);
#endif
#if AXIS_IS_TMC(W)
if (w) tmc_parse_drv_status(stepperW, n);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
@ -1088,6 +1118,15 @@
#if AXIS_IS_TMC(K)
if (k) tmc_get_registers(stepperK, n);
#endif
#if AXIS_IS_TMC(U)
if (u) tmc_get_registers(stepperU, n);
#endif
#if AXIS_IS_TMC(V)
if (v) tmc_get_registers(stepperV, n);
#endif
#if AXIS_IS_TMC(W)
if (w) tmc_get_registers(stepperW, n);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
@ -1244,6 +1283,15 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) {
#if AXIS_IS_TMC(K)
if (k) axis_connection += test_connection(stepperK);
#endif
#if AXIS_IS_TMC(U)
if (u) axis_connection += test_connection(stepperU);
#endif
#if AXIS_IS_TMC(V)
if (v) axis_connection += test_connection(stepperV);
#endif
#if AXIS_IS_TMC(W)
if (w) axis_connection += test_connection(stepperW);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
@ -1313,6 +1361,15 @@ void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) {
#if AXIS_HAS_SPI(K)
SET_CS_PIN(K);
#endif
#if AXIS_HAS_SPI(U)
SET_CS_PIN(U);
#endif
#if AXIS_HAS_SPI(V)
SET_CS_PIN(V);
#endif
#if AXIS_HAS_SPI(W)
SET_CS_PIN(W);
#endif
#if AXIS_HAS_SPI(E0)
SET_CS_PIN(E0);
#endif

View File

@ -348,7 +348,7 @@ void test_tmc_connection(LOGICAL_AXIS_DECL(const bool, true));
#if USE_SENSORLESS
// Track enabled status of stealthChop and only re-enable where applicable
struct sensorless_t { bool LINEAR_AXIS_ARGS(), x2, y2, z2, z3, z4; };
struct sensorless_t { bool NUM_AXIS_ARGS(), x2, y2, z2, z3, z4; };
#if ENABLED(IMPROVE_HOMING_RELIABILITY)
extern millis_t sg_guard_period;