Added experimental features stallguard on E0.

master
Marcio Teixeira 7 years ago
parent adf64f2613
commit 52fe770eb2

@ -1044,21 +1044,64 @@
else \
SERIAL_ERRORLNPGM("Probe not triggered");
/*#define LULZBOT_TMC_G0G1_STALLGUARD_REPORT \
static int nextSgReport = 100; \
if(planner.blocks_queued()) { \
if(nextSgReport-- == 0) { \
nextSgReport = 100; \
LULZBOT_TMC_REPORT(AXIS)\
/* The following function accumulates the average of a
stallguard value during a planner move and reports
it once the motion ends */
#define LULZBOT_TMC_STALLGUARD_AVERAGE(AXIS, SUM, NUM) \
static uint8_t current_tail; \
static uint32_t SUM; \
static uint16_t NUM; \
if(current_tail != planner.block_buffer_tail) { \
current_tail = planner.block_buffer_tail; \
/* When the planner finishes move, report results */ \
SERIAL_ECHOLNPAIR(#AXIS " avg_sg: ", SUM/NUM); \
SUM = 0; \
NUM = 0; \
} else if(planner.blocks_queued()) { \
/* While in motion, accumulate sg values */ \
SUM += stepper##AXIS.DRV_STATUS() & 0b111111111; \
NUM++; \
}
/* The following function reports when the average of the
stallguard value changes significantly */
#define LULZBOT_TMC_STALLGUARD_REPORT_CHANGES(AXIS, SUM, NUM, THRESH) \
static uint8_t current_tail; \
static uint32_t SUM; \
static uint16_t NUM; \
static uint16_t last_avg; \
if(current_tail != planner.block_buffer_tail) { \
current_tail = planner.block_buffer_tail; \
uint16_t avg = SUM/NUM; \
if(abs(int(last_avg) - avg) > last_avg * THRESH) { \
SERIAL_ECHOLNPAIR("Detected changed in sg value:", avg - last_avg); \
} \
}*/
SERIAL_ECHOLNPAIR(#AXIS " avg_sg: ", avg); \
last_avg = avg; \
SUM = 0; \
NUM = 0; \
} else if(planner.blocks_queued()) { \
/* While in motion, accumulate sg values */ \
SUM += stepper##AXIS.DRV_STATUS() & 0b111111111; \
NUM++; \
}
#define LULZBOT_TMC_G0G1_STALLGUARD_REPORT
#define LULZBOT_TMC_G0G1_STALLGUARD_REPORT \
LULZBOT_TMC_STALLGUARD_AVERAGE(E0, sg_sum_e, sg_num_e)
//#define LULZBOT_TMC_G0G1_STALLGUARD_REPORT
#define LULZBOT_TMC_M119_STALLGUARD_REPORT \
LULZBOT_TMC_REPORT(X) \
LULZBOT_TMC_REPORT(Y) \
LULZBOT_TMC_REPORT(Z)
#define LULZBOT_TMC2130_ADV { \
/* Turn off stealhchop for extruder motor */ \
stepperE0.coolstep_min_speed(1024UL * 1024UL - 1UL); \
/* Set stallguard value for filament sensing */ \
stepperE0.sg_stall_value(5); \
}
#else
#define LULZBOT_TMC_M119_STALLGUARD_REPORT
#define LULZBOT_TMC_G0G1_STALLGUARD_REPORT

@ -1072,7 +1072,7 @@
* stepperX.interpolate(0); \
* }
*/
#define TMC2130_ADV() { }
#define TMC2130_ADV() LULZBOT_TMC2130_ADV
#endif // HAVE_TMC2130

@ -9933,8 +9933,7 @@ inline void gcode_M502() {
static void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
SERIAL_CHAR(name);
SERIAL_ECHOPGM(" driver homing sensitivity set to ");
SERIAL_ECHOLN(st.sgt());
SERIAL_ECHOLNPAIR(" driver homing sensitivity set to ", st.sgt());
}
static void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
st.sgt(sgt_val);
@ -10057,6 +10056,10 @@ inline void gcode_M502() {
if (parser.seen(axis_codes[Y_AXIS])) tmc2130_set_sgt(stepperY, 'Y', parser.value_int());
else tmc2130_get_sgt(stepperY, 'Y');
#endif
#if ENABLED(E0_IS_TMC2130)
if (parser.seen(axis_codes[E_AXIS])) tmc2130_set_sgt(stepperE0, 'E', parser.value_int());
else tmc2130_get_sgt(stepperE0, 'E');
#endif
}
#endif // SENSORLESS_HOMING

Loading…
Cancel
Save