Coolstep for TMC2130, 2209, 5130, 5160 (#16790)

This commit is contained in:
Fabio Santos 2020-02-08 19:01:57 -08:00 committed by GitHub
parent f0cbc85a07
commit 894762259b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 473 additions and 86 deletions

View file

@ -674,11 +674,6 @@
//#define X_DRIVER_TYPE A4988 //#define X_DRIVER_TYPE A4988
//#define Y_DRIVER_TYPE A4988 //#define Y_DRIVER_TYPE A4988
//#define Z_DRIVER_TYPE A4988 //#define Z_DRIVER_TYPE A4988
//#define X2_DRIVER_TYPE A4988
//#define Y2_DRIVER_TYPE A4988
//#define Z2_DRIVER_TYPE A4988
//#define Z3_DRIVER_TYPE A4988
//#define Z4_DRIVER_TYPE A4988
//#define E0_DRIVER_TYPE A4988 //#define E0_DRIVER_TYPE A4988
//#define E1_DRIVER_TYPE A4988 //#define E1_DRIVER_TYPE A4988
//#define E2_DRIVER_TYPE A4988 //#define E2_DRIVER_TYPE A4988

View file

@ -2275,6 +2275,166 @@
#define E6_HYBRID_THRESHOLD 30 #define E6_HYBRID_THRESHOLD 30
#define E7_HYBRID_THRESHOLD 30 #define E7_HYBRID_THRESHOLD 30
/**
* CoolStep. Currently supported for TMC2130, TMC2209, TMC5130 and TMC5160 only.
* This mode allows for cooler steppers and energy savings.
* The driver will switch to coolStep when stepper speed is over COOLSTEP_THRESHOLD mm/s.
*
* If SG_RESULT goes below COOLSTEP_LOWER_LOAD_THRESHOLD * 32 stepper current will be increased.
* Set to 0 to disable CoolStep.
*
* If SG_RESULT goes above (COOLSTEP_LOWER_LOAD_THRESHOLD + COOLSTEP_UPPER_LOAD_THRESHOLD + 1) * 32
* stepper current will be decreased.
*
* SEUP sets the increase step width. Value range is 0..3 and computed as 2^SEUP.
* SEDN sets the decrease delay. Value range is 0..3, 0 being the slowest.
* SEIMIN sets the lower current limit. 0: 1/2 of IRUN, 1:1/4 of IRUN
*/
#if AXIS_HAS_COOLSTEP(X)
#define X_COOLSTEP_SPEED_THRESHOLD 5
#define X_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define X_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define X_COOLSTEP_SEUP 2
#define X_COOLSTEP_SEDN 0
#define X_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(X2)
#define X2_COOLSTEP_SPEED_THRESHOLD 5
#define X2_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define X2_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define X2_COOLSTEP_SEUP 2
#define X2_COOLSTEP_SEDN 0
#define X2_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(Y)
#define Y_COOLSTEP_SPEED_THRESHOLD 5
#define Y_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define Y_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define Y_COOLSTEP_SEUP 2
#define Y_COOLSTEP_SEDN 0
#define Y_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(Y2)
#define Y2_COOLSTEP_SPEED_THRESHOLD 5
#define Y2_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define Y2_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define Y2_COOLSTEP_SEUP 2
#define Y2_COOLSTEP_SEDN 0
#define Y2_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(Z)
#define Z_COOLSTEP_SPEED_THRESHOLD 5
#define Z_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define Z_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define Z_COOLSTEP_SEUP 2
#define Z_COOLSTEP_SEDN 0
#define Z_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(Z2)
#define Z2_COOLSTEP_SPEED_THRESHOLD 5
#define Z2_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define Z2_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define Z2_COOLSTEP_SEUP 2
#define Z2_COOLSTEP_SEDN 0
#define Z2_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(Z3)
#define Z3_COOLSTEP_SPEED_THRESHOLD 5
#define Z3_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define Z3_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define Z3_COOLSTEP_SEUP 2
#define Z3_COOLSTEP_SEDN 0
#define Z3_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(Z4)
#define Z4_COOLSTEP_SPEED_THRESHOLD 5
#define Z4_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define Z4_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define Z4_COOLSTEP_SEUP 2
#define Z4_COOLSTEP_SEDN 0
#define Z4_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E0)
#define E0_COOLSTEP_SPEED_THRESHOLD 5
#define E0_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E0_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E0_COOLSTEP_SEUP 2
#define E0_COOLSTEP_SEDN 0
#define E0_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E1)
#define E1_COOLSTEP_SPEED_THRESHOLD 5
#define E1_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E1_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E1_COOLSTEP_SEUP 2
#define E1_COOLSTEP_SEDN 0
#define E1_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E2)
#define E2_COOLSTEP_SPEED_THRESHOLD 5
#define E2_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E2_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E2_COOLSTEP_SEUP 2
#define E2_COOLSTEP_SEDN 0
#define E2_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E3)
#define E3_COOLSTEP_SPEED_THRESHOLD 5
#define E3_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E3_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E3_COOLSTEP_SEUP 2
#define E3_COOLSTEP_SEDN 0
#define E3_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E4)
#define E4_COOLSTEP_SPEED_THRESHOLD 5
#define E4_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E4_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E4_COOLSTEP_SEUP 2
#define E4_COOLSTEP_SEDN 0
#define E4_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E5)
#define E5_COOLSTEP_SPEED_THRESHOLD 5
#define E5_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E5_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E5_COOLSTEP_SEUP 2
#define E5_COOLSTEP_SEDN 0
#define E5_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E6)
#define E6_COOLSTEP_SPEED_THRESHOLD 5
#define E6_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E6_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E6_COOLSTEP_SEUP 2
#define E6_COOLSTEP_SEDN 0
#define E6_COOLSTEP_SEIMIN 1
#endif
#if AXIS_HAS_COOLSTEP(E7)
#define E7_COOLSTEP_SPEED_THRESHOLD 5
#define E7_COOLSTEP_LOWER_LOAD_THRESHOLD 7
#define E7_COOLSTEP_UPPER_LOAD_THRESHOLD 0
#define E7_COOLSTEP_SEUP 2
#define E7_COOLSTEP_SEDN 0
#define E7_COOLSTEP_SEIMIN 1
#endif
/** /**
* Use StallGuard2 to home / probe X, Y, Z. * Use StallGuard2 to home / probe X, Y, Z.
* *

View file

@ -60,6 +60,6 @@
#error "TMCStepper includes SoftwareSerial.h which is incompatible with ENDSTOP_INTERRUPTS_FEATURE. Disable ENDSTOP_INTERRUPTS_FEATURE to continue." #error "TMCStepper includes SoftwareSerial.h which is incompatible with ENDSTOP_INTERRUPTS_FEATURE. Disable ENDSTOP_INTERRUPTS_FEATURE to continue."
#endif #endif
#if TMC_HAS_SW_SERIAL && ENABLED(MONITOR_DRIVER_STATUS) #if HAS_TMC_SW_SERIAL && ENABLED(MONITOR_DRIVER_STATUS)
#error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue." #error "MONITOR_DRIVER_STATUS causes performance issues when used with SoftwareSerial-connected drivers. Disable MONITOR_DRIVER_STATUS or use hardware serial to continue."
#endif #endif

View file

@ -56,6 +56,6 @@
#error "FAST_PWM_FAN is not yet implemented for this platform." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform." #error "TMC220x Software Serial is not supported on this platform."
#endif #endif

View file

@ -29,7 +29,7 @@
#error "FAST_PWM_FAN is not yet implemented for this platform." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform." #error "TMC220x Software Serial is not supported on this platform."
#endif #endif

View file

@ -34,6 +34,6 @@
#error "FAST_PWM_FAN is not yet implemented for this platform." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform." #error "TMC220x Software Serial is not supported on this platform."
#endif #endif

View file

@ -47,6 +47,6 @@
#warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Activator" #warning "Did you activate the SmartEEPROM? See https://github.com/GMagician/SAMD51-SmartEEprom-Activator"
#endif #endif
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform." #error "TMC220x Software Serial is not supported on this platform."
#endif #endif

View file

@ -28,7 +28,7 @@
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#include "../shared/Delay.h" #include "../shared/Delay.h"
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#include "SoftwareSerial.h" #include "SoftwareSerial.h"
#endif #endif
@ -87,7 +87,7 @@ void HAL_init() {
while (!LL_PWR_IsActiveFlag_BRR()); while (!LL_PWR_IsActiveFlag_BRR());
#endif // EEPROM_EMULATED_SRAM #endif // EEPROM_EMULATED_SRAM
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0); SoftwareSerial::setInterruptPriority(SWSERIAL_TIMER_IRQ_PRIO, 0);
#endif #endif
} }

View file

@ -37,7 +37,7 @@
#error "FAST_PWM_FAN is not yet implemented for this platform." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if !defined(HAVE_SW_SERIAL) && TMC_HAS_SW_SERIAL #if !defined(HAVE_SW_SERIAL) && HAS_TMC_SW_SERIAL
#warning "With TMC2208/9 consider using SoftwareSerialM with HAVE_SW_SERIAL and appropriate SS_TIMER." #warning "With TMC2208/9 consider using SoftwareSerialM with HAVE_SW_SERIAL and appropriate SS_TIMER."
#error "Missing SoftwareSerial implementation." #error "Missing SoftwareSerial implementation."
#endif #endif

View file

@ -36,6 +36,6 @@
#error "FAST_PWM_FAN is not yet implemented for this platform." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform." #error "TMC220x Software Serial is not supported on this platform."
#endif #endif

View file

@ -33,6 +33,6 @@
#error "FAST_PWM_FAN is not yet implemented for this platform." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform." #error "TMC220x Software Serial is not supported on this platform."
#endif #endif

View file

@ -33,6 +33,6 @@
#error "FAST_PWM_FAN is not yet implemented for this platform." #error "FAST_PWM_FAN is not yet implemented for this platform."
#endif #endif
#if TMC_HAS_SW_SERIAL #if HAS_TMC_SW_SERIAL
#error "TMC220x Software Serial is not supported on this platform." #error "TMC220x Software Serial is not supported on this platform."
#endif #endif

View file

@ -892,7 +892,7 @@ void setup() {
SERIAL_ECHOLNPGM("start"); SERIAL_ECHOLNPGM("start");
SERIAL_ECHO_START(); SERIAL_ECHO_START();
#if TMC_HAS_SPI #if HAS_TMC_SPI
#if DISABLED(TMC_USE_SW_SPI) #if DISABLED(TMC_USE_SW_SPI)
SPI.begin(); SPI.begin();
#endif #endif

View file

@ -52,7 +52,7 @@
#define _TMC5160_STANDALONE 0x5160B #define _TMC5160_STANDALONE 0x5160B
#define _DRIVER_ID(V) _CAT(_, V) #define _DRIVER_ID(V) _CAT(_, V)
#define _AXIS_DRIVER_TYPE(A,T) (_DRIVER_ID(A##_DRIVER_TYPE) == _CAT(_, T)) #define _AXIS_DRIVER_TYPE(A,T) (_DRIVER_ID(A##_DRIVER_TYPE) == _DRIVER_ID(T))
#define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T) #define AXIS_DRIVER_TYPE_X(T) _AXIS_DRIVER_TYPE(X,T)
#define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T) #define AXIS_DRIVER_TYPE_Y(T) _AXIS_DRIVER_TYPE(Y,T)
@ -148,19 +148,32 @@
|| AXIS_DRIVER_TYPE(A,TMC5130) \ || AXIS_DRIVER_TYPE(A,TMC5130) \
|| AXIS_DRIVER_TYPE(A,TMC5160) ) || AXIS_DRIVER_TYPE(A,TMC5160) )
#define AXIS_HAS_SG_RESULT(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|| AXIS_DRIVER_TYPE(A,TMC2160) \
|| AXIS_DRIVER_TYPE(A,TMC2208) \
|| AXIS_DRIVER_TYPE(A,TMC2209) )
#define AXIS_HAS_COOLSTEP(A) ( AXIS_DRIVER_TYPE(A,TMC2130) \
|| AXIS_DRIVER_TYPE(A,TMC2209) \
|| AXIS_DRIVER_TYPE(A,TMC5130) \
|| AXIS_DRIVER_TYPE(A,TMC5160) )
#define _OR_EAH(N,T) || AXIS_HAS_##T(E##N)
#define E_AXIS_HAS(T) (0 RREPEAT2(E_STEPPERS, _OR_EAH, T))
#define ANY_AXIS_HAS(T) ( AXIS_HAS_##T(X) || AXIS_HAS_##T(X2) \ #define ANY_AXIS_HAS(T) ( AXIS_HAS_##T(X) || AXIS_HAS_##T(X2) \
|| AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \ || AXIS_HAS_##T(Y) || AXIS_HAS_##T(Y2) \
|| AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) \ || AXIS_HAS_##T(Z) || AXIS_HAS_##T(Z2) \
|| AXIS_HAS_##T(Z3) \ || AXIS_HAS_##T(Z3) || AXIS_HAS_##T(Z4) \
|| AXIS_HAS_##T(E0) || AXIS_HAS_##T(E1) \ || E_AXIS_HAS(T) )
|| AXIS_HAS_##T(E2) || AXIS_HAS_##T(E3) \
|| AXIS_HAS_##T(E4) || AXIS_HAS_##T(E5) \
|| AXIS_HAS_##T(E6) || AXIS_HAS_##T(E7) )
#define HAS_STEALTHCHOP ANY_AXIS_HAS(STEALTHCHOP) #define HAS_STEALTHCHOP ANY_AXIS_HAS(STEALTHCHOP)
#define HAS_STALLGUARD ANY_AXIS_HAS(STALLGUARD) #define HAS_STALLGUARD ANY_AXIS_HAS(STALLGUARD)
#define TMC_HAS_SPI ANY_AXIS_HAS(SPI) #define HAS_SG_RESULT ANY_AXIS_HAS(SG_RESULT)
#define TMC_HAS_SW_SERIAL ANY_AXIS_HAS(SW_SERIAL) #define HAS_COOLSTEP ANY_AXIS_HAS(COOLSTEP)
#define HAS_TMC_UART ANY_AXIS_HAS(UART)
#define HAS_TMC_SPI ANY_AXIS_HAS(SPI)
#define HAS_TMC_SW_SERIAL ANY_AXIS_HAS(SW_SERIAL)
// //
// Stretching 'drivers.h' to include LPC/SAMD51 SD options // Stretching 'drivers.h' to include LPC/SAMD51 SD options

View file

@ -629,6 +629,15 @@
default: break; default: break;
} }
} }
#if HAS_DRIVER(TMC2209)
static void _tmc_parse_drv_status(TMC2209Stepper &st, const TMC_drv_status_enum i) {
switch (i) {
case TMC_SG_RESULT: SERIAL_PRINT(st.SG_RESULT(), DEC); break;
default: _tmc_parse_drv_status(static_cast<TMC2208Stepper &>(st), i); break;
}
}
#endif
#endif #endif
#if HAS_DRIVER(TMC2660) #if HAS_DRIVER(TMC2660)
@ -891,24 +900,24 @@
TMC_REPORT("stealthChop", TMC_STEALTHCHOP); TMC_REPORT("stealthChop", TMC_STEALTHCHOP);
TMC_REPORT("msteps\t", TMC_MICROSTEPS); TMC_REPORT("msteps\t", TMC_MICROSTEPS);
TMC_REPORT("tstep\t", TMC_TSTEP); TMC_REPORT("tstep\t", TMC_TSTEP);
TMC_REPORT("pwm\nthreshold", TMC_TPWMTHRS); TMC_REPORT("PWM thresh.", TMC_TPWMTHRS);
TMC_REPORT("[mm/s]\t", TMC_TPWMTHRS_MMS); TMC_REPORT("[mm/s]\t", TMC_TPWMTHRS_MMS);
TMC_REPORT("OT prewarn", TMC_OTPW); TMC_REPORT("OT prewarn", TMC_OTPW);
#if ENABLED(MONITOR_DRIVER_STATUS) #if ENABLED(MONITOR_DRIVER_STATUS)
TMC_REPORT("OT prewarn has\n" TMC_REPORT("triggered\n OTP\t", TMC_OTPW_TRIGGERED);
"been triggered", TMC_OTPW_TRIGGERED);
#endif #endif
TMC_REPORT("off time", TMC_TOFF); TMC_REPORT("off time", TMC_TOFF);
TMC_REPORT("blank time", TMC_TBL); TMC_REPORT("blank time", TMC_TBL);
TMC_REPORT("hysteresis\n-end\t", TMC_HEND); TMC_REPORT("hysteresis\n -end\t", TMC_HEND);
TMC_REPORT("-start\t", TMC_HSTRT); TMC_REPORT(" -start\t", TMC_HSTRT);
TMC_REPORT("Stallguard thrs", TMC_SGT); TMC_REPORT("Stallguard thrs", TMC_SGT);
DRV_REPORT("DRVSTATUS", TMC_DRV_CODES); DRV_REPORT("DRVSTATUS", TMC_DRV_CODES);
#if HAS_TMCX1X0 #if HAS_TMCX1X0 || HAS_TMC220x
DRV_REPORT("stallguard\t", TMC_STALLGUARD);
DRV_REPORT("sg_result", TMC_SG_RESULT); DRV_REPORT("sg_result", TMC_SG_RESULT);
DRV_REPORT("fsactive\t", TMC_FSACTIVE); #endif
#if HAS_TMCX1X0
DRV_REPORT("stallguard", TMC_STALLGUARD);
DRV_REPORT("fsactive", TMC_FSACTIVE);
#endif #endif
DRV_REPORT("stst\t", TMC_STST); DRV_REPORT("stst\t", TMC_STST);
DRV_REPORT("olb\t", TMC_OLB); DRV_REPORT("olb\t", TMC_OLB);
@ -1103,7 +1112,7 @@
#endif // USE_SENSORLESS #endif // USE_SENSORLESS
#if TMC_HAS_SPI #if HAS_TMC_SPI
#define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) #define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH)
void tmc_init_cs_pins() { void tmc_init_cs_pins() {
#if AXIS_HAS_SPI(X) #if AXIS_HAS_SPI(X)
@ -1155,7 +1164,7 @@
SET_CS_PIN(E7); SET_CS_PIN(E7);
#endif #endif
} }
#endif // TMC_HAS_SPI #endif // HAS_TMC_SPI
template<typename TMC> template<typename TMC>
static bool test_connection(TMC &st) { static bool test_connection(TMC &st) {

View file

@ -110,6 +110,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); } inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return this->en_pwm_mode(); } inline bool get_stealthChop_status() { return this->en_pwm_mode(); }
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() { uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -121,6 +122,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
#endif #endif
} }
#endif #endif
#if USE_SENSORLESS #if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC::sgt(); } inline int16_t homing_threshold() { return TMC::sgt(); }
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
@ -135,6 +137,13 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
#endif #endif
#endif #endif
uint32_t get_cool_thrs() {
return _tmc_thrs(this->microsteps(), this->TCOOLTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_cool_thrs(const uint32_t thrs) {
TMC::TCOOLTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
}
#if HAS_LCD_MENU #if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); } inline void refresh_stepper_current() { rms_current(this->val_mA); }
@ -149,6 +158,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
static constexpr int8_t sgt_min = -64, static constexpr int8_t sgt_min = -64,
sgt_max = 63; sgt_max = 63;
}; };
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC2208Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> { class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC2208Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
public: public:
@ -172,6 +182,7 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); } inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return !this->en_spreadCycle(); } inline bool get_stealthChop_status() { return !this->en_spreadCycle(); }
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() { uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -217,6 +228,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); } inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return !this->en_spreadCycle(); } inline bool get_stealthChop_status() { return !this->en_spreadCycle(); }
#endif #endif
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() { uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]); return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -228,6 +240,14 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
#endif #endif
} }
#endif #endif
uint32_t get_cool_thrs() {
return _tmc_thrs(this->microsteps(), this->TCOOLTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_cool_thrs(const uint32_t thrs) {
TMC2209Stepper::TCOOLTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
}
#if USE_SENSORLESS #if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); } inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); }
void homing_threshold(int16_t sgt_val) { void homing_threshold(int16_t sgt_val) {
@ -241,7 +261,6 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
#if HAS_LCD_MENU #if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); } inline void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); } inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
#endif #endif
@ -391,7 +410,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#endif // USE_SENSORLESS #endif // USE_SENSORLESS
#if TMC_HAS_SPI #if HAS_TMC_SPI
void tmc_init_cs_pins(); void tmc_init_cs_pins();
#endif #endif

View file

@ -2040,6 +2040,62 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "LED_USER_PRESET_STARTUP is required for FYSETC_MINI_12864 2.x displays." #error "LED_USER_PRESET_STARTUP is required for FYSETC_MINI_12864 2.x displays."
#endif #endif
/**
* Make sure CoolStep settings exist
*/
#if HAS_COOLSTEP
#define NEEDS_COOLSTEP(A) AXIS_HAS_COOLSTEP(A) && !(defined(A##_COOLSTEP_SPEED_THRESHOLD) && defined(A##_COOLSTEP_LOWER_LOAD_THRESHOLD) && defined(A##_COOLSTEP_UPPER_LOAD_THRESHOLD) && defined(A##_COOLSTEP_SEUP) && defined(A##_COOLSTEP_SEDN) && defined(A##_COOLSTEP_SEIMIN))
#if NEEDS_COOLSTEP(X)
#error "X COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(X2)
#error "X2 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(Y)
#error "Y COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(Y2)
#error "Y2 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(Z)
#error "Z COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(Z2)
#error "Z2 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(Z3)
#error "Z3 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(Z4)
#error "Z4 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E0)
#error "E0 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E1)
#error "E1 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E2)
#error "E2 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E3)
#error "E3 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E4)
#error "E4 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E5)
#error "E5 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E6)
#error "E6 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#if NEEDS_COOLSTEP(E7)
#error "E7 COOLSTEP settings must be defined in Configuration_adv.h."
#endif
#undef NEEDS_COOLSTEP
#endif
/** /**
* Check existing CS pins against enabled TMC SPI drivers. * Check existing CS pins against enabled TMC SPI drivers.
*/ */
@ -2650,6 +2706,6 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
* Check to make sure MONITOR_DRIVER_STATUS isn't enabled * Check to make sure MONITOR_DRIVER_STATUS isn't enabled
* on boards where TMC drivers share the SPI bus with SD. * on boards where TMC drivers share the SPI bus with SD.
*/ */
#if TMC_HAS_SPI && ALL(MONITOR_DRIVER_STATUS, SDSUPPORT, USES_SHARED_SPI) #if HAS_TMC_SPI && ALL(MONITOR_DRIVER_STATUS, SDSUPPORT, USES_SHARED_SPI)
#error "MONITOR_DRIVER_STATUS and SDSUPPORT cannot be used together on boards with shared SPI." #error "MONITOR_DRIVER_STATUS and SDSUPPORT cannot be used together on boards with shared SPI."
#endif #endif

View file

@ -1496,7 +1496,7 @@ void Stepper::stepper_pulse_phase_isr() {
#define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP #define _APPLY_STEP(AXIS) AXIS ##_APPLY_STEP
#define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN #define _INVERT_STEP_PIN(AXIS) INVERT_## AXIS ##_STEP_PIN
// Determine if pulses are needed // Determine if a pulse is needed using Bresenham
#define PULSE_PREP(AXIS) do{ \ #define PULSE_PREP(AXIS) do{ \
delta_error[_AXIS(AXIS)] += advance_dividend[_AXIS(AXIS)]; \ delta_error[_AXIS(AXIS)] += advance_dividend[_AXIS(AXIS)]; \
step_needed[_AXIS(AXIS)] = (delta_error[_AXIS(AXIS)] >= 0); \ step_needed[_AXIS(AXIS)] = (delta_error[_AXIS(AXIS)] >= 0); \

View file

@ -36,7 +36,19 @@
#include <SPI.h> #include <SPI.h>
enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E }; enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#define _TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX]) #define _TMC_INIT_1(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS)
#define _TMC_INIT_2(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, stealthchop_by_axis[STEALTH_INDEX], ST##_HYBRID_THRESHOLD)
#define _TMC_INIT_3(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, stealthchop_by_axis[STEALTH_INDEX], ST##_HYBRID_THRESHOLD, ST##_COOLSTEP_SPEED_THRESHOLD, ST##_COOLSTEP_LOWER_LOAD_THRESHOLD, ST##_COOLSTEP_UPPER_LOAD_THRESHOLD, ST##_COOLSTEP_SEUP, ST##_COOLSTEP_SEDN, ST##_COOLSTEP_SEIMIN)
#define _TMC_INIT_TMC2660(ST, STEALTH_INDEX) _TMC_INIT_1(ST, STEALTH_INDEX)
#define _TMC_INIT_TMC2160(ST, STEALTH_INDEX) _TMC_INIT_2(ST, STEALTH_INDEX)
#define _TMC_INIT_TMC2208(ST, STEALTH_INDEX) _TMC_INIT_2(ST, STEALTH_INDEX)
#define _TMC_INIT_TMC5130(ST, STEALTH_INDEX) _TMC_INIT_3(ST, STEALTH_INDEX)
#define _TMC_INIT_TMC5160(ST, STEALTH_INDEX) _TMC_INIT_3(ST, STEALTH_INDEX)
#define _TMC_INIT_TMC2130(ST, STEALTH_INDEX) _TMC_INIT_3(ST, STEALTH_INDEX)
#define _TMC_INIT_TMC2209(ST, STEALTH_INDEX) _TMC_INIT_3(ST, STEALTH_INDEX)
#define __TMC_INIT(DRV, ST, STEALTH_INDEX) _TMC_INIT_##DRV(ST, STEALTH_INDEX)
#define _TMC_INIT(DRV, ST, STEALTH_INDEX) __TMC_INIT(DRV, ST, STEALTH_INDEX)
#define TMC_INIT(ST, STEALTH_INDEX) _TMC_INIT(ST##_DRIVER_TYPE, ST, STEALTH_INDEX)
// IC = TMC model number // IC = TMC model number
// ST = Stepper object letter // ST = Stepper object letter
@ -122,7 +134,19 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2130) #if HAS_DRIVER(TMC2130)
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) { void tmc_init(
TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st,
const uint16_t mA,
const uint16_t microsteps,
const bool stealth,
const uint32_t hyb_thrs,
const uint32_t cool_thrs,
const uint8_t cool_semin,
const uint8_t cool_semax,
const uint8_t cool_seup,
const uint8_t cool_sedn,
const bool cool_seimin
) {
st.begin(); st.begin();
CHOPCONF_t chopconf{0}; CHOPCONF_t chopconf{0};
@ -152,18 +176,33 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
st.PWMCONF(pwmconf.sr); st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(thrs); st.set_pwm_thrs(hyb_thrs);
#else #else
UNUSED(thrs); UNUSED(hyb_thrs);
#endif #endif
st.set_cool_thrs(cool_thrs); // (mm/s)
COOLCONF_t coolconf{0};
coolconf.semin = cool_semin;
coolconf.semax = cool_semax;
coolconf.seup = cool_seup;
coolconf.sedn = cool_sedn;
coolconf.seimin = cool_seimin;
st.COOLCONF(coolconf.sr);
st.GSTAT(); // Clear GSTAT st.GSTAT(); // Clear GSTAT
} }
#endif // TMC2130 #endif // TMC2130
#if HAS_DRIVER(TMC2160) #if HAS_DRIVER(TMC2160)
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) { void tmc_init(
TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st,
const uint16_t mA,
const uint16_t microsteps,
const bool stealth,
const uint32_t hyb_thrs
) {
st.begin(); st.begin();
CHOPCONF_t chopconf{0}; CHOPCONF_t chopconf{0};
@ -196,9 +235,9 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
st.PWMCONF(pwmconf.sr); st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(thrs); st.set_pwm_thrs(hyb_thrs);
#else #else
UNUSED(thrs); UNUSED(hyb_thrs);
#endif #endif
st.GSTAT(); // Clear GSTAT st.GSTAT(); // Clear GSTAT
@ -440,7 +479,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2208) #if HAS_DRIVER(TMC2208)
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) { void tmc_init(
TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st,
const uint16_t mA,
const uint16_t microsteps,
const bool stealth,
const uint32_t hyb_thrs
) {
TMC2208_n::GCONF_t gconf{0}; TMC2208_n::GCONF_t gconf{0};
gconf.pdn_disable = true; // Use UART gconf.pdn_disable = true; // Use UART
gconf.mstep_reg_select = true; // Select microsteps with UART gconf.mstep_reg_select = true; // Select microsteps with UART
@ -476,9 +521,9 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
st.PWMCONF(pwmconf.sr); st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(thrs); st.set_pwm_thrs(hyb_thrs);
#else #else
UNUSED(thrs); UNUSED(hyb_thrs);
#endif #endif
st.GSTAT(0b111); // Clear st.GSTAT(0b111); // Clear
@ -488,7 +533,19 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2209) #if HAS_DRIVER(TMC2209)
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) { void tmc_init(
TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st,
const uint16_t mA,
const uint16_t microsteps,
const bool stealth,
const uint32_t hyb_thrs,
const uint32_t cool_thrs,
const uint8_t cool_semin,
const uint8_t cool_semax,
const uint8_t cool_seup,
const uint8_t cool_sedn,
const bool cool_seimin
) {
TMC2208_n::GCONF_t gconf{0}; TMC2208_n::GCONF_t gconf{0};
gconf.pdn_disable = true; // Use UART gconf.pdn_disable = true; // Use UART
gconf.mstep_reg_select = true; // Select microsteps with UART gconf.mstep_reg_select = true; // Select microsteps with UART
@ -524,11 +581,20 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
st.PWMCONF(pwmconf.sr); st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(thrs); st.set_pwm_thrs(hyb_thrs);
#else #else
UNUSED(thrs); UNUSED(hyb_thrs);
#endif #endif
st.set_cool_thrs(cool_thrs); // (mm/s)
COOLCONF_t coolconf{0};
coolconf.semin = cool_semin;
coolconf.semax = cool_semax;
coolconf.seup = cool_seup;
coolconf.sedn = cool_sedn;
coolconf.seimin = cool_seimin;
st.COOLCONF(coolconf.sr);
st.GSTAT(0b111); // Clear st.GSTAT(0b111); // Clear
delay(200); delay(200);
} }
@ -536,7 +602,11 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2660) #if HAS_DRIVER(TMC2660)
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_init(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool) { void tmc_init(
TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st,
const uint16_t mA,
const uint16_t microsteps
) {
st.begin(); st.begin();
TMC2660_n::CHOPCONF_t chopconf{0}; TMC2660_n::CHOPCONF_t chopconf{0};
@ -563,7 +633,19 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC5130) #if HAS_DRIVER(TMC5130)
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) { void tmc_init(
TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st,
const uint16_t mA,
const uint16_t microsteps,
const bool stealth,
const uint32_t hyb_thrs,
const uint32_t cool_thrs,
const uint8_t cool_semin,
const uint8_t cool_semax,
const uint8_t cool_seup,
const uint8_t cool_sedn,
const bool cool_seimin
) {
st.begin(); st.begin();
CHOPCONF_t chopconf{0}; CHOPCONF_t chopconf{0};
@ -593,18 +675,39 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
st.PWMCONF(pwmconf.sr); st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(thrs); st.set_pwm_thrs(hyb_thrs);
#else #else
UNUSED(thrs); UNUSED(hyb_thrs);
#endif #endif
st.set_cool_thrs(cool_thrs); // (mm/s)
COOLCONF_t coolconf{0};
coolconf.semin = cool_semin;
coolconf.semax = cool_semax;
coolconf.seup = cool_seup;
coolconf.sedn = cool_sedn;
coolconf.seimin = cool_seimin;
st.COOLCONF(coolconf.sr);
st.GSTAT(); // Clear GSTAT st.GSTAT(); // Clear GSTAT
} }
#endif // TMC5130 #endif // TMC5130
#if HAS_DRIVER(TMC5160) #if HAS_DRIVER(TMC5160)
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID> template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const bool stealth) { void tmc_init(
TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st,
const uint16_t mA,
const uint16_t microsteps,
const bool stealth,
const uint32_t hyb_thrs,
const uint32_t cool_thrs,
const uint8_t cool_semin,
const uint8_t cool_semax,
const uint8_t cool_seup,
const uint8_t cool_sedn,
const bool cool_seimin
) {
st.begin(); st.begin();
CHOPCONF_t chopconf{0}; CHOPCONF_t chopconf{0};
@ -637,10 +740,20 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
st.PWMCONF(pwmconf.sr); st.PWMCONF(pwmconf.sr);
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
st.set_pwm_thrs(thrs); st.set_pwm_thrs(hyb_thrs);
#else #else
UNUSED(thrs); UNUSED(hyb_thrs);
#endif #endif
st.set_cool_thrs(cool_thrs); // (mm/s)
COOLCONF_t coolconf{0};
coolconf.semin = cool_semin;
coolconf.semax = cool_semax;
coolconf.seup = cool_seup;
coolconf.sedn = cool_sedn;
coolconf.seimin = cool_seimin;
st.COOLCONF(coolconf.sr);
st.GSTAT(); // Clear GSTAT st.GSTAT(); // Clear GSTAT
} }
#endif // TMC5160 #endif // TMC5160
@ -718,52 +831,52 @@ void reset_trinamic_drivers() {
}; };
#if AXIS_IS_TMC(X) #if AXIS_IS_TMC(X)
_TMC_INIT(X, STEALTH_AXIS_XY); TMC_INIT(X, STEALTH_AXIS_XY);
#endif #endif
#if AXIS_IS_TMC(X2) #if AXIS_IS_TMC(X2)
_TMC_INIT(X2, STEALTH_AXIS_XY); TMC_INIT(X2, STEALTH_AXIS_XY);
#endif #endif
#if AXIS_IS_TMC(Y) #if AXIS_IS_TMC(Y)
_TMC_INIT(Y, STEALTH_AXIS_XY); TMC_INIT(Y, STEALTH_AXIS_XY);
#endif #endif
#if AXIS_IS_TMC(Y2) #if AXIS_IS_TMC(Y2)
_TMC_INIT(Y2, STEALTH_AXIS_XY); TMC_INIT(Y2, STEALTH_AXIS_XY);
#endif #endif
#if AXIS_IS_TMC(Z) #if AXIS_IS_TMC(Z)
_TMC_INIT(Z, STEALTH_AXIS_Z); TMC_INIT(Z, STEALTH_AXIS_Z);
#endif #endif
#if AXIS_IS_TMC(Z2) #if AXIS_IS_TMC(Z2)
_TMC_INIT(Z2, STEALTH_AXIS_Z); TMC_INIT(Z2, STEALTH_AXIS_Z);
#endif #endif
#if AXIS_IS_TMC(Z3) #if AXIS_IS_TMC(Z3)
_TMC_INIT(Z3, STEALTH_AXIS_Z); TMC_INIT(Z3, STEALTH_AXIS_Z);
#endif #endif
#if AXIS_IS_TMC(Z4) #if AXIS_IS_TMC(Z4)
_TMC_INIT(Z4, STEALTH_AXIS_Z); TMC_INIT(Z4, STEALTH_AXIS_Z);
#endif #endif
#if AXIS_IS_TMC(E0) #if AXIS_IS_TMC(E0)
_TMC_INIT(E0, STEALTH_AXIS_E); TMC_INIT(E0, STEALTH_AXIS_E);
#endif #endif
#if AXIS_IS_TMC(E1) #if AXIS_IS_TMC(E1)
_TMC_INIT(E1, STEALTH_AXIS_E); TMC_INIT(E1, STEALTH_AXIS_E);
#endif #endif
#if AXIS_IS_TMC(E2) #if AXIS_IS_TMC(E2)
_TMC_INIT(E2, STEALTH_AXIS_E); TMC_INIT(E2, STEALTH_AXIS_E);
#endif #endif
#if AXIS_IS_TMC(E3) #if AXIS_IS_TMC(E3)
_TMC_INIT(E3, STEALTH_AXIS_E); TMC_INIT(E3, STEALTH_AXIS_E);
#endif #endif
#if AXIS_IS_TMC(E4) #if AXIS_IS_TMC(E4)
_TMC_INIT(E4, STEALTH_AXIS_E); TMC_INIT(E4, STEALTH_AXIS_E);
#endif #endif
#if AXIS_IS_TMC(E5) #if AXIS_IS_TMC(E5)
_TMC_INIT(E5, STEALTH_AXIS_E); TMC_INIT(E5, STEALTH_AXIS_E);
#endif #endif
#if AXIS_IS_TMC(E6) #if AXIS_IS_TMC(E6)
_TMC_INIT(E6, STEALTH_AXIS_E); TMC_INIT(E6, STEALTH_AXIS_E);
#endif #endif
#if AXIS_IS_TMC(E7) #if AXIS_IS_TMC(E7)
_TMC_INIT(E7, STEALTH_AXIS_E); TMC_INIT(E7, STEALTH_AXIS_E);
#endif #endif
#if USE_SENSORLESS #if USE_SENSORLESS

