Distinct Chopper Timing settings (#19781)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
committed by
GitHub
parent
2693d0eb27
commit
c2802d35bb
@@ -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])
|
||||
#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)
|
||||
|
||||
// IC = TMC model number
|
||||
// ST = Stepper object letter
|
||||
@@ -131,15 +131,15 @@ 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) {
|
||||
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) {
|
||||
st.begin();
|
||||
|
||||
CHOPCONF_t chopconf{0};
|
||||
chopconf.tbl = 1;
|
||||
chopconf.toff = chopper_timing.toff;
|
||||
chopconf.tbl = 0b01;
|
||||
chopconf.toff = chop_init.toff;
|
||||
chopconf.intpol = INTERPOLATE;
|
||||
chopconf.hend = chopper_timing.hend + 3;
|
||||
chopconf.hstrt = chopper_timing.hstrt - 1;
|
||||
chopconf.hend = chop_init.hend + 3;
|
||||
chopconf.hstrt = chop_init.hstrt - 1;
|
||||
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
||||
st.CHOPCONF(chopconf.sr);
|
||||
|
||||
@@ -166,15 +166,15 @@ 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) {
|
||||
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) {
|
||||
st.begin();
|
||||
|
||||
CHOPCONF_t chopconf{0};
|
||||
chopconf.tbl = 1;
|
||||
chopconf.toff = chopper_timing.toff;
|
||||
chopconf.tbl = 0b01;
|
||||
chopconf.toff = chop_init.toff;
|
||||
chopconf.intpol = INTERPOLATE;
|
||||
chopconf.hend = chopper_timing.hend + 3;
|
||||
chopconf.hstrt = chopper_timing.hstrt - 1;
|
||||
chopconf.hend = chop_init.hend + 3;
|
||||
chopconf.hstrt = chop_init.hstrt - 1;
|
||||
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
||||
st.CHOPCONF(chopconf.sr);
|
||||
|
||||
@@ -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) {
|
||||
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) {
|
||||
TMC2208_n::GCONF_t gconf{0};
|
||||
gconf.pdn_disable = true; // Use UART
|
||||
gconf.mstep_reg_select = true; // Select microsteps with UART
|
||||
@@ -495,10 +495,10 @@ 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 = chopper_timing.toff;
|
||||
chopconf.toff = chop_init.toff;
|
||||
chopconf.intpol = INTERPOLATE;
|
||||
chopconf.hend = chopper_timing.hend + 3;
|
||||
chopconf.hstrt = chopper_timing.hstrt - 1;
|
||||
chopconf.hend = chop_init.hend + 3;
|
||||
chopconf.hstrt = chop_init.hstrt - 1;
|
||||
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
||||
st.CHOPCONF(chopconf.sr);
|
||||
|
||||
@@ -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) {
|
||||
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) {
|
||||
TMC2208_n::GCONF_t gconf{0};
|
||||
gconf.pdn_disable = true; // Use UART
|
||||
gconf.mstep_reg_select = true; // Select microsteps with UART
|
||||
@@ -537,10 +537,10 @@ 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 = chopper_timing.toff;
|
||||
chopconf.toff = chop_init.toff;
|
||||
chopconf.intpol = INTERPOLATE;
|
||||
chopconf.hend = chopper_timing.hend + 3;
|
||||
chopconf.hstrt = chopper_timing.hstrt - 1;
|
||||
chopconf.hend = chop_init.hend + 3;
|
||||
chopconf.hstrt = chop_init.hstrt - 1;
|
||||
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
||||
st.CHOPCONF(chopconf.sr);
|
||||
|
||||
@@ -568,14 +568,14 @@ 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) {
|
||||
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) {
|
||||
st.begin();
|
||||
|
||||
TMC2660_n::CHOPCONF_t chopconf{0};
|
||||
chopconf.tbl = 1;
|
||||
chopconf.toff = chopper_timing.toff;
|
||||
chopconf.hend = chopper_timing.hend + 3;
|
||||
chopconf.hstrt = chopper_timing.hstrt - 1;
|
||||
chopconf.tbl = 0b01;
|
||||
chopconf.toff = chop_init.toff;
|
||||
chopconf.hend = chop_init.hend + 3;
|
||||
chopconf.hstrt = chop_init.hstrt - 1;
|
||||
st.CHOPCONF(chopconf.sr);
|
||||
|
||||
st.sdoff(0);
|
||||
@@ -590,15 +590,15 @@ 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) {
|
||||
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) {
|
||||
st.begin();
|
||||
|
||||
CHOPCONF_t chopconf{0};
|
||||
chopconf.tbl = 1;
|
||||
chopconf.toff = chopper_timing.toff;
|
||||
chopconf.tbl = 0b01;
|
||||
chopconf.toff = chop_init.toff;
|
||||
chopconf.intpol = INTERPOLATE;
|
||||
chopconf.hend = chopper_timing.hend + 3;
|
||||
chopconf.hstrt = chopper_timing.hstrt - 1;
|
||||
chopconf.hend = chop_init.hend + 3;
|
||||
chopconf.hstrt = chop_init.hstrt - 1;
|
||||
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
||||
st.CHOPCONF(chopconf.sr);
|
||||
|
||||
@@ -625,15 +625,15 @@ 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) {
|
||||
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) {
|
||||
st.begin();
|
||||
|
||||
CHOPCONF_t chopconf{0};
|
||||
chopconf.tbl = 1;
|
||||
chopconf.toff = chopper_timing.toff;
|
||||
chopconf.tbl = 0b01;
|
||||
chopconf.toff = chop_init.toff;
|
||||
chopconf.intpol = INTERPOLATE;
|
||||
chopconf.hend = chopper_timing.hend + 3;
|
||||
chopconf.hstrt = chopper_timing.hstrt - 1;
|
||||
chopconf.hend = chop_init.hend + 3;
|
||||
chopconf.hstrt = chop_init.hstrt - 1;
|
||||
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
||||
st.CHOPCONF(chopconf.sr);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user