Merge pull request #80 from XPila/MK3

TMC2130 configuration in eeprom (not finished).
This commit is contained in:
XPila 2017-11-07 17:15:36 +01:00 committed by GitHub
commit aea267e87f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 29012 additions and 7 deletions

View File

@ -9,7 +9,7 @@
// Firmware version
#define FW_version "3.0.12-RC2"
#define FW_build 105
#define FW_build 106
#define FW_version_build FW_version " b" STR(FW_build)
@ -77,6 +77,28 @@
// Power loss errors
#define EEPROM_POWER_COUNT (EEPROM_UVLO_MESH_BED_LEVELING-17)
//TMC2130 configuration
#define EEPROM_TMC_AXIS_SIZE //axis configuration block size
#define EEPROM_TMC_X (EEPROM_TMC + 0 * EEPROM_TMC_AXIS_SIZE) //X axis configuration blok
#define EEPROM_TMC_Y (EEPROM_TMC + 1 * EEPROM_TMC_AXIS_SIZE) //Y axis
#define EEPROM_TMC_Z (EEPROM_TMC + 2 * EEPROM_TMC_AXIS_SIZE) //Z axis
#define EEPROM_TMC_E (EEPROM_TMC + 3 * EEPROM_TMC_AXIS_SIZE) //E axis
//TMC2130 - X axis
#define EEPROM_TMC_X_USTEPS_INTPOL (EEPROM_TMC_X + 0) // 1byte, bit 0..4 USTEPS, bit 7 INTPOL
#define EEPROM_TMC_X_PWM_AMPL (EEPROM_TMC_X + 1) // 1byte (0..255)
#define EEPROM_TMC_X_PWM_GRAD_FREQ (EEPROM_TMC_X + 2) // 1byte, bit 0..3 GRAD, bit 4..5 FREQ
#define EEPROM_TMC_X_TCOOLTHRS (EEPROM_TMC_X + 3) // 2bytes (0..)
#define EEPROM_TMC_X_SG_THRS (EEPROM_TMC_X + 5) // 1byte, (-64..+63)
#define EEPROM_TMC_X_CURRENT_H (EEPROM_TMC_X + 6) // 1byte, (0..63)
#define EEPROM_TMC_X_CURRENT_R (EEPROM_TMC_X + 7) // 1byte, (0..63)
#define EEPROM_TMC_X_HOME_SG_THRS (EEPROM_TMC_X + 8) // 1byte, (-64..+63)
#define EEPROM_TMC_X_HOME_CURRENT_R (EEPROM_TMC_X + 9) // 1byte, (-64..+63)
#define EEPROM_TMC_X_HOME_DTCOOLTHRS (EEPROM_TMC_X + 10) // 1byte (-128..+127)
#define EEPROM_TMC_X_DTCOOLTHRS_LOW (EEPROM_TMC_X + 11) // 1byte (-128..+127)
#define EEPROM_TMC_X_DTCOOLTHRS_HIGH (EEPROM_TMC_X + 12) // 1byte (-128..+127)
#define EEPROM_TMC_X_SG_THRS_LOW (EEPROM_TMC_X + 13) // 1byte, (-64..+63)
#define EEPROM_TMC_X_SG_THRS_HIGH (EEPROM_TMC_X + 14) // 1byte, (-64..+63)
#define EEPROM_XYZ_CAL_SKEW (EEPROM_POWER_COUNT - 4) //float for skew backup
// Currently running firmware, each digit stored as uint16_t.

View File

@ -83,7 +83,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
//DEBUG
#define DEBUG_DCODES //D codes
#if 1
#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial
//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial
//#define DEBUG_CRASHDET_COUNTERS //Display crash-detection counters on LCD
//#define DEBUG_RESUME_PRINT //Resume/save print debug enable
//#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output
@ -162,7 +162,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_SG_DELTA 128 // stallguard delta [usteps] (minimum usteps before stallguard readed - SW homing)
//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only)
#define TMC2130_CURRENTS_H {3, 3, 5, 12} // default holding currents for all axes
#define TMC2130_CURRENTS_H {3, 3, 20, 28} // default holding currents for all axes
#define TMC2130_CURRENTS_R {13, 20, 20, 28} // default running currents for all axes
//#define TMC2130_DEBUG
@ -249,7 +249,8 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define FILAMENTCHANGE_XYFEED 50
#define FILAMENTCHANGE_EFEED 20
#define FILAMENTCHANGE_RFEED 400
//#define FILAMENTCHANGE_RFEED 400
#define FILAMENTCHANGE_RFEED 7000 / 60
#define FILAMENTCHANGE_EXFEED 2
#define FILAMENTCHANGE_ZFEED 15

View File

@ -244,3 +244,6 @@ void dcode_9125()
}
}
void dcode_2130()
{
}

View File

@ -8,6 +8,7 @@ extern void dcode_3();
extern void dcode_4();
extern void dcode_9125();
extern void dcode_2130();
#endif //DCODES_H

