Skip to content

Commit

Permalink
🔧 SQUARE_WAVE_STEPPING => EDGE_STEPPING (#25526)
Browse files Browse the repository at this point in the history
Co-Authored-By: Scott Lahteine <[email protected]>
  • Loading branch information
thisiskeithb and thinkyhead committed Apr 10, 2023
1 parent 0663081 commit 4ef67ca
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 38 deletions.
9 changes: 4 additions & 5 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3154,7 +3154,7 @@
*
* It is recommended to set HOMING_BUMP_MM to { 0, 0, 0 }.
*
* SPI_ENDSTOPS *** Beta feature! *** TMC2130/TMC5160 Only ***
* SPI_ENDSTOPS *** TMC2130/TMC5160 Only ***
* Poll the driver through SPI to determine load when homing.
* Removes the need for a wire from DIAG1 to an endstop pin.
*
Expand Down Expand Up @@ -3182,7 +3182,7 @@
//#define U_STALL_SENSITIVITY 8
//#define V_STALL_SENSITIVITY 8
//#define W_STALL_SENSITIVITY 8
//#define SPI_ENDSTOPS // TMC2130 only
//#define SPI_ENDSTOPS // TMC2130/TMC5160 only
//#define IMPROVE_HOMING_RELIABILITY
#endif

Expand All @@ -3201,10 +3201,9 @@
//#define TMC_HOME_PHASE { 896, 896, 896 }

/**
* Beta feature!
* Create a 50/50 square wave step pulse optimal for stepper drivers.
* Step on both rising and falling edge signals (as with a square wave).
*/
//#define SQUARE_WAVE_STEPPING
//#define EDGE_STEPPING

/**
* Enable M122 debugging command for TMC stepper drivers.
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,8 @@
#error "INVERT_*_STEP_PIN true is now STEP_STATE_* LOW, and INVERT_*_STEP_PIN false is now STEP_STATE_* HIGH."
#elif defined(PROBE_PT_1_X) || defined(PROBE_PT_1_Y) || defined(PROBE_PT_2_X) || defined(PROBE_PT_2_Y) || defined(PROBE_PT_3_X) || defined(PROBE_PT_3_Y)
#error "PROBE_PT_[123]_[XY] is now defined using PROBE_PT_[123] with an array { x, y }."
#elif defined(SQUARE_WAVE_STEPPING)
#error "SQUARE_WAVE_STEPPING is now EDGE_STEPPING."
#endif

// L64xx stepper drivers have been removed
Expand Down
14 changes: 7 additions & 7 deletions Marlin/src/module/stepper/trinamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ enum StealthIndex : uint8_t {
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
TERN_(EDGE_STEPPING, chopconf.dedge = true);
st.CHOPCONF(chopconf.sr);

st.rms_current(mA, hold_multiplier);
Expand Down Expand Up @@ -262,7 +262,7 @@ enum StealthIndex : uint8_t {
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
TERN_(EDGE_STEPPING, chopconf.dedge = true);
st.CHOPCONF(chopconf.sr);

st.rms_current(mA, hold_multiplier);
Expand Down Expand Up @@ -684,7 +684,7 @@ enum StealthIndex : uint8_t {
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
TERN_(EDGE_STEPPING, chopconf.dedge = true);
st.CHOPCONF(chopconf.sr);

st.rms_current(mA, hold_multiplier);
Expand Down Expand Up @@ -726,7 +726,7 @@ enum StealthIndex : uint8_t {
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
TERN_(EDGE_STEPPING, chopconf.dedge = true);
st.CHOPCONF(chopconf.sr);

st.rms_current(mA, hold_multiplier);
Expand Down Expand Up @@ -766,7 +766,7 @@ enum StealthIndex : uint8_t {
st.sdoff(0);
st.rms_current(mA);
st.microsteps(microsteps);
TERN_(SQUARE_WAVE_STEPPING, st.dedge(true));
TERN_(EDGE_STEPPING, st.dedge(true));
st.intpol(interpolate);
st.diss2g(true); // Disable short to ground protection. Too many false readings?
TERN_(TMC_DEBUG, st.rdsel(0b01));
Expand All @@ -784,7 +784,7 @@ enum StealthIndex : uint8_t {
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
TERN_(EDGE_STEPPING, chopconf.dedge = true);
st.CHOPCONF(chopconf.sr);

st.rms_current(mA, hold_multiplier);
Expand Down Expand Up @@ -819,7 +819,7 @@ enum StealthIndex : uint8_t {
chopconf.intpol = interpolate;
chopconf.hend = chop_init.hend + 3;
chopconf.hstrt = chop_init.hstrt - 1;
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
TERN_(EDGE_STEPPING, chopconf.dedge = true);
st.CHOPCONF(chopconf.sr);

st.rms_current(mA, hold_multiplier);
Expand Down
46 changes: 23 additions & 23 deletions Marlin/src/module/stepper/trinamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
void restore_trinamic_drivers();
void reset_trinamic_drivers();

#define AXIS_HAS_SQUARE_WAVE(A) (AXIS_IS_TMC(A) && ENABLED(SQUARE_WAVE_STEPPING))
#define AXIS_HAS_DEDGE(A) (AXIS_IS_TMC(A) && ENABLED(EDGE_STEPPING))

// X Stepper
#if AXIS_IS_TMC(X)
Expand All @@ -126,7 +126,7 @@ void reset_trinamic_drivers();
#define X_ENABLE_WRITE(STATE) stepperX.toff((STATE)==X_ENABLE_ON ? chopper_timing_X.toff : 0)
#define X_ENABLE_READ() stepperX.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(X)
#if AXIS_HAS_DEDGE(X)
#define X_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(X_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -140,7 +140,7 @@ void reset_trinamic_drivers();
#define Y_ENABLE_WRITE(STATE) stepperY.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y.toff : 0)
#define Y_ENABLE_READ() stepperY.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(Y)
#if AXIS_HAS_DEDGE(Y)
#define Y_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(Y_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -154,7 +154,7 @@ void reset_trinamic_drivers();
#define Z_ENABLE_WRITE(STATE) stepperZ.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z.toff : 0)
#define Z_ENABLE_READ() stepperZ.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(Z)
#if AXIS_HAS_DEDGE(Z)
#define Z_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(Z_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -171,7 +171,7 @@ void reset_trinamic_drivers();
#define X2_ENABLE_WRITE(STATE) stepperX2.toff((STATE)==X_ENABLE_ON ? chopper_timing_X2.toff : 0)
#define X2_ENABLE_READ() stepperX2.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(X2)
#if AXIS_HAS_DEDGE(X2)
#define X2_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(X2_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -188,7 +188,7 @@ void reset_trinamic_drivers();
#define Y2_ENABLE_WRITE(STATE) stepperY2.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y2.toff : 0)
#define Y2_ENABLE_READ() stepperY2.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(Y2)
#if AXIS_HAS_DEDGE(Y2)
#define Y2_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(Y2_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -205,7 +205,7 @@ void reset_trinamic_drivers();
#define Z2_ENABLE_WRITE(STATE) stepperZ2.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z2.toff : 0)
#define Z2_ENABLE_READ() stepperZ2.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(Z2)
#if AXIS_HAS_DEDGE(Z2)
#define Z2_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(Z2_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -222,7 +222,7 @@ void reset_trinamic_drivers();
#define Z3_ENABLE_WRITE(STATE) stepperZ3.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z3.toff : 0)
#define Z3_ENABLE_READ() stepperZ3.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(Z3)
#if AXIS_HAS_DEDGE(Z3)
#define Z3_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(Z3_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -239,7 +239,7 @@ void reset_trinamic_drivers();
#define Z4_ENABLE_WRITE(STATE) stepperZ4.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z4.toff : 0)
#define Z4_ENABLE_READ() stepperZ4.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(Z4)
#if AXIS_HAS_DEDGE(Z4)
#define Z4_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(Z4_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -253,7 +253,7 @@ void reset_trinamic_drivers();
#define I_ENABLE_WRITE(STATE) stepperI.toff((STATE)==I_ENABLE_ON ? chopper_timing.toff : 0)
#define I_ENABLE_READ() stepperI.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(I)
#if AXIS_HAS_DEDGE(I)
#define I_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(I_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -267,7 +267,7 @@ void reset_trinamic_drivers();
#define J_ENABLE_WRITE(STATE) stepperJ.toff((STATE)==J_ENABLE_ON ? chopper_timing.toff : 0)
#define J_ENABLE_READ() stepperJ.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(J)
#if AXIS_HAS_DEDGE(J)
#define J_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(J_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -281,7 +281,7 @@ void reset_trinamic_drivers();
#define K_ENABLE_WRITE(STATE) stepperK.toff((STATE)==K_ENABLE_ON ? chopper_timing.toff : 0)
#define K_ENABLE_READ() stepperK.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(K)
#if AXIS_HAS_DEDGE(K)
#define K_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(K_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -295,7 +295,7 @@ void reset_trinamic_drivers();
#define U_ENABLE_WRITE(STATE) stepperU.toff((STATE)==U_ENABLE_ON ? chopper_timing_U.toff : 0)
#define U_ENABLE_READ() stepperU.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(U)
#if AXIS_HAS_DEDGE(U)
#define U_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(U_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -309,7 +309,7 @@ void reset_trinamic_drivers();
#define V_ENABLE_WRITE(STATE) stepperV.toff((STATE)==V_ENABLE_ON ? chopper_timing_V.toff : 0)
#define V_ENABLE_READ() stepperV.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(V)
#if AXIS_HAS_DEDGE(V)
#define V_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(V_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -323,7 +323,7 @@ void reset_trinamic_drivers();
#define W_ENABLE_WRITE(STATE) stepperW.toff((STATE)==W_ENABLE_ON ? chopper_timing_W.toff : 0)
#define W_ENABLE_READ() stepperW.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(W)
#if AXIS_HAS_DEDGE(W)
#define W_STEP_WRITE(STATE) do{ if(STATE) TOGGLE(W_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -340,7 +340,7 @@ void reset_trinamic_drivers();
#define E0_ENABLE_WRITE(STATE) stepperE0.toff((STATE)==E_ENABLE_ON ? chopper_timing_E0.toff : 0)
#define E0_ENABLE_READ() stepperE0.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E0)
#if AXIS_HAS_DEDGE(E0)
#define E0_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E0_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -357,7 +357,7 @@ void reset_trinamic_drivers();
#define E1_ENABLE_WRITE(STATE) stepperE1.toff((STATE)==E_ENABLE_ON ? chopper_timing_E1.toff : 0)
#define E1_ENABLE_READ() stepperE1.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E1)
#if AXIS_HAS_DEDGE(E1)
#define E1_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E1_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -374,7 +374,7 @@ void reset_trinamic_drivers();
#define E2_ENABLE_WRITE(STATE) stepperE2.toff((STATE)==E_ENABLE_ON ? chopper_timing_E2.toff : 0)
#define E2_ENABLE_READ() stepperE2.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E2)
#if AXIS_HAS_DEDGE(E2)
#define E2_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E2_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -391,7 +391,7 @@ void reset_trinamic_drivers();
#define E3_ENABLE_WRITE(STATE) stepperE3.toff((STATE)==E_ENABLE_ON ? chopper_timing_E3.toff : 0)
#define E3_ENABLE_READ() stepperE3.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E3)
#if AXIS_HAS_DEDGE(E3)
#define E3_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E3_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -408,7 +408,7 @@ void reset_trinamic_drivers();
#define E4_ENABLE_WRITE(STATE) stepperE4.toff((STATE)==E_ENABLE_ON ? chopper_timing_E4.toff : 0)
#define E4_ENABLE_READ() stepperE4.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E4)
#if AXIS_HAS_DEDGE(E4)
#define E4_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E4_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -425,7 +425,7 @@ void reset_trinamic_drivers();
#define E5_ENABLE_WRITE(STATE) stepperE5.toff((STATE)==E_ENABLE_ON ? chopper_timing_E5.toff : 0)
#define E5_ENABLE_READ() stepperE5.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E5)
#if AXIS_HAS_DEDGE(E5)
#define E5_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E5_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -442,7 +442,7 @@ void reset_trinamic_drivers();
#define E6_ENABLE_WRITE(STATE) stepperE6.toff((STATE)==E_ENABLE_ON ? chopper_timing_E6.toff : 0)
#define E6_ENABLE_READ() stepperE6.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E6)
#if AXIS_HAS_DEDGE(E6)
#define E6_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E6_STEP_PIN); }while(0)
#endif
#endif
Expand All @@ -459,7 +459,7 @@ void reset_trinamic_drivers();
#define E7_ENABLE_WRITE(STATE) stepperE7.toff((STATE)==E_ENABLE_ON ? chopper_timing_E7.toff : 0)
#define E7_ENABLE_READ() stepperE7.isEnabled()
#endif
#if AXIS_HAS_SQUARE_WAVE(E7)
#if AXIS_HAS_DEDGE(E7)
#define E7_STEP_WRITE(STATE) do{ if (STATE) TOGGLE(E7_STEP_PIN); }while(0)
#endif
#endif
2 changes: 1 addition & 1 deletion buildroot/tests/FYSETC_F6
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ opt_set MOTHERBOARD BOARD_FYSETC_F6_13 \
X_HARDWARE_SERIAL Serial2
opt_enable USE_ZMIN_PLUG FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR PAUSE_BEFORE_DEPLOY_STOW \
FYSETC_242_OLED_12864 EEPROM_SETTINGS EEPROM_CHITCHAT M114_DETAIL Z_SAFE_HOMING \
STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD SENSORLESS_HOMING SQUARE_WAVE_STEPPING
STEALTHCHOP_XY STEALTHCHOP_Z STEALTHCHOP_E HYBRID_THRESHOLD SENSORLESS_HOMING EDGE_STEPPING
exec_test $1 $2 "FYSETC_F6 | SCARA | Mixed TMC | EEPROM" "$3"

# clean up
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/SAMD21_minitronics20
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ opt_enable ENDSTOP_INTERRUPTS_FEATURE BLTOUCH Z_MIN_PROBE_REPEATABILITY_TEST \
SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \
MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_GFX_OVERLAY \
LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS SENSORLESS_HOMING \
SQUARE_WAVE_STEPPING
EDGE_STEPPING
exec_test $1 $2 "Minitronics 2.0 with assorted features" "$3"

# clean up
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/SAMD51_grandcentral_m4
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ opt_enable ENDSTOP_INTERRUPTS_FEATURE S_CURVE_ACCELERATION BLTOUCH Z_MIN_PROBE_R
SCROLL_LONG_FILENAMES BABYSTEPPING DOUBLECLICK_FOR_Z_BABYSTEPPING \
MOVE_Z_WHEN_IDLE BABYSTEP_ZPROBE_OFFSET BABYSTEP_GFX_OVERLAY \
LIN_ADVANCE ADVANCED_PAUSE_FEATURE PARK_HEAD_ON_PAUSE MONITOR_DRIVER_STATUS SENSORLESS_HOMING \
SQUARE_WAVE_STEPPING TMC_DEBUG
EDGE_STEPPING TMC_DEBUG
exec_test $1 $2 "Grand Central M4 with assorted features" "$3"

# clean up
Expand Down

0 comments on commit 4ef67ca

Please sign in to comment.