Changed jerks, disabled oversampling, debug code, commands for seting pwm_ampl and pwm_grad (M917, M918), changed configuration files
This commit is contained in:
parent
b8025e63e6
commit
2b24e9ceb3
@ -433,14 +433,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
|
||||
// #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis
|
||||
|
||||
// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
|
||||
//#define DEFAULT_XJERK 5.0 // (mm/sec)
|
||||
//#define DEFAULT_YJERK 5.0 // (mm/sec)
|
||||
//#define DEFAULT_ZJERK 0.2 // (mm/sec)
|
||||
//#define DEFAULT_EJERK 2.5 // (mm/sec)
|
||||
#define DEFAULT_XJERK 0.5 // (mm/sec)
|
||||
#define DEFAULT_YJERK 0.5 // (mm/sec)
|
||||
#define DEFAULT_ZJERK 0.1 // (mm/sec)
|
||||
#define DEFAULT_EJERK 0.5 // (mm/sec)
|
||||
#define DEFAULT_XJERK 15 // (mm/sec)
|
||||
#define DEFAULT_YJERK 15 // (mm/sec)
|
||||
#define DEFAULT_ZJERK 0.4 // (mm/sec)
|
||||
#define DEFAULT_EJERK 2.5 // (mm/sec)
|
||||
|
||||
//===========================================================================
|
||||
//=============================Additional Features===========================
|
||||
|
@ -1204,7 +1204,7 @@ void setup()
|
||||
eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0);
|
||||
}
|
||||
|
||||
#ifndef DEBUG_SKIP_STARTMSGS
|
||||
#ifndef DEBUG_DISABLE_STARTMSGS
|
||||
check_babystep(); //checking if Z babystep is in allowed range
|
||||
|
||||
if (calibration_status() == CALIBRATION_STATUS_ASSEMBLED ||
|
||||
@ -1224,7 +1224,7 @@ void setup()
|
||||
// Show the message.
|
||||
lcd_show_fullscreen_message_and_wait_P(MSG_FOLLOW_CALIBRATION_FLOW);
|
||||
}
|
||||
#endif //DEBUG_SKIP_STARTMSGS
|
||||
#endif //DEBUG_DISABLE_STARTMSGS
|
||||
for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]);
|
||||
lcd_update_enable(true);
|
||||
|
||||
@ -1881,14 +1881,14 @@ void homeaxis(int axis) {
|
||||
feedrate = homing_feedrate[axis];
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||
|
||||
// sg_homing_delay = 0;
|
||||
sg_homing_delay = 0;
|
||||
st_synchronize();
|
||||
|
||||
current_position[axis] = 0;
|
||||
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||
destination[axis] = -home_retract_mm(axis) * axis_home_dir;
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||
// sg_homing_delay = 0;
|
||||
sg_homing_delay = 0;
|
||||
st_synchronize();
|
||||
|
||||
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
||||
@ -1899,7 +1899,7 @@ void homeaxis(int axis) {
|
||||
#endif
|
||||
feedrate = homing_feedrate[axis] / 2;
|
||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||
// sg_homing_delay = 0;
|
||||
sg_homing_delay = 0;
|
||||
st_synchronize();
|
||||
axis_is_at_home(axis);
|
||||
destination[axis] = current_position[axis];
|
||||
@ -5547,6 +5547,24 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
||||
MYSERIAL.print(" sg_thrs_y=");
|
||||
MYSERIAL.println(sg_thrs_y, DEC);
|
||||
}
|
||||
break;
|
||||
|
||||
case 917: // M917 Set TMC2130 pwm_ampl
|
||||
{
|
||||
if (code_seen('X')) tmc2130_set_pwm_ampl(0, code_value());
|
||||
if (code_seen('Y')) tmc2130_set_pwm_ampl(1, code_value());
|
||||
if (code_seen('Z')) tmc2130_set_pwm_ampl(2, code_value());
|
||||
if (code_seen('E')) tmc2130_set_pwm_ampl(3, code_value());
|
||||
}
|
||||
break;
|
||||
|
||||
case 918: // M918 Set TMC2130 pwm_grad
|
||||
{
|
||||
if (code_seen('X')) tmc2130_set_pwm_grad(0, code_value());
|
||||
if (code_seen('Y')) tmc2130_set_pwm_grad(1, code_value());
|
||||
if (code_seen('Z')) tmc2130_set_pwm_grad(2, code_value());
|
||||
if (code_seen('E')) tmc2130_set_pwm_grad(3, code_value());
|
||||
}
|
||||
break;
|
||||
|
||||
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
||||
|
@ -978,7 +978,7 @@ Having the real displacement of the head, we can calculate the total movement le
|
||||
// Acceleration of the segment, in mm/sec^2
|
||||
block->acceleration = block->acceleration_st / steps_per_mm;
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
// Oversample diagonal movements by a power of 2 up to 8x
|
||||
// to achieve more accurate diagonal movements.
|
||||
uint8_t bresenham_oversample = 1;
|
||||
|
@ -582,14 +582,23 @@ ISR(TIMER1_COMPA_vect)
|
||||
counter_x += current_block->steps_x;
|
||||
if (counter_x > 0) {
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
#ifdef DEBUG_XSTEP_DUP_PIN
|
||||
WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
|
||||
#endif //DEBUG_XSTEP_DUP_PIN
|
||||
counter_x -= current_block->step_event_count;
|
||||
count_position[X_AXIS]+=count_direction[X_AXIS];
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
#ifdef DEBUG_XSTEP_DUP_PIN
|
||||
WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
|
||||
#endif //DEBUG_XSTEP_DUP_PIN
|
||||
}
|
||||
|
||||
counter_y += current_block->steps_y;
|
||||
if (counter_y > 0) {
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
#ifdef DEBUG_YSTEP_DUP_PIN
|
||||
WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
|
||||
#endif //DEBUG_YSTEP_DUP_PIN
|
||||
|
||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Y2_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
@ -598,6 +607,9 @@ ISR(TIMER1_COMPA_vect)
|
||||
counter_y -= current_block->step_event_count;
|
||||
count_position[Y_AXIS]+=count_direction[Y_AXIS];
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
#ifdef DEBUG_YSTEP_DUP_PIN
|
||||
WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
|
||||
#endif //DEBUG_YSTEP_DUP_PIN
|
||||
|
||||
#ifdef Y_DUAL_STEPPER_DRIVERS
|
||||
WRITE(Y2_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
@ -809,9 +821,13 @@ void st_init()
|
||||
|
||||
|
||||
//Initialize Step Pins
|
||||
#if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
|
||||
#if defined(X_STEP_PIN) && (X_STEP_PIN > -1)
|
||||
SET_OUTPUT(X_STEP_PIN);
|
||||
WRITE(X_STEP_PIN,INVERT_X_STEP_PIN);
|
||||
#ifdef DEBUG_XSTEP_DUP_PIN
|
||||
SET_OUTPUT(DEBUG_XSTEP_DUP_PIN);
|
||||
WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
|
||||
#endif //DEBUG_XSTEP_DUP_PIN
|
||||
disable_x();
|
||||
#endif
|
||||
#if defined(X2_STEP_PIN) && (X2_STEP_PIN > -1)
|
||||
@ -822,6 +838,10 @@ void st_init()
|
||||
#if defined(Y_STEP_PIN) && (Y_STEP_PIN > -1)
|
||||
SET_OUTPUT(Y_STEP_PIN);
|
||||
WRITE(Y_STEP_PIN,INVERT_Y_STEP_PIN);
|
||||
#ifdef DEBUG_YSTEP_DUP_PIN
|
||||
SET_OUTPUT(DEBUG_YSTEP_DUP_PIN);
|
||||
WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
|
||||
#endif //DEBUG_YSTEP_DUP_PIN
|
||||
#if defined(Y_DUAL_STEPPER_DRIVERS) && defined(Y2_STEP_PIN) && (Y2_STEP_PIN > -1)
|
||||
SET_OUTPUT(Y2_STEP_PIN);
|
||||
WRITE(Y2_STEP_PIN,INVERT_Y_STEP_PIN);
|
||||
@ -980,10 +1000,16 @@ void babystep(const uint8_t axis,const bool direction)
|
||||
|
||||
//perform step
|
||||
WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN);
|
||||
#ifdef DEBUG_XSTEP_DUP_PIN
|
||||
WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN);
|
||||
#endif //DEBUG_XSTEP_DUP_PIN
|
||||
{
|
||||
volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
|
||||
}
|
||||
WRITE(X_STEP_PIN, INVERT_X_STEP_PIN);
|
||||
#ifdef DEBUG_XSTEP_DUP_PIN
|
||||
WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN);
|
||||
#endif //DEBUG_XSTEP_DUP_PIN
|
||||
|
||||
//get old pin state back.
|
||||
WRITE(X_DIR_PIN,old_x_dir_pin);
|
||||
@ -999,10 +1025,16 @@ void babystep(const uint8_t axis,const bool direction)
|
||||
|
||||
//perform step
|
||||
WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN);
|
||||
#ifdef DEBUG_YSTEP_DUP_PIN
|
||||
WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN);
|
||||
#endif //DEBUG_YSTEP_DUP_PIN
|
||||
{
|
||||
volatile float x=1./float(axis+1)/float(axis+2); //wait a tiny bit
|
||||
}
|
||||
WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN);
|
||||
#ifdef DEBUG_YSTEP_DUP_PIN
|
||||
WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN);
|
||||
#endif //DEBUG_YSTEP_DUP_PIN
|
||||
|
||||
//get old pin state back.
|
||||
WRITE(Y_DIR_PIN,old_y_dir_pin);
|
||||
|
@ -18,15 +18,26 @@ uint8_t tmc2130_current_h[4] = TMC2130_CURRENTS_H;
|
||||
//running currents
|
||||
uint8_t tmc2130_current_r[4] = TMC2130_CURRENTS_R;
|
||||
//axis stalled flags
|
||||
uint8_t tmc2130_axis_stalled[4] = {0, 0, 0, 0};
|
||||
uint8_t tmc2130_axis_stalled[2] = {0, 0};
|
||||
//last homing stalled
|
||||
uint8_t tmc2130_LastHomingStalled = 0;
|
||||
|
||||
//pwm_ampl
|
||||
uint8_t tmc2130_pwm_ampl[2] = {TMC2130_PWM_AMPL_XY, TMC2130_PWM_AMPL_XY};
|
||||
//pwm_grad
|
||||
uint8_t tmc2130_pwm_grad[2] = {TMC2130_PWM_GRAD_XY, TMC2130_PWM_GRAD_XY};
|
||||
//pwm_auto
|
||||
uint8_t tmc2130_pwm_auto[2] = {TMC2130_PWM_AUTO_XY, TMC2130_PWM_AUTO_XY};
|
||||
//pwm_freq
|
||||
uint8_t tmc2130_pwm_freq[2] = {TMC2130_PWM_FREQ_XY, TMC2130_PWM_FREQ_XY};
|
||||
|
||||
|
||||
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;
|
||||
|
||||
bool skip_debug_msg = false;
|
||||
|
||||
//TMC2130 registers
|
||||
#define TMC2130_REG_GCONF 0x00 // 17 bits
|
||||
@ -65,14 +76,17 @@ uint8_t sg_thrs_y = TMC2130_SG_THRS_Y;
|
||||
uint16_t tmc2130_rd_TSTEP(uint8_t cs);
|
||||
uint16_t tmc2130_rd_DRV_STATUS(uint8_t chipselect);
|
||||
|
||||
void tmc2130_wr_CHOPCONF(uint8_t cs, bool extrapolate256 = 0, uint16_t microstep_resolution = 16);
|
||||
void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t PWMautoScale = TMC2130_PWM_AUTO, uint8_t PWMfreq = TMC2130_PWM_FREQ, uint8_t PWMgrad = TMC2130_PWM_GRAD, uint8_t PWMampl = TMC2130_PWM_AMPL);
|
||||
void tmc2130_wr_CHOPCONF(uint8_t cs, uint8_t toff = 3, uint8_t hstrt = 4, uint8_t hend = 1, uint8_t fd3 = 0, uint8_t disfdcc = 0, uint8_t rndtf = 0, uint8_t chm = 0, uint8_t tbl = 2, uint8_t vsense = 0, uint8_t vhighfs = 0, uint8_t vhighchm = 0, uint8_t sync = 0, uint8_t mres = 0b0100, uint8_t intpol = 1, uint8_t dedge = 0, uint8_t diss2g = 0);
|
||||
void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t pwm_ampl, uint8_t pwm_grad, uint8_t pwm_freq, uint8_t pwm_auto, uint8_t pwm_symm, uint8_t freewheel);
|
||||
void tmc2130_wr_TPWMTHRS(uint8_t cs, uint32_t val32);
|
||||
void tmc2130_wr_THIGH(uint8_t cs, uint32_t val32);
|
||||
|
||||
uint8_t tmc2130_txrx(uint8_t cs, uint8_t addr, uint32_t wval, uint32_t* rval);
|
||||
uint8_t tmc2130_axis_by_cs(uint8_t cs);
|
||||
uint8_t tmc2130_mres(uint16_t microstep_resolution);
|
||||
|
||||
uint8_t tmc2130_wr(uint8_t cs, uint8_t addr, uint32_t wval);
|
||||
uint8_t tmc2130_rd(uint8_t cs, uint8_t addr, uint32_t* rval);
|
||||
uint8_t tmc2130_txrx(uint8_t cs, uint8_t addr, uint32_t wval, uint32_t* rval);
|
||||
|
||||
|
||||
|
||||
@ -91,30 +105,30 @@ void tmc2130_init()
|
||||
SPI.begin();
|
||||
for (int i = 0; i < 2; i++) // X Y axes
|
||||
{
|
||||
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?0x00000004:0x00000000);
|
||||
uint8_t mres = tmc2130_mres(TMC2130_USTEPS_XY);
|
||||
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_PWMCONF(tmc2130_cs[i]); //PWM_CONF //reset default=0x00050480
|
||||
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?0x00000004:0x00000000);
|
||||
tmc2130_wr_PWMCONF(tmc2130_cs[i], tmc2130_pwm_ampl[i], tmc2130_pwm_grad[i], tmc2130_pwm_freq[i], tmc2130_pwm_auto[i], 0, 0);
|
||||
tmc2130_wr_TPWMTHRS(tmc2130_cs[i], TMC2130_TPWMTHRS);
|
||||
//tmc2130_wr_THIGH(tmc2130_cs[i], TMC2130_THIGH);
|
||||
tmc2130_wr_CHOPCONF(tmc2130_cs[i], TMC2130_EXP256_XY, TMC2130_USTEPS_XY);
|
||||
}
|
||||
for (int i = 2; i < 3; i++) // Z axis
|
||||
{
|
||||
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, (tmc2130_mode == TMC2130_MODE_SILENT)?0x00000004:0x00000000);
|
||||
uint8_t mres = tmc2130_mres(TMC2130_USTEPS_Z);
|
||||
tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, TMC2130_INTPOL_Z, 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_PWMCONF(tmc2130_cs[i]); //PWM_CONF //reset default=0x00050480
|
||||
tmc2130_wr_TPWMTHRS(tmc2130_cs[i], TMC2130_TPWMTHRS);
|
||||
//tmc2130_wr_THIGH(tmc2130_cs[i], TMC2130_THIGH);
|
||||
tmc2130_wr_CHOPCONF(tmc2130_cs[i], TMC2130_EXP256_Z, TMC2130_USTEPS_Z);
|
||||
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, 0x00000000);
|
||||
}
|
||||
for (int i = 3; i < 4; i++) // E axis
|
||||
{
|
||||
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, 0x00000004); //GCONF - bit 2 activate stealthChop
|
||||
uint8_t mres = tmc2130_mres(TMC2130_USTEPS_E);
|
||||
tmc2130_wr_CHOPCONF(tmc2130_cs[i], 3, 5, 1, 0, 0, 0, 0, 2, 1, 0, 0, 0, mres, TMC2130_INTPOL_E, 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_CHOPCONF(tmc2130_cs[i], TMC2130_EXP256_E, TMC2130_USTEPS_E);
|
||||
tmc2130_wr(tmc2130_cs[i], TMC2130_REG_GCONF, 0x00000000);
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,6 +179,9 @@ void tmc2130_check_overtemp()
|
||||
for(int i=0;i<4;i++)
|
||||
{
|
||||
uint32_t drv_status = 0;
|
||||
|
||||
skip_debug_msg = true;
|
||||
|
||||
tmc2130_rd(cs[i], TMC2130_REG_DRV_STATUS, &drv_status);
|
||||
if (drv_status & ((uint32_t)1<<26))
|
||||
{ // BIT 26 - over temp prewarning ~120C (+-20C)
|
||||
@ -215,7 +232,7 @@ void tmc2130_home_exit()
|
||||
#endif
|
||||
}
|
||||
|
||||
extern uint8_t tmc2130_didLastHomingStall()
|
||||
uint8_t tmc2130_didLastHomingStall()
|
||||
{
|
||||
uint8_t ret = tmc2130_LastHomingStalled;
|
||||
tmc2130_LastHomingStalled = false;
|
||||
@ -228,7 +245,7 @@ void tmc2130_set_current_h(uint8_t axis, uint8_t current)
|
||||
MYSERIAL.print((int)axis);
|
||||
MYSERIAL.print(" ");
|
||||
MYSERIAL.println((int)current);
|
||||
if (current > 15) current = 15; //current>15 is unsafe
|
||||
// if (current > 15) current = 15; //current>15 is unsafe
|
||||
tmc2130_current_h[axis] = current;
|
||||
tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[axis] & 0x1f) << 8) | (tmc2130_current_h[axis] & 0x1f));
|
||||
}
|
||||
@ -239,7 +256,7 @@ void tmc2130_set_current_r(uint8_t axis, uint8_t current)
|
||||
MYSERIAL.print((int)axis);
|
||||
MYSERIAL.print(" ");
|
||||
MYSERIAL.println((int)current);
|
||||
if (current > 15) current = 15; //current>15 is unsafe
|
||||
// if (current > 15) current = 15; //current>15 is unsafe
|
||||
tmc2130_current_r[axis] = current;
|
||||
tmc2130_wr(tmc2130_cs[axis], TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((tmc2130_current_r[axis] & 0x1f) << 8) | (tmc2130_current_h[axis] & 0x1f));
|
||||
}
|
||||
@ -266,6 +283,28 @@ void tmc2130_print_currents()
|
||||
MYSERIAL.println((int)tmc2130_current_r[3]);
|
||||
}
|
||||
|
||||
void tmc2130_set_pwm_ampl(uint8_t axis, uint8_t pwm_ampl)
|
||||
{
|
||||
MYSERIAL.print("tmc2130_set_pwm_ampl ");
|
||||
MYSERIAL.print((int)axis);
|
||||
MYSERIAL.print(" ");
|
||||
MYSERIAL.println((int)pwm_ampl);
|
||||
tmc2130_pwm_ampl[axis] = pwm_ampl;
|
||||
if (((axis == 0) || (axis == 1)) && (tmc2130_mode == TMC2130_MODE_SILENT))
|
||||
tmc2130_wr_PWMCONF(tmc2130_cs[axis], tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
|
||||
}
|
||||
|
||||
void tmc2130_set_pwm_grad(uint8_t axis, uint8_t pwm_grad)
|
||||
{
|
||||
MYSERIAL.print("tmc2130_set_pwm_grad ");
|
||||
MYSERIAL.print((int)axis);
|
||||
MYSERIAL.print(" ");
|
||||
MYSERIAL.println((int)pwm_grad);
|
||||
tmc2130_pwm_grad[axis] = pwm_grad;
|
||||
if (((axis == 0) || (axis == 1)) && (tmc2130_mode == TMC2130_MODE_SILENT))
|
||||
tmc2130_wr_PWMCONF(tmc2130_cs[axis], tmc2130_pwm_ampl[axis], tmc2130_pwm_grad[axis], tmc2130_pwm_freq[axis], tmc2130_pwm_auto[axis], 0, 0);
|
||||
}
|
||||
|
||||
uint16_t tmc2130_rd_TSTEP(uint8_t cs)
|
||||
{
|
||||
uint32_t val32 = 0;
|
||||
@ -281,27 +320,40 @@ uint16_t tmc2130_rd_DRV_STATUS(uint8_t cs)
|
||||
return val32;
|
||||
}
|
||||
|
||||
void tmc2130_wr_CHOPCONF(uint8_t cs, bool extrapolate256, uint16_t microstep_resolution)
|
||||
void tmc2130_wr_CHOPCONF(uint8_t cs, uint8_t toff, uint8_t hstrt, uint8_t hend, uint8_t fd3, uint8_t disfdcc, uint8_t rndtf, uint8_t chm, uint8_t tbl, uint8_t vsense, uint8_t vhighfs, uint8_t vhighchm, uint8_t sync, uint8_t mres, uint8_t intpol, uint8_t dedge, uint8_t diss2g)
|
||||
{
|
||||
uint8_t mres=0b0100;
|
||||
if(microstep_resolution == 256) mres = 0b0000;
|
||||
if(microstep_resolution == 128) mres = 0b0001;
|
||||
if(microstep_resolution == 64) mres = 0b0010;
|
||||
if(microstep_resolution == 32) mres = 0b0011;
|
||||
if(microstep_resolution == 16) mres = 0b0100;
|
||||
if(microstep_resolution == 8) mres = 0b0101;
|
||||
if(microstep_resolution == 4) mres = 0b0110;
|
||||
if(microstep_resolution == 2) mres = 0b0111;
|
||||
if(microstep_resolution == 1) mres = 0b1000;
|
||||
mres |= extrapolate256 << 4; //bit28 intpol
|
||||
//tmc2130_write(cs,0x6C,mres,0x01,0x00,0xD3);
|
||||
// tmc2130_write(cs,0x6C,mres,0x01,0x00,0xC3);
|
||||
tmc2130_wr(cs,TMC2130_REG_CHOPCONF,((uint32_t)mres << 24) | 0x0100C3);
|
||||
uint32_t val = 0;
|
||||
val |= (uint32_t)(toff & 15);
|
||||
val |= (uint32_t)(hstrt & 7) << 4;
|
||||
val |= (uint32_t)(hend & 15) << 7;
|
||||
val |= (uint32_t)(fd3 & 1) << 11;
|
||||
val |= (uint32_t)(disfdcc & 1) << 12;
|
||||
val |= (uint32_t)(rndtf & 1) << 13;
|
||||
val |= (uint32_t)(chm & 1) << 14;
|
||||
val |= (uint32_t)(tbl & 3) << 15;
|
||||
val |= (uint32_t)(vsense & 1) << 17;
|
||||
val |= (uint32_t)(vhighfs & 1) << 18;
|
||||
val |= (uint32_t)(vhighchm & 1) << 19;
|
||||
val |= (uint32_t)(sync & 15) << 20;
|
||||
val |= (uint32_t)(mres & 15) << 24;
|
||||
val |= (uint32_t)(intpol & 1) << 28;
|
||||
val |= (uint32_t)(dedge & 1) << 29;
|
||||
val |= (uint32_t)(diss2g & 1) << 30;
|
||||
tmc2130_wr(cs, TMC2130_REG_CHOPCONF, val);
|
||||
}
|
||||
|
||||
void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t PWMautoScale, uint8_t PWMfreq, uint8_t PWMgrad, uint8_t PWMampl)
|
||||
//void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t PWMautoScale, uint8_t PWMfreq, uint8_t PWMgrad, uint8_t PWMampl)
|
||||
void tmc2130_wr_PWMCONF(uint8_t cs, uint8_t pwm_ampl, uint8_t pwm_grad, uint8_t pwm_freq, uint8_t pwm_auto, uint8_t pwm_symm, uint8_t freewheel)
|
||||
{
|
||||
tmc2130_wr(cs, TMC2130_REG_PWMCONF, ((uint32_t)(PWMautoScale+PWMfreq) << 16) | ((uint32_t)PWMgrad << 8) | PWMampl); // TMC LJ -> For better readability changed to 0x00 and added PWMautoScale and PWMfreq
|
||||
uint32_t val = 0;
|
||||
val |= (uint32_t)(pwm_ampl & 255);
|
||||
val |= (uint32_t)(pwm_grad & 255) << 8;
|
||||
val |= (uint32_t)(pwm_freq & 3) << 16;
|
||||
val |= (uint32_t)(pwm_auto & 1) << 18;
|
||||
val |= (uint32_t)(pwm_symm & 1) << 19;
|
||||
val |= (uint32_t)(freewheel & 3) << 20;
|
||||
tmc2130_wr(cs, TMC2130_REG_PWMCONF, val);
|
||||
// tmc2130_wr(cs, TMC2130_REG_PWMCONF, ((uint32_t)(PWMautoScale+PWMfreq) << 16) | ((uint32_t)PWMgrad << 8) | PWMampl); // TMC LJ -> For better readability changed to 0x00 and added PWMautoScale and PWMfreq
|
||||
}
|
||||
|
||||
void tmc2130_wr_TPWMTHRS(uint8_t cs, uint32_t val32)
|
||||
@ -327,6 +379,20 @@ uint8_t tmc2130_axis_by_cs(uint8_t cs)
|
||||
return -1;
|
||||
}
|
||||
|
||||
uint8_t tmc2130_mres(uint16_t microstep_resolution)
|
||||
{
|
||||
if (microstep_resolution == 256) return 0b0000;
|
||||
if (microstep_resolution == 128) return 0b0001;
|
||||
if (microstep_resolution == 64) return 0b0010;
|
||||
if (microstep_resolution == 32) return 0b0011;
|
||||
if (microstep_resolution == 16) return 0b0100;
|
||||
if (microstep_resolution == 8) return 0b0101;
|
||||
if (microstep_resolution == 4) return 0b0110;
|
||||
if (microstep_resolution == 2) return 0b0111;
|
||||
if (microstep_resolution == 1) return 0b1000;
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint8_t tmc2130_wr(uint8_t cs, uint8_t addr, uint32_t wval)
|
||||
{
|
||||
uint8_t stat = tmc2130_txrx(cs, addr | 0x80, wval, 0);
|
||||
@ -349,14 +415,18 @@ uint8_t tmc2130_rd(uint8_t cs, uint8_t addr, uint32_t* rval)
|
||||
uint8_t stat = tmc2130_txrx(cs, addr, 0x00000000, &val32);
|
||||
if (rval != 0) *rval = val32;
|
||||
#ifdef TMC2130_DEBUG_RD
|
||||
MYSERIAL.print("tmc2130_rd(");
|
||||
MYSERIAL.print((unsigned char)tmc2130_axis_by_cs(cs), DEC);
|
||||
MYSERIAL.print(", 0x");
|
||||
MYSERIAL.print((unsigned char)addr, HEX);
|
||||
MYSERIAL.print(", 0x");
|
||||
MYSERIAL.print((unsigned long)val32, HEX);
|
||||
MYSERIAL.print(")=0x");
|
||||
MYSERIAL.println((unsigned char)stat, HEX);
|
||||
if (!skip_debug_msg)
|
||||
{
|
||||
MYSERIAL.print("tmc2130_rd(");
|
||||
MYSERIAL.print((unsigned char)tmc2130_axis_by_cs(cs), DEC);
|
||||
MYSERIAL.print(", 0x");
|
||||
MYSERIAL.print((unsigned char)addr, HEX);
|
||||
MYSERIAL.print(", 0x");
|
||||
MYSERIAL.print((unsigned long)val32, HEX);
|
||||
MYSERIAL.print(")=0x");
|
||||
MYSERIAL.println((unsigned char)stat, HEX);
|
||||
}
|
||||
skip_debug_msg = false;
|
||||
#endif //TMC2130_DEBUG_RD
|
||||
return stat;
|
||||
}
|
||||
|
@ -7,11 +7,13 @@ extern uint8_t tmc2130_mode;
|
||||
extern uint8_t tmc2130_current_h[4];
|
||||
extern uint8_t tmc2130_current_r[4];
|
||||
//flags for axis stall detection
|
||||
extern uint8_t tmc2130_axis_stalled[4];
|
||||
extern uint8_t tmc2130_axis_stalled[2];
|
||||
|
||||
extern uint8_t sg_thrs_x;
|
||||
extern uint8_t sg_thrs_y;
|
||||
|
||||
extern uint8_t sg_homing_delay;
|
||||
|
||||
#define TMC2130_MODE_NORMAL 0
|
||||
#define TMC2130_MODE_SILENT 1
|
||||
|
||||
@ -35,5 +37,10 @@ extern void tmc2130_set_current_r(uint8_t axis, uint8_t current);
|
||||
//print currents (M913)
|
||||
extern void tmc2130_print_currents();
|
||||
|
||||
//set PWM_AMPL for any axis (M917)
|
||||
extern void tmc2130_set_pwm_ampl(uint8_t axis, uint8_t pwm_ampl);
|
||||
//set PWM_GRAD for any axis (M918)
|
||||
extern void tmc2130_set_pwm_grad(uint8_t axis, uint8_t pwm_ampl);
|
||||
|
||||
|
||||
#endif //TMC2130_H
|
@ -66,25 +66,28 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
|
||||
|
||||
//#define DEFAULT_MAX_FEEDRATE {400, 400, 12, 120} // (mm/sec)
|
||||
#define DEFAULT_MAX_FEEDRATE {400, 400, 12, 120} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {1000, 1000, 100, 5000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 12, 120} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {2000, 2000, 250, 5000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
|
||||
|
||||
#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts
|
||||
#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for retracts
|
||||
|
||||
|
||||
#define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min)
|
||||
#define MAX_SILENT_FEEDRATE 2700 //
|
||||
//#define MAX_SILENT_FEEDRATE 2700 //
|
||||
|
||||
#define Z_AXIS_ALWAYS_ON 1
|
||||
|
||||
//DEBUG
|
||||
//#define DEBUG_DISABLE_MINTEMP
|
||||
//#define DEBUG_DISABLE_SWLIMITS
|
||||
//#define DEBUG_DISABLE_PREVENT_EXTRUDER
|
||||
#define DEBUG_BLINK_ACTIVE
|
||||
//#define DEBUG_SKIP_STARTMSGS
|
||||
|
||||
#if 0
|
||||
#define DEBUG_DISABLE_STARTMSGS //no startup messages
|
||||
#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
|
||||
#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
|
||||
#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed
|
||||
#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3)
|
||||
//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3)
|
||||
//#define DEBUG_BLINK_ACTIVE
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
TMC2130 default settings
|
||||
@ -92,32 +95,33 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
|
||||
#define TMC2130_FCLK 12000000 // fclk = 12MHz
|
||||
|
||||
#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes
|
||||
#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis
|
||||
#define TMC2130_USTEPS_E 16 // microstep resolution for E axis
|
||||
#define TMC2130_EXP256_XY 1 // extrapolate 256 for XY axes
|
||||
#define TMC2130_EXP256_Z 1 // extrapolate 256 for Z axis
|
||||
#define TMC2130_EXP256_E 1 // extrapolate 256 for E axis
|
||||
#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes
|
||||
#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis
|
||||
#define TMC2130_USTEPS_E 16 // microstep resolution for E axis
|
||||
#define TMC2130_INTPOL_XY 1 // extrapolate 256 for XY axes
|
||||
#define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis
|
||||
#define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis
|
||||
|
||||
// PWM register configuration
|
||||
//#define TMC2130_PWM_GRAD 0x08 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
||||
//#define TMC2130_PWM_AMPL 0xC8 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
||||
#define TMC2130_PWM_GRAD 0x01 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
||||
#define TMC2130_PWM_AMPL 0xc8 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
||||
#define TMC2130_PWM_AUTO 0x04 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
||||
//#define TMC2130_PWM_FREQ 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK) 35.1kHz
|
||||
#define TMC2130_PWM_FREQ 0x01 // 0x02 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK) 46.9kHz
|
||||
#define TMC2130_PWM_GRAD_XY 15 // PWMCONF
|
||||
#define TMC2130_PWM_AMPL_XY 200 // PWMCONF
|
||||
#define TMC2130_PWM_AUTO_XY 1 // PWMCONF
|
||||
#define TMC2130_PWM_FREQ_XY 2 // PWMCONF
|
||||
|
||||
#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410)
|
||||
/* //not used
|
||||
#define TMC2130_PWM_GRAD_Z 4 // PWMCONF
|
||||
#define TMC2130_PWM_AMPL_Z 200 // PWMCONF
|
||||
#define TMC2130_PWM_AUTO_Z 1 // PWMCONF
|
||||
#define TMC2130_PWM_FREQ_Z 2 // PWMCONF
|
||||
#define TMC2130_PWM_GRAD_E 4 // PWMCONF
|
||||
#define TMC2130_PWM_AMPL_E 200 // PWMCONF
|
||||
#define TMC2130_PWM_AUTO_E 1 // PWMCONF
|
||||
#define TMC2130_PWM_FREQ_E 2 // PWMCONF
|
||||
*/
|
||||
|
||||
//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410)
|
||||
#define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410)
|
||||
#define TMC2130_PWM_CLK (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk)
|
||||
|
||||
// Special configuration for XY axes for operation (during standstill, use same settings as for other axes) //todo
|
||||
// RP: this settings does not work (overtemp)
|
||||
//#define TMC2130_PWM_GRAD_XY 156 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
||||
//#define TMC2130_PWM_AMPL_XY 63 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
||||
//#define TMC2130_PWM_AUTO_XY 0x00 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
||||
//#define TMC2130_PWM_FREQ_XY 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK)
|
||||
|
||||
#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
|
||||
#define TMC2130_THIGH 0 // THIGH - unused
|
||||
|
||||
@ -125,15 +129,17 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
|
||||
#define TMC2130_SG_HOMING 1 // stallguard homing
|
||||
#define TMC2130_SG_HOMING_SW 1 // stallguard "software" homing
|
||||
#define TMC2130_SG_THRS_X 12 // stallguard sensitivity for X axis
|
||||
#define TMC2130_SG_THRS_Y 12 // stallguard sensitivity for Y axis
|
||||
#define TMC2130_SG_THRS_X 30 // stallguard sensitivity for X axis
|
||||
#define TMC2130_SG_THRS_Y 30 // stallguard sensitivity for Y axis
|
||||
#define TMC2130_SG_DELAY 10 // stallguard delay (temporary solution)
|
||||
|
||||
#define TMC2130_CURRENTS_H {2, 2, 2, 4} // default holding currents for all axes
|
||||
#define TMC2130_CURRENTS_R {6, 6, 8, 8} // default running currents for all axes
|
||||
//new settings is possible for vsense = 1
|
||||
#define TMC2130_CURRENTS_H {3, 3, 5, 8} // default holding currents for all axes
|
||||
#define TMC2130_CURRENTS_R {13, 13, 20, 20} // default running currents for all axes
|
||||
|
||||
#define TMC2130_DEBUG
|
||||
#define TMC2130_DEBUG_WR
|
||||
#define TMC2130_DEBUG_RD
|
||||
//#define TMC2130_DEBUG_WR
|
||||
//#define TMC2130_DEBUG_RD
|
||||
|
||||
|
||||
/*------------------------------------
|
||||
|
@ -66,25 +66,28 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
|
||||
|
||||
//#define DEFAULT_MAX_FEEDRATE {400, 400, 12, 120} // (mm/sec)
|
||||
#define DEFAULT_MAX_FEEDRATE {400, 400, 12, 120} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {1000, 1000, 100, 5000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
|
||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 12, 120} // (mm/sec)
|
||||
#define DEFAULT_MAX_ACCELERATION {2000, 2000, 250, 5000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for Skeinforge 40+, for older versions raise them a lot.
|
||||
|
||||
#define DEFAULT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 1250 // X, Y, Z and E max acceleration in mm/s^2 for retracts
|
||||
#define DEFAULT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||
#define DEFAULT_RETRACT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for retracts
|
||||
|
||||
|
||||
#define MANUAL_FEEDRATE {2700, 2700, 1000, 100} // set the speeds for manual moves (mm/min)
|
||||
#define MAX_SILENT_FEEDRATE 2700 //
|
||||
//#define MAX_SILENT_FEEDRATE 2700 //
|
||||
|
||||
#define Z_AXIS_ALWAYS_ON 1
|
||||
|
||||
//DEBUG
|
||||
//#define DEBUG_DISABLE_MINTEMP
|
||||
//#define DEBUG_DISABLE_SWLIMITS
|
||||
//#define DEBUG_DISABLE_PREVENT_EXTRUDER
|
||||
#define DEBUG_BLINK_ACTIVE
|
||||
//#define DEBUG_SKIP_STARTMSGS
|
||||
|
||||
#if 0
|
||||
#define DEBUG_DISABLE_STARTMSGS //no startup messages
|
||||
#define DEBUG_DISABLE_MINTEMP //mintemp error ignored
|
||||
#define DEBUG_DISABLE_SWLIMITS //sw limits ignored
|
||||
#define DEBUG_DISABLE_PREVENT_EXTRUDER //cold extrusion and long extrusion allowed
|
||||
#define DEBUG_XSTEP_DUP_PIN 21 //duplicate x-step output to pin 21 (SCL on P3)
|
||||
//#define DEBUG_YSTEP_DUP_PIN 21 //duplicate y-step output to pin 21 (SCL on P3)
|
||||
//#define DEBUG_BLINK_ACTIVE
|
||||
#endif
|
||||
|
||||
/*------------------------------------
|
||||
TMC2130 default settings
|
||||
@ -92,32 +95,33 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
|
||||
#define TMC2130_FCLK 12000000 // fclk = 12MHz
|
||||
|
||||
#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes
|
||||
#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis
|
||||
#define TMC2130_USTEPS_E 16 // microstep resolution for E axis
|
||||
#define TMC2130_EXP256_XY 1 // extrapolate 256 for XY axes
|
||||
#define TMC2130_EXP256_Z 1 // extrapolate 256 for Z axis
|
||||
#define TMC2130_EXP256_E 1 // extrapolate 256 for E axis
|
||||
#define TMC2130_USTEPS_XY 16 // microstep resolution for XY axes
|
||||
#define TMC2130_USTEPS_Z 16 // microstep resolution for Z axis
|
||||
#define TMC2130_USTEPS_E 16 // microstep resolution for E axis
|
||||
#define TMC2130_INTPOL_XY 1 // extrapolate 256 for XY axes
|
||||
#define TMC2130_INTPOL_Z 1 // extrapolate 256 for Z axis
|
||||
#define TMC2130_INTPOL_E 1 // extrapolate 256 for E axis
|
||||
|
||||
// PWM register configuration
|
||||
//#define TMC2130_PWM_GRAD 0x08 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
||||
//#define TMC2130_PWM_AMPL 0xC8 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
||||
#define TMC2130_PWM_GRAD 0x01 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
||||
#define TMC2130_PWM_AMPL 0xc8 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
||||
#define TMC2130_PWM_AUTO 0x04 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
||||
//#define TMC2130_PWM_FREQ 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK) 35.1kHz
|
||||
#define TMC2130_PWM_FREQ 0x01 // 0x02 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK) 46.9kHz
|
||||
#define TMC2130_PWM_GRAD_XY 15 // PWMCONF
|
||||
#define TMC2130_PWM_AMPL_XY 200 // PWMCONF
|
||||
#define TMC2130_PWM_AUTO_XY 1 // PWMCONF
|
||||
#define TMC2130_PWM_FREQ_XY 2 // PWMCONF
|
||||
|
||||
#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410)
|
||||
/* //not used
|
||||
#define TMC2130_PWM_GRAD_Z 4 // PWMCONF
|
||||
#define TMC2130_PWM_AMPL_Z 200 // PWMCONF
|
||||
#define TMC2130_PWM_AUTO_Z 1 // PWMCONF
|
||||
#define TMC2130_PWM_FREQ_Z 2 // PWMCONF
|
||||
#define TMC2130_PWM_GRAD_E 4 // PWMCONF
|
||||
#define TMC2130_PWM_AMPL_E 200 // PWMCONF
|
||||
#define TMC2130_PWM_AUTO_E 1 // PWMCONF
|
||||
#define TMC2130_PWM_FREQ_E 2 // PWMCONF
|
||||
*/
|
||||
|
||||
//#define TMC2130_PWM_DIV 683 // PWM frequency divider (1024, 683, 512, 410)
|
||||
#define TMC2130_PWM_DIV 512 // PWM frequency divider (1024, 683, 512, 410)
|
||||
#define TMC2130_PWM_CLK (2 * TMC2130_FCLK / TMC2130_PWM_DIV) // PWM frequency (23.4kHz, 35.1kHz, 46.9kHz, 58.5kHz for 12MHz fclk)
|
||||
|
||||
// Special configuration for XY axes for operation (during standstill, use same settings as for other axes) //todo
|
||||
// RP: this settings does not work (overtemp)
|
||||
//#define TMC2130_PWM_GRAD_XY 156 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
||||
//#define TMC2130_PWM_AMPL_XY 63 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
||||
//#define TMC2130_PWM_AUTO_XY 0x00 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
||||
//#define TMC2130_PWM_FREQ_XY 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK)
|
||||
|
||||
#define TMC2130_TPWMTHRS 0 // TPWMTHRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
|
||||
#define TMC2130_THIGH 0 // THIGH - unused
|
||||
|
||||
@ -125,15 +129,17 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||
|
||||
#define TMC2130_SG_HOMING 1 // stallguard homing
|
||||
#define TMC2130_SG_HOMING_SW 1 // stallguard "software" homing
|
||||
#define TMC2130_SG_THRS_X 12 // stallguard sensitivity for X axis
|
||||
#define TMC2130_SG_THRS_Y 12 // stallguard sensitivity for Y axis
|
||||
#define TMC2130_SG_THRS_X 30 // stallguard sensitivity for X axis
|
||||
#define TMC2130_SG_THRS_Y 30 // stallguard sensitivity for Y axis
|
||||
#define TMC2130_SG_DELAY 10 // stallguard delay (temporary solution)
|
||||
|
||||
#define TMC2130_CURRENTS_H {2, 2, 2, 4} // default holding currents for all axes
|
||||
#define TMC2130_CURRENTS_R {6, 6, 8, 8} // default running currents for all axes
|
||||
//new settings is possible for vsense = 1
|
||||
#define TMC2130_CURRENTS_H {3, 3, 5, 8} // default holding currents for all axes
|
||||
#define TMC2130_CURRENTS_R {13, 13, 20, 20} // default running currents for all axes
|
||||
|
||||
#define TMC2130_DEBUG
|
||||
#define TMC2130_DEBUG_WR
|
||||
#define TMC2130_DEBUG_RD
|
||||
//#define TMC2130_DEBUG_WR
|
||||
//#define TMC2130_DEBUG_RD
|
||||
|
||||
|
||||
/*------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user