Save/Load distinct TMC SG thresholds (#17741)

This commit is contained in:
Neil van Geffen 2020-04-28 18:22:03 +12:00 committed by GitHub
parent 07a6bf9b84
commit 7c3909bc3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 73 deletions

View File

@ -2393,7 +2393,11 @@
#define X_STALL_SENSITIVITY 8
#define X2_STALL_SENSITIVITY X_STALL_SENSITIVITY
#define Y_STALL_SENSITIVITY 8
//#define Z_STALL_SENSITIVITY 8
#define Y2_STALL_SENSITIVITY Y_STALL_SENSITIVITY
#define Z_STALL_SENSITIVITY 8
#define Z2_STALL_SENSITIVITY Z_STALL_SENSITIVITY
#define Z3_STALL_SENSITIVITY Z_STALL_SENSITIVITY
#define Z4_STALL_SENSITIVITY Z_STALL_SENSITIVITY
//#define SPI_ENDSTOPS // TMC2130 only
//#define IMPROVE_HOMING_RELIABILITY
#endif

View File

@ -37,7 +37,7 @@
*/
// Change EEPROM version if the structure changes
#define EEPROM_VERSION "V77"
#define EEPROM_VERSION "V78"
#define EEPROM_OFFSET 100
// Check the integrity of data offsets.
@ -135,7 +135,7 @@
typedef struct { uint16_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stepper_current_t;
typedef struct { uint32_t X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_hybrid_threshold_t;
typedef struct { int16_t X, Y, Z, X2; } tmc_sgt_t;
typedef struct { int16_t X, Y, Z, X2, Y2, Z2, Z3, Z4; } tmc_sgt_t;
typedef struct { bool X, Y, Z, X2, Y2, Z2, Z3, Z4, E0, E1, E2, E3, E4, E5, E6, E7; } tmc_stealth_enabled_t;
// Limit an index to an array size
@ -328,7 +328,7 @@ typedef struct SettingsDataStruct {
//
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_sgt_t tmc_sgt; // M914 X Y Z X2 Y2 Z2 Z3 Z4
tmc_stealth_enabled_t tmc_stealth_enabled; // M569 X Y Z X2 Y2 Z2 Z3 Z4 E0 E1 E2 E3 E4 E5
//
@ -1112,10 +1112,14 @@ void MarlinSettings::postprocess() {
{
tmc_sgt_t tmc_sgt{0};
#if USE_SENSORLESS
TERN_(X_SENSORLESS, tmc_sgt.X = stepperX.homing_threshold());
TERN_(X_SENSORLESS, tmc_sgt.X = stepperX.homing_threshold());
TERN_(X2_SENSORLESS, tmc_sgt.X2 = stepperX2.homing_threshold());
TERN_(Y_SENSORLESS, tmc_sgt.Y = stepperY.homing_threshold());
TERN_(Z_SENSORLESS, tmc_sgt.Z = stepperZ.homing_threshold());
TERN_(Y_SENSORLESS, tmc_sgt.Y = stepperY.homing_threshold());
TERN_(Y2_SENSORLESS, tmc_sgt.Y2 = stepperY2.homing_threshold());
TERN_(Z_SENSORLESS, tmc_sgt.Z = stepperZ.homing_threshold());
TERN_(Z2_SENSORLESS, tmc_sgt.Z2 = stepperZ2.homing_threshold());
TERN_(Z3_SENSORLESS, tmc_sgt.Z3 = stepperZ3.homing_threshold());
TERN_(Z4_SENSORLESS, tmc_sgt.Z4 = stepperZ4.homing_threshold());
#endif
EEPROM_WRITE(tmc_sgt);
}
@ -1929,9 +1933,6 @@ void MarlinSettings::postprocess() {
//
// TMC StallGuard threshold.
// X and X2 use the same value
// Y and Y2 use the same value
// Z, Z2, Z3 and Z4 use the same value
//
{
tmc_sgt_t tmc_sgt;
@ -1939,37 +1940,14 @@ void MarlinSettings::postprocess() {
EEPROM_READ(tmc_sgt);
#if USE_SENSORLESS
if (!validating) {
#ifdef X_STALL_SENSITIVITY
#if AXIS_HAS_STALLGUARD(X)
stepperX.homing_threshold(tmc_sgt.X);
#endif
#if AXIS_HAS_STALLGUARD(X2) && !X2_SENSORLESS
stepperX2.homing_threshold(tmc_sgt.X);
#endif
#endif
TERN_(X_SENSORLESS, stepperX.homing_threshold(tmc_sgt.X));
TERN_(X2_SENSORLESS, stepperX2.homing_threshold(tmc_sgt.X2));
#ifdef Y_STALL_SENSITIVITY
#if AXIS_HAS_STALLGUARD(Y)
stepperY.homing_threshold(tmc_sgt.Y);
#endif
#if AXIS_HAS_STALLGUARD(Y2)
stepperY2.homing_threshold(tmc_sgt.Y);
#endif
#endif
#ifdef Z_STALL_SENSITIVITY
#if AXIS_HAS_STALLGUARD(Z)
stepperZ.homing_threshold(tmc_sgt.Z);
#endif
#if AXIS_HAS_STALLGUARD(Z2)
stepperZ2.homing_threshold(tmc_sgt.Z);
#endif
#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
TERN_(Y_SENSORLESS, stepperY.homing_threshold(tmc_sgt.Y));
TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(tmc_sgt.Y2));
TERN_(Z_SENSORLESS, stepperZ.homing_threshold(tmc_sgt.Z));
TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(tmc_sgt.Z2));
TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(tmc_sgt.Z3));
TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(tmc_sgt.Z4));
}
#endif
}

View File

@ -770,39 +770,14 @@ void reset_trinamic_drivers() {
#endif
#if USE_SENSORLESS
#if X_SENSORLESS
#if AXIS_HAS_STALLGUARD(X)
stepperX.homing_threshold(X_STALL_SENSITIVITY);
#endif
#if AXIS_HAS_STALLGUARD(X2) && !X2_SENSORLESS
stepperX2.homing_threshold(X_STALL_SENSITIVITY);
#endif
#endif
#if X2_SENSORLESS
stepperX2.homing_threshold(X2_STALL_SENSITIVITY);
#endif
#if Y_SENSORLESS
#if AXIS_HAS_STALLGUARD(Y)
stepperY.homing_threshold(Y_STALL_SENSITIVITY);
#endif
#if AXIS_HAS_STALLGUARD(Y2)
stepperY2.homing_threshold(Y_STALL_SENSITIVITY);
#endif
#endif
#if Z_SENSORLESS
#if AXIS_HAS_STALLGUARD(Z)
stepperZ.homing_threshold(Z_STALL_SENSITIVITY);
#endif
#if AXIS_HAS_STALLGUARD(Z2)
stepperZ2.homing_threshold(Z_STALL_SENSITIVITY);
#endif
#if AXIS_HAS_STALLGUARD(Z3)
stepperZ3.homing_threshold(Z_STALL_SENSITIVITY);
#endif
#if AXIS_HAS_STALLGUARD(Z4)
stepperZ4.homing_threshold(Z_STALL_SENSITIVITY);
#endif
#endif
TERN_(X_SENSORLESS, stepperX.homing_threshold(X_STALL_SENSITIVITY));
TERN_(X2_SENSORLESS, stepperX2.homing_threshold(X2_STALL_SENSITIVITY));
TERN_(Y_SENSORLESS, stepperY.homing_threshold(Y_STALL_SENSITIVITY));
TERN_(Y2_SENSORLESS, stepperY2.homing_threshold(Y2_STALL_SENSITIVITY));
TERN_(Z_SENSORLESS, stepperZ.homing_threshold(Z_STALL_SENSITIVITY));
TERN_(Z2_SENSORLESS, stepperZ2.homing_threshold(Z2_STALL_SENSITIVITY));
TERN_(Z3_SENSORLESS, stepperZ3.homing_threshold(Z3_STALL_SENSITIVITY));
TERN_(Z4_SENSORLESS, stepperZ4.homing_threshold(Z4_STALL_SENSITIVITY));
#endif
#ifdef TMC_ADV