Browse Source

✨ Per-axis TMC hold multiplier (#23345)

fflosi 2 years ago
parent
commit
c74161c011
No account linked to committer's email address
3 changed files with 336 additions and 216 deletions
  1. 19
    0
      Marlin/Configuration_adv.h
  2. 303
    202
      Marlin/src/inc/Conditionals_post.h
  3. 14
    14
      Marlin/src/module/stepper/trinamic.cpp

+ 19
- 0
Marlin/Configuration_adv.h View File

@@ -2690,6 +2690,7 @@
2690 2690
     #define X_RSENSE          0.11
2691 2691
     #define X_CHAIN_POS      -1        // -1..0: Not chained. 1: MCU MOSI connected. 2: Next in chain, ...
2692 2692
     //#define X_INTERPOLATE  true      // Enable to override 'INTERPOLATE' for the X axis
2693
+    //#define X_HOLD_MULTIPLIER 0.5    // Enable to override 'HOLD_MULTIPLIER' for the X axis
2693 2694
   #endif
2694 2695
 
2695 2696
   #if AXIS_IS_TMC(X2)
@@ -2699,6 +2700,7 @@
2699 2700
     #define X2_RSENSE         0.11
2700 2701
     #define X2_CHAIN_POS     -1
2701 2702
     //#define X2_INTERPOLATE true
2703
+    //#define X2_HOLD_MULTIPLIER 0.5
2702 2704
   #endif
2703 2705
 
2704 2706
   #if AXIS_IS_TMC(Y)
@@ -2708,6 +2710,7 @@
2708 2710
     #define Y_RSENSE          0.11
2709 2711
     #define Y_CHAIN_POS      -1
2710 2712
     //#define Y_INTERPOLATE  true
2713
+    //#define Y_HOLD_MULTIPLIER 0.5
2711 2714
   #endif
2712 2715
 
2713 2716
   #if AXIS_IS_TMC(Y2)
@@ -2717,6 +2720,7 @@
2717 2720
     #define Y2_RSENSE         0.11
2718 2721
     #define Y2_CHAIN_POS     -1
2719 2722
     //#define Y2_INTERPOLATE true
2723
+    //#define Y2_HOLD_MULTIPLIER 0.5
2720 2724
   #endif
2721 2725
 
2722 2726
   #if AXIS_IS_TMC(Z)
@@ -2726,6 +2730,7 @@
2726 2730
     #define Z_RSENSE          0.11
2727 2731
     #define Z_CHAIN_POS      -1
2728 2732
     //#define Z_INTERPOLATE  true
2733
+    //#define Z_HOLD_MULTIPLIER 0.5
2729 2734
   #endif
2730 2735
 
2731 2736
   #if AXIS_IS_TMC(Z2)
@@ -2735,6 +2740,7 @@
2735 2740
     #define Z2_RSENSE         0.11
2736 2741
     #define Z2_CHAIN_POS     -1
2737 2742
     //#define Z2_INTERPOLATE true
2743
+    //#define Z2_HOLD_MULTIPLIER 0.5
2738 2744
   #endif
2739 2745
 
2740 2746
   #if AXIS_IS_TMC(Z3)
@@ -2744,6 +2750,7 @@
2744 2750
     #define Z3_RSENSE         0.11
2745 2751
     #define Z3_CHAIN_POS     -1
2746 2752
     //#define Z3_INTERPOLATE true
2753
+    //#define Z3_HOLD_MULTIPLIER 0.5
2747 2754
   #endif
2748 2755
 
2749 2756
   #if AXIS_IS_TMC(Z4)
@@ -2753,6 +2760,7 @@
2753 2760
     #define Z4_RSENSE         0.11
2754 2761
     #define Z4_CHAIN_POS     -1
2755 2762
     //#define Z4_INTERPOLATE true
2763
+    //#define Z4_HOLD_MULTIPLIER 0.5
2756 2764
   #endif
2757 2765
 
2758 2766
   #if AXIS_IS_TMC(I)
@@ -2762,6 +2770,7 @@
2762 2770
     #define I_RSENSE         0.11
2763 2771
     #define I_CHAIN_POS     -1
2764 2772
     //#define I_INTERPOLATE  true
2773
+    //#define I_HOLD_MULTIPLIER 0.5
2765 2774
   #endif
2766 2775
 
2767 2776
   #if AXIS_IS_TMC(J)
@@ -2771,6 +2780,7 @@
2771 2780
     #define J_RSENSE         0.11
2772 2781
     #define J_CHAIN_POS     -1
2773 2782
     //#define J_INTERPOLATE  true
2783
+    //#define J_HOLD_MULTIPLIER 0.5
2774 2784
   #endif
2775 2785
 
2776 2786
   #if AXIS_IS_TMC(K)
@@ -2780,6 +2790,7 @@
2780 2790
     #define K_RSENSE         0.11
2781 2791
     #define K_CHAIN_POS     -1
2782 2792
     //#define K_INTERPOLATE  true
2793
+    //#define K_HOLD_MULTIPLIER 0.5
2783 2794
   #endif
2784 2795
 
2785 2796
   #if AXIS_IS_TMC(E0)
@@ -2788,6 +2799,7 @@
2788 2799
     #define E0_RSENSE         0.11
2789 2800
     #define E0_CHAIN_POS     -1
2790 2801
     //#define E0_INTERPOLATE true
2802
+    //#define E0_HOLD_MULTIPLIER 0.5
2791 2803
   #endif
2792 2804
 
2793 2805
   #if AXIS_IS_TMC(E1)
@@ -2796,6 +2808,7 @@
2796 2808
     #define E1_RSENSE         0.11
2797 2809
     #define E1_CHAIN_POS     -1
2798 2810
     //#define E1_INTERPOLATE true
2811
+    //#define E1_HOLD_MULTIPLIER 0.5
2799 2812
   #endif
2800 2813
 
2801 2814
   #if AXIS_IS_TMC(E2)
@@ -2804,6 +2817,7 @@
2804 2817
     #define E2_RSENSE         0.11
2805 2818
     #define E2_CHAIN_POS     -1
2806 2819
     //#define E2_INTERPOLATE true
2820
+    //#define E2_HOLD_MULTIPLIER 0.5
2807 2821
   #endif
2808 2822
 
2809 2823
   #if AXIS_IS_TMC(E3)
@@ -2812,6 +2826,7 @@
2812 2826
     #define E3_RSENSE         0.11
2813 2827
     #define E3_CHAIN_POS     -1
2814 2828
     //#define E3_INTERPOLATE true
2829
+    //#define E3_HOLD_MULTIPLIER 0.5
2815 2830
   #endif
2816 2831
 
2817 2832
   #if AXIS_IS_TMC(E4)
@@ -2820,6 +2835,7 @@
2820 2835
     #define E4_RSENSE         0.11
2821 2836
     #define E4_CHAIN_POS     -1
2822 2837
     //#define E4_INTERPOLATE true
2838
+    //#define E4_HOLD_MULTIPLIER 0.5
2823 2839
   #endif
2824 2840
 
2825 2841
   #if AXIS_IS_TMC(E5)
@@ -2828,6 +2844,7 @@
2828 2844
     #define E5_RSENSE         0.11
2829 2845
     #define E5_CHAIN_POS     -1
2830 2846
     //#define E5_INTERPOLATE true
2847
+    //#define E5_HOLD_MULTIPLIER 0.5
2831 2848
   #endif
2832 2849
 
2833 2850
   #if AXIS_IS_TMC(E6)
@@ -2836,6 +2853,7 @@
2836 2853
     #define E6_RSENSE         0.11
2837 2854
     #define E6_CHAIN_POS     -1
2838 2855
     //#define E6_INTERPOLATE true
2856
+    //#define E6_HOLD_MULTIPLIER 0.5
2839 2857
   #endif
2840 2858
 
2841 2859
   #if AXIS_IS_TMC(E7)
@@ -2844,6 +2862,7 @@
2844 2862
     #define E7_RSENSE         0.11
2845 2863
     #define E7_CHAIN_POS     -1
2846 2864
     //#define E7_INTERPOLATE true
2865
+    //#define E7_HOLD_MULTIPLIER 0.5
2847 2866
   #endif
2848 2867
 
2849 2868
   /**

+ 303
- 202
Marlin/src/inc/Conditionals_post.h View File

@@ -1861,231 +1861,332 @@
1861 1861
     #undef Z3_STALL_SENSITIVITY
1862 1862
     #undef Z4_STALL_SENSITIVITY
1863 1863
   #endif
1864
-  #if defined(X_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(X)
1865
-    #define X_SENSORLESS 1
1866
-  #endif
1867
-  #if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2)
1868
-    #define X2_SENSORLESS 1
1869
-  #endif
1870
-  #if defined(Y_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(Y)
1871
-    #define Y_SENSORLESS 1
1872
-  #endif
1873
-  #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2)
1874
-    #define Y2_SENSORLESS 1
1875
-  #endif
1876
-  #if defined(Z_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(Z)
1877
-    #define Z_SENSORLESS 1
1878
-  #endif
1879
-  #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2)
1880
-    #define Z2_SENSORLESS 1
1881
-  #endif
1882
-  #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3)
1883
-    #define Z3_SENSORLESS 1
1884
-  #endif
1885
-  #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4)
1886
-    #define Z4_SENSORLESS 1
1887
-  #endif
1888
-  #if defined(I_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(I)
1889
-    #define I_SENSORLESS 1
1890
-  #endif
1891
-  #if defined(J_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(J)
1892
-    #define J_SENSORLESS 1
1893
-  #endif
1894
-  #if defined(K_STALL_SENSITIVITY)  && AXIS_HAS_STALLGUARD(K)
1895
-    #define K_SENSORLESS 1
1896
-  #endif
1897 1864
 
1898
-  #if AXIS_HAS_STEALTHCHOP(X)
1899
-    #define X_HAS_STEALTHCHOP 1
1900
-  #endif
1901
-  #if AXIS_HAS_STEALTHCHOP(X2)
1902
-    #define X2_HAS_STEALTHCHOP 1
1903
-  #endif
1904
-  #if AXIS_HAS_STEALTHCHOP(Y)
1905
-    #define Y_HAS_STEALTHCHOP 1
1906
-  #endif
1907
-  #if AXIS_HAS_STEALTHCHOP(Y2)
1908
-    #define Y2_HAS_STEALTHCHOP 1
1909
-  #endif
1910
-  #if AXIS_HAS_STEALTHCHOP(Z)
1911
-    #define Z_HAS_STEALTHCHOP 1
1912
-  #endif
1913
-  #if AXIS_HAS_STEALTHCHOP(Z2)
1914
-    #define Z2_HAS_STEALTHCHOP 1
1915
-  #endif
1916
-  #if AXIS_HAS_STEALTHCHOP(Z3)
1917
-    #define Z3_HAS_STEALTHCHOP 1
1918
-  #endif
1919
-  #if AXIS_HAS_STEALTHCHOP(Z4)
1920
-    #define Z4_HAS_STEALTHCHOP 1
1921
-  #endif
1922
-  #if AXIS_HAS_STEALTHCHOP(I)
1923
-    #define I_HAS_STEALTHCHOP 1
1924
-  #endif
1925
-  #if AXIS_HAS_STEALTHCHOP(J)
1926
-    #define J_HAS_STEALTHCHOP 1
1927
-  #endif
1928
-  #if AXIS_HAS_STEALTHCHOP(K)
1929
-    #define K_HAS_STEALTHCHOP 1
1930
-  #endif
1931
-  #if E_STEPPERS > 0 && AXIS_HAS_STEALTHCHOP(E0)
1932
-    #define E0_HAS_STEALTHCHOP 1
1933
-  #endif
1934
-  #if E_STEPPERS > 1 && AXIS_HAS_STEALTHCHOP(E1)
1935
-    #define E1_HAS_STEALTHCHOP 1
1936
-  #endif
1937
-  #if E_STEPPERS > 2 && AXIS_HAS_STEALTHCHOP(E2)
1938
-    #define E2_HAS_STEALTHCHOP 1
1939
-  #endif
1940
-  #if E_STEPPERS > 3 && AXIS_HAS_STEALTHCHOP(E3)
1941
-    #define E3_HAS_STEALTHCHOP 1
1942
-  #endif
1943
-  #if E_STEPPERS > 4 && AXIS_HAS_STEALTHCHOP(E4)
1944
-    #define E4_HAS_STEALTHCHOP 1
1945
-  #endif
1946
-  #if E_STEPPERS > 5 && AXIS_HAS_STEALTHCHOP(E5)
1947
-    #define E5_HAS_STEALTHCHOP 1
1948
-  #endif
1949
-  #if E_STEPPERS > 6 && AXIS_HAS_STEALTHCHOP(E6)
1950
-    #define E6_HAS_STEALTHCHOP 1
1865
+  #if AXIS_IS_TMC(X)
1866
+    #if defined(X_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X)
1867
+      #define X_SENSORLESS 1
1868
+    #endif
1869
+    #if AXIS_HAS_STEALTHCHOP(X)
1870
+      #define X_HAS_STEALTHCHOP 1
1871
+    #endif
1872
+    #if ENABLED(SPI_ENDSTOPS)
1873
+      #define X_SPI_SENSORLESS X_SENSORLESS
1874
+    #endif
1875
+    #ifndef X_INTERPOLATE
1876
+      #define X_INTERPOLATE INTERPOLATE
1877
+    #endif
1878
+    #ifndef X_HOLD_MULTIPLIER
1879
+      #define X_HOLD_MULTIPLIER HOLD_MULTIPLIER
1880
+    #endif
1881
+    #ifndef X_SLAVE_ADDRESS
1882
+      #define X_SLAVE_ADDRESS 0
1883
+    #endif
1951 1884
   #endif
1952
-  #if E_STEPPERS > 7 && AXIS_HAS_STEALTHCHOP(E7)
1953
-    #define E7_HAS_STEALTHCHOP 1
1885
+
1886
+  #if AXIS_IS_TMC(X2)
1887
+    #if defined(X2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(X2)
1888
+      #define X2_SENSORLESS 1
1889
+    #endif
1890
+    #if AXIS_HAS_STEALTHCHOP(X2)
1891
+      #define X2_HAS_STEALTHCHOP 1
1892
+    #endif
1893
+    #ifndef X2_INTERPOLATE
1894
+      #define X2_INTERPOLATE X_INTERPOLATE
1895
+    #endif
1896
+    #ifndef X2_HOLD_MULTIPLIER
1897
+      #define X2_HOLD_MULTIPLIER X_HOLD_MULTIPLIER
1898
+    #endif
1899
+    #ifndef X2_SLAVE_ADDRESS
1900
+      #define X2_SLAVE_ADDRESS 0
1901
+    #endif
1954 1902
   #endif
1955 1903
 
1956
-  #if ENABLED(SPI_ENDSTOPS)
1957
-    #define X_SPI_SENSORLESS X_SENSORLESS
1958
-    #if HAS_Y_AXIS
1904
+  #if AXIS_IS_TMC(Y)
1905
+    #if defined(Y_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y)
1906
+      #define Y_SENSORLESS 1
1907
+    #endif
1908
+    #if AXIS_HAS_STEALTHCHOP(Y)
1909
+      #define Y_HAS_STEALTHCHOP 1
1910
+    #endif
1911
+    #if ENABLED(SPI_ENDSTOPS)
1959 1912
       #define Y_SPI_SENSORLESS Y_SENSORLESS
1960 1913
     #endif
1961
-    #if HAS_Z_AXIS
1962
-      #define Z_SPI_SENSORLESS Z_SENSORLESS
1914
+    #ifndef Y_INTERPOLATE
1915
+      #define Y_INTERPOLATE INTERPOLATE
1963 1916
     #endif
1964
-    #if LINEAR_AXES >= 4
1965
-      #define I_SPI_SENSORLESS I_SENSORLESS
1917
+    #ifndef Y_HOLD_MULTIPLIER
1918
+      #define Y_HOLD_MULTIPLIER HOLD_MULTIPLIER
1966 1919
     #endif
1967
-    #if LINEAR_AXES >= 5
1968
-      #define J_SPI_SENSORLESS J_SENSORLESS
1920
+    #ifndef Y_SLAVE_ADDRESS
1921
+      #define Y_SLAVE_ADDRESS 0
1969 1922
     #endif
1970
-    #if LINEAR_AXES >= 6
1971
-      #define K_SPI_SENSORLESS K_SENSORLESS
1923
+    #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
1924
+      #if defined(Y2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Y2)
1925
+        #define Y2_SENSORLESS 1
1926
+      #endif
1927
+      #if AXIS_HAS_STEALTHCHOP(Y2)
1928
+        #define Y2_HAS_STEALTHCHOP 1
1929
+      #endif
1930
+      #ifndef Y2_INTERPOLATE
1931
+        #define Y2_INTERPOLATE Y_INTERPOLATE
1932
+      #endif
1933
+      #ifndef Y2_HOLD_MULTIPLIER
1934
+        #define Y2_HOLD_MULTIPLIER Y_HOLD_MULTIPLIER
1935
+      #endif
1936
+      #ifndef Y2_SLAVE_ADDRESS
1937
+        #define Y2_SLAVE_ADDRESS 0
1938
+      #endif
1972 1939
     #endif
1973 1940
   #endif
1974
-  #ifndef X_INTERPOLATE
1975
-    #define X_INTERPOLATE INTERPOLATE
1976
-  #endif
1977
-  #ifndef X2_INTERPOLATE
1978
-    #define X2_INTERPOLATE INTERPOLATE
1979
-  #endif
1980
-  #ifndef Y_INTERPOLATE
1981
-    #define Y_INTERPOLATE INTERPOLATE
1982
-  #endif
1983
-  #ifndef Y2_INTERPOLATE
1984
-    #define Y2_INTERPOLATE INTERPOLATE
1985
-  #endif
1986
-  #ifndef Z_INTERPOLATE
1987
-    #define Z_INTERPOLATE INTERPOLATE
1988
-  #endif
1989
-  #ifndef Z2_INTERPOLATE
1990
-    #define Z2_INTERPOLATE INTERPOLATE
1991
-  #endif
1992
-  #ifndef Z3_INTERPOLATE
1993
-    #define Z3_INTERPOLATE INTERPOLATE
1994
-  #endif
1995
-  #ifndef Z4_INTERPOLATE
1996
-    #define Z4_INTERPOLATE INTERPOLATE
1997
-  #endif
1998
-  #if LINEAR_AXES >= 4 && !defined(I_INTERPOLATE)
1999
-    #define I_INTERPOLATE INTERPOLATE
2000
-  #endif
2001
-  #if LINEAR_AXES >= 5 && !defined(J_INTERPOLATE)
2002
-    #define J_INTERPOLATE INTERPOLATE
2003
-  #endif
2004
-  #if LINEAR_AXES >= 6 && !defined(K_INTERPOLATE)
2005
-    #define K_INTERPOLATE INTERPOLATE
2006
-  #endif
2007
-  #ifndef E0_INTERPOLATE
2008
-    #define E0_INTERPOLATE INTERPOLATE
2009
-  #endif
2010
-  #ifndef E1_INTERPOLATE
2011
-    #define E1_INTERPOLATE INTERPOLATE
2012
-  #endif
2013
-  #ifndef E2_INTERPOLATE
2014
-    #define E2_INTERPOLATE INTERPOLATE
2015
-  #endif
2016
-  #ifndef E3_INTERPOLATE
2017
-    #define E3_INTERPOLATE INTERPOLATE
2018
-  #endif
2019
-  #ifndef E4_INTERPOLATE
2020
-    #define E4_INTERPOLATE INTERPOLATE
2021
-  #endif
2022
-  #ifndef E5_INTERPOLATE
2023
-    #define E5_INTERPOLATE INTERPOLATE
2024
-  #endif
2025
-  #ifndef E6_INTERPOLATE
2026
-    #define E6_INTERPOLATE INTERPOLATE
2027
-  #endif
2028
-  #ifndef E7_INTERPOLATE
2029
-    #define E7_INTERPOLATE INTERPOLATE
2030
-  #endif
2031
-  #ifndef X_SLAVE_ADDRESS
2032
-    #define X_SLAVE_ADDRESS 0
2033
-  #endif
2034
-  #ifndef Y_SLAVE_ADDRESS
2035
-    #define Y_SLAVE_ADDRESS 0
2036
-  #endif
2037
-  #ifndef Z_SLAVE_ADDRESS
2038
-    #define Z_SLAVE_ADDRESS 0
2039
-  #endif
2040
-  #ifndef I_SLAVE_ADDRESS
2041
-    #define I_SLAVE_ADDRESS 0
2042
-  #endif
2043
-  #ifndef J_SLAVE_ADDRESS
2044
-    #define J_SLAVE_ADDRESS 0
2045
-  #endif
2046
-  #ifndef K_SLAVE_ADDRESS
2047
-    #define K_SLAVE_ADDRESS 0
2048
-  #endif
2049
-  #ifndef X2_SLAVE_ADDRESS
2050
-    #define X2_SLAVE_ADDRESS 0
2051
-  #endif
2052
-  #ifndef Y2_SLAVE_ADDRESS
2053
-    #define Y2_SLAVE_ADDRESS 0
1941
+
1942
+  #if AXIS_IS_TMC(Z)
1943
+    #if defined(Z_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z)
1944
+      #define Z_SENSORLESS 1
1945
+    #endif
1946
+    #if AXIS_HAS_STEALTHCHOP(Z)
1947
+      #define Z_HAS_STEALTHCHOP 1
1948
+    #endif
1949
+    #if ENABLED(SPI_ENDSTOPS)
1950
+      #define Z_SPI_SENSORLESS Z_SENSORLESS
1951
+    #endif
1952
+    #ifndef Z_INTERPOLATE
1953
+      #define Z_INTERPOLATE INTERPOLATE
1954
+    #endif
1955
+    #ifndef Z_HOLD_MULTIPLIER
1956
+      #define Z_HOLD_MULTIPLIER HOLD_MULTIPLIER
1957
+    #endif
1958
+    #ifndef Z_SLAVE_ADDRESS
1959
+      #define Z_SLAVE_ADDRESS 0
1960
+    #endif
1961
+    #if NUM_Z_STEPPER_DRIVERS >= 2
1962
+      #if defined(Z2_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z2)
1963
+        #define Z2_SENSORLESS 1
1964
+      #endif
1965
+      #if AXIS_HAS_STEALTHCHOP(Z2)
1966
+        #define Z2_HAS_STEALTHCHOP 1
1967
+      #endif
1968
+      #ifndef Z2_INTERPOLATE
1969
+        #define Z2_INTERPOLATE Z_INTERPOLATE
1970
+      #endif
1971
+      #ifndef Z2_HOLD_MULTIPLIER
1972
+        #define Z2_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER
1973
+      #endif
1974
+      #ifndef Z2_SLAVE_ADDRESS
1975
+        #define Z2_SLAVE_ADDRESS 0
1976
+      #endif
1977
+    #endif
1978
+    #if NUM_Z_STEPPER_DRIVERS >= 3
1979
+      #if defined(Z3_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z3)
1980
+        #define Z3_SENSORLESS 1
1981
+      #endif
1982
+      #if AXIS_HAS_STEALTHCHOP(Z3)
1983
+        #define Z3_HAS_STEALTHCHOP 1
1984
+      #endif
1985
+      #ifndef Z3_INTERPOLATE
1986
+        #define Z3_INTERPOLATE Z_INTERPOLATE
1987
+      #endif
1988
+      #ifndef Z3_HOLD_MULTIPLIER
1989
+        #define Z3_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER
1990
+      #endif
1991
+      #ifndef Z3_SLAVE_ADDRESS
1992
+        #define Z3_SLAVE_ADDRESS 0
1993
+      #endif
1994
+    #endif
1995
+    #if NUM_Z_STEPPER_DRIVERS >= 4
1996
+      #if defined(Z4_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(Z4)
1997
+        #define Z4_SENSORLESS 1
1998
+      #endif
1999
+      #if AXIS_HAS_STEALTHCHOP(Z4)
2000
+        #define Z4_HAS_STEALTHCHOP 1
2001
+      #endif
2002
+      #ifndef Z4_INTERPOLATE
2003
+        #define Z4_INTERPOLATE Z_INTERPOLATE
2004
+      #endif
2005
+      #ifndef Z4_HOLD_MULTIPLIER
2006
+        #define Z4_HOLD_MULTIPLIER Z_HOLD_MULTIPLIER
2007
+      #endif
2008
+      #ifndef Z4_SLAVE_ADDRESS
2009
+        #define Z4_SLAVE_ADDRESS 0
2010
+      #endif
2011
+    #endif
2054 2012
   #endif
2055
-  #ifndef Z2_SLAVE_ADDRESS
2056
-    #define Z2_SLAVE_ADDRESS 0
2013
+
2014
+  #if AXIS_IS_TMC(I)
2015
+    #if defined(I_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(I)
2016
+      #define I_SENSORLESS 1
2017
+    #endif
2018
+    #if AXIS_HAS_STEALTHCHOP(I)
2019
+      #define I_HAS_STEALTHCHOP 1
2020
+    #endif
2021
+    #if ENABLED(SPI_ENDSTOPS)
2022
+      #define I_SPI_SENSORLESS I_SENSORLESS
2023
+    #endif
2024
+    #ifndef I_INTERPOLATE
2025
+      #define I_INTERPOLATE INTERPOLATE
2026
+    #endif
2027
+    #ifndef I_HOLD_MULTIPLIER
2028
+      #define I_HOLD_MULTIPLIER HOLD_MULTIPLIER
2029
+    #endif
2030
+    #ifndef I_SLAVE_ADDRESS
2031
+      #define I_SLAVE_ADDRESS 0
2032
+    #endif
2057 2033
   #endif
2058
-  #ifndef Z3_SLAVE_ADDRESS
2059
-    #define Z3_SLAVE_ADDRESS 0
2034
+
2035
+  #if AXIS_IS_TMC(J)
2036
+    #if defined(J_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(J)
2037
+      #define J_SENSORLESS 1
2038
+    #endif
2039
+    #if AXIS_HAS_STEALTHCHOP(J)
2040
+      #define J_HAS_STEALTHCHOP 1
2041
+    #endif
2042
+    #if ENABLED(SPI_ENDSTOPS)
2043
+      #define J_SPI_SENSORLESS J_SENSORLESS
2044
+    #endif
2045
+    #ifndef J_INTERPOLATE
2046
+      #define J_INTERPOLATE INTERPOLATE
2047
+    #endif
2048
+    #ifndef J_HOLD_MULTIPLIER
2049
+      #define J_HOLD_MULTIPLIER HOLD_MULTIPLIER
2050
+    #endif
2051
+    #ifndef J_SLAVE_ADDRESS
2052
+      #define J_SLAVE_ADDRESS 0
2053
+    #endif
2060 2054
   #endif
2061
-  #ifndef Z4_SLAVE_ADDRESS
2062
-    #define Z4_SLAVE_ADDRESS 0
2055
+
2056
+  #if AXIS_IS_TMC(K)
2057
+    #if defined(K_STALL_SENSITIVITY) && AXIS_HAS_STALLGUARD(K)
2058
+      #define K_SENSORLESS 1
2059
+    #endif
2060
+    #if AXIS_HAS_STEALTHCHOP(K)
2061
+      #define K_HAS_STEALTHCHOP 1
2062
+    #endif
2063
+    #if ENABLED(SPI_ENDSTOPS)
2064
+      #define K_SPI_SENSORLESS K_SENSORLESS
2065
+    #endif
2066
+    #ifndef K_INTERPOLATE
2067
+      #define K_INTERPOLATE INTERPOLATE
2068
+    #endif
2069
+    #ifndef K_HOLD_MULTIPLIER
2070
+      #define K_HOLD_MULTIPLIER HOLD_MULTIPLIER
2071
+    #endif
2072
+    #ifndef K_SLAVE_ADDRESS
2073
+      #define K_SLAVE_ADDRESS 0
2074
+    #endif
2063 2075
   #endif
2064
-  #ifndef E0_SLAVE_ADDRESS
2065
-    #define E0_SLAVE_ADDRESS 0
2076
+
2077
+  #if AXIS_IS_TMC(E0)
2078
+    #if AXIS_HAS_STEALTHCHOP(E0)
2079
+      #define E0_HAS_STEALTHCHOP 1
2080
+    #endif
2081
+    #ifndef E0_INTERPOLATE
2082
+      #define E0_INTERPOLATE INTERPOLATE
2083
+    #endif
2084
+    #ifndef E0_HOLD_MULTIPLIER
2085
+      #define E0_HOLD_MULTIPLIER HOLD_MULTIPLIER
2086
+    #endif
2087
+    #ifndef E0_SLAVE_ADDRESS
2088
+      #define E0_SLAVE_ADDRESS 0
2089
+    #endif
2066 2090
   #endif
2067
-  #ifndef E1_SLAVE_ADDRESS
2068
-    #define E1_SLAVE_ADDRESS 0
2091
+  #if AXIS_IS_TMC(E1)
2092
+    #if AXIS_HAS_STEALTHCHOP(E1)
2093
+      #define E1_HAS_STEALTHCHOP 1
2094
+    #endif
2095
+    #ifndef E1_INTERPOLATE
2096
+      #define E1_INTERPOLATE E0_INTERPOLATE
2097
+    #endif
2098
+    #ifndef E1_HOLD_MULTIPLIER
2099
+      #define E1_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
2100
+    #endif
2101
+    #ifndef E1_SLAVE_ADDRESS
2102
+      #define E1_SLAVE_ADDRESS 0
2103
+    #endif
2069 2104
   #endif
2070
-  #ifndef E2_SLAVE_ADDRESS
2071
-    #define E2_SLAVE_ADDRESS 0
2105
+  #if AXIS_IS_TMC(E2)
2106
+    #if AXIS_HAS_STEALTHCHOP(E2)
2107
+      #define E2_HAS_STEALTHCHOP 1
2108
+    #endif
2109
+    #ifndef E2_INTERPOLATE
2110
+      #define E2_INTERPOLATE E0_INTERPOLATE
2111
+    #endif
2112
+    #ifndef E2_HOLD_MULTIPLIER
2113
+      #define E2_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
2114
+    #endif
2115
+    #ifndef E2_SLAVE_ADDRESS
2116
+      #define E2_SLAVE_ADDRESS 0
2117
+    #endif
2072 2118
   #endif
2073
-  #ifndef E3_SLAVE_ADDRESS
2074
-    #define E3_SLAVE_ADDRESS 0
2119
+  #if AXIS_IS_TMC(E3)
2120
+    #if AXIS_HAS_STEALTHCHOP(E3)
2121
+      #define E3_HAS_STEALTHCHOP 1
2122
+    #endif
2123
+    #ifndef E3_INTERPOLATE
2124
+      #define E3_INTERPOLATE E0_INTERPOLATE
2125
+    #endif
2126
+    #ifndef E3_HOLD_MULTIPLIER
2127
+      #define E3_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
2128
+    #endif
2129
+    #ifndef E3_SLAVE_ADDRESS
2130
+      #define E3_SLAVE_ADDRESS 0
2131
+    #endif
2075 2132
   #endif
2076
-  #ifndef E4_SLAVE_ADDRESS
2077
-    #define E4_SLAVE_ADDRESS 0
2133
+  #if AXIS_IS_TMC(E4)
2134
+    #if AXIS_HAS_STEALTHCHOP(E4)
2135
+      #define E4_HAS_STEALTHCHOP 1
2136
+    #endif
2137
+    #ifndef E4_INTERPOLATE
2138
+      #define E4_INTERPOLATE E0_INTERPOLATE
2139
+    #endif
2140
+    #ifndef E4_HOLD_MULTIPLIER
2141
+      #define E4_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
2142
+    #endif
2143
+    #ifndef E4_SLAVE_ADDRESS
2144
+      #define E4_SLAVE_ADDRESS 0
2145
+    #endif
2078 2146
   #endif
2079
-  #ifndef E5_SLAVE_ADDRESS
2080
-    #define E5_SLAVE_ADDRESS 0
2147
+  #if AXIS_IS_TMC(E5)
2148
+    #if AXIS_HAS_STEALTHCHOP(E5)
2149
+      #define E5_HAS_STEALTHCHOP 1
2150
+    #endif
2151
+    #ifndef E5_INTERPOLATE
2152
+      #define E5_INTERPOLATE E0_INTERPOLATE
2153
+    #endif
2154
+    #ifndef E5_HOLD_MULTIPLIER
2155
+      #define E5_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
2156
+    #endif
2157
+    #ifndef E5_SLAVE_ADDRESS
2158
+      #define E5_SLAVE_ADDRESS 0
2159
+    #endif
2081 2160
   #endif
2082
-  #ifndef E6_SLAVE_ADDRESS
2083
-    #define E6_SLAVE_ADDRESS 0
2161
+  #if AXIS_IS_TMC(E6)
2162
+    #if AXIS_HAS_STEALTHCHOP(E6)
2163
+      #define E6_HAS_STEALTHCHOP 1
2164
+    #endif
2165
+    #ifndef E6_INTERPOLATE
2166
+      #define E6_INTERPOLATE E0_INTERPOLATE
2167
+    #endif
2168
+    #ifndef E6_HOLD_MULTIPLIER
2169
+      #define E6_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
2170
+    #endif
2171
+    #ifndef E6_SLAVE_ADDRESS
2172
+      #define E6_SLAVE_ADDRESS 0
2173
+    #endif
2084 2174
   #endif
2085
-  #ifndef E7_SLAVE_ADDRESS
2086
-    #define E7_SLAVE_ADDRESS 0
2175
+  #if AXIS_IS_TMC(E7)
2176
+    #if AXIS_HAS_STEALTHCHOP(E7)
2177
+      #define E7_HAS_STEALTHCHOP 1
2178
+    #endif
2179
+    #ifndef E7_INTERPOLATE
2180
+      #define E7_INTERPOLATE E0_INTERPOLATE
2181
+    #endif
2182
+    #ifndef E7_HOLD_MULTIPLIER
2183
+      #define E7_HOLD_MULTIPLIER E0_HOLD_MULTIPLIER
2184
+    #endif
2185
+    #ifndef E7_SLAVE_ADDRESS
2186
+      #define E7_SLAVE_ADDRESS 0
2187
+    #endif
2087 2188
   #endif
2088
-#endif
2189
+#endif // HAS_TRINAMIC_CONFIG
2089 2190
 
2090 2191
 #if ANY_AXIS_HAS(HW_SERIAL)
2091 2192
   #define HAS_TMC_HW_SERIAL 1

+ 14
- 14
Marlin/src/module/stepper/trinamic.cpp View File

@@ -38,7 +38,7 @@
38 38
 enum StealthIndex : uint8_t {
39 39
   LOGICAL_AXIS_LIST(STEALTH_AXIS_E, STEALTH_AXIS_X, STEALTH_AXIS_Y, STEALTH_AXIS_Z, STEALTH_AXIS_I, STEALTH_AXIS_J, STEALTH_AXIS_K)
40 40
 };
41
-#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE)
41
+#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE, ST##_HOLD_MULTIPLIER)
42 42
 
43 43
 //   IC = TMC model number
44 44
 //   ST = Stepper object letter
@@ -200,7 +200,7 @@ enum StealthIndex : uint8_t {
200 200
 
201 201
 #if HAS_DRIVER(TMC2130)
202 202
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
203
-  void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
203
+  void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) {
204 204
     st.begin();
205 205
 
206 206
     CHOPCONF_t chopconf{0};
@@ -212,7 +212,7 @@ enum StealthIndex : uint8_t {
212 212
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
213 213
     st.CHOPCONF(chopconf.sr);
214 214
 
215
-    st.rms_current(mA, HOLD_MULTIPLIER);
215
+    st.rms_current(mA, hold_multiplier);
216 216
     st.microsteps(microsteps);
217 217
     st.iholddelay(10);
218 218
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
@@ -235,7 +235,7 @@ enum StealthIndex : uint8_t {
235 235
 
236 236
 #if HAS_DRIVER(TMC2160)
237 237
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
238
-  void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
238
+  void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) {
239 239
     st.begin();
240 240
 
241 241
     CHOPCONF_t chopconf{0};
@@ -247,7 +247,7 @@ enum StealthIndex : uint8_t {
247 247
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
248 248
     st.CHOPCONF(chopconf.sr);
249 249
 
250
-    st.rms_current(mA, HOLD_MULTIPLIER);
250
+    st.rms_current(mA, hold_multiplier);
251 251
     st.microsteps(microsteps);
252 252
     st.iholddelay(10);
253 253
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
@@ -604,7 +604,7 @@ enum StealthIndex : uint8_t {
604 604
 
605 605
 #if HAS_DRIVER(TMC2208)
606 606
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
607
-  void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
607
+  void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) {
608 608
     TMC2208_n::GCONF_t gconf{0};
609 609
     gconf.pdn_disable = true; // Use UART
610 610
     gconf.mstep_reg_select = true; // Select microsteps with UART
@@ -622,7 +622,7 @@ enum StealthIndex : uint8_t {
622 622
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
623 623
     st.CHOPCONF(chopconf.sr);
624 624
 
625
-    st.rms_current(mA, HOLD_MULTIPLIER);
625
+    st.rms_current(mA, hold_multiplier);
626 626
     st.microsteps(microsteps);
627 627
     st.iholddelay(10);
628 628
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
@@ -646,7 +646,7 @@ enum StealthIndex : uint8_t {
646 646
 
647 647
 #if HAS_DRIVER(TMC2209)
648 648
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
649
-  void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
649
+  void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) {
650 650
     TMC2208_n::GCONF_t gconf{0};
651 651
     gconf.pdn_disable = true; // Use UART
652 652
     gconf.mstep_reg_select = true; // Select microsteps with UART
@@ -664,7 +664,7 @@ enum StealthIndex : uint8_t {
664 664
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
665 665
     st.CHOPCONF(chopconf.sr);
666 666
 
667
-    st.rms_current(mA, HOLD_MULTIPLIER);
667
+    st.rms_current(mA, hold_multiplier);
668 668
     st.microsteps(microsteps);
669 669
     st.iholddelay(10);
670 670
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
@@ -688,7 +688,7 @@ enum StealthIndex : uint8_t {
688 688
 
689 689
 #if HAS_DRIVER(TMC2660)
690 690
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
691
-  void tmc_init(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool, const chopper_timing_t &chop_init, const bool interpolate) {
691
+  void tmc_init(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) {
692 692
     st.begin();
693 693
 
694 694
     TMC2660_n::CHOPCONF_t chopconf{0};
@@ -710,7 +710,7 @@ enum StealthIndex : uint8_t {
710 710
 
711 711
 #if HAS_DRIVER(TMC5130)
712 712
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
713
-  void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
713
+  void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) {
714 714
     st.begin();
715 715
 
716 716
     CHOPCONF_t chopconf{0};
@@ -722,7 +722,7 @@ enum StealthIndex : uint8_t {
722 722
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
723 723
     st.CHOPCONF(chopconf.sr);
724 724
 
725
-    st.rms_current(mA, HOLD_MULTIPLIER);
725
+    st.rms_current(mA, hold_multiplier);
726 726
     st.microsteps(microsteps);
727 727
     st.iholddelay(10);
728 728
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
@@ -745,7 +745,7 @@ enum StealthIndex : uint8_t {
745 745
 
746 746
 #if HAS_DRIVER(TMC5160)
747 747
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
748
-  void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
748
+  void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate, float hold_multiplier) {
749 749
     st.begin();
750 750
 
751 751
     CHOPCONF_t chopconf{0};
@@ -757,7 +757,7 @@ enum StealthIndex : uint8_t {
757 757
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
758 758
     st.CHOPCONF(chopconf.sr);
759 759
 
760
-    st.rms_current(mA, HOLD_MULTIPLIER);
760
+    st.rms_current(mA, hold_multiplier);
761 761
     st.microsteps(microsteps);
762 762
     st.iholddelay(10);
763 763
     st.TPOWERDOWN(128); // ~2s until driver lowers to hold current

Loading…
Cancel
Save