|
|
@ -36,8 +36,6 @@ |
|
|
|
#include "../module/planner.h" |
|
|
|
#endif |
|
|
|
|
|
|
|
bool report_tmc_status = false; |
|
|
|
|
|
|
|
/**
|
|
|
|
* Check for over temperature or short to ground error flags. |
|
|
|
* Report and log warning of overtemperature condition. |
|
|
@ -46,6 +44,8 @@ bool report_tmc_status = false; |
|
|
|
* and so we don't repeatedly report warning before the condition is cleared. |
|
|
|
*/ |
|
|
|
#if ENABLED(MONITOR_DRIVER_STATUS) |
|
|
|
static bool report_tmc_status = false; |
|
|
|
|
|
|
|
struct TMC_driver_data { |
|
|
|
uint32_t drv_status; |
|
|
|
bool is_otpw; |
|
|
@ -95,13 +95,13 @@ bool report_tmc_status = false; |
|
|
|
#endif |
|
|
|
|
|
|
|
template<typename TMC> |
|
|
|
void monitor_tmc_driver(TMC &st, const TMC_AxisEnum axis, uint8_t &otpw_cnt) { |
|
|
|
void monitor_tmc_driver(TMC &st) { |
|
|
|
TMC_driver_data data = get_driver_data(st); |
|
|
|
|
|
|
|
#if ENABLED(STOP_ON_ERROR) |
|
|
|
if (data.is_error) { |
|
|
|
SERIAL_EOL(); |
|
|
|
_tmc_say_axis(axis); |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOLNPGM(" driver error detected:"); |
|
|
|
if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature"); |
|
|
|
if (st.s2ga()) SERIAL_ECHOLNPGM("short to ground (coil A)"); |
|
|
@ -114,7 +114,7 @@ bool report_tmc_status = false; |
|
|
|
#endif |
|
|
|
|
|
|
|
// Report if a warning was triggered
|
|
|
|
if (data.is_otpw && otpw_cnt == 0) { |
|
|
|
if (data.is_otpw && st.otpw_count == 0) { |
|
|
|
char timestamp[10]; |
|
|
|
duration_t elapsed = print_job_timer.duration(); |
|
|
|
const bool has_days = (elapsed.value > 60*60*24L); |
|
|
@ -122,38 +122,38 @@ bool report_tmc_status = false; |
|
|
|
SERIAL_EOL(); |
|
|
|
SERIAL_ECHO(timestamp); |
|
|
|
SERIAL_ECHOPGM(": "); |
|
|
|
_tmc_say_axis(axis); |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOPGM(" driver overtemperature warning! ("); |
|
|
|
SERIAL_ECHO(st.getCurrent()); |
|
|
|
SERIAL_ECHO(st.getMilliamps()); |
|
|
|
SERIAL_ECHOLNPGM("mA)"); |
|
|
|
} |
|
|
|
#if CURRENT_STEP_DOWN > 0 |
|
|
|
// Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings
|
|
|
|
if (data.is_otpw && st.isEnabled() && otpw_cnt > 4) { |
|
|
|
st.setCurrent(st.getCurrent() - (CURRENT_STEP_DOWN), R_SENSE, HOLD_MULTIPLIER); |
|
|
|
if (data.is_otpw && st.isEnabled() && st.otpw_count > 4) { |
|
|
|
st.rms_current(st.getMilliamps() - (CURRENT_STEP_DOWN)); |
|
|
|
#if ENABLED(REPORT_CURRENT_CHANGE) |
|
|
|
_tmc_say_axis(axis); |
|
|
|
SERIAL_ECHOLNPAIR(" current decreased to ", st.getCurrent()); |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps()); |
|
|
|
#endif |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
if (data.is_otpw) { |
|
|
|
otpw_cnt++; |
|
|
|
st.otpw_count++; |
|
|
|
st.flag_otpw = true; |
|
|
|
} |
|
|
|
else if (otpw_cnt > 0) otpw_cnt = 0; |
|
|
|
else if (st.otpw_count > 0) st.otpw_count = 0; |
|
|
|
|
|
|
|
if (report_tmc_status) { |
|
|
|
const uint32_t pwm_scale = get_pwm_scale(st); |
|
|
|
_tmc_say_axis(axis); |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOPAIR(":", pwm_scale); |
|
|
|
SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN); |
|
|
|
SERIAL_ECHOPGM("| "); |
|
|
|
if (data.is_error) SERIAL_CHAR('E'); |
|
|
|
else if (data.is_ot) SERIAL_CHAR('O'); |
|
|
|
else if (data.is_otpw) SERIAL_CHAR('W'); |
|
|
|
else if (otpw_cnt > 0) SERIAL_PRINT(otpw_cnt, DEC); |
|
|
|
else if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC); |
|
|
|
else if (st.flag_otpw) SERIAL_CHAR('F'); |
|
|
|
SERIAL_CHAR('\t'); |
|
|
|
} |
|
|
@ -166,56 +166,43 @@ bool report_tmc_status = false; |
|
|
|
if (ELAPSED(millis(), next_cOT)) { |
|
|
|
next_cOT = millis() + 500; |
|
|
|
#if HAS_HW_COMMS(X) |
|
|
|
static uint8_t x_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperX, TMC_X, x_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperX); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Y) |
|
|
|
static uint8_t y_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperY, TMC_Y, y_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperY); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Z) |
|
|
|
static uint8_t z_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperZ, TMC_Z, z_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperZ); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(X2) |
|
|
|
static uint8_t x2_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperX2, TMC_X, x2_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperX2); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Y2) |
|
|
|
static uint8_t y2_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperY2, TMC_Y, y2_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperY2); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Z2) |
|
|
|
static uint8_t z2_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperZ2, TMC_Z, z2_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperZ2); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Z3) |
|
|
|
static uint8_t z3_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperZ3, TMC_Z, z3_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperZ3); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E0) |
|
|
|
static uint8_t e0_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperE0, TMC_E0, e0_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperE0); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E1) |
|
|
|
static uint8_t e1_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperE1, TMC_E1, e1_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperE1); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E2) |
|
|
|
static uint8_t e2_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperE2, TMC_E2, e2_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperE2); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E3) |
|
|
|
static uint8_t e3_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperE3, TMC_E3, e3_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperE3); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E4) |
|
|
|
static uint8_t e4_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperE4, TMC_E4, e4_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperE4); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E5) |
|
|
|
static uint8_t e5_otpw_cnt = 0; |
|
|
|
monitor_tmc_driver(stepperE5, TMC_E5, e5_otpw_cnt); |
|
|
|
monitor_tmc_driver(stepperE5); |
|
|
|
#endif |
|
|
|
|
|
|
|
if (report_tmc_status) SERIAL_EOL(); |
|
|
@ -224,100 +211,6 @@ bool report_tmc_status = false; |
|
|
|
|
|
|
|
#endif // MONITOR_DRIVER_STATUS
|
|
|
|
|
|
|
|
void _tmc_say_axis(const TMC_AxisEnum axis) { |
|
|
|
static const char ext_X[] PROGMEM = "X", ext_Y[] PROGMEM = "Y", ext_Z[] PROGMEM = "Z" |
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(X_DUAL_STEPPER_DRIVERS) |
|
|
|
, ext_X2[] PROGMEM = "X2" |
|
|
|
#endif |
|
|
|
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) |
|
|
|
, ext_Y2[] PROGMEM = "Y2" |
|
|
|
#endif |
|
|
|
#if Z_MULTI_STEPPER_DRIVERS |
|
|
|
, ext_Z2[] PROGMEM = "Z2" |
|
|
|
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) |
|
|
|
, ext_Z3[] PROGMEM = "Z3" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#if E_STEPPERS |
|
|
|
, ext_E0[] PROGMEM = "E0" |
|
|
|
#if E_STEPPERS > 1 |
|
|
|
, ext_E1[] PROGMEM = "E1" |
|
|
|
#if E_STEPPERS > 2 |
|
|
|
, ext_E2[] PROGMEM = "E2" |
|
|
|
#if E_STEPPERS > 3 |
|
|
|
, ext_E3[] PROGMEM = "E3" |
|
|
|
#if E_STEPPERS > 4 |
|
|
|
, ext_E4[] PROGMEM = "E4" |
|
|
|
#if E_STEPPERS > 5 |
|
|
|
, ext_E5[] PROGMEM = "E5" |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
; |
|
|
|
|
|
|
|
static PGM_P const tmc_axes[] PROGMEM = { |
|
|
|
ext_X, ext_Y, ext_Z |
|
|
|
#if ENABLED(DUAL_X_CARRIAGE) || ENABLED(X_DUAL_STEPPER_DRIVERS) |
|
|
|
, ext_X2 |
|
|
|
#endif |
|
|
|
#if ENABLED(Y_DUAL_STEPPER_DRIVERS) |
|
|
|
, ext_Y2 |
|
|
|
#endif |
|
|
|
#if Z_MULTI_STEPPER_DRIVERS |
|
|
|
, ext_Z2 |
|
|
|
#if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) |
|
|
|
, ext_Z3 |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#if E_STEPPERS |
|
|
|
, ext_E0 |
|
|
|
#if E_STEPPERS > 1 |
|
|
|
, ext_E1 |
|
|
|
#if E_STEPPERS > 2 |
|
|
|
, ext_E2 |
|
|
|
#if E_STEPPERS > 3 |
|
|
|
, ext_E3 |
|
|
|
#if E_STEPPERS > 4 |
|
|
|
, ext_E4 |
|
|
|
#if E_STEPPERS > 5 |
|
|
|
, ext_E5 |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
}; |
|
|
|
serialprintPGM((char*)pgm_read_ptr(&tmc_axes[axis])); |
|
|
|
} |
|
|
|
|
|
|
|
void _tmc_say_current(const TMC_AxisEnum axis, const uint16_t curr) { |
|
|
|
_tmc_say_axis(axis); |
|
|
|
SERIAL_ECHOLNPAIR(" driver current: ", curr); |
|
|
|
} |
|
|
|
void _tmc_say_otpw(const TMC_AxisEnum axis, const bool otpw) { |
|
|
|
_tmc_say_axis(axis); |
|
|
|
SERIAL_ECHOPGM(" temperature prewarn triggered: "); |
|
|
|
serialprintPGM(otpw ? PSTR("true") : PSTR("false")); |
|
|
|
SERIAL_EOL(); |
|
|
|
} |
|
|
|
void _tmc_say_otpw_cleared(const TMC_AxisEnum axis) { |
|
|
|
_tmc_say_axis(axis); |
|
|
|
SERIAL_ECHOLNPGM(" prewarn flag cleared"); |
|
|
|
} |
|
|
|
void _tmc_say_pwmthrs(const TMC_AxisEnum axis, const uint32_t thrs) { |
|
|
|
_tmc_say_axis(axis); |
|
|
|
SERIAL_ECHOLNPAIR(" stealthChop max speed: ", thrs); |
|
|
|
} |
|
|
|
void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
_tmc_say_axis(axis); |
|
|
|
SERIAL_ECHOPGM(" homing sensitivity: "); |
|
|
|
SERIAL_PRINTLN(sgt, DEC); |
|
|
|
} |
|
|
|
|
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
|
|
|
|
enum TMC_debug_enum : char { |
|
|
@ -366,9 +259,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
TMC_S2VSB, |
|
|
|
TMC_S2VSA |
|
|
|
}; |
|
|
|
static void drv_status_print_hex(const TMC_AxisEnum axis, const uint32_t drv_status) { |
|
|
|
_tmc_say_axis(axis); |
|
|
|
SERIAL_ECHOPGM(" = 0x"); |
|
|
|
static void drv_status_print_hex(const uint32_t drv_status) { |
|
|
|
for (int B = 24; B >= 8; B -= 8){ |
|
|
|
SERIAL_PRINT((drv_status >> (B + 4)) & 0xF, HEX); |
|
|
|
SERIAL_PRINT((drv_status >> B) & 0xF, HEX); |
|
|
@ -379,17 +270,19 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
SERIAL_EOL(); |
|
|
|
} |
|
|
|
|
|
|
|
template<class TMC> |
|
|
|
static void print_vsense(TMC &st) { serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); } |
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2130) |
|
|
|
static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { |
|
|
|
switch (i) { |
|
|
|
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break; |
|
|
|
case TMC_TSTEP: SERIAL_ECHO(st.TSTEP()); break; |
|
|
|
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break; |
|
|
|
case TMC_STEALTHCHOP: serialprintPGM(st.stealthChop() ? PSTR("true") : PSTR("false")); break; |
|
|
|
case TMC_STEALTHCHOP: serialprintPGM(st.en_pwm_mode() ? PSTR("true") : PSTR("false")); break; |
|
|
|
default: break; |
|
|
|
} |
|
|
|
} |
|
|
|
static void tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) { |
|
|
|
static void _tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) { |
|
|
|
switch (i) { |
|
|
|
case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('X'); break; |
|
|
|
case TMC_SG_RESULT: SERIAL_PRINT(st.sg_result(), DEC); break; |
|
|
@ -402,7 +295,6 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
#if HAS_DRIVER(TMC2208) |
|
|
|
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) { |
|
|
|
switch (i) { |
|
|
|
case TMC_TSTEP: { uint32_t data = 0; st.TSTEP(&data); SERIAL_PROTOCOL(data); break; } |
|
|
|
case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break; |
|
|
|
case TMC_STEALTHCHOP: serialprintPGM(st.stealth() ? PSTR("true") : PSTR("false")); break; |
|
|
|
case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('X'); break; |
|
|
@ -410,7 +302,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
default: break; |
|
|
|
} |
|
|
|
} |
|
|
|
static void tmc_parse_drv_status(TMC2208Stepper &st, const TMC_drv_status_enum i) { |
|
|
|
static void _tmc_parse_drv_status(TMC2208Stepper &st, const TMC_drv_status_enum i) { |
|
|
|
switch (i) { |
|
|
|
case TMC_T157: if (st.t157()) SERIAL_CHAR('X'); break; |
|
|
|
case TMC_T150: if (st.t150()) SERIAL_CHAR('X'); break; |
|
|
@ -422,12 +314,12 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
#endif |
|
|
|
|
|
|
|
template <typename TMC> |
|
|
|
static void tmc_status(TMC &st, const TMC_AxisEnum axis, const TMC_debug_enum i, const float spmm) { |
|
|
|
static void tmc_status(TMC &st, const TMC_debug_enum i, const float spmm) { |
|
|
|
SERIAL_ECHO('\t'); |
|
|
|
switch (i) { |
|
|
|
case TMC_CODES: _tmc_say_axis(axis); break; |
|
|
|
case TMC_CODES: st.printLabel(); break; |
|
|
|
case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break; |
|
|
|
case TMC_CURRENT: SERIAL_ECHO(st.getCurrent()); break; |
|
|
|
case TMC_CURRENT: SERIAL_ECHO(st.getMilliamps()); break; |
|
|
|
case TMC_RMS_CURRENT: SERIAL_PROTOCOL(st.rms_current()); break; |
|
|
|
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break; |
|
|
|
case TMC_IRUN: |
|
|
@ -442,10 +334,9 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
SERIAL_PRINT(st.cs_actual(), DEC); |
|
|
|
SERIAL_ECHOPGM("/31"); |
|
|
|
break; |
|
|
|
|
|
|
|
case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); break; |
|
|
|
|
|
|
|
case TMC_VSENSE: print_vsense(st); break; |
|
|
|
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break; |
|
|
|
case TMC_TSTEP: SERIAL_ECHO(st.TSTEP()); break; |
|
|
|
case TMC_TPWMTHRS: { |
|
|
|
uint32_t tpwmthrs_val = st.TPWMTHRS(); |
|
|
|
SERIAL_ECHO(tpwmthrs_val); |
|
|
@ -470,10 +361,10 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
} |
|
|
|
|
|
|
|
template <typename TMC> |
|
|
|
static void tmc_parse_drv_status(TMC &st, const TMC_AxisEnum axis, const TMC_drv_status_enum i) { |
|
|
|
static void tmc_parse_drv_status(TMC &st, const TMC_drv_status_enum i) { |
|
|
|
SERIAL_CHAR('\t'); |
|
|
|
switch (i) { |
|
|
|
case TMC_DRV_CODES: _tmc_say_axis(axis); break; |
|
|
|
case TMC_DRV_CODES: st.printLabel(); break; |
|
|
|
case TMC_STST: if (st.stst()) SERIAL_CHAR('X'); break; |
|
|
|
case TMC_OLB: if (st.olb()) SERIAL_CHAR('X'); break; |
|
|
|
case TMC_OLA: if (st.ola()) SERIAL_CHAR('X'); break; |
|
|
@ -482,69 +373,73 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
case TMC_DRV_OTPW: if (st.otpw()) SERIAL_CHAR('X'); break; |
|
|
|
case TMC_OT: if (st.ot()) SERIAL_CHAR('X'); break; |
|
|
|
case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break; |
|
|
|
case TMC_DRV_STATUS_HEX:drv_status_print_hex(axis, st.DRV_STATUS()); break; |
|
|
|
default: tmc_parse_drv_status(st, i); break; |
|
|
|
case TMC_DRV_STATUS_HEX: |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOPGM("\t0x"); |
|
|
|
drv_status_print_hex(st.DRV_STATUS()); |
|
|
|
break; |
|
|
|
default: _tmc_parse_drv_status(st, i); break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static void tmc_debug_loop(const TMC_debug_enum i) { |
|
|
|
#if AXIS_IS_TMC(X) |
|
|
|
tmc_status(stepperX, TMC_X, i, planner.axis_steps_per_mm[X_AXIS]); |
|
|
|
tmc_status(stepperX, i, planner.axis_steps_per_mm[X_AXIS]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(X2) |
|
|
|
tmc_status(stepperX2, TMC_X2, i, planner.axis_steps_per_mm[X_AXIS]); |
|
|
|
tmc_status(stepperX2, i, planner.axis_steps_per_mm[X_AXIS]); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if AXIS_IS_TMC(Y) |
|
|
|
tmc_status(stepperY, TMC_Y, i, planner.axis_steps_per_mm[Y_AXIS]); |
|
|
|
tmc_status(stepperY, i, planner.axis_steps_per_mm[Y_AXIS]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(Y2) |
|
|
|
tmc_status(stepperY2, TMC_Y2, i, planner.axis_steps_per_mm[Y_AXIS]); |
|
|
|
tmc_status(stepperY2, i, planner.axis_steps_per_mm[Y_AXIS]); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if AXIS_IS_TMC(Z) |
|
|
|
tmc_status(stepperZ, TMC_Z, i, planner.axis_steps_per_mm[Z_AXIS]); |
|
|
|
tmc_status(stepperZ, i, planner.axis_steps_per_mm[Z_AXIS]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(Z2) |
|
|
|
tmc_status(stepperZ2, TMC_Z2, i, planner.axis_steps_per_mm[Z_AXIS]); |
|
|
|
tmc_status(stepperZ2, i, planner.axis_steps_per_mm[Z_AXIS]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(Z3) |
|
|
|
tmc_status(stepperZ3, TMC_Z3, i, planner.axis_steps_per_mm[Z_AXIS]); |
|
|
|
tmc_status(stepperZ3, i, planner.axis_steps_per_mm[Z_AXIS]); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if AXIS_IS_TMC(E0) |
|
|
|
tmc_status(stepperE0, TMC_E0, i, planner.axis_steps_per_mm[E_AXIS]); |
|
|
|
tmc_status(stepperE0, i, planner.axis_steps_per_mm[E_AXIS]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E1) |
|
|
|
tmc_status(stepperE1, TMC_E1, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
tmc_status(stepperE1, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
#if ENABLED(DISTINCT_E_FACTORS) |
|
|
|
+ 1 |
|
|
|
#endif |
|
|
|
]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E2) |
|
|
|
tmc_status(stepperE2, TMC_E2, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
tmc_status(stepperE2, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
#if ENABLED(DISTINCT_E_FACTORS) |
|
|
|
+ 2 |
|
|
|
#endif |
|
|
|
]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E3) |
|
|
|
tmc_status(stepperE3, TMC_E3, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
tmc_status(stepperE3, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
#if ENABLED(DISTINCT_E_FACTORS) |
|
|
|
+ 3 |
|
|
|
#endif |
|
|
|
]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E4) |
|
|
|
tmc_status(stepperE4, TMC_E4, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
tmc_status(stepperE4, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
#if ENABLED(DISTINCT_E_FACTORS) |
|
|
|
+ 4 |
|
|
|
#endif |
|
|
|
]); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E5) |
|
|
|
tmc_status(stepperE5, TMC_E5, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
tmc_status(stepperE5, i, planner.axis_steps_per_mm[E_AXIS |
|
|
|
#if ENABLED(DISTINCT_E_FACTORS) |
|
|
|
+ 5 |
|
|
|
#endif |
|
|
@ -556,46 +451,46 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
|
|
|
|
static void drv_status_loop(const TMC_drv_status_enum i) { |
|
|
|
#if AXIS_IS_TMC(X) |
|
|
|
tmc_parse_drv_status(stepperX, TMC_X, i); |
|
|
|
tmc_parse_drv_status(stepperX, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(X2) |
|
|
|
tmc_parse_drv_status(stepperX2, TMC_X2, i); |
|
|
|
tmc_parse_drv_status(stepperX2, i); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if AXIS_IS_TMC(Y) |
|
|
|
tmc_parse_drv_status(stepperY, TMC_Y, i); |
|
|
|
tmc_parse_drv_status(stepperY, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(Y2) |
|
|
|
tmc_parse_drv_status(stepperY2, TMC_Y2, i); |
|
|
|
tmc_parse_drv_status(stepperY2, i); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if AXIS_IS_TMC(Z) |
|
|
|
tmc_parse_drv_status(stepperZ, TMC_Z, i); |
|
|
|
tmc_parse_drv_status(stepperZ, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(Z2) |
|
|
|
tmc_parse_drv_status(stepperZ2, TMC_Z2, i); |
|
|
|
tmc_parse_drv_status(stepperZ2, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(Z3) |
|
|
|
tmc_parse_drv_status(stepperZ3, TMC_Z3, i); |
|
|
|
tmc_parse_drv_status(stepperZ3, i); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if AXIS_IS_TMC(E0) |
|
|
|
tmc_parse_drv_status(stepperE0, TMC_E0, i); |
|
|
|
tmc_parse_drv_status(stepperE0, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E1) |
|
|
|
tmc_parse_drv_status(stepperE1, TMC_E1, i); |
|
|
|
tmc_parse_drv_status(stepperE1, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E2) |
|
|
|
tmc_parse_drv_status(stepperE2, TMC_E2, i); |
|
|
|
tmc_parse_drv_status(stepperE2, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E3) |
|
|
|
tmc_parse_drv_status(stepperE3, TMC_E3, i); |
|
|
|
tmc_parse_drv_status(stepperE3, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E4) |
|
|
|
tmc_parse_drv_status(stepperE4, TMC_E4, i); |
|
|
|
tmc_parse_drv_status(stepperE4, i); |
|
|
|
#endif |
|
|
|
#if AXIS_IS_TMC(E5) |
|
|
|
tmc_parse_drv_status(stepperE5, TMC_E5, i); |
|
|
|
tmc_parse_drv_status(stepperE5, i); |
|
|
|
#endif |
|
|
|
|
|
|
|
SERIAL_EOL(); |
|
|
@ -620,7 +515,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
TMC_REPORT("Run current", TMC_IRUN); |
|
|
|
TMC_REPORT("Hold current", TMC_IHOLD); |
|
|
|
TMC_REPORT("CS actual\t", TMC_CS_ACTUAL); |
|
|
|
TMC_REPORT("PWM scale\t", TMC_PWM_SCALE); |
|
|
|
TMC_REPORT("PWM scale", TMC_PWM_SCALE); |
|
|
|
TMC_REPORT("vsense\t", TMC_VSENSE); |
|
|
|
TMC_REPORT("stealthChop", TMC_STEALTHCHOP); |
|
|
|
TMC_REPORT("msteps\t", TMC_MICROSTEPS); |
|
|
@ -657,7 +552,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
DRV_REPORT("s2vsa\t", TMC_S2VSA); |
|
|
|
DRV_REPORT("s2vsb\t", TMC_S2VSB); |
|
|
|
#endif |
|
|
|
DRV_REPORT("Driver registers:", TMC_DRV_STATUS_HEX); |
|
|
|
DRV_REPORT("Driver registers:\n",TMC_DRV_STATUS_HEX); |
|
|
|
SERIAL_EOL(); |
|
|
|
} |
|
|
|
|
|
|
@ -666,9 +561,9 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
#if USE_SENSORLESS |
|
|
|
|
|
|
|
void tmc_stallguard(TMC2130Stepper &st, const bool enable/*=true*/) { |
|
|
|
st.coolstep_min_speed(enable ? 1024UL * 1024UL - 1UL : 0); |
|
|
|
st.TCOOLTHRS(enable ? 0xFFFFF : 0); |
|
|
|
#if ENABLED(STEALTHCHOP) |
|
|
|
st.stealthChop(!enable); |
|
|
|
st.en_pwm_mode(!enable); |
|
|
|
#endif |
|
|
|
st.diag1_stall(enable ? 1 : 0); |
|
|
|
} |
|
|
@ -676,45 +571,46 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) { |
|
|
|
#endif // USE_SENSORLESS
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2130) |
|
|
|
#define IS_TMC_SPI(ST) AXIS_DRIVER_TYPE(ST, TMC2130) |
|
|
|
#define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH) |
|
|
|
void tmc_init_cs_pins() { |
|
|
|
#if AXIS_DRIVER_TYPE(X, TMC2130) |
|
|
|
#if IS_TMC_SPI(X) |
|
|
|
SET_CS_PIN(X); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(Y, TMC2130) |
|
|
|
#if IS_TMC_SPI(Y) |
|
|
|
SET_CS_PIN(Y); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(Z, TMC2130) |
|
|
|
#if IS_TMC_SPI(Z) |
|
|
|
SET_CS_PIN(Z); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(X2, TMC2130) |
|
|
|
#if IS_TMC_SPI(X2) |
|
|
|
SET_CS_PIN(X2); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(Y2, TMC2130) |
|
|
|
#if IS_TMC_SPI(Y2) |
|
|
|
SET_CS_PIN(Y2); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(Z2, TMC2130) |
|
|
|
#if IS_TMC_SPI(Z2) |
|
|
|
SET_CS_PIN(Z2); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(Z3, TMC2130) |
|
|
|
#if IS_TMC_SPI(Z3) |
|
|
|
SET_CS_PIN(Z3); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(E0, TMC2130) |
|
|
|
#if IS_TMC_SPI(E0) |
|
|
|
SET_CS_PIN(E0); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(E1, TMC2130) |
|
|
|
#if IS_TMC_SPI(E1) |
|
|
|
SET_CS_PIN(E1); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(E2, TMC2130) |
|
|
|
#if IS_TMC_SPI(E2) |
|
|
|
SET_CS_PIN(E2); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(E3, TMC2130) |
|
|
|
#if IS_TMC_SPI(E3) |
|
|
|
SET_CS_PIN(E3); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(E4, TMC2130) |
|
|
|
#if IS_TMC_SPI(E4) |
|
|
|
SET_CS_PIN(E4); |
|
|
|
#endif |
|
|
|
#if AXIS_DRIVER_TYPE(E5, TMC2130) |
|
|
|
#if IS_TMC_SPI(E5) |
|
|
|
SET_CS_PIN(E5); |
|
|
|
#endif |
|
|
|
} |
|
|
|