Quad Z stepper support (#16277)
This commit is contained in:
committed by
Scott Lahteine
parent
f36f084465
commit
0fcf2b1110
@@ -37,7 +37,7 @@
|
||||
*/
|
||||
|
||||
// Change EEPROM version if the structure changes
|
||||
#define EEPROM_VERSION "V74"
|
||||
#define EEPROM_VERSION "V75"
|
||||
#define EEPROM_OFFSET 100
|
||||
|
||||
// Check the integrity of data offsets.
|
||||
@@ -120,10 +120,10 @@
|
||||
|
||||
#pragma pack(push, 1) // No padding between variables
|
||||
|
||||
typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_stepper_current_t;
|
||||
typedef struct { uint32_t X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_hybrid_threshold_t;
|
||||
typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5; } tmc_stepper_current_t;
|
||||
typedef struct { uint32_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5; } tmc_hybrid_threshold_t;
|
||||
typedef struct { int16_t X, Y, Z, X2; } tmc_sgt_t;
|
||||
typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5; } tmc_stealth_enabled_t;
|
||||
typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5; } tmc_stealth_enabled_t;
|
||||
|
||||
// Limit an index to an array size
|
||||
#define ALIM(I,ARR) _MIN(I, COUNT(ARR) - 1)
|
||||
@@ -243,11 +243,12 @@ typedef struct SettingsDataStruct {
|
||||
delta_diagonal_rod, // M665 L
|
||||
delta_segments_per_second; // M665 S
|
||||
abc_float_t delta_tower_angle_trim; // M665 XYZ
|
||||
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#elif HAS_EXTRA_ENDSTOPS
|
||||
float x2_endstop_adj, // M666 X
|
||||
y2_endstop_adj, // M666 Y
|
||||
z2_endstop_adj, // M666 Z (S2)
|
||||
z3_endstop_adj; // M666 Z (S3)
|
||||
z2_endstop_adj, // M666 (S2) Z
|
||||
z3_endstop_adj, // M666 (S3) Z
|
||||
z4_endstop_adj; // M666 (S4) Z
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -300,10 +301,10 @@ typedef struct SettingsDataStruct {
|
||||
//
|
||||
// HAS_TRINAMIC
|
||||
//
|
||||
tmc_stepper_current_t tmc_stepper_current; // M906 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
|
||||
tmc_hybrid_threshold_t tmc_hybrid_threshold; // M913 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
|
||||
tmc_stepper_current_t tmc_stepper_current; // M906 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
|
||||
tmc_hybrid_threshold_t tmc_hybrid_threshold; // M913 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
|
||||
tmc_sgt_t tmc_sgt; // M914 X Y Z X2
|
||||
tmc_stealth_enabled_t tmc_stealth_enabled; // M569 X Y Z X2 Y2 Z2 Z3 E0 E1 E2 E3 E4 E5
|
||||
tmc_stealth_enabled_t tmc_stealth_enabled; // M569 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
|
||||
|
||||
//
|
||||
// LIN_ADVANCE
|
||||
@@ -756,7 +757,7 @@ void MarlinSettings::postprocess() {
|
||||
EEPROM_WRITE(delta_segments_per_second); // 1 float
|
||||
EEPROM_WRITE(delta_tower_angle_trim); // 3 floats
|
||||
|
||||
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#elif HAS_EXTRA_ENDSTOPS
|
||||
|
||||
_FIELD_TEST(x2_endstop_adj);
|
||||
|
||||
@@ -774,18 +775,24 @@ void MarlinSettings::postprocess() {
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
#if Z_MULTI_ENDSTOPS
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS)
|
||||
EEPROM_WRITE(endstops.z2_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
|
||||
EEPROM_WRITE(endstops.z3_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
|
||||
EEPROM_WRITE(endstops.z4_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_WRITE(dummy);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -974,6 +981,9 @@ void MarlinSettings::postprocess() {
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
tmc_stepper_current.Z3 = stepperZ3.getMilliamps();
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
tmc_stepper_current.Z4 = stepperZ4.getMilliamps();
|
||||
#endif
|
||||
#if MAX_EXTRUDERS
|
||||
#if AXIS_IS_TMC(E0)
|
||||
tmc_stepper_current.E0 = stepperE0.getMilliamps();
|
||||
@@ -1037,6 +1047,9 @@ void MarlinSettings::postprocess() {
|
||||
#if AXIS_HAS_STEALTHCHOP(Z3)
|
||||
tmc_hybrid_threshold.Z3 = stepperZ3.get_pwm_thrs();
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
tmc_hybrid_threshold.Z4 = stepperZ4.get_pwm_thrs();
|
||||
#endif
|
||||
#if MAX_EXTRUDERS
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
tmc_hybrid_threshold.E0 = stepperE0.get_pwm_thrs();
|
||||
@@ -1070,7 +1083,7 @@ void MarlinSettings::postprocess() {
|
||||
#else
|
||||
const tmc_hybrid_threshold_t tmc_hybrid_threshold = {
|
||||
.X = 100, .Y = 100, .Z = 3,
|
||||
.X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3,
|
||||
.X2 = 100, .Y2 = 100, .Z2 = 3, .Z3 = 3, .Z4 = 3,
|
||||
.E0 = 30, .E1 = 30, .E2 = 30,
|
||||
.E3 = 30, .E4 = 30, .E5 = 30
|
||||
};
|
||||
@@ -1130,6 +1143,9 @@ void MarlinSettings::postprocess() {
|
||||
#if AXIS_HAS_STEALTHCHOP(Z3)
|
||||
tmc_stealth_enabled.Z3 = stepperZ3.get_stealthChop_status();
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
tmc_stealth_enabled.Z4 = stepperZ4.get_stealthChop_status();
|
||||
#endif
|
||||
#if MAX_EXTRUDERS
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
tmc_stealth_enabled.E0 = stepperE0.get_stealthChop_status();
|
||||
@@ -1585,7 +1601,7 @@ void MarlinSettings::postprocess() {
|
||||
EEPROM_READ(delta_segments_per_second); // 1 float
|
||||
EEPROM_READ(delta_tower_angle_trim); // 3 floats
|
||||
|
||||
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#elif HAS_EXTRA_ENDSTOPS
|
||||
|
||||
_FIELD_TEST(x2_endstop_adj);
|
||||
|
||||
@@ -1599,16 +1615,21 @@ void MarlinSettings::postprocess() {
|
||||
#else
|
||||
EEPROM_READ(dummy);
|
||||
#endif
|
||||
#if Z_MULTI_ENDSTOPS
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS)
|
||||
EEPROM_READ(endstops.z2_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_READ(dummy);
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3
|
||||
EEPROM_READ(endstops.z3_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_READ(dummy);
|
||||
#endif
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4
|
||||
EEPROM_READ(endstops.z4_endstop_adj); // 1 float
|
||||
#else
|
||||
EEPROM_READ(dummy);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1800,6 +1821,9 @@ void MarlinSettings::postprocess() {
|
||||
#if AXIS_IS_TMC(Z3)
|
||||
SET_CURR(Z3);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
SET_CURR(Z4);
|
||||
#endif
|
||||
#if AXIS_IS_TMC(E0)
|
||||
SET_CURR(E0);
|
||||
#endif
|
||||
@@ -1851,6 +1875,9 @@ void MarlinSettings::postprocess() {
|
||||
#if AXIS_HAS_STEALTHCHOP(Z3)
|
||||
stepperZ3.set_pwm_thrs(tmc_hybrid_threshold.Z3);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
stepperZ4.set_pwm_thrs(tmc_hybrid_threshold.Z4);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
stepperE0.set_pwm_thrs(tmc_hybrid_threshold.E0);
|
||||
#endif
|
||||
@@ -1877,7 +1904,7 @@ void MarlinSettings::postprocess() {
|
||||
// TMC StallGuard threshold.
|
||||
// X and X2 use the same value
|
||||
// Y and Y2 use the same value
|
||||
// Z, Z2 and Z3 use the same value
|
||||
// Z, Z2, Z3 and Z4 use the same value
|
||||
//
|
||||
{
|
||||
tmc_sgt_t tmc_sgt;
|
||||
@@ -1914,6 +1941,9 @@ void MarlinSettings::postprocess() {
|
||||
#if AXIS_HAS_STALLGUARD(Z3)
|
||||
stepperZ3.homing_threshold(tmc_sgt.Z);
|
||||
#endif
|
||||
#if AXIS_HAS_STALLGUARD(Z4)
|
||||
stepperZ4.homing_threshold(tmc_sgt.Z);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -1951,6 +1981,9 @@ void MarlinSettings::postprocess() {
|
||||
#if AXIS_HAS_STEALTHCHOP(Z3)
|
||||
SET_STEPPING_MODE(Z3);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
SET_STEPPING_MODE(Z4);
|
||||
#endif
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
SET_STEPPING_MODE(E0);
|
||||
#endif
|
||||
@@ -2433,51 +2466,39 @@ void MarlinSettings::reset() {
|
||||
delta_segments_per_second = DELTA_SEGMENTS_PER_SECOND;
|
||||
delta_tower_angle_trim = dta;
|
||||
|
||||
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#endif
|
||||
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
endstops.x2_endstop_adj = (
|
||||
#ifdef X_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
X_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
endstops.y2_endstop_adj = (
|
||||
#ifdef Y_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
Y_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
#endif
|
||||
#if ENABLED(Z_DUAL_ENDSTOPS)
|
||||
endstops.z2_endstop_adj = (
|
||||
#ifdef Z_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
Z_DUAL_ENDSTOPS_ADJUSTMENT
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
#elif ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
endstops.z2_endstop_adj = (
|
||||
#ifdef Z_TRIPLE_ENDSTOPS_ADJUSTMENT2
|
||||
Z_TRIPLE_ENDSTOPS_ADJUSTMENT2
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
endstops.z3_endstop_adj = (
|
||||
#ifdef Z_TRIPLE_ENDSTOPS_ADJUSTMENT3
|
||||
Z_TRIPLE_ENDSTOPS_ADJUSTMENT3
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
);
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
#ifndef X2_ENDSTOP_ADJUSTMENT
|
||||
#define X2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.x2_endstop_adj = X2_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
#ifndef Y2_ENDSTOP_ADJUSTMENT
|
||||
#define Y2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.y2_endstop_adj = Y2_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS)
|
||||
#ifndef Z2_ENDSTOP_ADJUSTMENT
|
||||
#define Z2_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z2_endstop_adj = Z2_ENDSTOP_ADJUSTMENT;
|
||||
#if NUM_Z_STEPPER_DRIVERS >= 3
|
||||
#ifndef Z3_ENDSTOP_ADJUSTMENT
|
||||
#define Z3_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z3_endstop_adj = Z3_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
#if NUM_Z_STEPPER_DRIVERS >= 4
|
||||
#ifndef Z4_ENDSTOP_ADJUSTMENT
|
||||
#define Z4_ENDSTOP_ADJUSTMENT 0
|
||||
#endif
|
||||
endstops.z4_endstop_adj = Z4_ENDSTOP_ADJUSTMENT;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//
|
||||
@@ -3016,25 +3037,30 @@ void MarlinSettings::reset() {
|
||||
, SP_Z_STR, LINEAR_UNIT(delta_tower_angle_trim.c)
|
||||
);
|
||||
|
||||
#elif EITHER(X_DUAL_ENDSTOPS, Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS
|
||||
#elif HAS_EXTRA_ENDSTOPS
|
||||
|
||||
CONFIG_ECHO_HEADING("Endstop adjustment:");
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOPGM(" M666");
|
||||
#if ENABLED(X_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
|
||||
SERIAL_ECHOLNPAIR_P(SP_X_STR, LINEAR_UNIT(endstops.x2_endstop_adj));
|
||||
#endif
|
||||
#if ENABLED(Y_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
|
||||
SERIAL_ECHOLNPAIR_P(SP_Y_STR, LINEAR_UNIT(endstops.y2_endstop_adj));
|
||||
#endif
|
||||
#if ENABLED(Z_TRIPLE_ENDSTOPS)
|
||||
SERIAL_ECHOLNPAIR("S1 Z", LINEAR_UNIT(endstops.z2_endstop_adj));
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOPAIR(" M666 S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
|
||||
#elif ENABLED(Z_DUAL_ENDSTOPS)
|
||||
SERIAL_ECHOPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
|
||||
#if ENABLED(Z_MULTI_ENDSTOPS)
|
||||
#if NUM_Z_STEPPER_DRIVERS >= 3
|
||||
SERIAL_ECHOPAIR(" S2 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOPAIR(" M666 S3 Z", LINEAR_UNIT(endstops.z3_endstop_adj));
|
||||
#if NUM_Z_STEPPER_DRIVERS >= 4
|
||||
CONFIG_ECHO_START();
|
||||
SERIAL_ECHOPAIR(" M666 S4 Z", LINEAR_UNIT(endstops.z4_endstop_adj));
|
||||
#endif
|
||||
#else
|
||||
SERIAL_ECHOLNPAIR_P(SP_Z_STR, LINEAR_UNIT(endstops.z2_endstop_adj));
|
||||
#endif
|
||||
#endif
|
||||
SERIAL_EOL();
|
||||
|
||||
#endif // [XYZ]_DUAL_ENDSTOPS
|
||||
|
||||
@@ -3218,6 +3244,11 @@ void MarlinSettings::reset() {
|
||||
SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.getMilliamps());
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(Z4)
|
||||
say_M906(forReplay);
|
||||
SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.getMilliamps());
|
||||
#endif
|
||||
|
||||
#if AXIS_IS_TMC(E0)
|
||||
say_M906(forReplay);
|
||||
SERIAL_ECHOLNPAIR(" T0 E", stepperE0.getMilliamps());
|
||||
@@ -3287,6 +3318,11 @@ void MarlinSettings::reset() {
|
||||
SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.get_pwm_thrs());
|
||||
#endif
|
||||
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
say_M913(forReplay);
|
||||
SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.get_pwm_thrs());
|
||||
#endif
|
||||
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
say_M913(forReplay);
|
||||
SERIAL_ECHOLNPAIR(" T0 E", stepperE0.get_pwm_thrs());
|
||||
@@ -3356,6 +3392,12 @@ void MarlinSettings::reset() {
|
||||
SERIAL_ECHOLNPAIR(" I2 Z", stepperZ3.homing_threshold());
|
||||
#endif
|
||||
|
||||
#if Z4_SENSORLESS
|
||||
CONFIG_ECHO_START();
|
||||
say_M914();
|
||||
SERIAL_ECHOLNPAIR(" I3 Z", stepperZ4.homing_threshold());
|
||||
#endif
|
||||
|
||||
#endif // USE_SENSORLESS
|
||||
|
||||
/**
|
||||
@@ -3415,6 +3457,10 @@ void MarlinSettings::reset() {
|
||||
if (stepperZ3.get_stealthChop_status()) { say_M569(forReplay, PSTR("I2 Z"), true); }
|
||||
#endif
|
||||
|
||||
#if AXIS_HAS_STEALTHCHOP(Z4)
|
||||
if (stepperZ4.get_stealthChop_status()) { say_M569(forReplay, PSTR("I3 Z"), true); }
|
||||
#endif
|
||||
|
||||
#if AXIS_HAS_STEALTHCHOP(E0)
|
||||
if (stepperE0.get_stealthChop_status()) { say_M569(forReplay, PSTR("T0 E"), true); }
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user