From 6017600714a751a46b879964d186ea97115c5277 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 16 Jun 2019 21:05:13 +0200 Subject: [PATCH 01/20] Reintroduce the ability to disable TMC interpolation per-axis --- Firmware/tmc2130.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 108d00b1..b87272e2 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -437,6 +437,9 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_ uint8_t tbl = tmc2130_chopper_config[axis].tbl; //blanking time, original value = 2 if (axis == E_AXIS) { +#if defined(TMC2130_INTPOL_E) && (TMC2130_INTPOL_E == 0) + intpol = 0; +#endif #ifdef TMC2130_CNSTOFF_E // fd = 0 (slow decay only) hstrt = 0; //fd0..2 @@ -447,6 +450,16 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_ // toff = TMC2130_TOFF_E; // toff = 3-5 // rndtf = 1; } +#if defined(TMC2130_INTPOL_XY) && (TMC2130_INTPOL_XY == 0) + else if (axis == X_AXIS || axis == Y_AXIS) { + intpol = 0; + } +#endif +#if defined(TMC2130_INTPOL_Z) && (TMC2130_INTPOL_Z == 0) + else if (axis == Z_AXIS) { + intpol = 0; + } +#endif // DBG(_n("tmc2130_setup_chopper(axis=%hhd, mres=%hhd, curh=%hhd, curr=%hhd\n"), axis, mres, current_h, current_r); // DBG(_n(" toff=%hhd, hstr=%hhd, hend=%hhd, tbl=%hhd\n"), toff, hstrt, hend, tbl); if (current_r <= 31) From 6ceca9bf85f93479e677194635e873bbfa831bbb Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 18 Feb 2020 11:52:36 +0100 Subject: [PATCH 02/20] Implement double-edge stepping Introduce new wrapper macros to tick the stepper pins. Default to the original raising-edge stepping mode. When using the TMC double-edge stepping mode (aka half-wave or square-wave mode) the _LO macros become no-ops. --- Firmware/stepper.cpp | 128 +++++++++++++++++++++++++++++-------------- Firmware/tmc2130.cpp | 16 +++++- 2 files changed, 100 insertions(+), 44 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index de250ec9..8f2a4f12 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -48,6 +48,50 @@ int fsensor_counter; //counter for e-steps uint16_t SP_min = 0x21FF; #endif //DEBUG_STACK_MONITOR + +/* + * Stepping macros + */ +#define _STEP_PIN_X_AXIS X_STEP_PIN +#define _STEP_PIN_Y_AXIS Y_STEP_PIN +#define _STEP_PIN_Z_AXIS Z_STEP_PIN +#define _STEP_PIN_E_AXIS E0_STEP_PIN + +#ifdef DEBUG_XSTEP_DUP_PIN +#define _STEP_PIN_X_DUP_AXIS DEBUG_XSTEP_DUP_PIN +#endif +#ifdef DEBUG_YSTEP_DUP_PIN +#define _STEP_PIN_Y_DUP_AXIS DEBUG_YSTEP_DUP_PIN +#endif +#ifdef Y_DUAL_STEPPER_DRIVERS +#error Y_DUAL_STEPPER_DRIVERS not fully implemented +#define _STEP_PIN_Y2_AXIS Y2_STEP_PIN +#endif +#ifdef Z_DUAL_STEPPER_DRIVERS +#error Z_DUAL_STEPPER_DRIVERS not fully implemented +#define _STEP_PIN_Z2_AXIS Z2_STEP_PIN +#endif + +#ifdef TMC2130_DEDGE_STEPPING +#define STEP_NC_HI(axis) TOGGLE(_STEP_PIN_##axis) +#define STEP_NC_LO(axis) //NOP +#else + +#define _STEP_HI_X_AXIS !INVERT_X_STEP_PIN +#define _STEP_LO_X_AXIS INVERT_X_STEP_PIN +#define _STEP_HI_Y_AXIS !INVERT_Y_STEP_PIN +#define _STEP_LO_Y_AXIS INVERT_Y_STEP_PIN +#define _STEP_HI_Z_AXIS !INVERT_Z_STEP_PIN +#define _STEP_LO_Z_AXIS INVERT_Z_STEP_PIN +#define _STEP_HI_E_AXIS !INVERT_E_STEP_PIN +#define _STEP_LO_E_AXIS INVERT_E_STEP_PIN + +#define STEP_NC_HI(axis) WRITE_NC(_STEP_PIN_##axis, _STEP_HI_##axis) +#define STEP_NC_LO(axis) WRITE_NC(_STEP_PIN_##axis, _STEP_LO_##axis) + +#endif //TMC2130_DEDGE_STEPPING + + //=========================================================================== //=============================public variables ============================ //=========================================================================== @@ -300,9 +344,9 @@ FORCE_INLINE void stepper_next_block() _delay_us(100); for (uint8_t i = 0; i < st_backlash_x; i++) { - WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN); + STEP_NC_HI(X_AXIS); _delay_us(100); - WRITE_NC(X_STEP_PIN, INVERT_X_STEP_PIN); + STEP_NC_LO(X_AXIS); _delay_us(900); } } @@ -323,9 +367,9 @@ FORCE_INLINE void stepper_next_block() _delay_us(100); for (uint8_t i = 0; i < st_backlash_y; i++) { - WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + STEP_NC_HI(Y_AXIS); _delay_us(100); - WRITE_NC(Y_STEP_PIN, INVERT_Y_STEP_PIN); + STEP_NC_LO(Y_AXIS); _delay_us(900); } } @@ -607,44 +651,44 @@ FORCE_INLINE void stepper_tick_lowres() // Step in X axis counter_x.lo += current_block->steps_x.lo; if (counter_x.lo > 0) { - WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN); + STEP_NC_HI(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - WRITE_NC(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN); + STEP_NC_HI(X_DUP_AXIS); #endif //DEBUG_XSTEP_DUP_PIN counter_x.lo -= current_block->step_event_count.lo; count_position[X_AXIS]+=count_direction[X_AXIS]; - WRITE_NC(X_STEP_PIN, INVERT_X_STEP_PIN); + STEP_NC_LO(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - WRITE_NC(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN); + STEP_NC_LO(X_DUP_AXIS); #endif //DEBUG_XSTEP_DUP_PIN } // Step in Y axis counter_y.lo += current_block->steps_y.lo; if (counter_y.lo > 0) { - WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + STEP_NC_HI(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - WRITE_NC(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN); + STEP_NC_HI(Y_DUP_AXIS); #endif //DEBUG_YSTEP_DUP_PIN counter_y.lo -= current_block->step_event_count.lo; count_position[Y_AXIS]+=count_direction[Y_AXIS]; - WRITE_NC(Y_STEP_PIN, INVERT_Y_STEP_PIN); + STEP_NC_LO(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - WRITE_NC(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN); + STEP_NC_LO(Y_DUP_AXIS); #endif //DEBUG_YSTEP_DUP_PIN } // Step in Z axis counter_z.lo += current_block->steps_z.lo; if (counter_z.lo > 0) { - WRITE_NC(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + STEP_NC_HI(Z_AXIS); counter_z.lo -= current_block->step_event_count.lo; count_position[Z_AXIS]+=count_direction[Z_AXIS]; - WRITE_NC(Z_STEP_PIN, INVERT_Z_STEP_PIN); + STEP_NC_LO(Z_AXIS); } // Step in E axis counter_e.lo += current_block->steps_e.lo; if (counter_e.lo > 0) { #ifndef LIN_ADVANCE - WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); + STEP_NC_HI(E_AXIS); #endif /* LIN_ADVANCE */ counter_e.lo -= current_block->step_event_count.lo; count_position[E_AXIS] += count_direction[E_AXIS]; @@ -654,7 +698,7 @@ FORCE_INLINE void stepper_tick_lowres() #ifdef FILAMENT_SENSOR fsensor_counter += count_direction[E_AXIS]; #endif //FILAMENT_SENSOR - WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); + STEP_NC_LO(E_AXIS); #endif } if(++ step_events_completed.lo >= current_block->step_event_count.lo) @@ -669,44 +713,44 @@ FORCE_INLINE void stepper_tick_highres() // Step in X axis counter_x.wide += current_block->steps_x.wide; if (counter_x.wide > 0) { - WRITE_NC(X_STEP_PIN, !INVERT_X_STEP_PIN); + STEP_NC_HI(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - WRITE_NC(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN); + STEP_NC_HI(X_DUP_AXIS); #endif //DEBUG_XSTEP_DUP_PIN counter_x.wide -= current_block->step_event_count.wide; count_position[X_AXIS]+=count_direction[X_AXIS]; - WRITE_NC(X_STEP_PIN, INVERT_X_STEP_PIN); + STEP_NC_LO(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - WRITE_NC(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN); + STEP_NC_LO(X_DUP_AXIS); #endif //DEBUG_XSTEP_DUP_PIN } // Step in Y axis counter_y.wide += current_block->steps_y.wide; if (counter_y.wide > 0) { - WRITE_NC(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + STEP_NC_HI(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - WRITE_NC(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN); + STEP_NC_HI(Y_DUP_AXIS); #endif //DEBUG_YSTEP_DUP_PIN counter_y.wide -= current_block->step_event_count.wide; count_position[Y_AXIS]+=count_direction[Y_AXIS]; - WRITE_NC(Y_STEP_PIN, INVERT_Y_STEP_PIN); + STEP_NC_LO(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - WRITE_NC(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN); + STEP_NC_LO(Y_DUP_AXIS); #endif //DEBUG_YSTEP_DUP_PIN } // Step in Z axis counter_z.wide += current_block->steps_z.wide; if (counter_z.wide > 0) { - WRITE_NC(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + STEP_NC_HI(Z_AXIS); counter_z.wide -= current_block->step_event_count.wide; count_position[Z_AXIS]+=count_direction[Z_AXIS]; - WRITE_NC(Z_STEP_PIN, INVERT_Z_STEP_PIN); + STEP_NC_LO(Z_AXIS); } // Step in E axis counter_e.wide += current_block->steps_e.wide; if (counter_e.wide > 0) { #ifndef LIN_ADVANCE - WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); + STEP_NC_HI(E_AXIS); #endif /* LIN_ADVANCE */ counter_e.wide -= current_block->step_event_count.wide; count_position[E_AXIS]+=count_direction[E_AXIS]; @@ -716,7 +760,7 @@ FORCE_INLINE void stepper_tick_highres() #ifdef FILAMENT_SENSOR fsensor_counter += count_direction[E_AXIS]; #endif //FILAMENT_SENSOR - WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); + STEP_NC_LO(E_AXIS); #endif } if(++ step_events_completed.wide >= current_block->step_event_count.wide) @@ -997,9 +1041,9 @@ FORCE_INLINE void advance_isr_scheduler() { bool rev = (e_steps < 0); do { - WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN); + STEP_NC_HI(E_AXIS); e_steps += (rev? 1: -1); - WRITE_NC(E0_STEP_PIN, INVERT_E_STEP_PIN); + STEP_NC_LO(E_AXIS); #if defined(FILAMENT_SENSOR) && defined(PAT9125) fsensor_counter += (rev? -1: 1); #endif @@ -1385,14 +1429,14 @@ void babystep(const uint8_t axis,const bool direction) WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); //perform step - WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); + STEP_NC_HI(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - WRITE(DEBUG_XSTEP_DUP_PIN,!INVERT_X_STEP_PIN); + STEP_NC_HI(X_DUP_AXIS); #endif //DEBUG_XSTEP_DUP_PIN delayMicroseconds(1); - WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); + STEP_NC_LO(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - WRITE(DEBUG_XSTEP_DUP_PIN,INVERT_X_STEP_PIN); + STEP_NC_LO(X_DUP_AXIS); #endif //DEBUG_XSTEP_DUP_PIN //get old pin state back. @@ -1408,14 +1452,14 @@ void babystep(const uint8_t axis,const bool direction) WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); //perform step - WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); + STEP_NC_HI(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - WRITE(DEBUG_YSTEP_DUP_PIN,!INVERT_Y_STEP_PIN); + STEP_NC_HI(Y_DUP_AXIS); #endif //DEBUG_YSTEP_DUP_PIN delayMicroseconds(1); - WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); + STEP_NC_LO(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - WRITE(DEBUG_YSTEP_DUP_PIN,INVERT_Y_STEP_PIN); + STEP_NC_LO(Y_DUP_AXIS); #endif //DEBUG_YSTEP_DUP_PIN //get old pin state back. @@ -1434,14 +1478,14 @@ void babystep(const uint8_t axis,const bool direction) WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); #endif //perform step - WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); + STEP_NC_HI(Z_AXIS); #ifdef Z_DUAL_STEPPER_DRIVERS - WRITE(Z2_STEP_PIN, !INVERT_Z_STEP_PIN); + STEP_NC_HI(Z2_AXIS); #endif delayMicroseconds(1); - WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); + STEP_NC_LO(Z_AXIS); #ifdef Z_DUAL_STEPPER_DRIVERS - WRITE(Z2_STEP_PIN, INVERT_Z_STEP_PIN); + STEP_NC_LO(Z2_AXIS); #endif //get old pin state back. diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index b87272e2..20c23704 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -428,6 +428,11 @@ void tmc2130_check_overtemp() void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_t current_r) { uint8_t intpol = (mres != 0); // intpol to 256 only if microsteps aren't 256 +#ifdef TMC2130_DEDGE_STEPPING + uint8_t dedge = 1; +#else + uint8_t dedge = 0; +#endif uint8_t toff = tmc2130_chopper_config[axis].toff; // toff = 3 (fchop = 27.778kHz) uint8_t hstrt = tmc2130_chopper_config[axis].hstr; //initial 4, modified to 5 uint8_t hend = tmc2130_chopper_config[axis].hend; //original value = 1 @@ -464,12 +469,12 @@ void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_ // DBG(_n(" toff=%hhd, hstr=%hhd, hend=%hhd, tbl=%hhd\n"), toff, hstrt, hend, tbl); if (current_r <= 31) { - tmc2130_wr_CHOPCONF(axis, toff, hstrt, hend, fd3, 0, rndtf, chm, tbl, 1, 0, 0, 0, mres, intpol, 0, 0); + tmc2130_wr_CHOPCONF(axis, toff, hstrt, hend, fd3, 0, rndtf, chm, tbl, 1, 0, 0, 0, mres, intpol, dedge, 0); tmc2130_wr(axis, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | ((current_r & 0x1f) << 8) | (current_h & 0x1f)); } else { - tmc2130_wr_CHOPCONF(axis, toff, hstrt, hend, fd3, 0, rndtf, chm, tbl, 0, 0, 0, 0, mres, intpol, 0, 0); + tmc2130_wr_CHOPCONF(axis, toff, hstrt, hend, fd3, 0, rndtf, chm, tbl, 0, 0, 0, 0, mres, intpol, dedge, 0); tmc2130_wr(axis, TMC2130_REG_IHOLD_IRUN, 0x000f0000 | (((current_r >> 1) & 0x1f) << 8) | ((current_h >> 1) & 0x1f)); } } @@ -706,10 +711,17 @@ static uint8_t tmc2130_rx(uint8_t axis, uint8_t addr, uint32_t* rval) #define _SET_DIR_Z(dir) { WRITE(Z_DIR_PIN, dir?INVERT_Z_DIR:!INVERT_Z_DIR); asm("nop"); } #define _SET_DIR_E(dir) { WRITE(E0_DIR_PIN, dir?INVERT_E0_DIR:!INVERT_E0_DIR); asm("nop"); } +#ifdef TMC2130_DEDGE_STEPPING +#define _DO_STEP_X { TOGGLE(X_STEP_PIN); asm("nop"); } +#define _DO_STEP_Y { TOGGLE(Y_STEP_PIN); asm("nop"); } +#define _DO_STEP_Z { TOGGLE(Z_STEP_PIN); asm("nop"); } +#define _DO_STEP_E { TOGGLE(E0_STEP_PIN); asm("nop"); } +#else #define _DO_STEP_X { WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); asm("nop"); WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); asm("nop"); } #define _DO_STEP_Y { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); asm("nop"); WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); asm("nop"); } #define _DO_STEP_Z { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); asm("nop"); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); asm("nop"); } #define _DO_STEP_E { WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); asm("nop"); WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); asm("nop"); } +#endif uint16_t tmc2130_get_res(uint8_t axis) From 1181beffb1c47828a1d40303348b53f2c06345e7 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 17 Jun 2019 21:10:18 +0200 Subject: [PATCH 03/20] Enable DEDGE stepping on supported variants --- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 1 + Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 1 + 2 files changed, 2 insertions(+) diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index b135d8d1..e1eb2ef1 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -269,6 +269,7 @@ // #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z +#define TMC2130_DEDGE_STEPPING //#define TMC2130_SERVICE_CODES_M910_M918 diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index e618c54e..d4c52281 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -271,6 +271,7 @@ // #define TMC2130_UNLOAD_CURRENT_R 12 // lower current for M600 to protect filament sensor - Unused #define TMC2130_STEALTH_Z +#define TMC2130_DEDGE_STEPPING //#define TMC2130_SERVICE_CODES_M910_M918 From e6b182aa9fc3a8f812a8580a0c25152418f3c2bc Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 18 Jun 2019 17:11:01 +0200 Subject: [PATCH 04/20] Implement proper step/delay pauses in tmc2130 functions Add constants for the various required delays in tmc2130.h, which will come in handy for stepper.cpp as well. Move the delays in the _set functions and remove the pauses from the various calling points and macros. Note that the hard-coded pause wouldn't cut it for the stepper ISR, but it's fine for other use cases. --- Firmware/tmc2130.cpp | 39 ++++++++++++++++++++------------------- Firmware/tmc2130.h | 4 ++++ 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 20c23704..15646b92 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -696,31 +696,31 @@ static uint8_t tmc2130_rx(uint8_t axis, uint8_t addr, uint32_t* rval) #define _GET_PWR_Z (READ(Z_ENABLE_PIN) == Z_ENABLE_ON) #define _GET_PWR_E (READ(E0_ENABLE_PIN) == E_ENABLE_ON) -#define _SET_PWR_X(ena) { WRITE(X_ENABLE_PIN, ena?X_ENABLE_ON:!X_ENABLE_ON); asm("nop"); } -#define _SET_PWR_Y(ena) { WRITE(Y_ENABLE_PIN, ena?Y_ENABLE_ON:!Y_ENABLE_ON); asm("nop"); } -#define _SET_PWR_Z(ena) { WRITE(Z_ENABLE_PIN, ena?Z_ENABLE_ON:!Z_ENABLE_ON); asm("nop"); } -#define _SET_PWR_E(ena) { WRITE(E0_ENABLE_PIN, ena?E_ENABLE_ON:!E_ENABLE_ON); asm("nop"); } +#define _SET_PWR_X(ena) WRITE(X_ENABLE_PIN, ena?X_ENABLE_ON:!X_ENABLE_ON) +#define _SET_PWR_Y(ena) WRITE(Y_ENABLE_PIN, ena?Y_ENABLE_ON:!Y_ENABLE_ON) +#define _SET_PWR_Z(ena) WRITE(Z_ENABLE_PIN, ena?Z_ENABLE_ON:!Z_ENABLE_ON) +#define _SET_PWR_E(ena) WRITE(E0_ENABLE_PIN, ena?E_ENABLE_ON:!E_ENABLE_ON) #define _GET_DIR_X (READ(X_DIR_PIN) == INVERT_X_DIR) #define _GET_DIR_Y (READ(Y_DIR_PIN) == INVERT_Y_DIR) #define _GET_DIR_Z (READ(Z_DIR_PIN) == INVERT_Z_DIR) #define _GET_DIR_E (READ(E0_DIR_PIN) == INVERT_E0_DIR) -#define _SET_DIR_X(dir) { WRITE(X_DIR_PIN, dir?INVERT_X_DIR:!INVERT_X_DIR); asm("nop"); } -#define _SET_DIR_Y(dir) { WRITE(Y_DIR_PIN, dir?INVERT_Y_DIR:!INVERT_Y_DIR); asm("nop"); } -#define _SET_DIR_Z(dir) { WRITE(Z_DIR_PIN, dir?INVERT_Z_DIR:!INVERT_Z_DIR); asm("nop"); } -#define _SET_DIR_E(dir) { WRITE(E0_DIR_PIN, dir?INVERT_E0_DIR:!INVERT_E0_DIR); asm("nop"); } +#define _SET_DIR_X(dir) WRITE(X_DIR_PIN, dir?INVERT_X_DIR:!INVERT_X_DIR) +#define _SET_DIR_Y(dir) WRITE(Y_DIR_PIN, dir?INVERT_Y_DIR:!INVERT_Y_DIR) +#define _SET_DIR_Z(dir) WRITE(Z_DIR_PIN, dir?INVERT_Z_DIR:!INVERT_Z_DIR) +#define _SET_DIR_E(dir) WRITE(E0_DIR_PIN, dir?INVERT_E0_DIR:!INVERT_E0_DIR) #ifdef TMC2130_DEDGE_STEPPING -#define _DO_STEP_X { TOGGLE(X_STEP_PIN); asm("nop"); } -#define _DO_STEP_Y { TOGGLE(Y_STEP_PIN); asm("nop"); } -#define _DO_STEP_Z { TOGGLE(Z_STEP_PIN); asm("nop"); } -#define _DO_STEP_E { TOGGLE(E0_STEP_PIN); asm("nop"); } +#define _DO_STEP_X TOGGLE(X_STEP_PIN) +#define _DO_STEP_Y TOGGLE(Y_STEP_PIN) +#define _DO_STEP_Z TOGGLE(Z_STEP_PIN) +#define _DO_STEP_E TOGGLE(E0_STEP_PIN) #else -#define _DO_STEP_X { WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); asm("nop"); WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); asm("nop"); } -#define _DO_STEP_Y { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); asm("nop"); WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); asm("nop"); } -#define _DO_STEP_Z { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); asm("nop"); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); asm("nop"); } -#define _DO_STEP_E { WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); asm("nop"); WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); asm("nop"); } +#define _DO_STEP_X { WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); } +#define _DO_STEP_Y { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); } +#define _DO_STEP_Z { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); } +#define _DO_STEP_E { WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); } #endif @@ -762,6 +762,7 @@ void tmc2130_set_pwr(uint8_t axis, uint8_t pwr) case Z_AXIS: _SET_PWR_Z(pwr); break; case E_AXIS: _SET_PWR_E(pwr); break; } + delayMicroseconds(TMC2130_SET_PWR_DELAY); } uint8_t tmc2130_get_inv(uint8_t axis) @@ -798,6 +799,7 @@ void tmc2130_set_dir(uint8_t axis, uint8_t dir) case Z_AXIS: _SET_DIR_Z(dir); break; case E_AXIS: _SET_DIR_E(dir); break; } + delayMicroseconds(TMC2130_SET_DIR_DELAY); } void tmc2130_do_step(uint8_t axis) @@ -813,8 +815,8 @@ void tmc2130_do_step(uint8_t axis) void tmc2130_do_steps(uint8_t axis, uint16_t steps, uint8_t dir, uint16_t delay_us) { - tmc2130_set_dir(axis, dir); - delayMicroseconds(100); + if (tmc2130_get_dir(axis) != dir) + tmc2130_set_dir(axis, dir); while (steps--) { tmc2130_do_step(axis); @@ -845,7 +847,6 @@ void tmc2130_goto_step(uint8_t axis, uint8_t step, uint8_t dir, uint16_t delay_u cnt = steps; } tmc2130_set_dir(axis, dir); - delayMicroseconds(100); mscnt = tmc2130_rd_MSCNT(axis); while ((cnt--) && ((mscnt >> shift) != step)) { diff --git a/Firmware/tmc2130.h b/Firmware/tmc2130.h index ed4c0d7c..4b5b764c 100644 --- a/Firmware/tmc2130.h +++ b/Firmware/tmc2130.h @@ -29,6 +29,10 @@ extern uint8_t tmc2130_sg_homing_axes_mask; #define TMC2130_WAVE_FAC1000_MAX 200 #define TMC2130_WAVE_FAC1000_STP 1 +#define TMC2130_MINIMUM_PULSE 0 // minimum pulse width in uS +#define TMC2130_SET_DIR_DELAY 20 // minimum delay after setting direction in uS +#define TMC2130_SET_PWR_DELAY 0 // minimum delay after changing pwr mode in uS + extern uint8_t tmc2130_home_enabled; extern uint8_t tmc2130_home_origin[2]; extern uint8_t tmc2130_home_bsteps[2]; From 6ea198a866efcc6ecc55d2c7c29a4535ee9bee14 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 14 Jul 2019 17:39:06 +0200 Subject: [PATCH 05/20] Fix DEDGE in sm4.c (fixes xyz calibration) --- Firmware/sm4.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index 34cf8a3c..b68e0276 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -129,11 +129,15 @@ void sm4_set_dir_bits(uint8_t dir_bits) void sm4_do_step(uint8_t axes_mask) { #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a)) +#ifdef TMC2130_DEDGE_STEPPING + PORTC ^= (axes_mask & 0x0f); //set step signals by mask +#else register uint8_t portC = PORTC & 0xf0; PORTC = portC | (axes_mask & 0x0f); //set step signals by mask asm("nop"); PORTC = portC; //set step signals to zero asm("nop"); +#endif #endif //((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a)) } From 78bbfc62379719a127cd5edcc48b3eb21aa2594f Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 14 Jul 2019 18:53:37 +0200 Subject: [PATCH 06/20] Fix delay calculations inside babystep() - Avoid all delays when using DEDGE stepping - Correctly account for direction change delays --- Firmware/stepper.cpp | 179 +++++++++++++++++++++++++------------------ 1 file changed, 105 insertions(+), 74 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 8f2a4f12..b3cc5a57 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -72,6 +72,14 @@ uint16_t SP_min = 0x21FF; #define _STEP_PIN_Z2_AXIS Z2_STEP_PIN #endif +#ifdef TMC2130 +#define STEPPER_MINIMUM_PULSE TMC2130_MINIMUM_PULSE +#define STEPPER_SET_DIR_DELAY TMC2130_SET_DIR_DELAY +#else +#define STEPPER_MINIMUM_PULSE 2 +#define STEPPER_SET_DIR_DELAY 100 +#endif + #ifdef TMC2130_DEDGE_STEPPING #define STEP_NC_HI(axis) TOGGLE(_STEP_PIN_##axis) #define STEP_NC_LO(axis) //NOP @@ -1416,89 +1424,112 @@ void quickStop() #ifdef BABYSTEPPING void babystep(const uint8_t axis,const bool direction) { - //MUST ONLY BE CALLED BY A ISR, it depends on that no other ISR interrupts this - //store initial pin states - switch(axis) - { - case X_AXIS: - { - enable_x(); - uint8_t old_x_dir_pin= READ(X_DIR_PIN); //if dualzstepper, both point to same direction. - - //setup new step - WRITE(X_DIR_PIN,(INVERT_X_DIR)^direction); - - //perform step - STEP_NC_HI(X_AXIS); + // MUST ONLY BE CALLED BY A ISR as stepper pins are manipulated directly. + // note: when switching direction no delay is inserted at the end when the + // original is restored. We assume enough time passes as the function + // returns and the stepper is manipulated again (to avoid dead times) + switch(axis) + { + case X_AXIS: + { + enable_x(); + uint8_t old_x_dir_pin = READ(X_DIR_PIN); //if dualzstepper, both point to same direction. + uint8_t new_x_dir_pin = (INVERT_X_DIR)^direction; + + //setup new step + if (new_x_dir_pin != old_x_dir_pin) { + WRITE_NC(X_DIR_PIN, new_x_dir_pin); + delayMicroseconds(STEPPER_SET_DIR_DELAY); + } + + //perform step + STEP_NC_HI(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - STEP_NC_HI(X_DUP_AXIS); -#endif //DEBUG_XSTEP_DUP_PIN - delayMicroseconds(1); - STEP_NC_LO(X_AXIS); + STEP_NC_HI(X_DUP_AXIS); +#endif +#ifndef TMC2130_DEDGE_STEPPING + delayMicroseconds(STEPPER_MINIMUM_PULSE); + STEP_NC_LO(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN - STEP_NC_LO(X_DUP_AXIS); -#endif //DEBUG_XSTEP_DUP_PIN + STEP_NC_LO(X_DUP_AXIS); +#endif +#endif - //get old pin state back. - WRITE(X_DIR_PIN,old_x_dir_pin); - } - break; - case Y_AXIS: - { - enable_y(); - uint8_t old_y_dir_pin= READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. - - //setup new step - WRITE(Y_DIR_PIN,(INVERT_Y_DIR)^direction); - - //perform step - STEP_NC_HI(Y_AXIS); + //get old pin state back. + WRITE_NC(X_DIR_PIN, old_x_dir_pin); + } + break; + + case Y_AXIS: + { + enable_y(); + uint8_t old_y_dir_pin = READ(Y_DIR_PIN); //if dualzstepper, both point to same direction. + uint8_t new_y_dir_pin = (INVERT_Y_DIR)^direction; + + //setup new step + if (new_y_dir_pin != old_y_dir_pin) { + WRITE_NC(Y_DIR_PIN, new_y_dir_pin); + delayMicroseconds(STEPPER_SET_DIR_DELAY); + } + + //perform step + STEP_NC_HI(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - STEP_NC_HI(Y_DUP_AXIS); -#endif //DEBUG_YSTEP_DUP_PIN - delayMicroseconds(1); - STEP_NC_LO(Y_AXIS); + STEP_NC_HI(Y_DUP_AXIS); +#endif +#ifndef TMC2130_DEDGE_STEPPING + delayMicroseconds(STEPPER_MINIMUM_PULSE); + STEP_NC_LO(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN - STEP_NC_LO(Y_DUP_AXIS); -#endif //DEBUG_YSTEP_DUP_PIN + STEP_NC_LO(Y_DUP_AXIS); +#endif +#endif - //get old pin state back. - WRITE(Y_DIR_PIN,old_y_dir_pin); + //get old pin state back. + WRITE_NC(Y_DIR_PIN, old_y_dir_pin); + } + break; - } - break; - - case Z_AXIS: - { - enable_z(); - uint8_t old_z_dir_pin= READ(Z_DIR_PIN); //if dualzstepper, both point to same direction. - //setup new step - WRITE(Z_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - #ifdef Z_DUAL_STEPPER_DRIVERS - WRITE(Z2_DIR_PIN,(INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z); - #endif - //perform step - STEP_NC_HI(Z_AXIS); - #ifdef Z_DUAL_STEPPER_DRIVERS - STEP_NC_HI(Z2_AXIS); - #endif - delayMicroseconds(1); - STEP_NC_LO(Z_AXIS); - #ifdef Z_DUAL_STEPPER_DRIVERS - STEP_NC_LO(Z2_AXIS); - #endif + case Z_AXIS: + { + enable_z(); + uint8_t old_z_dir_pin = READ(Z_DIR_PIN); //if dualzstepper, both point to same direction. + uint8_t new_z_dir_pin = (INVERT_Z_DIR)^direction^BABYSTEP_INVERT_Z; - //get old pin state back. - WRITE(Z_DIR_PIN,old_z_dir_pin); - #ifdef Z_DUAL_STEPPER_DRIVERS - WRITE(Z2_DIR_PIN,old_z_dir_pin); - #endif + //setup new step + if (new_z_dir_pin != old_z_dir_pin) { + WRITE_NC(Z_DIR_PIN, new_z_dir_pin); +#ifdef Z_DUAL_STEPPER_DRIVERS + WRITE_NC(Z2_DIR_PIN, new_z_dir_pin); +#endif + delayMicroseconds(STEPPER_SET_DIR_DELAY); + } - } - break; - - default: break; - } + //perform step + STEP_NC_HI(Z_AXIS); +#ifdef Z_DUAL_STEPPER_DRIVERS + STEP_NC_HI(Z2_AXIS); +#endif +#ifndef TMC2130_DEDGE_STEPPING + delayMicroseconds(STEPPER_MINIMUM_PULSE); + STEP_NC_LO(Z_AXIS); +#ifdef Z_DUAL_STEPPER_DRIVERS + STEP_NC_LO(Z2_AXIS); +#endif +#endif + + //get old pin state back. + if (new_z_dir_pin != old_z_dir_pin) { + WRITE_NC(Z_DIR_PIN, old_z_dir_pin); +#ifdef Z_DUAL_STEPPER_DRIVERS + WRITE_NC(Z2_DIR_PIN, old_z_dir_pin); +#endif + } + } + break; + + default: break; + } } #endif //BABYSTEPPING From 8a083c99705f5927ff76daca9b62c9f230f5ddb0 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Fri, 8 Jan 2021 13:52:39 +0100 Subject: [PATCH 07/20] Add PVB preheat and 0.8mm nozzle presets minor features reflecting the latest announcement Needs some 300B of CPU flash though, after 3.9.3 we need to optimize code size again. --- Firmware/eeprom.h | 2 + Firmware/ultralcd.cpp | 59 +++++++++++-------- Firmware/util.h | 1 + .../variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h | 4 ++ .../variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h | 3 + .../variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h | 3 + .../variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h | 3 + .../1_75mm_MK25S-RAMBo10a-E3Dv6full.h | 3 + .../1_75mm_MK25S-RAMBo13a-E3Dv6full.h | 3 + .../variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 3 + .../variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 3 + 11 files changed, 62 insertions(+), 25 deletions(-) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 731db1da..5445df4f 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -242,9 +242,11 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP | ^ | ^ | ^ | 00h 0 | ^ | Check mode for nozzle is: __none__ | ^ | ^ | 0x0DA7 3495 | uint8 | EEPROM_NOZZLE_DIAMETER | 28h 40 | ffh 255 | Nozzle diameter is: __40 or 0.40mm__ | LCD menu | D3 Ax0da7 C1 | ^ | ^ | ^ | 3ch 60 | ^ | Nozzle diameter is: __60 or 0.60mm__ | ^ | ^ +| ^ | ^ | ^ | 3ch 80 | ^ | Nozzle diameter is: __80 or 0.80mm__ | ^ | ^ | ^ | ^ | ^ | 19h 25 | ^ | Nozzle diameter is: __25 or 0.25mm__ | ^ | ^ | 0x0DA5 3493 | uint16 | EEPROM_NOZZLE_DIAMETER_uM | 9001h | ff ffh 65535 | Nozzle diameter is: __400um__ | LCD menu | D3 Ax0da5 C2 | ^ | ^ | ^ | 5802h | ^ | Nozzle diameter is: __600um__ | ^ | ^ +| ^ | ^ | ^ | 2003h | ^ | Nozzle diameter is: __800um__ | ^ | ^ | ^ | ^ | ^ | fa00h | ^ | Nozzle diameter is: __250um__ | ^ | ^ | 0x0DA4 3492 | uint8 | EEPROM_CHECK_MODEL | 01h 1 | ffh 255 | Check mode for printer model is: __warn__ | LCD menu | D3 Ax0da4 C1 | ^ | ^ | ^ | 02h 0 | ^ | Check mode for printer model is: __strict__ | ^ | ^ diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index a12db7f4..731de9fe 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -2533,6 +2533,12 @@ static void mFilamentItem_FLEX() mFilamentItem(FLEX_PREHEAT_HOTEND_TEMP, FLEX_PREHEAT_HPB_TEMP); } +static void mFilamentItem_PVB() +{ + bFilamentPreheatState = false; + mFilamentItem(PVB_PREHEAT_HOTEND_TEMP, PVB_PREHEAT_HPB_TEMP); +} + void mFilamentBack() { menu_back(); @@ -2569,6 +2575,7 @@ void lcd_generic_preheat_menu() MENU_ITEM_SUBMENU_P(PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)),mFilamentItem_PET); MENU_ITEM_SUBMENU_P(PSTR("ASA - " STRINGIFY(ASA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ASA_PREHEAT_HPB_TEMP)),mFilamentItem_ASA); MENU_ITEM_SUBMENU_P(PSTR("PC - " STRINGIFY(PC_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PC_PREHEAT_HPB_TEMP)),mFilamentItem_PC); + MENU_ITEM_SUBMENU_P(PSTR("PVB - " STRINGIFY(PVB_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PVB_PREHEAT_HPB_TEMP)),mFilamentItem_PVB); MENU_ITEM_SUBMENU_P(PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)),mFilamentItem_ABS); MENU_ITEM_SUBMENU_P(PSTR("HIPS - " STRINGIFY(HIPS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(HIPS_PREHEAT_HPB_TEMP)),mFilamentItem_HIPS); MENU_ITEM_SUBMENU_P(PSTR("PP - " STRINGIFY(PP_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PP_PREHEAT_HPB_TEMP)),mFilamentItem_PP); @@ -5488,30 +5495,31 @@ do\ }\ while (0) -static void lcd_nozzle_diameter_set(void) -{ -uint16_t nDiameter; - -switch(oNozzleDiameter) - { - case ClNozzleDiameter::_Diameter_250: - oNozzleDiameter=ClNozzleDiameter::_Diameter_400; - nDiameter=400; - break; - case ClNozzleDiameter::_Diameter_400: - oNozzleDiameter=ClNozzleDiameter::_Diameter_600; - nDiameter=600; - break; - case ClNozzleDiameter::_Diameter_600: - oNozzleDiameter=ClNozzleDiameter::_Diameter_250; - nDiameter=250; - break; - default: - oNozzleDiameter=ClNozzleDiameter::_Diameter_400; - nDiameter=400; - } -eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,(uint8_t)oNozzleDiameter); -eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,nDiameter); +static void lcd_nozzle_diameter_cycle(void) { + uint16_t nDiameter; + switch(oNozzleDiameter){ + case ClNozzleDiameter::_Diameter_250: + oNozzleDiameter=ClNozzleDiameter::_Diameter_400; + nDiameter=400; + break; + case ClNozzleDiameter::_Diameter_400: + oNozzleDiameter=ClNozzleDiameter::_Diameter_600; + nDiameter=600; + break; + case ClNozzleDiameter::_Diameter_600: + oNozzleDiameter=ClNozzleDiameter::_Diameter_800; + nDiameter=800; + break; + case ClNozzleDiameter::_Diameter_800: + oNozzleDiameter=ClNozzleDiameter::_Diameter_250; + nDiameter=250; + break; + default: + oNozzleDiameter=ClNozzleDiameter::_Diameter_400; + nDiameter=400; + } + eeprom_update_byte((uint8_t*)EEPROM_NOZZLE_DIAMETER,(uint8_t)oNozzleDiameter); + eeprom_update_word((uint16_t*)EEPROM_NOZZLE_DIAMETER_uM,nDiameter); } #define SETTINGS_NOZZLE \ @@ -5523,9 +5531,10 @@ do\ case ClNozzleDiameter::_Diameter_250: fNozzleDiam = 0.25f; break;\ case ClNozzleDiameter::_Diameter_400: fNozzleDiam = 0.4f; break;\ case ClNozzleDiameter::_Diameter_600: fNozzleDiam = 0.6f; break;\ + case ClNozzleDiameter::_Diameter_800: fNozzleDiam = 0.8f; break;\ default: fNozzleDiam = 0.4f; break;\ }\ - MENU_ITEM_TOGGLE(_T(MSG_NOZZLE_DIAMETER), ftostr12ns(fNozzleDiam), lcd_nozzle_diameter_set);\ + MENU_ITEM_TOGGLE(_T(MSG_NOZZLE_DIAMETER), ftostr12ns(fNozzleDiam), lcd_nozzle_diameter_cycle);\ }\ while (0) diff --git a/Firmware/util.h b/Firmware/util.h index 8f23cd5c..f25749de 100644 --- a/Firmware/util.h +++ b/Firmware/util.h @@ -51,6 +51,7 @@ enum class ClNozzleDiameter:uint_least8_t _Diameter_250=25, _Diameter_400=40, _Diameter_600=60, + _Diameter_800=80, _Diameter_Undef=EEPROM_EMPTY_VALUE }; diff --git a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h index 887a90a6..a74b6948 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo10a-E3Dv6full.h @@ -326,6 +326,10 @@ PREHEAT SETTINGS #define PLA_PREHEAT_HPB_TEMP 55 #define PLA_PREHEAT_FAN_SPEED 0 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 +#define PVB_PREHEAT_FAN_SPEED 0 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 #define ASA_PREHEAT_FAN_SPEED 0 diff --git a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h index c9c4ed6c..72ac605f 100644 --- a/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK2-RAMBo13a-E3Dv6full.h @@ -323,6 +323,9 @@ PREHEAT SETTINGS #define PLA_PREHEAT_HOTEND_TEMP 215 #define PLA_PREHEAT_HPB_TEMP 55 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 diff --git a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h index 1e77dce8..ba40e046 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo10a-E3Dv6full.h @@ -384,6 +384,9 @@ #define PLA_PREHEAT_HOTEND_TEMP 215 #define PLA_PREHEAT_HPB_TEMP 60 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 diff --git a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h index 2d4d73c2..33bb4717 100644 --- a/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25-RAMBo13a-E3Dv6full.h @@ -385,6 +385,9 @@ #define PLA_PREHEAT_HOTEND_TEMP 215 #define PLA_PREHEAT_HPB_TEMP 60 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h index 4670d218..19b2c76f 100644 --- a/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25S-RAMBo10a-E3Dv6full.h @@ -384,6 +384,9 @@ #define PLA_PREHEAT_HOTEND_TEMP 215 #define PLA_PREHEAT_HPB_TEMP 60 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 diff --git a/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h index 22af4341..cc02867d 100644 --- a/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK25S-RAMBo13a-E3Dv6full.h @@ -385,6 +385,9 @@ #define PLA_PREHEAT_HOTEND_TEMP 215 #define PLA_PREHEAT_HPB_TEMP 60 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index 7bd7be43..ab9e6a2c 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -498,6 +498,9 @@ #define PLA_PREHEAT_HOTEND_TEMP 215 #define PLA_PREHEAT_HPB_TEMP 60 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index 3056c436..9e2d1c44 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -502,6 +502,9 @@ #define PLA_PREHEAT_HOTEND_TEMP 215 #define PLA_PREHEAT_HPB_TEMP 60 +#define PVB_PREHEAT_HOTEND_TEMP 215 +#define PVB_PREHEAT_HPB_TEMP 75 + #define ASA_PREHEAT_HOTEND_TEMP 260 #define ASA_PREHEAT_HPB_TEMP 105 From ced3d9fa77622a0988c15759a085ec0088262988 Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Fri, 22 Jan 2021 11:13:44 +0200 Subject: [PATCH 08/20] "M20 L" support. Print long filenames --- Firmware/Marlin_main.cpp | 2 +- Firmware/cardreader.cpp | 25 +++++++++++++++++++------ Firmware/cardreader.h | 4 ++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 3be46591..1a157668 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5677,7 +5677,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) */ case 20: SERIAL_PROTOCOLLNRPGM(_N("Begin file list"));////MSG_BEGIN_FILE_LIST - card.ls(); + card.ls(code_seen('L')); SERIAL_PROTOCOLLNRPGM(_N("End file list"));////MSG_END_FILE_LIST break; diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index 94077f4c..b8dffb3e 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -62,9 +62,10 @@ char *createFilename(char *buffer,const dir_t &p) //buffer>12characters /** +* Dive into a folder and recurse depth-first to perform a pre-set operation lsAction: -+* LS_Count - Add +1 to nrFiles for every file within the parent -+* LS_GetFilename - Get the filename of the file indexed by nrFiles -+* LS_SerialPrint - Print the full path and size of each file to serial output ++* LS_Count - Add +1 to nrFiles for every file within the parent ++* LS_GetFilename - Get the filename of the file indexed by nrFiles ++* LS_SerialPrint - Print the full path and size of each file to serial output ++* LS_SerialPrint_LFN - Print the full path, long filename and size of each file to serial output +*/ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const match/*=NULL*/) { @@ -90,9 +91,13 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m // Serial.print(path); // Get a new directory object using the full path // and dive recursively into it. + + if (lsAction == LS_SerialPrint_LFN) + printf_P(PSTR("DIR_ENTER: %s \"%s\"\n"), path, longFilename[0] ? longFilename : lfilename); + SdFile dir; if (!dir.open(parent, lfilename, O_READ)) { - if (lsAction == LS_SerialPrint) { + if (lsAction == LS_SerialPrint || lsAction == LS_SerialPrint_LFN) { //SERIAL_ECHO_START(); //SERIAL_ECHOPGM(_i("Cannot open subdir"));////MSG_SD_CANT_OPEN_SUBDIR //SERIAL_ECHOLN(lfilename); @@ -100,6 +105,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } lsDive(path, dir); // close() is done automatically by destructor of SdFile + + if (lsAction == LS_SerialPrint_LFN) + puts_P(PSTR("DIR_EXIT")); } else { uint8_t pn0 = p.name[0]; @@ -114,11 +122,16 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m nrFiles++; break; + case LS_SerialPrint_LFN: case LS_SerialPrint: createFilename(filename, p); SERIAL_PROTOCOL(prepend); SERIAL_PROTOCOL(filename); MYSERIAL.write(' '); + + if (lsAction == LS_SerialPrint_LFN) + printf_P(PSTR("\"%s\" "), LONGEST_FILENAME); + SERIAL_PROTOCOLLN(p.fileSize); break; @@ -160,9 +173,9 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m } // while readDir } -void CardReader::ls() +void CardReader::ls(bool printLFN) { - lsAction=LS_SerialPrint; + lsAction = printLFN ? LS_SerialPrint_LFN : LS_SerialPrint; //if(lsAction==LS_Count) //nrFiles=0; diff --git a/Firmware/cardreader.h b/Firmware/cardreader.h index 12e83d96..25e97882 100644 --- a/Firmware/cardreader.h +++ b/Firmware/cardreader.h @@ -6,7 +6,7 @@ #define MAX_DIR_DEPTH 10 #include "SdFile.h" -enum LsAction {LS_SerialPrint,LS_Count,LS_GetFilename}; +enum LsAction {LS_SerialPrint,LS_SerialPrint_LFN,LS_Count,LS_GetFilename}; class CardReader { public: @@ -38,7 +38,7 @@ public: uint16_t getWorkDirDepth(); - void ls(); + void ls(bool printLFN); void chdir(const char * relpath); void updir(); void setroot(); From 9fda6b774d69c31becb560f0d324c38741f79f95 Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Fri, 22 Jan 2021 17:58:01 +0200 Subject: [PATCH 09/20] Do not send CR on the serial line --- Firmware/MarlinSerial.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/MarlinSerial.cpp b/Firmware/MarlinSerial.cpp index d3ffdfbe..2210eac7 100644 --- a/Firmware/MarlinSerial.cpp +++ b/Firmware/MarlinSerial.cpp @@ -255,7 +255,7 @@ void MarlinSerial::print(double n, int digits) void MarlinSerial::println(void) { - print('\r'); + // print('\r'); print('\n'); } From bc7d36b6ffb8eb1fc6021f160567423caeaefc18 Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Fri, 22 Jan 2021 18:57:24 +0200 Subject: [PATCH 10/20] Fix sm4.h line ending --- Firmware/sm4.h | 114 ++++++++++++++++++++++++------------------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/Firmware/sm4.h b/Firmware/sm4.h index ce110caa..9b553154 100644 --- a/Firmware/sm4.h +++ b/Firmware/sm4.h @@ -1,57 +1,57 @@ -//sm4.h - simple 4-axis stepper control -#ifndef _SM4_H -#define _SM4_H - -#include -#include "config.h" - - -#if defined(__cplusplus) -extern "C" { -#endif //defined(__cplusplus) - - -// callback prototype for stop condition (return 0 - continue, return 1 - stop) -typedef uint8_t (*sm4_stop_cb_t)(); - -// callback prototype for updating position counters -typedef void (*sm4_update_pos_cb_t)(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de); - -// callback prototype for calculating delay -typedef uint16_t (*sm4_calc_delay_cb_t)(uint16_t nd, uint16_t dd); - - -// callback pointer - stop -extern sm4_stop_cb_t sm4_stop_cb; - -// callback pointer - update_pos -extern sm4_update_pos_cb_t sm4_update_pos_cb; - -// callback pointer - calc_delay -extern sm4_calc_delay_cb_t sm4_calc_delay_cb; - - -// returns direction for single axis (0 - positive, 1 - negative) -extern uint8_t sm4_get_dir(uint8_t axis); - -// set direction for single axis (0 - positive, 1 - negative) -extern void sm4_set_dir(uint8_t axis, uint8_t dir); - -// returns direction of all axes as bitmask (0 - positive, 1 - negative) -extern uint8_t sm4_get_dir_bits(void); - -// set direction for all axes as bitmask (0 - positive, 1 - negative) -extern void sm4_set_dir_bits(uint8_t dir_bits); - -// step axes by bitmask -extern void sm4_do_step(uint8_t axes_mask); - -// xyze linear-interpolated relative move, returns remaining diagonal steps (>0 means stoped) -extern uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de); -extern uint16_t sm4_line_xyz_ui(uint16_t dx, uint16_t dy, uint16_t dz); - - -#if defined(__cplusplus) -} -#endif //defined(__cplusplus) -#endif //_SM4_H +//sm4.h - simple 4-axis stepper control +#ifndef _SM4_H +#define _SM4_H + +#include +#include "config.h" + + +#if defined(__cplusplus) +extern "C" { +#endif //defined(__cplusplus) + + +// callback prototype for stop condition (return 0 - continue, return 1 - stop) +typedef uint8_t (*sm4_stop_cb_t)(); + +// callback prototype for updating position counters +typedef void (*sm4_update_pos_cb_t)(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de); + +// callback prototype for calculating delay +typedef uint16_t (*sm4_calc_delay_cb_t)(uint16_t nd, uint16_t dd); + + +// callback pointer - stop +extern sm4_stop_cb_t sm4_stop_cb; + +// callback pointer - update_pos +extern sm4_update_pos_cb_t sm4_update_pos_cb; + +// callback pointer - calc_delay +extern sm4_calc_delay_cb_t sm4_calc_delay_cb; + + +// returns direction for single axis (0 - positive, 1 - negative) +extern uint8_t sm4_get_dir(uint8_t axis); + +// set direction for single axis (0 - positive, 1 - negative) +extern void sm4_set_dir(uint8_t axis, uint8_t dir); + +// returns direction of all axes as bitmask (0 - positive, 1 - negative) +extern uint8_t sm4_get_dir_bits(void); + +// set direction for all axes as bitmask (0 - positive, 1 - negative) +extern void sm4_set_dir_bits(uint8_t dir_bits); + +// step axes by bitmask +extern void sm4_do_step(uint8_t axes_mask); + +// xyze linear-interpolated relative move, returns remaining diagonal steps (>0 means stoped) +extern uint16_t sm4_line_xyze_ui(uint16_t dx, uint16_t dy, uint16_t dz, uint16_t de); +extern uint16_t sm4_line_xyz_ui(uint16_t dx, uint16_t dy, uint16_t dz); + + +#if defined(__cplusplus) +} +#endif //defined(__cplusplus) +#endif //_SM4_H From e8e4aabfdb2b16d1bffd4c04f1ad1a8d5c2e4cf5 Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Fri, 22 Jan 2021 21:07:14 +0200 Subject: [PATCH 11/20] Add gcode documentation --- Firmware/Marlin_main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 1a157668..750f1d19 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5674,6 +5674,11 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) /*! ### M20 - SD Card file list M20: List SD card + #### Usage + + M20 [ L ] + #### Parameters + - `L` - Reports ling filenames instead of just short filenames. Requires host software parsing. */ case 20: SERIAL_PROTOCOLLNRPGM(_N("Begin file list"));////MSG_BEGIN_FILE_LIST From 2b3729125d51d250ead7eb2364f0a03fc4c8563b Mon Sep 17 00:00:00 2001 From: Voinea Dragos Date: Mon, 25 Jan 2021 11:46:51 +0200 Subject: [PATCH 12/20] Prevent wdt reset during file listing --- Firmware/Marlin_main.cpp | 1 + Firmware/cardreader.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 750f1d19..a86782df 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -5681,6 +5681,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) - `L` - Reports ling filenames instead of just short filenames. Requires host software parsing. */ case 20: + KEEPALIVE_STATE(NOT_BUSY); // do not send busy messages during listing. Inhibits the output of manage_heater() SERIAL_PROTOCOLLNRPGM(_N("Begin file list"));////MSG_BEGIN_FILE_LIST card.ls(code_seen('L')); SERIAL_PROTOCOLLNRPGM(_N("End file list"));////MSG_END_FILE_LIST diff --git a/Firmware/cardreader.cpp b/Firmware/cardreader.cpp index b8dffb3e..7005e650 100644 --- a/Firmware/cardreader.cpp +++ b/Firmware/cardreader.cpp @@ -133,6 +133,7 @@ void CardReader::lsDive(const char *prepend, SdFile parent, const char * const m printf_P(PSTR("\"%s\" "), LONGEST_FILENAME); SERIAL_PROTOCOLLN(p.fileSize); + manage_heater(); break; case LS_GetFilename: From c28e5a9dbc482d077fdc60ada75456b58230d434 Mon Sep 17 00:00:00 2001 From: "D.R.racer" Date: Tue, 26 Jan 2021 09:08:03 +0100 Subject: [PATCH 13/20] Farmer's request 2 Farmers request having the Change filament menu item always visible in the main menu and located after the Live Adjust Z (which disappears after the first few printed layers). --- Firmware/ultralcd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index d175ad2b..d7976d27 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -6610,11 +6610,11 @@ static void lcd_main_menu() if ( ( IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) && (current_position[Z_AXIS] < Z_HEIGHT_HIDE_LIVE_ADJUST_MENU) && !homing_flag && !mesh_bed_leveling_flag) { - if (farm_mode) - MENU_ITEM_FUNCTION_P(_T(MSG_FILAMENTCHANGE), lcd_colorprint_change);//8 MENU_ITEM_SUBMENU_P(_T(MSG_BABYSTEP_Z), lcd_babystep_z);//8 } + if (farm_mode) + MENU_ITEM_FUNCTION_P(_T(MSG_FILAMENTCHANGE), lcd_colorprint_change);//8 if ( moves_planned() || IS_SD_PRINTING || is_usb_printing || (lcd_commands_type == LcdCommands::Layer1Cal)) { From 4fed728e083306aa4cddc950a9a1624bf7c61faf Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 26 Jan 2021 15:59:21 +0100 Subject: [PATCH 14/20] Elide delayMicroseconds for TMC2130 in non-DEDGE mode Introduce new macros TMC2130_MINIMUM_DELAY/STEPPER_MINIMUM_DELAY for blocking pauses. If MINIMUM_PULSE has defined to be zero, avoid the delay call entirely. --- Firmware/stepper.cpp | 8 +++++--- Firmware/tmc2130.cpp | 8 ++++---- Firmware/tmc2130.h | 6 ++++++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index b3cc5a57..e06e0602 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -75,9 +75,11 @@ uint16_t SP_min = 0x21FF; #ifdef TMC2130 #define STEPPER_MINIMUM_PULSE TMC2130_MINIMUM_PULSE #define STEPPER_SET_DIR_DELAY TMC2130_SET_DIR_DELAY +#define STEPPER_MINIMUM_DELAY TMC2130_MINIMUM_DELAY #else #define STEPPER_MINIMUM_PULSE 2 #define STEPPER_SET_DIR_DELAY 100 +#define STEPPER_MINIMUM_DELAY delayMicroseconds(STEPPER_MINIMUM_PULSE) #endif #ifdef TMC2130_DEDGE_STEPPING @@ -1448,7 +1450,7 @@ void babystep(const uint8_t axis,const bool direction) STEP_NC_HI(X_DUP_AXIS); #endif #ifndef TMC2130_DEDGE_STEPPING - delayMicroseconds(STEPPER_MINIMUM_PULSE); + STEPPER_MINIMUM_DELAY; STEP_NC_LO(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN STEP_NC_LO(X_DUP_AXIS); @@ -1478,7 +1480,7 @@ void babystep(const uint8_t axis,const bool direction) STEP_NC_HI(Y_DUP_AXIS); #endif #ifndef TMC2130_DEDGE_STEPPING - delayMicroseconds(STEPPER_MINIMUM_PULSE); + STEPPER_MINIMUM_DELAY; STEP_NC_LO(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN STEP_NC_LO(Y_DUP_AXIS); @@ -1511,7 +1513,7 @@ void babystep(const uint8_t axis,const bool direction) STEP_NC_HI(Z2_AXIS); #endif #ifndef TMC2130_DEDGE_STEPPING - delayMicroseconds(STEPPER_MINIMUM_PULSE); + STEPPER_MINIMUM_DELAY; STEP_NC_LO(Z_AXIS); #ifdef Z_DUAL_STEPPER_DRIVERS STEP_NC_LO(Z2_AXIS); diff --git a/Firmware/tmc2130.cpp b/Firmware/tmc2130.cpp index 15646b92..41f7b7c1 100755 --- a/Firmware/tmc2130.cpp +++ b/Firmware/tmc2130.cpp @@ -717,10 +717,10 @@ static uint8_t tmc2130_rx(uint8_t axis, uint8_t addr, uint32_t* rval) #define _DO_STEP_Z TOGGLE(Z_STEP_PIN) #define _DO_STEP_E TOGGLE(E0_STEP_PIN) #else -#define _DO_STEP_X { WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); } -#define _DO_STEP_Y { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); } -#define _DO_STEP_Z { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); } -#define _DO_STEP_E { WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); delayMicroseconds(TMC2130_MINIMUM_PULSE); WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); } +#define _DO_STEP_X { WRITE(X_STEP_PIN, !INVERT_X_STEP_PIN); TMC2130_MINIMUM_DELAY; WRITE(X_STEP_PIN, INVERT_X_STEP_PIN); } +#define _DO_STEP_Y { WRITE(Y_STEP_PIN, !INVERT_Y_STEP_PIN); TMC2130_MINIMUM_DELAY; WRITE(Y_STEP_PIN, INVERT_Y_STEP_PIN); } +#define _DO_STEP_Z { WRITE(Z_STEP_PIN, !INVERT_Z_STEP_PIN); TMC2130_MINIMUM_DELAY; WRITE(Z_STEP_PIN, INVERT_Z_STEP_PIN); } +#define _DO_STEP_E { WRITE(E0_STEP_PIN, !INVERT_E_STEP_PIN); TMC2130_MINIMUM_DELAY; WRITE(E0_STEP_PIN, INVERT_E_STEP_PIN); } #endif diff --git a/Firmware/tmc2130.h b/Firmware/tmc2130.h index 4b5b764c..36ba5552 100644 --- a/Firmware/tmc2130.h +++ b/Firmware/tmc2130.h @@ -33,6 +33,12 @@ extern uint8_t tmc2130_sg_homing_axes_mask; #define TMC2130_SET_DIR_DELAY 20 // minimum delay after setting direction in uS #define TMC2130_SET_PWR_DELAY 0 // minimum delay after changing pwr mode in uS +#if TMC2130_MINIMUM_PULSE == 0 +#define TMC2130_MINIMUM_DELAY //NOP +#else +#define TMC2130_MINIMUM_DELAY delayMicroseconds(TMC2130_MINIMUM_PULSE) +#endif + extern uint8_t tmc2130_home_enabled; extern uint8_t tmc2130_home_origin[2]; extern uint8_t tmc2130_home_bsteps[2]; From 2a6989ecd559f70ceb08aa471e0399c52747ddc8 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 26 Jan 2021 16:09:23 +0100 Subject: [PATCH 15/20] Remove TMC2130 special-cases With the new STEPPER_MINIMUM_DELAY being automatically removed for TMC2130 we no longer need to add specialized #ifdefs for DEDGE in babystep. --- Firmware/stepper.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index e06e0602..e74d7154 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -1449,12 +1449,10 @@ void babystep(const uint8_t axis,const bool direction) #ifdef DEBUG_XSTEP_DUP_PIN STEP_NC_HI(X_DUP_AXIS); #endif -#ifndef TMC2130_DEDGE_STEPPING STEPPER_MINIMUM_DELAY; STEP_NC_LO(X_AXIS); #ifdef DEBUG_XSTEP_DUP_PIN STEP_NC_LO(X_DUP_AXIS); -#endif #endif //get old pin state back. @@ -1479,12 +1477,10 @@ void babystep(const uint8_t axis,const bool direction) #ifdef DEBUG_YSTEP_DUP_PIN STEP_NC_HI(Y_DUP_AXIS); #endif -#ifndef TMC2130_DEDGE_STEPPING STEPPER_MINIMUM_DELAY; STEP_NC_LO(Y_AXIS); #ifdef DEBUG_YSTEP_DUP_PIN STEP_NC_LO(Y_DUP_AXIS); -#endif #endif //get old pin state back. @@ -1512,12 +1508,10 @@ void babystep(const uint8_t axis,const bool direction) #ifdef Z_DUAL_STEPPER_DRIVERS STEP_NC_HI(Z2_AXIS); #endif -#ifndef TMC2130_DEDGE_STEPPING STEPPER_MINIMUM_DELAY; STEP_NC_LO(Z_AXIS); #ifdef Z_DUAL_STEPPER_DRIVERS STEP_NC_LO(Z2_AXIS); -#endif #endif //get old pin state back. From b17cdcd4d7ebd9e53a4180cf9e6768845d1b1eef Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 26 Jan 2021 16:12:59 +0100 Subject: [PATCH 16/20] Ensure MINIMUM_PULSE is always 0 in DEDGE mode This ensures delays are always properly elided without having to check for DEDGE all over the place. --- Firmware/stepper.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index e74d7154..8684713b 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -83,6 +83,7 @@ uint16_t SP_min = 0x21FF; #endif #ifdef TMC2130_DEDGE_STEPPING +static_assert(TMC2130_MINIMUM_PULSE == 0, "DEDGE requires/implies TMC2130_MINIMUM_PULSE == 0"); #define STEP_NC_HI(axis) TOGGLE(_STEP_PIN_##axis) #define STEP_NC_LO(axis) //NOP #else From d3734b02cc1fbb8ba9a446d9ac5ef83b91756178 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 26 Jan 2021 16:18:23 +0100 Subject: [PATCH 17/20] Also fix delay instances inside unused BACKLASH_[XY] --- Firmware/stepper.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index 8684713b..d47dd2dc 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -352,13 +352,13 @@ FORCE_INLINE void stepper_next_block() WRITE_NC(X_DIR_PIN, INVERT_X_DIR); else WRITE_NC(X_DIR_PIN, !INVERT_X_DIR); - _delay_us(100); + delayMicroseconds(STEPPER_SET_DIR_DELAY); for (uint8_t i = 0; i < st_backlash_x; i++) { STEP_NC_HI(X_AXIS); - _delay_us(100); + STEPPER_MINIMUM_DELAY; STEP_NC_LO(X_AXIS); - _delay_us(900); + _delay_us(900); // hard-coded jerk! *bad* } } last_dir_bits &= ~1; @@ -375,13 +375,13 @@ FORCE_INLINE void stepper_next_block() WRITE_NC(Y_DIR_PIN, INVERT_Y_DIR); else WRITE_NC(Y_DIR_PIN, !INVERT_Y_DIR); - _delay_us(100); + delayMicroseconds(STEPPER_SET_DIR_DELAY); for (uint8_t i = 0; i < st_backlash_y; i++) { STEP_NC_HI(Y_AXIS); - _delay_us(100); + STEPPER_MINIMUM_DELAY; STEP_NC_LO(Y_AXIS); - _delay_us(900); + _delay_us(900); // hard-coded jerk! *bad* } } last_dir_bits &= ~2; From a9625747db85f22cb583d4fdc4c4f0dc2706e687 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 26 Jan 2021 19:37:14 +0100 Subject: [PATCH 18/20] Reinstate the nop instruction as delay in non-DEDGE When TMC2130_MINIMUM_PULSE is 0 a minimum delay is implied. In this case, use a single "nop" instruction. --- Firmware/stepper.cpp | 3 ++- Firmware/tmc2130.h | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Firmware/stepper.cpp b/Firmware/stepper.cpp index d47dd2dc..fc8d9f44 100644 --- a/Firmware/stepper.cpp +++ b/Firmware/stepper.cpp @@ -83,7 +83,8 @@ uint16_t SP_min = 0x21FF; #endif #ifdef TMC2130_DEDGE_STEPPING -static_assert(TMC2130_MINIMUM_PULSE == 0, "DEDGE requires/implies TMC2130_MINIMUM_PULSE == 0"); +static_assert(TMC2130_MINIMUM_DELAY 1, // this will fail to compile when non-empty + "DEDGE implies/requires an empty TMC2130_MINIMUM_DELAY"); #define STEP_NC_HI(axis) TOGGLE(_STEP_PIN_##axis) #define STEP_NC_LO(axis) //NOP #else diff --git a/Firmware/tmc2130.h b/Firmware/tmc2130.h index 36ba5552..485bf41c 100644 --- a/Firmware/tmc2130.h +++ b/Firmware/tmc2130.h @@ -33,8 +33,10 @@ extern uint8_t tmc2130_sg_homing_axes_mask; #define TMC2130_SET_DIR_DELAY 20 // minimum delay after setting direction in uS #define TMC2130_SET_PWR_DELAY 0 // minimum delay after changing pwr mode in uS -#if TMC2130_MINIMUM_PULSE == 0 +#ifdef TMC2130_DEDGE_STEPPING #define TMC2130_MINIMUM_DELAY //NOP +#elif TMC2130_MINIMUM_PULSE == 0 +#define TMC2130_MINIMUM_DELAY asm("nop") #else #define TMC2130_MINIMUM_DELAY delayMicroseconds(TMC2130_MINIMUM_PULSE) #endif From fba83bd3091414bda8d0e1b220ab4f229610e436 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Wed, 27 Jan 2021 12:43:41 +0100 Subject: [PATCH 19/20] Add new flags -c -p -n --- PF-build.sh | 47 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/PF-build.sh b/PF-build.sh index b7539578..5b0979e2 100755 --- a/PF-build.sh +++ b/PF-build.sh @@ -56,7 +56,7 @@ # Some may argue that this is only used by a script, BUT as soon someone accidentally or on purpose starts Arduino IDE # it will use the default Arduino IDE folders and so can corrupt the build environment. # -# Version: 1.0.6-Build_33 +# Version: 1.0.6-Build_36 # Change log: # 12 Jan 2019, 3d-gussner, Fixed "compiler.c.elf.flags=-w -Os -Wl,-u,vfprintf -lprintf_flt -lm -Wl,--gc-sections" in 'platform.txt' # 16 Jan 2019, 3d-gussner, Build_2, Added development check to modify 'Configuration.h' to prevent unwanted LCD messages that Firmware is unknown @@ -135,6 +135,7 @@ # Update exit numbers 1-13 for prepare build env 21-29 for prepare compiling 30-36 compiling # 08 Jan 2021, 3d-gussner, Comment out 'sudo' auto installation # Add '-?' '-h' help option +# 27 Jan 2021, 3d-gussner, Add `-c`, `-p` and `-n` options #### Start check if OSTYPE is supported OS_FOUND=$( command -v uname) @@ -451,7 +452,7 @@ if type git > /dev/null; then git_available="1" fi -while getopts v:l:d:b:o:?h flag +while getopts v:l:d:b:o:c:p:n:?h flag do case "${flag}" in v) variant_flag=${OPTARG};; @@ -459,6 +460,9 @@ while getopts v:l:d:b:o:?h flag d) devel_flag=${OPTARG};; b) build_flag=${OPTARG};; o) output_flag=${OPTARG};; + c) clean_flag=${OPTARG};; + p) prusa_flag=${OPTARG};; + n) new_build_flag=${OPTARG};; ?) help_flag=1;; h) help_flag=1;; esac @@ -469,6 +473,9 @@ while getopts v:l:d:b:o:?h flag #echo "build_flag: $build_flag"; #echo "output_flag: $output_flag"; #echo "help_flag: $help_flag" +#echo "clean_flag: $clean_flag" +#echo "prusa_flag: $prusa_flag" +#echo "new_build_flag: $new_build_flag" # # '?' 'h' argument usage and help @@ -482,19 +489,23 @@ echo "$(tput setaf 2)-l$(tput sgr0) Languages '$(tput setaf 2)ALL$(tput sgr0)' f echo "$(tput setaf 2)-d$(tput sgr0) Devel build '$(tput setaf 2)GOLD$(tput sgr0)', '$(tput setaf 2)RC$(tput sgr0)', '$(tput setaf 2)BETA$(tput sgr0)', '$(tput setaf 2)ALPHA$(tput sgr0)', '$(tput setaf 2)DEBUG$(tput sgr0)', '$(tput setaf 2)DEVEL$(tput sgr0)' and '$(tput setaf 2)UNKNOWN$(tput sgr0)'" echo "$(tput setaf 2)-b$(tput sgr0) Build/commit number '$(tput setaf 2)Auto$(tput sgr0)' needs git or a number" echo "$(tput setaf 2)-o$(tput sgr0) Output '$(tput setaf 2)1$(tput sgr0)' force or '$(tput setaf 2)0$(tput sgr0)' block output and delays" +echo "$(tput setaf 2)-c$(tput sgr0) Do not clean up lang build'$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes" +echo "$(tput setaf 2)-p$(tput sgr0) Keep Configuration_prusa.h '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes" +echo "$(tput setaf 2)-n$(tput sgr0) New fresh build '$(tput setaf 2)0$(tput sgr0)' no '$(tput setaf 2)1$(tput sgr0)' yes" echo "$(tput setaf 2)-?$(tput sgr0) Help" echo "$(tput setaf 2)-h$(tput sgr0) Help" echo echo "Brief USAGE:" -echo " $(tput setaf 2)./PF-build.sh$(tput sgr0) [-v] [-l] [-d] [-b] [-o]" +echo " $(tput setaf 2)./PF-build.sh$(tput sgr0) [-v] [-l] [-d] [-b] [-o] [-c] [-p] [-n]" echo echo "Example:" echo " $(tput setaf 2)./PF-build.sh -v All -l ALL -d GOLD$(tput sgr0)" echo " Will build all variants as multi language and final GOLD version" echo -echo " $(tput setaf 2) ./PF-build.sh -v 1_75mm_MK3S-EINSy10a-E3Dv6full.h -b Auto -l ALL -d GOLD -o 1$(tput sgr0)" +echo " $(tput setaf 2) ./PF-build.sh -v 1_75mm_MK3S-EINSy10a-E3Dv6full.h -b Auto -l ALL -d GOLD -o 1 -c 1 -p 1 -n 1$(tput sgr0)" echo " Will build MK3S multi language final GOLD firmware " -echo " with current commit count number and output extra information" +echo " with current commit count number and output extra information," +echo " not delete lang build temporary files, keep Configuration_prusa.h and build with new fresh build folder." echo exit @@ -807,6 +818,12 @@ do if [ $OUTPUT == "1" ] ; then sleep 2 fi + + #New fresh PF-Firmware-build + if [ "$new_build_flag" == "1" ]; then + rm -r -f $BUILD_PATH/* || exit 36 + fi + #$BUILD_ENV_PATH/arduino-builder -dump-prefs -debug-level 10 -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 14 $BUILD_ENV_PATH/arduino-builder -compile -hardware $ARDUINO/hardware -hardware $ARDUINO/portable/packages -tools $ARDUINO/tools-builder -tools $ARDUINO/hardware/tools/avr -tools $ARDUINO/portable/packages -built-in-libraries $ARDUINO/libraries -libraries $ARDUINO/portable/sketchbook/libraries -fqbn=$BOARD_PACKAGE_NAME:avr:$BOARD -build-path=$BUILD_PATH -warnings=all $SCRIPT_PATH/Firmware/Firmware.ino || exit 30 echo "$(tput sgr 0)" @@ -874,17 +891,21 @@ do fi fi # Cleanup after build - echo "$(tput setaf 3)" - ./fw-clean.sh || exit 34 - ./lang-clean.sh || exit 35 - echo "$(tput sgr 0)" + if [[ -z "$clean_flag" || "$clean_flag" == "0" ]]; then + echo "$(tput setaf 3)" + ./fw-clean.sh || exit 34 + ./lang-clean.sh || exit 35 + echo "$(tput sgr 0)" + fi else echo "$(tput setaf 2)Copying English only firmware to PF-build-hex folder$(tput sgr 0)" cp -f $BUILD_PATH/Firmware.ino.hex $SCRIPT_PATH/../$OUTPUT_FOLDER/FW$FW-Build$BUILD-$VARIANT-EN_ONLY.hex || exit 34 fi # Cleanup Firmware - rm $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 36 + if [[ -z "$prusa_flag" || "$prusa_flag" == "0" ]]; then + rm $SCRIPT_PATH/Firmware/Configuration_prusa.h || exit 36 + fi if find $SCRIPT_PATH/lang/ -name '*RAMBo10a*.txt' -printf 1 -quit | grep -q 1 then rm $SCRIPT_PATH/lang/*RAMBo10a*.txt @@ -901,6 +922,12 @@ do then rm $SCRIPT_PATH/lang/not_used.txt fi + + #New fresh PF-Firmware-build + if [ "$new_build_flag" == "1" ]; then + rm -r -f $BUILD_PATH/* || exit 36 + fi + # Restore files to previous state sed -i -- "s/^#define FW_DEV_VERSION FW_VERSION_$DEV_STATUS/#define FW_DEV_VERSION FW_VERSION_UNKNOWN/g" $SCRIPT_PATH/Firmware/Configuration.h sed -i -- 's/^#define FW_REPOSITORY "Prusa3d"/#define FW_REPOSITORY "Unknown"/g' $SCRIPT_PATH/Firmware/Configuration.h From e9d5c447322e899b0e7cfdc71146e4911e7a0b5a Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 29 Jan 2021 00:13:49 +0100 Subject: [PATCH 20/20] Also toggle pins efficiently in sm4.c Use the same technique used in fastio to toggle pins efficiently in sm4 when DEDGE is used. --- Firmware/sm4.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/sm4.c b/Firmware/sm4.c index b68e0276..c2f12824 100644 --- a/Firmware/sm4.c +++ b/Firmware/sm4.c @@ -130,7 +130,7 @@ void sm4_do_step(uint8_t axes_mask) { #if ((MOTHERBOARD == BOARD_RAMBO_MINI_1_0) || (MOTHERBOARD == BOARD_RAMBO_MINI_1_3) || (MOTHERBOARD == BOARD_EINSY_1_0a)) #ifdef TMC2130_DEDGE_STEPPING - PORTC ^= (axes_mask & 0x0f); //set step signals by mask + PINC = (axes_mask & 0x0f); // toggle step signals by mask #else register uint8_t portC = PORTC & 0xf0; PORTC = portC | (axes_mask & 0x0f); //set step signals by mask