Merge pull request #65 from XPila/MK3

Silent / Hight Power mode switching - wait for standstill
This commit is contained in:
XPila 2017-09-26 12:27:40 +02:00 committed by GitHub
commit c1f5ba9cc9
4 changed files with 43 additions and 6 deletions

View File

@ -112,13 +112,13 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis #define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis
#define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis #define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis
#define TMC2130_PWM_GRAD_X 4 // PWMCONF #define TMC2130_PWM_GRAD_X 8 // PWMCONF
#define TMC2130_PWM_AMPL_X 210 // PWMCONF #define TMC2130_PWM_AMPL_X 220 // PWMCONF
#define TMC2130_PWM_AUTO_X 1 // PWMCONF #define TMC2130_PWM_AUTO_X 1 // PWMCONF
#define TMC2130_PWM_FREQ_X 2 // PWMCONF #define TMC2130_PWM_FREQ_X 2 // PWMCONF
#define TMC2130_PWM_GRAD_Y 4 // PWMCONF #define TMC2130_PWM_GRAD_Y 8 // PWMCONF
#define TMC2130_PWM_AMPL_Y 215 // PWMCONF #define TMC2130_PWM_AMPL_Y 225 // PWMCONF
#define TMC2130_PWM_AUTO_Y 1 // PWMCONF #define TMC2130_PWM_AUTO_Y 1 // PWMCONF
#define TMC2130_PWM_FREQ_Y 2 // PWMCONF #define TMC2130_PWM_FREQ_Y 2 // PWMCONF
@ -140,8 +140,10 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode #define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
#define TMC2130_THIGH 0 // THIGH - unused #define TMC2130_THIGH 0 // THIGH - unused
#define TMC2130_TCOOLTHRS_X 450 // TCOOLTHRS - coolstep treshold //#define TMC2130_TCOOLTHRS_X 450 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_Y 450 // TCOOLTHRS - coolstep treshold //#define TMC2130_TCOOLTHRS_Y 450 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_X 430 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_Y 430 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold #define TMC2130_TCOOLTHRS_Z 500 // TCOOLTHRS - coolstep treshold
#define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold #define TMC2130_TCOOLTHRS_E 500 // TCOOLTHRS - coolstep treshold

View File

@ -429,17 +429,46 @@ void tmc2130_home_restart(uint8_t axis)
tmc2130_axis_stalled[axis] = false; tmc2130_axis_stalled[axis] = false;
} }
bool tmc2130_wait_standstill_xy(int timeout)
{
// MYSERIAL.println("tmc2130_wait_standstill_xy");
bool standstill = false;
while (!standstill && (timeout > 0))
{
uint32_t drv_status_x = 0;
uint32_t drv_status_y = 0;
tmc2130_rd(tmc2130_cs[X_AXIS], TMC2130_REG_DRV_STATUS, &drv_status_x);
tmc2130_rd(tmc2130_cs[Y_AXIS], TMC2130_REG_DRV_STATUS, &drv_status_y);
/* MYSERIAL.print(timeout, 10);
MYSERIAL.println(' ');
MYSERIAL.print(drv_status_x, 16);
MYSERIAL.println(' ');
MYSERIAL.print(drv_status_y, 16);
MYSERIAL.println('#');*/
standstill = (drv_status_x & 0x80000000) && (drv_status_y & 0x80000000);
tmc2130_check_overtemp();
timeout--;
}
return standstill;
}
void tmc2130_check_overtemp() void tmc2130_check_overtemp()
{ {
const static char TMC_OVERTEMP_MSG[] PROGMEM = "TMC DRIVER OVERTEMP "; const static char TMC_OVERTEMP_MSG[] PROGMEM = "TMC DRIVER OVERTEMP ";
static uint32_t checktime = 0; static uint32_t checktime = 0;
if (millis() - checktime > 1000 ) if (millis() - checktime > 1000 )
{ {
// MYSERIAL.print("DRV_STATUS ");
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
{ {
uint32_t drv_status = 0; uint32_t drv_status = 0;
skip_debug_msg = true; skip_debug_msg = true;
tmc2130_rd(tmc2130_cs[i], TMC2130_REG_DRV_STATUS, &drv_status); tmc2130_rd(tmc2130_cs[i], TMC2130_REG_DRV_STATUS, &drv_status);
/* MYSERIAL.print(i, DEC);
MYSERIAL.print(' ');
MYSERIAL.print(drv_status, 16);*/
if (drv_status & ((uint32_t)1 << 26)) if (drv_status & ((uint32_t)1 << 26))
{ // BIT 26 - over temp prewarning ~120C (+-20C) { // BIT 26 - over temp prewarning ~120C (+-20C)
SERIAL_ERRORRPGM(TMC_OVERTEMP_MSG); SERIAL_ERRORRPGM(TMC_OVERTEMP_MSG);
@ -450,6 +479,7 @@ void tmc2130_check_overtemp()
} }
} }
// MYSERIAL.println('#');
checktime = millis(); checktime = millis();
tmc2130_sg_change = true; tmc2130_sg_change = true;
} }

View File

@ -52,6 +52,7 @@ extern uint16_t tmc2130_rd_MSCNT(uint8_t cs);
extern void tmc2130_home_pause(uint8_t axis); extern void tmc2130_home_pause(uint8_t axis);
extern void tmc2130_home_resume(uint8_t axis); extern void tmc2130_home_resume(uint8_t axis);
extern bool tmc2130_wait_standstill_xy(int timeout);
#endif //TMC2130_H #endif //TMC2130_H

View File

@ -2533,6 +2533,10 @@ static void lcd_silent_mode_set() {
eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu); eeprom_update_byte((unsigned char *)EEPROM_SILENT, SilentModeMenu);
#ifdef TMC2130 #ifdef TMC2130
st_synchronize(); st_synchronize();
if (tmc2130_wait_standstill_xy(100))
MYSERIAL.print("standstill OK");
else
MYSERIAL.print("standstill NG!");
cli(); cli();
tmc2130_mode = SilentModeMenu?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL; tmc2130_mode = SilentModeMenu?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
tmc2130_init(); tmc2130_init();