Configure TMC interpolation per driver (#19828)

This commit is contained in:
ManuelMcLure
2020-10-22 04:27:33 -07:00
committed by GitHub
parent ec596315bd
commit 4fccb92e07
4 changed files with 99 additions and 19 deletions

View File

@ -497,7 +497,8 @@
TMC_HEND,
TMC_HSTRT,
TMC_SGT,
TMC_MSCNT
TMC_MSCNT,
TMC_INTERPOLATE
};
enum TMC_drv_status_enum : char {
TMC_DRV_CODES,
@ -553,6 +554,7 @@
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
@ -588,6 +590,7 @@
SERIAL_ECHOPGM("/256");
}
break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
@ -603,6 +606,7 @@
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('*'); break;
case TMC_S2VSB: if (st.s2vsb()) SERIAL_CHAR('*'); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
@ -644,6 +648,12 @@
#if HAS_DRIVER(TMC2660)
static void _tmc_parse_drv_status(TMC2660Stepper, const TMC_drv_status_enum) { }
static void _tmc_status(TMC2660Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
#endif
template <typename TMC>
@ -902,6 +912,7 @@
#endif
TMC_REPORT("stealthChop", TMC_STEALTHCHOP);
TMC_REPORT("msteps\t", TMC_MICROSTEPS);
TMC_REPORT("interp\t", TMC_INTERPOLATE);
TMC_REPORT("tstep\t", TMC_TSTEP);
TMC_REPORT("PWM thresh.", TMC_TPWMTHRS);
TMC_REPORT("[mm/s]\t", TMC_TPWMTHRS_MMS);

View File

@ -1608,6 +1608,54 @@
#define Y_SPI_SENSORLESS Y_SENSORLESS
#define Z_SPI_SENSORLESS Z_SENSORLESS
#endif
#ifndef X_INTERPOLATE
#define X_INTERPOLATE INTERPOLATE
#endif
#ifndef X2_INTERPOLATE
#define X2_INTERPOLATE INTERPOLATE
#endif
#ifndef Y_INTERPOLATE
#define Y_INTERPOLATE INTERPOLATE
#endif
#ifndef Y2_INTERPOLATE
#define Y2_INTERPOLATE INTERPOLATE
#endif
#ifndef Z_INTERPOLATE
#define Z_INTERPOLATE INTERPOLATE
#endif
#ifndef Z2_INTERPOLATE
#define Z2_INTERPOLATE INTERPOLATE
#endif
#ifndef Z3_INTERPOLATE
#define Z3_INTERPOLATE INTERPOLATE
#endif
#ifndef Z4_INTERPOLATE
#define Z4_INTERPOLATE INTERPOLATE
#endif
#ifndef E0_INTERPOLATE
#define E0_INTERPOLATE INTERPOLATE
#endif
#ifndef E1_INTERPOLATE
#define E1_INTERPOLATE INTERPOLATE
#endif
#ifndef E2_INTERPOLATE
#define E2_INTERPOLATE INTERPOLATE
#endif
#ifndef E3_INTERPOLATE
#define E3_INTERPOLATE INTERPOLATE
#endif
#ifndef E4_INTERPOLATE
#define E4_INTERPOLATE INTERPOLATE
#endif
#ifndef E5_INTERPOLATE
#define E5_INTERPOLATE INTERPOLATE
#endif
#ifndef E6_INTERPOLATE
#define E6_INTERPOLATE INTERPOLATE
#endif
#ifndef E7_INTERPOLATE
#define E7_INTERPOLATE INTERPOLATE
#endif
#endif
#if (HAS_E_DRIVER(TMC2660) \

View File

@ -36,7 +36,7 @@
#include <SPI.h>
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], chopper_timing_##ST)
#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE)
// IC = TMC model number
// ST = Stepper object letter
@ -131,13 +131,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2130)
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 hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
st.begin();
CHOPCONF_t chopconf{0};
chopconf.tbl = 0b01;
chopconf.toff = chop_init.toff;
chopconf.intpol = INTERPOLATE;
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
@ -166,13 +166,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2160)
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 hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
st.begin();
CHOPCONF_t chopconf{0};
chopconf.tbl = 0b01;
chopconf.toff = chop_init.toff;
chopconf.intpol = INTERPOLATE;
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
@ -484,7 +484,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2208)
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 hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
TMC2208_n::GCONF_t gconf{0};
gconf.pdn_disable = true; // Use UART
gconf.mstep_reg_select = true; // Select microsteps with UART
@ -496,7 +496,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
TMC2208_n::CHOPCONF_t chopconf{0};
chopconf.tbl = 0b01; // blank_time = 24
chopconf.toff = chop_init.toff;
chopconf.intpol = INTERPOLATE;
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
@ -526,7 +526,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2209)
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 hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
TMC2208_n::GCONF_t gconf{0};
gconf.pdn_disable = true; // Use UART
gconf.mstep_reg_select = true; // Select microsteps with UART
@ -538,7 +538,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
TMC2208_n::CHOPCONF_t chopconf{0};
chopconf.tbl = 0b01; // blank_time = 24
chopconf.toff = chop_init.toff;
chopconf.intpol = INTERPOLATE;
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
@ -568,7 +568,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC2660)
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, const chopper_timing_t &chop_init) {
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, const chopper_timing_t &chop_init, const bool interpolate) {
st.begin();
TMC2660_n::CHOPCONF_t chopconf{0};
@ -582,7 +582,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
st.rms_current(mA);
st.microsteps(microsteps);
TERN_(SQUARE_WAVE_STEPPING, st.dedge(true));
st.intpol(INTERPOLATE);
st.intpol(interpolate);
st.diss2g(true); // Disable short to ground protection. Too many false readings?
TERN_(TMC_DEBUG, st.rdsel(0b01));
}
@ -590,13 +590,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC5130)
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 hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
st.begin();
CHOPCONF_t chopconf{0};
chopconf.tbl = 0b01;
chopconf.toff = chop_init.toff;
chopconf.intpol = INTERPOLATE;
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
@ -625,13 +625,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
#if HAS_DRIVER(TMC5160)
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 hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
st.begin();
CHOPCONF_t chopconf{0};
chopconf.tbl = 0b01;
chopconf.toff = chop_init.toff;
chopconf.intpol = INTERPOLATE;
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);