View file

@ -82,7 +82,7 @@
// //
// TMC2208 UART pins // TMC2208 UART pins
// //
#if HAS_DRIVER(TMC2208) #if HAS_TMC_UART
#define X_SERIAL_TX_PIN P1_00 #define X_SERIAL_TX_PIN P1_00
#define X_SERIAL_RX_PIN P1_00 #define X_SERIAL_RX_PIN P1_00
#define Y_SERIAL_TX_PIN P1_09 #define Y_SERIAL_TX_PIN P1_09

View file

@ -74,9 +74,9 @@
#define E1_DIR_PIN P2_13 #define E1_DIR_PIN P2_13
#define E1_ENABLE_PIN P4_29 #define E1_ENABLE_PIN P4_29
#if HAS_DRIVER(TMC2208) #if HAS_TMC_UART
// //
// TMC2208 stepper drivers // TMC220x stepper drivers
// Software serial // Software serial
// //
#define X_SERIAL_TX_PIN P0_04 #define X_SERIAL_TX_PIN P0_04

View file

@ -264,11 +264,11 @@
#define SD_DETECT_PIN 9 // H6 #define SD_DETECT_PIN 9 // H6
// //
//TMC 2208 // TMC 220x
// //
#if HAS_DRIVER(TMC2208) #if HAS_TMC_UART
/** /**
* TMC2208 stepper drivers * TMC220x stepper drivers
* *
* Hardware serial communication ports. * Hardware serial communication ports.
* If undefined software serial is used according to the pins below * If undefined software serial is used according to the pins below

View file

@ -1189,12 +1189,18 @@
#define _PEXI(p,q) __PEXI(p,q) #define _PEXI(p,q) __PEXI(p,q)
#define __EPIN(p,q) E##p##_##q##_PIN #define __EPIN(p,q) E##p##_##q##_PIN
#define _EPIN(p,q) __EPIN(p,q) #define _EPIN(p,q) __EPIN(p,q)
#define __EDRV(p) E##p##_DRIVER_TYPE
#define _EDRV(p) __EDRV(p)
#define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN) #define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
// The X2 axis, if any, should be the next open extruder port // The X2 axis, if any, should be the next open extruder port
#define X2_E_INDEX E_STEPPERS #define X2_E_INDEX E_STEPPERS
#if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS)
#ifndef X2_DRIVER_TYPE
#define X2_DRIVER_TYPE _EDRV(X2_E_INDEX)
#endif
#ifndef X2_STEP_PIN #ifndef X2_STEP_PIN
#define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP) #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
#define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR) #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR)
@ -1268,6 +1274,10 @@
// The Y2 axis, if any, should be the next open extruder port // The Y2 axis, if any, should be the next open extruder port
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
#ifndef Y2_DRIVER_TYPE
#define Y2_DRIVER_TYPE _EDRV(Y2_E_INDEX)
#endif
#ifndef Y2_STEP_PIN #ifndef Y2_STEP_PIN
#define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP) #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
#define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR) #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
@ -1336,6 +1346,10 @@
// The Z2 axis, if any, should be the next open extruder port // The Z2 axis, if any, should be the next open extruder port
#if NUM_Z_STEPPER_DRIVERS >= 2 #if NUM_Z_STEPPER_DRIVERS >= 2
#ifndef Z2_DRIVER_TYPE
#define Z2_DRIVER_TYPE _EDRV(Z2_E_INDEX)
#endif
#ifndef Z2_STEP_PIN #ifndef Z2_STEP_PIN
#define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP) #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
#define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR) #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
@ -1403,6 +1417,10 @@
#endif #endif
#if NUM_Z_STEPPER_DRIVERS >= 3 #if NUM_Z_STEPPER_DRIVERS >= 3
#ifndef Z3_DRIVER_TYPE
#define Z3_DRIVER_TYPE _EDRV(Z3_E_INDEX)
#endif
#ifndef Z3_STEP_PIN #ifndef Z3_STEP_PIN
#define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP) #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP)
#define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR) #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR)
@ -1470,6 +1488,10 @@
#endif #endif
#if NUM_Z_STEPPER_DRIVERS >= 4 #if NUM_Z_STEPPER_DRIVERS >= 4
#ifndef Z4_DRIVER_TYPE
#define Z4_DRIVER_TYPE _EDRV(Z4_E_INDEX)
#endif
#ifndef Z4_STEP_PIN #ifndef Z4_STEP_PIN
#define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP) #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP)
#define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR) #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR)

View file

@ -193,9 +193,9 @@
#endif #endif
#endif #endif
#if HAS_DRIVER(TMC2208) #if HAS_TMC_UART
/** /**
* TMC2208 stepper drivers * TMC220x stepper drivers
* *
* Hardware serial communication ports. * Hardware serial communication ports.
* If undefined software serial is used according to the pins below * If undefined software serial is used according to the pins below

View file

@ -26,10 +26,10 @@
#define BOARD_INFO_NAME "BIGTREE SKR Mini E3" #define BOARD_INFO_NAME "BIGTREE SKR Mini E3"
/** /**
* TMC2209 stepper drivers * TMC220x stepper drivers
* Hardware serial communication ports. * Hardware serial communication ports.
*/ */
#if HAS_DRIVER(TMC2209) #if HAS_TMC_UART
#define X_HARDWARE_SERIAL Serial4 #define X_HARDWARE_SERIAL Serial4
#define Y_HARDWARE_SERIAL Serial4 #define Y_HARDWARE_SERIAL Serial4
#define Z_HARDWARE_SERIAL Serial4 #define Z_HARDWARE_SERIAL Serial4