commit
dc8625d7e4
@ -2034,7 +2034,11 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
|
||||
// SERIAL_ECHO(int(verbosity_level));
|
||||
// SERIAL_ECHOPGM("");
|
||||
|
||||
#ifdef NEW_XYZCAL
|
||||
{
|
||||
#else //NEW_XYZCAL
|
||||
while (iteration < 3) {
|
||||
#endif //NEW_XYZCAL
|
||||
|
||||
SERIAL_ECHOPGM("Iteration: ");
|
||||
MYSERIAL.println(int(iteration + 1));
|
||||
|
@ -585,7 +585,12 @@ FORCE_INLINE void stepper_check_endstops()
|
||||
if (! check_z_endstop) {
|
||||
#ifdef TMC2130_SG_HOMING
|
||||
// Stall guard homing turned on
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
||||
#ifdef TMC2130_STEALTH_Z
|
||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
||||
else
|
||||
#endif //TMC2130_STEALTH_Z
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
||||
#else
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
||||
#endif //TMC2130_SG_HOMING
|
||||
@ -601,6 +606,11 @@ FORCE_INLINE void stepper_check_endstops()
|
||||
#if defined(Z_MAX_PIN) && (Z_MAX_PIN > -1) && !defined(DEBUG_DISABLE_ZMAXLIMIT)
|
||||
#ifdef TMC2130_SG_HOMING
|
||||
// Stall guard homing turned on
|
||||
#ifdef TMC2130_STEALTH_Z
|
||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
||||
z_max_endstop = false;
|
||||
else
|
||||
#endif //TMC2130_STEALTH_Z
|
||||
z_max_endstop = (READ(Z_TMC2130_DIAG) != 0);
|
||||
#else
|
||||
z_max_endstop = (READ(Z_MAX_PIN) != Z_MAX_ENDSTOP_INVERTING);
|
||||
@ -622,7 +632,12 @@ FORCE_INLINE void stepper_check_endstops()
|
||||
// Good for searching for the center of an induction target.
|
||||
#ifdef TMC2130_SG_HOMING
|
||||
// Stall guard homing turned on
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
||||
#ifdef TMC2130_STEALTH_Z
|
||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && !(tmc2130_sg_homing_axes_mask & 0x04))
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
||||
else
|
||||
#endif //TMC2130_STEALTH_Z
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING) || (READ(Z_TMC2130_DIAG) != 0);
|
||||
#else
|
||||
z_min_endstop = (READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING);
|
||||
#endif //TMC2130_SG_HOMING
|
||||
|
@ -52,7 +52,7 @@ uint8_t tmc2130_sg_thr[4] = {TMC2130_SG_THRS_X, TMC2130_SG_THRS_Y, TMC2130_SG_TH
|
||||
uint8_t tmc2130_sg_thr_home[4] = {3, 3, TMC2130_SG_THRS_Z, TMC2130_SG_THRS_E};
|
||||
|
||||
|
||||
uint8_t sg_homing_axes_mask = 0x00;
|
||||
uint8_t tmc2130_sg_homing_axes_mask = 0x00;
|
||||
|
||||
uint8_t tmc2130_sg_meassure = 0xff;
|
||||
uint32_t tmc2130_sg_meassure_cnt = 0;
|
||||
@ -131,7 +131,16 @@ uint8_t tmc2130_rx(uint8_t axis, uint8_t addr, uint32_t* rval);
|
||||
|
||||
void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_t current_r);
|
||||
|
||||
|
||||
uint16_t __tcoolthrs(uint8_t axis)
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
case X_AXIS: return TMC2130_TCOOLTHRS_X;
|
||||
case Y_AXIS: return TMC2130_TCOOLTHRS_Y;
|
||||
case Z_AXIS: return TMC2130_TCOOLTHRS_Z;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tmc2130_init()
|
||||
{
|
||||
@ -156,7 +165,7 @@ void tmc2130_init()
|
||||
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
|
||||
tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000);
|
||||
tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr[axis]) << 16));
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, (tmc2130_mode == TMC2130_MODE_SILENT)?0:((axis==X_AXIS)?TMC2130_TCOOLTHRS_X:TMC2130_TCOOLTHRS_Y));
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, (tmc2130_mode == TMC2130_MODE_SILENT)?0:__tcoolthrs(axis));
|
||||
tmc2130_wr(axis, TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?TMC2130_GCONF_SILENT:TMC2130_GCONF_SGSENS);
|
||||
tmc2130_wr_PWMCONF(axis, tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
|
||||
tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS);
|
||||
@ -166,7 +175,15 @@ void tmc2130_init()
|
||||
{
|
||||
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
|
||||
tmc2130_wr(axis, TMC2130_REG_TPOWERDOWN, 0x00000000);
|
||||
#ifndef TMC2130_STEALTH_Z
|
||||
tmc2130_wr(axis, TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS);
|
||||
#else //TMC2130_STEALTH_Z
|
||||
tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr[axis]) << 16));
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, (tmc2130_mode == TMC2130_MODE_SILENT)?0:__tcoolthrs(axis));
|
||||
tmc2130_wr(axis, TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?TMC2130_GCONF_SILENT:TMC2130_GCONF_SGSENS);
|
||||
tmc2130_wr_PWMCONF(axis, tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
|
||||
tmc2130_wr_TPWMTHRS(axis, TMC2130_TPWMTHRS);
|
||||
#endif //TMC2130_STEALTH_Z
|
||||
}
|
||||
for (int axis = 3; axis < 4; axis++) // E axis
|
||||
{
|
||||
@ -238,7 +255,7 @@ void tmc2130_st_isr(uint8_t last_step_mask)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sg_homing_axes_mask == 0)
|
||||
if (tmc2130_sg_homing_axes_mask == 0)
|
||||
{
|
||||
if (tmc2130_sg_stop_on_crash && crash)
|
||||
{
|
||||
@ -265,7 +282,7 @@ bool tmc2130_update_sg()
|
||||
|
||||
void tmc2130_home_enter(uint8_t axes_mask)
|
||||
{
|
||||
// printf_P(PSTR("tmc2130_home_enter(axes_mask=0x%02x)\n"), axes_mask);
|
||||
printf_P(PSTR("tmc2130_home_enter(axes_mask=0x%02x)\n"), axes_mask);
|
||||
#ifdef TMC2130_SG_HOMING
|
||||
if (axes_mask & 0x03) //X or Y
|
||||
tmc2130_wait_standstill_xy(1000);
|
||||
@ -274,12 +291,12 @@ void tmc2130_home_enter(uint8_t axes_mask)
|
||||
uint8_t mask = (X_AXIS_MASK << axis);
|
||||
if (axes_mask & mask)
|
||||
{
|
||||
sg_homing_axes_mask |= mask;
|
||||
tmc2130_sg_homing_axes_mask |= mask;
|
||||
//Configuration to spreadCycle
|
||||
tmc2130_wr(axis, TMC2130_REG_GCONF, TMC2130_GCONF_NORMAL);
|
||||
tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr_home[axis]) << 16));
|
||||
// tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr[axis]) << 16) | ((uint32_t)1 << 24));
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, (axis==X_AXIS)?TMC2130_TCOOLTHRS_X:TMC2130_TCOOLTHRS_Y);
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, __tcoolthrs(axis));
|
||||
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r_home[axis]);
|
||||
if (mask & (X_AXIS_MASK | Y_AXIS_MASK | Z_AXIS_MASK))
|
||||
tmc2130_wr(axis, TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS); //stallguard output DIAG1, DIAG1 = pushpull
|
||||
@ -290,18 +307,22 @@ void tmc2130_home_enter(uint8_t axes_mask)
|
||||
|
||||
void tmc2130_home_exit()
|
||||
{
|
||||
// printf_P(PSTR("tmc2130_home_exit sg_homing_axes_mask=0x%02x\n"), sg_homing_axes_mask);
|
||||
printf_P(PSTR("tmc2130_home_exit tmc2130_sg_homing_axes_mask=0x%02x\n"), tmc2130_sg_homing_axes_mask);
|
||||
#ifdef TMC2130_SG_HOMING
|
||||
if (sg_homing_axes_mask & 0x03) //X or Y
|
||||
if (tmc2130_sg_homing_axes_mask & 0x03) //X or Y
|
||||
tmc2130_wait_standstill_xy(1000);
|
||||
if (sg_homing_axes_mask)
|
||||
if (tmc2130_sg_homing_axes_mask)
|
||||
{
|
||||
for (uint8_t axis = X_AXIS; axis <= Z_AXIS; axis++) //X Y and Z axes
|
||||
{
|
||||
uint8_t mask = (X_AXIS_MASK << axis);
|
||||
if (sg_homing_axes_mask & mask & (X_AXIS_MASK | Y_AXIS_MASK))
|
||||
if (tmc2130_sg_homing_axes_mask & mask & (X_AXIS_MASK | Y_AXIS_MASK | Z_AXIS_MASK))
|
||||
{
|
||||
#ifndef TMC2130_STEALTH_Z
|
||||
if ((tmc2130_mode == TMC2130_MODE_SILENT) && (axis != Z_AXIS))
|
||||
#else //TMC2130_STEALTH_Z
|
||||
if (tmc2130_mode == TMC2130_MODE_SILENT)
|
||||
#endif //TMC2130_STEALTH_Z
|
||||
{
|
||||
tmc2130_wr(axis, TMC2130_REG_GCONF, TMC2130_GCONF_SILENT); // Configuration back to stealthChop
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, 0);
|
||||
@ -313,12 +334,12 @@ void tmc2130_home_exit()
|
||||
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
|
||||
// tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr[axis]) << 16) | ((uint32_t)1 << 24));
|
||||
tmc2130_wr(axis, TMC2130_REG_COOLCONF, (((uint32_t)tmc2130_sg_thr[axis]) << 16));
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, (tmc2130_mode == TMC2130_MODE_SILENT)?0:((axis==X_AXIS)?TMC2130_TCOOLTHRS_X:TMC2130_TCOOLTHRS_Y));
|
||||
tmc2130_wr(axis, TMC2130_REG_TCOOLTHRS, __tcoolthrs(axis));
|
||||
tmc2130_wr(axis, TMC2130_REG_GCONF, TMC2130_GCONF_SGSENS);
|
||||
}
|
||||
}
|
||||
}
|
||||
sg_homing_axes_mask = 0x00;
|
||||
tmc2130_sg_homing_axes_mask = 0x00;
|
||||
}
|
||||
tmc2130_sg_crash = false;
|
||||
#endif
|
||||
|
@ -20,6 +20,8 @@ extern uint8_t tmc2130_sg_meassure;
|
||||
extern uint32_t tmc2130_sg_meassure_cnt;
|
||||
extern uint32_t tmc2130_sg_meassure_val;
|
||||
|
||||
extern uint8_t tmc2130_sg_homing_axes_mask;
|
||||
|
||||
#define TMC2130_MODE_NORMAL 0
|
||||
#define TMC2130_MODE_SILENT 1
|
||||
|
||||
|
@ -245,6 +245,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
#define TMC2130_CURRENTS_R {16, 20, 28, 36} // default running currents for all axes
|
||||
#define TMC2130_UNLOAD_CURRENT_R 12 // lowe current for M600 to protect filament sensor
|
||||
|
||||
#define TMC2130_STEALTH_Z
|
||||
|
||||
//#define TMC2130_DEBUG
|
||||
//#define TMC2130_DEBUG_WR
|
||||
//#define TMC2130_DEBUG_RD
|
||||
|
@ -370,7 +370,7 @@ void xyzcal_adjust_pixels(uint8_t* pixels, uint16_t* histo)
|
||||
{
|
||||
uint8_t l;
|
||||
uint16_t max_c = histo[0];
|
||||
uint8_t max_l = 0;
|
||||
uint8_t max_l = 1;
|
||||
for (l = 1; l < 16; l++)
|
||||
{
|
||||
uint16_t c = histo[l];
|
||||
@ -384,7 +384,7 @@ void xyzcal_adjust_pixels(uint8_t* pixels, uint16_t* histo)
|
||||
for (l = 15; l > 8; l--)
|
||||
if (histo[l] >= 10)
|
||||
break;
|
||||
uint8_t pix_min = (max_l + 2) << 4;
|
||||
uint8_t pix_min = (max_l + 1) << 4;
|
||||
uint8_t pix_max = l << 4;
|
||||
uint8_t pix_dif = pix_max - pix_min;
|
||||
DBG(_n(" min=%d max=%d dif=%d\n"), pix_min, pix_max, pix_dif);
|
||||
@ -425,7 +425,7 @@ void xyzcal_draw_pattern_12x12_in_32x32(uint8_t* pattern, uint32_t* pixels, int
|
||||
|
||||
int16_t xyzcal_match_pattern_12x12_in_32x32(uint16_t* pattern, uint8_t* pixels, uint8_t c, uint8_t r)
|
||||
{
|
||||
uint8_t thr = 32;
|
||||
uint8_t thr = 16;
|
||||
int16_t match = 0;
|
||||
for (uint8_t i = 0; i < 12; i++)
|
||||
for (uint8_t j = 0; j < 12; j++)
|
||||
|
Loading…
Reference in New Issue
Block a user