Merge pull request #7 from XPila/MK3
TMC2130 stallguard homing - sg_thrs_x and sg_thrs_y - command M916, l…
This commit is contained in:
commit
4480aa3b6a
@ -5516,7 +5516,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
||||
}
|
||||
break;
|
||||
|
||||
case 913: // M912 Print TMC2130 currents
|
||||
case 913: // M913 Print TMC2130 currents
|
||||
{
|
||||
tmc2130_print_currents();
|
||||
}
|
||||
@ -5534,6 +5534,17 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
||||
tmc2130_mode = TMC2130_MODE_SILENT;
|
||||
tmc2130_init();
|
||||
}
|
||||
break;
|
||||
|
||||
case 916: // M916 Set sg_thrs
|
||||
{
|
||||
if (code_seen('X')) sg_thrs_x = code_value();
|
||||
if (code_seen('Y')) sg_thrs_y = code_value();
|
||||
MYSERIAL.print("sg_thrs_x=");
|
||||
MYSERIAL.print(sg_thrs_x, DEC);
|
||||
MYSERIAL.print(" sg_thrs_y=");
|
||||
MYSERIAL.println(sg_thrs_y, DEC);
|
||||
}
|
||||
break;
|
||||
|
||||
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
||||
|
@ -24,6 +24,9 @@ uint8_t tmc2130_LastHomingStalled = 0;
|
||||
|
||||
uint8_t sg_homing_axis = 0xff;
|
||||
uint8_t sg_homing_delay = 0;
|
||||
uint8_t sg_thrs_x = TMC2130_SG_THRS_X;
|
||||
uint8_t sg_thrs_y = TMC2130_SG_THRS_Y;
|
||||
|
||||
|
||||
//TMC2130 registers
|
||||
#define TMC2130_REG_GCONF 0x00 // 17 bits
|
||||
@ -117,6 +120,7 @@ void tmc2130_init()
|
||||
|
||||
bool tmc2130_update_sg()
|
||||
{
|
||||
#if (defined(TMC2130_SG_HOMING) && defined(TMC2130_SG_HOMING_SW))
|
||||
if ((sg_homing_axis == X_AXIS) || (sg_homing_axis == Y_AXIS))
|
||||
{
|
||||
uint8_t cs = tmc2130_cs[sg_homing_axis];
|
||||
@ -146,6 +150,7 @@ bool tmc2130_update_sg()
|
||||
tmc2130_axis_stalled[X_AXIS] = false;
|
||||
tmc2130_axis_stalled[Y_AXIS] = false;
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -178,6 +183,7 @@ void tmc2130_home_enter(uint8_t axis)
|
||||
{
|
||||
MYSERIAL.print("tmc2130_home_enter ");
|
||||
MYSERIAL.println((int)axis);
|
||||
#ifdef TMC2130_SG_HOMING
|
||||
uint8_t cs = tmc2130_cs[axis];
|
||||
sg_homing_axis = axis;
|
||||
sg_homing_delay = 0;
|
||||
@ -185,22 +191,28 @@ void tmc2130_home_enter(uint8_t axis)
|
||||
tmc2130_axis_stalled[Y_AXIS] = false;
|
||||
//Configuration to spreadCycle
|
||||
tmc2130_wr(cs, TMC2130_REG_GCONF, 0x00000000);
|
||||
tmc2130_wr(cs, TMC2130_REG_COOLCONF, ((axis == X_AXIS)?TMC2130_SG_THRS_X:TMC2130_SG_THRS_Y) << 16);
|
||||
tmc2130_wr(cs, TMC2130_REG_COOLCONF, ((axis == X_AXIS)?sg_thrs_x:sg_thrs_y) << 16);
|
||||
tmc2130_wr(cs, TMC2130_REG_TCOOLTHRS, TMC2130_TCOOLTHRS);
|
||||
#ifndef TMC2130_SG_HOMING_SW
|
||||
tmc2130_wr(cs, TMC2130_REG_GCONF, 0x00000080); //stallguard output to DIAG0
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void tmc2130_home_exit()
|
||||
{
|
||||
MYSERIAL.println("tmc2130_home_exit");
|
||||
MYSERIAL.println("tmc2130_home_exit ");
|
||||
MYSERIAL.println((int)sg_homing_axis);
|
||||
#ifdef TMC2130_SG_HOMING
|
||||
if ((sg_homing_axis == X_AXIS) || (sg_homing_axis == Y_AXIS))
|
||||
{
|
||||
if (tmc2130_mode == TMC2130_MODE_SILENT)
|
||||
{
|
||||
// Configuration back to stealthChop
|
||||
tmc2130_wr(tmc2130_cs[sg_homing_axis], TMC2130_REG_GCONF, 0x00000004);
|
||||
}
|
||||
tmc2130_wr(tmc2130_cs[sg_homing_axis], TMC2130_REG_GCONF, 0x00000004); // Configuration back to stealthChop
|
||||
else
|
||||
tmc2130_wr(tmc2130_cs[sg_homing_axis], TMC2130_REG_GCONF, 0x00000000);
|
||||
sg_homing_axis = 0xff;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
extern uint8_t tmc2130_didLastHomingStall()
|
||||
|
@ -9,7 +9,8 @@ extern uint8_t tmc2130_current_r[4];
|
||||
//flags for axis stall detection
|
||||
extern uint8_t tmc2130_axis_stalled[4];
|
||||
|
||||
//extern uint8_t sg_homing_delay;
|
||||
extern uint8_t sg_thrs_x;
|
||||
extern uint8_t sg_thrs_y;
|
||||
|
||||
#define TMC2130_MODE_NORMAL 0
|
||||
#define TMC2130_MODE_SILENT 1
|
||||
@ -27,11 +28,12 @@ extern void tmc2130_home_exit();
|
||||
//
|
||||
extern uint8_t tmc2130_didLastHomingStall();
|
||||
|
||||
//set holding current for any axis (G911)
|
||||
//set holding current for any axis (M911)
|
||||
extern void tmc2130_set_current_h(uint8_t axis, uint8_t current);
|
||||
//set running current for any axis (G912)
|
||||
//set running current for any axis (M912)
|
||||
extern void tmc2130_set_current_r(uint8_t axis, uint8_t current);
|
||||
//print currents
|
||||
//print currents (M913)
|
||||
extern void tmc2130_print_currents();
|
||||
|
||||
|
||||
#endif //TMC2130_H
|
@ -3852,6 +3852,10 @@ static void lcd_autostart_sd()
|
||||
static void lcd_silent_mode_set_tune() {
|
||||
SilentModeMenu = !SilentModeMenu;
|
||||
eeprom_update_byte((unsigned char*)EEPROM_SILENT, SilentModeMenu);
|
||||
#ifdef HAVE_TMC2130_DRIVERS
|
||||
tmc2130_mode = SilentModeMenu?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
|
||||
tmc2130_init();
|
||||
#endif //HAVE_TMC2130_DRIVERS
|
||||
digipot_init();
|
||||
lcd_goto_menu(lcd_tune_menu, 9);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user