View File

@ -5173,7 +5173,8 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
st_synchronize();
#else
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], FILAMENTCHANGE_RFEED, active_extruder);
// plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], FILAMENTCHANGE_RFEED, active_extruder);
plan_buffer_line(target[X_AXIS], target[Y_AXIS], target[Z_AXIS], target[E_AXIS], 3500/60, active_extruder);
#endif // SNMM

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -103,8 +103,9 @@ ISR(PCINT2_vect)
}
else
{ //propper movement
if (fsensor_err_cnt > 0)
fsensor_err_cnt--;
// if (fsensor_err_cnt > 0)
// fsensor_err_cnt--;
fsensor_err_cnt = 0;
#ifdef DEBUG_FSENSOR_LOG
MYSERIAL.print("\tOK err=");
MYSERIAL.println(fsensor_err_cnt, DEC);
@ -124,6 +125,7 @@ ISR(PCINT2_vect)
void fsensor_st_block_begin(block_t* bl)
{
if (!fsensor_enabled) return;
if ((fsensor_st_cnt > 0) && (bl->direction_bits & 0x8))
digitalWrite(fsensor_int_pin, LOW);
if ((fsensor_st_cnt < 0) && !(bl->direction_bits & 0x8))
@ -132,6 +134,7 @@ void fsensor_st_block_begin(block_t* bl)
void fsensor_st_block_chunk(block_t* bl, int cnt)
{
if (!fsensor_enabled) return;
fsensor_st_cnt += (bl->direction_bits & 0x8)?-cnt:cnt;
if ((fsensor_st_cnt >= fsensor_chunk_len) || (fsensor_st_cnt <= -fsensor_chunk_len))
digitalWrite(fsensor_int_pin, LOW);

View File

@ -739,4 +739,14 @@ uint8_t tmc2130_txrx(uint8_t cs, uint8_t addr, uint32_t wval, uint32_t* rval)
return stat;
}
void tmc2130_eeprom_load_config()
{
}
void tmc2130_eeprom_save_config()
{
}
#endif //TMC2130

View File

@ -54,5 +54,35 @@ extern void tmc2130_home_pause(uint8_t axis);
extern void tmc2130_home_resume(uint8_t axis);
extern bool tmc2130_wait_standstill_xy(int timeout);
extern void tmc2130_eeprom_load_config();
extern void tmc2130_eeprom_save_config();
#pragma pack(push)
#pragma pack(1)
struct
{
uint8_t mres:5; // mres - byte 0, bit 0..4 microstep resolution
uint8_t reserved_0_0:2; // reserved - byte 0, bit 5..6
uint8_t intpol:1; // intpol - byte 0, bit 7 linear interpolation to 255 usteps
uint8_t pwm_ampl:8; // pwm_ampl - byte 1, bit 0..7 pwm amplitude for silent mode
uint8_t pwm_grad:4; // pwm_grad - byte 2, bit 0..3 pwm gradient for silent mode
uint8_t pwm_freq:2; // pwm_freq - byte 2, bit 4..5 pwm frequency for silent mode
uint8_t reserved_2_0:2; // reserved - byte 2, bit 6..7
uint16_t tcoolthrs:16; // tcoolthrs - byte 3..4 coolstep threshold / middle sensitivity
int8_t sg_thrs:8; // sg_thrs - byte 5, bit 0..7 stallguard sensitivity in high power / middle sensitivity
int8_t current_h:6; // current_h - byte 6, bit 0..5 holding current for high power mode
uint8_t reserved_6_0:2; // reserved - byte 6, bit 6..7
int8_t current_r:6; // current_r - byte 7, bit 0..5 running current for high power mode
uint8_t reserved_7_0:2; // reserved - byte 7, bit 6..7
int8_t home_sg_thrs:8; // sg_thrs - byte 8, bit 0..7 stallguard sensitivity for homing
int8_t home_current:6; // current_r - byte 9, bit 0..5 running current for homing
uint8_t reserved_9_0:2; // reserved - byte 9, bit 6..7
int8_t home_dtcoolthrs:8; // dtcoolthrs - byte 10, bit 0..7 delta tcoolthrs for homing
int8_t dtcoolthrs_low:8; // dtcoolthrs - byte 11, bit 0..7 delta tcoolthrs for low sensitivity (based on value for middle sensitivity)
int8_t dtcoolthrs_high:8; // dtcoolthrs - byte 12, bit 0..7 delta tcoolthrs for high sensitivity (based on value for middle sensitivity)
int8_t sg_thrs_low:8; // sg_thrs - byte 13, bit 0..7 stallguard sensitivity in high power / low sensitivity
int8_t sg_thrs_high:8; // sg_thrs - byte 14, bit 0..7 stallguard sensitivity in high power / high sensitivity
} tmc2130_axis_config;
#pragma pack(pop)
#endif //TMC2130_H