From 89acf2924726a64f5df57f9934a4f8eda8ec46bf Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Sat, 23 Sep 2017 15:01:31 +0200 Subject: [PATCH] Silent/High Power mode switching with crashdetection. --- Firmware/Marlin_main.cpp | 40 ++++++++++++++++++++-------------------- Firmware/tmc2130.cpp | 11 ++++++----- Firmware/tmc2130.h | 2 +- Firmware/ultralcd.cpp | 4 ++-- 4 files changed, 29 insertions(+), 28 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index edc1db49..22463b8e 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -569,26 +569,26 @@ void stop_and_save_print_to_ram(float z_move, float e_move); void restore_print_from_ram_and_continue(float e_move); -void crashdet_enable() -{ - tmc2130_sg_stop_on_crash = true; -} - -void crashdet_disable() -{ - tmc2130_sg_stop_on_crash = false; -} - -void crashdet_stop_and_save_print() -{ - stop_and_save_print_to_ram(10, 0); //XY - no change, Z 10mm up, E - no change -} - -void crashdet_restore_print_and_continue() -{ - restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change -} - +void crashdet_enable() +{ + tmc2130_sg_stop_on_crash = true; +} + +void crashdet_disable() +{ + tmc2130_sg_stop_on_crash = false; +} + +void crashdet_stop_and_save_print() +{ + stop_and_save_print_to_ram(10, 0); //XY - no change, Z 10mm up, E - no change +} + +void crashdet_restore_print_and_continue() +{ + restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change +} + #ifdef PAT9125 diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 270394dc..92d39b7d 100644 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -45,7 +45,7 @@ uint32_t tmc2131_axis_sg_pos[4] = {0, 0, 0, 0}; uint8_t sg_homing_axes_mask = 0x00; -bool tmc2130_sg_stop_on_crash = false; +bool tmc2130_sg_stop_on_crash = false; bool tmc2130_sg_crash = false; uint8_t tmc2130_diag_mask = 0x00; @@ -137,7 +137,7 @@ void tmc2130_init() // tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, TMC2130_INTPOL_XY, 0, 0); // tmc2130_wr(tmc2130_cs[i], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[i] & 0x1f) << 8) | (tmc2130_current_h[i] & 0x1f)); tmc2130_wr(tmc2130_cs[i], TMC2130_REG_TPOWERDOWN, 0x00000000); - tmc2130_wr(tmc2130_cs[i], TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr[i]) << 16) | ((uint32_t)1 << 24)); + tmc2130_wr(tmc2130_cs[i], TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr[i]) << 16) | ((uint32_t)1 << 24)); tmc2130_wr(tmc2130_cs[i], TMC2130_REG_TCOOLTHRS, (tmc2130_mode == TMC2130_MODE_SILENT)?0:TMC2130_TCOOLTHRS); tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?TMC2130_GCONF_SILENT:TMC2130_GCONF_SGSENS); tmc2130_wr_PWMCONF(tmc2130_cs[i], tmc2130_pwm_ampl[i], tmc2130_pwm_grad[i], tmc2130_pwm_freq[i], tmc2130_pwm_auto[i], 0, 0); @@ -182,6 +182,7 @@ uint8_t tmc2130_sample_diag() void tmc2130_st_isr(uint8_t last_step_mask) { + if (tmc2130_mode == TMC2130_MODE_SILENT) return; bool error = false; uint8_t diag_mask = tmc2130_sample_diag(); for (uint8_t axis = X_AXIS; axis <= Y_AXIS; axis++) @@ -288,8 +289,8 @@ void tmc2130_home_enter(uint8_t axes_mask) tmc2130_axis_stalled[axis] = false; //Configuration to spreadCycle tmc2130_wr(cs, TMC2130_REG_GCONF, TMC2130_GCONF_NORMAL); - tmc2130_wr(cs, TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr_home[axis]) << 16)); -// tmc2130_wr(cs, TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr[axis]) << 16) | ((uint32_t)1 << 24)); + tmc2130_wr(cs, TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr_home[axis]) << 16)); +// tmc2130_wr(cs, TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr[axis]) << 16) | ((uint32_t)1 << 24)); tmc2130_wr(cs, TMC2130_REG_TCOOLTHRS, TMC2130_TCOOLTHRS); #ifndef TMC2130_SG_HOMING_SW_XY if (mask & (X_AXIS_MASK | Y_AXIS_MASK)) @@ -325,7 +326,7 @@ void tmc2130_home_exit() #ifdef TMC2130_SG_HOMING_SW_XY tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_GCONF, TMC2130_GCONF_NORMAL); #else //TMC2130_SG_HOMING_SW_XY - tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr[axis]) << 16) | ((uint32_t)1 << 24)); + tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_COOLCONF, (((uint32_t)tmc2131_axis_sg_thr[axis]) << 16) | ((uint32_t)1 << 24)); tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS); #endif //TMC2130_SG_HOMING_SW_XY } diff --git a/Firmware/tmc2130.h b/Firmware/tmc2130.h index 20a90b9b..392d5c24 100644 --- a/Firmware/tmc2130.h +++ b/Firmware/tmc2130.h @@ -13,7 +13,7 @@ extern uint8_t tmc2130_axis_stalled[4]; extern uint8_t tmc2131_axis_sg_thr[4]; -extern bool tmc2130_sg_stop_on_crash; +extern bool tmc2130_sg_stop_on_crash; extern bool tmc2130_sg_crash; diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 9959cd5d..4b996148 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -112,8 +112,8 @@ int8_t CrashDetectMenu = 0; extern void fsensor_enable(); extern void fsensor_disable(); -extern void crashdet_enable(); -extern void crashdet_disable(); +extern void crashdet_enable(); +extern void crashdet_disable(); #ifdef SNMM