Przeglądaj źródła

Distinct Chopper Timing settings (#19781)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
Jago Strong-Wright 4 lat temu
rodzic
commit
c2802d35bb
No account linked to committer's email address

+ 18
- 2
Marlin/Configuration_adv.h Wyświetl plik

@@ -2471,10 +2471,26 @@
2471 2471
    * CHOPPER_PRUSAMK3_24V // Imported parameters from the official Průša firmware for MK3 (24V)
2472 2472
    * CHOPPER_MARLIN_119   // Old defaults from Marlin v1.1.9
2473 2473
    *
2474
-   * Define you own with
2474
+   * Define your own with:
2475 2475
    * { <off_time[1..15]>, <hysteresis_end[-3..12]>, hysteresis_start[1..8] }
2476 2476
    */
2477
-  #define CHOPPER_TIMING CHOPPER_DEFAULT_12V
2477
+  #define CHOPPER_TIMING CHOPPER_DEFAULT_12V        // All axes (override below)
2478
+  //#define CHOPPER_TIMING_X  CHOPPER_DEFAULT_12V   // For X Axes (override below)
2479
+  //#define CHOPPER_TIMING_X2 CHOPPER_DEFAULT_12V
2480
+  //#define CHOPPER_TIMING_Y  CHOPPER_DEFAULT_12V   // For Y Axes (override below)
2481
+  //#define CHOPPER_TIMING_Y2 CHOPPER_DEFAULT_12V
2482
+  //#define CHOPPER_TIMING_Z  CHOPPER_DEFAULT_12V   // For Z Axes (override below)
2483
+  //#define CHOPPER_TIMING_Z2 CHOPPER_DEFAULT_12V
2484
+  //#define CHOPPER_TIMING_Z3 CHOPPER_DEFAULT_12V
2485
+  //#define CHOPPER_TIMING_Z4 CHOPPER_DEFAULT_12V
2486
+  //#define CHOPPER_TIMING_E  CHOPPER_DEFAULT_12V   // For Extruders (override below)
2487
+  //#define CHOPPER_TIMING_E1 CHOPPER_DEFAULT_12V
2488
+  //#define CHOPPER_TIMING_E2 CHOPPER_DEFAULT_12V
2489
+  //#define CHOPPER_TIMING_E3 CHOPPER_DEFAULT_12V
2490
+  //#define CHOPPER_TIMING_E4 CHOPPER_DEFAULT_12V
2491
+  //#define CHOPPER_TIMING_E5 CHOPPER_DEFAULT_12V
2492
+  //#define CHOPPER_TIMING_E6 CHOPPER_DEFAULT_12V
2493
+  //#define CHOPPER_TIMING_E7 CHOPPER_DEFAULT_12V
2478 2494
 
2479 2495
   /**
2480 2496
    * Monitor Trinamic drivers

+ 34
- 34
Marlin/src/module/stepper/trinamic.cpp Wyświetl plik

@@ -36,7 +36,7 @@
36 36
 #include <SPI.h>
37 37
 
38 38
 enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
39
-#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX])
39
+#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)
40 40
 
41 41
 //   IC = TMC model number
42 42
 //   ST = Stepper object letter
@@ -131,15 +131,15 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
131 131
 
132 132
 #if HAS_DRIVER(TMC2130)
133 133
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
134
-  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) {
134
+  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) {
135 135
     st.begin();
136 136
 
137 137
     CHOPCONF_t chopconf{0};
138
-    chopconf.tbl = 1;
139
-    chopconf.toff = chopper_timing.toff;
138
+    chopconf.tbl = 0b01;
139
+    chopconf.toff = chop_init.toff;
140 140
     chopconf.intpol = INTERPOLATE;
141
-    chopconf.hend = chopper_timing.hend + 3;
142
-    chopconf.hstrt = chopper_timing.hstrt - 1;
141
+    chopconf.hend = chop_init.hend + 3;
142
+    chopconf.hstrt = chop_init.hstrt - 1;
143 143
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
144 144
     st.CHOPCONF(chopconf.sr);
145 145
 
@@ -166,15 +166,15 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
166 166
 
167 167
 #if HAS_DRIVER(TMC2160)
168 168
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
169
-  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) {
169
+  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) {
170 170
     st.begin();
171 171
 
172 172
     CHOPCONF_t chopconf{0};
173
-    chopconf.tbl = 1;
174
-    chopconf.toff = chopper_timing.toff;
173
+    chopconf.tbl = 0b01;
174
+    chopconf.toff = chop_init.toff;
175 175
     chopconf.intpol = INTERPOLATE;
176
-    chopconf.hend = chopper_timing.hend + 3;
177
-    chopconf.hstrt = chopper_timing.hstrt - 1;
176
+    chopconf.hend = chop_init.hend + 3;
177
+    chopconf.hstrt = chop_init.hstrt - 1;
178 178
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
179 179
     st.CHOPCONF(chopconf.sr);
180 180
 
@@ -484,7 +484,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
484 484
 
485 485
 #if HAS_DRIVER(TMC2208)
486 486
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
487
-  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) {
487
+  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) {
488 488
     TMC2208_n::GCONF_t gconf{0};
489 489
     gconf.pdn_disable = true; // Use UART
490 490
     gconf.mstep_reg_select = true; // Select microsteps with UART
@@ -495,10 +495,10 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
495 495
 
496 496
     TMC2208_n::CHOPCONF_t chopconf{0};
497 497
     chopconf.tbl = 0b01; // blank_time = 24
498
-    chopconf.toff = chopper_timing.toff;
498
+    chopconf.toff = chop_init.toff;
499 499
     chopconf.intpol = INTERPOLATE;
500
-    chopconf.hend = chopper_timing.hend + 3;
501
-    chopconf.hstrt = chopper_timing.hstrt - 1;
500
+    chopconf.hend = chop_init.hend + 3;
501
+    chopconf.hstrt = chop_init.hstrt - 1;
502 502
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
503 503
     st.CHOPCONF(chopconf.sr);
504 504
 
@@ -526,7 +526,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
526 526
 
527 527
 #if HAS_DRIVER(TMC2209)
528 528
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
529
-  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) {
529
+  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) {
530 530
     TMC2208_n::GCONF_t gconf{0};
531 531
     gconf.pdn_disable = true; // Use UART
532 532
     gconf.mstep_reg_select = true; // Select microsteps with UART
@@ -537,10 +537,10 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
537 537
 
538 538
     TMC2208_n::CHOPCONF_t chopconf{0};
539 539
     chopconf.tbl = 0b01; // blank_time = 24
540
-    chopconf.toff = chopper_timing.toff;
540
+    chopconf.toff = chop_init.toff;
541 541
     chopconf.intpol = INTERPOLATE;
542
-    chopconf.hend = chopper_timing.hend + 3;
543
-    chopconf.hstrt = chopper_timing.hstrt - 1;
542
+    chopconf.hend = chop_init.hend + 3;
543
+    chopconf.hstrt = chop_init.hstrt - 1;
544 544
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
545 545
     st.CHOPCONF(chopconf.sr);
546 546
 
@@ -568,14 +568,14 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
568 568
 
569 569
 #if HAS_DRIVER(TMC2660)
570 570
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
571
-  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) {
571
+  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) {
572 572
     st.begin();
573 573
 
574 574
     TMC2660_n::CHOPCONF_t chopconf{0};
575
-    chopconf.tbl = 1;
576
-    chopconf.toff = chopper_timing.toff;
577
-    chopconf.hend = chopper_timing.hend + 3;
578
-    chopconf.hstrt = chopper_timing.hstrt - 1;
575
+    chopconf.tbl = 0b01;
576
+    chopconf.toff = chop_init.toff;
577
+    chopconf.hend = chop_init.hend + 3;
578
+    chopconf.hstrt = chop_init.hstrt - 1;
579 579
     st.CHOPCONF(chopconf.sr);
580 580
 
581 581
     st.sdoff(0);
@@ -590,15 +590,15 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
590 590
 
591 591
 #if HAS_DRIVER(TMC5130)
592 592
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
593
-  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) {
593
+  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) {
594 594
     st.begin();
595 595
 
596 596
     CHOPCONF_t chopconf{0};
597
-    chopconf.tbl = 1;
598
-    chopconf.toff = chopper_timing.toff;
597
+    chopconf.tbl = 0b01;
598
+    chopconf.toff = chop_init.toff;
599 599
     chopconf.intpol = INTERPOLATE;
600
-    chopconf.hend = chopper_timing.hend + 3;
601
-    chopconf.hstrt = chopper_timing.hstrt - 1;
600
+    chopconf.hend = chop_init.hend + 3;
601
+    chopconf.hstrt = chop_init.hstrt - 1;
602 602
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
603 603
     st.CHOPCONF(chopconf.sr);
604 604
 
@@ -625,15 +625,15 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
625 625
 
626 626
 #if HAS_DRIVER(TMC5160)
627 627
   template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
628
-  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) {
628
+  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) {
629 629
     st.begin();
630 630
 
631 631
     CHOPCONF_t chopconf{0};
632
-    chopconf.tbl = 1;
633
-    chopconf.toff = chopper_timing.toff;
632
+    chopconf.tbl = 0b01;
633
+    chopconf.toff = chop_init.toff;
634 634
     chopconf.intpol = INTERPOLATE;
635
-    chopconf.hend = chopper_timing.hend + 3;
636
-    chopconf.hstrt = chopper_timing.hstrt - 1;
635
+    chopconf.hend = chop_init.hend + 3;
636
+    chopconf.hstrt = chop_init.hstrt - 1;
637 637
     TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
638 638
     st.CHOPCONF(chopconf.sr);
639 639
 

+ 83
- 17
Marlin/src/module/stepper/trinamic.h Wyświetl plik

@@ -76,7 +76,18 @@ typedef struct {
76 76
   uint8_t hstrt;
77 77
 } chopper_timing_t;
78 78
 
79
-static constexpr chopper_timing_t chopper_timing = CHOPPER_TIMING;
79
+#ifndef CHOPPER_TIMING_X
80
+  #define CHOPPER_TIMING_X CHOPPER_TIMING
81
+#endif
82
+#ifndef CHOPPER_TIMING_Y
83
+  #define CHOPPER_TIMING_Y CHOPPER_TIMING
84
+#endif
85
+#ifndef CHOPPER_TIMING_Z
86
+  #define CHOPPER_TIMING_Z CHOPPER_TIMING
87
+#endif
88
+#ifndef CHOPPER_TIMING_E
89
+  #define CHOPPER_TIMING_E CHOPPER_TIMING
90
+#endif
80 91
 
81 92
 #if HAS_TMC220x
82 93
   void tmc_serial_begin();
@@ -90,9 +101,10 @@ void reset_trinamic_drivers();
90 101
 // X Stepper
91 102
 #if AXIS_IS_TMC(X)
92 103
   extern TMC_CLASS(X, X) stepperX;
104
+  static constexpr chopper_timing_t chopper_timing_X = CHOPPER_TIMING_X;
93 105
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
94 106
     #define X_ENABLE_INIT() NOOP
95
-    #define X_ENABLE_WRITE(STATE) stepperX.toff((STATE)==X_ENABLE_ON ? chopper_timing.toff : 0)
107
+    #define X_ENABLE_WRITE(STATE) stepperX.toff((STATE)==X_ENABLE_ON ? chopper_timing_X.toff : 0)
96 108
     #define X_ENABLE_READ() stepperX.isEnabled()
97 109
   #endif
98 110
   #if AXIS_HAS_SQUARE_WAVE(X)
@@ -103,9 +115,10 @@ void reset_trinamic_drivers();
103 115
 // Y Stepper
104 116
 #if AXIS_IS_TMC(Y)
105 117
   extern TMC_CLASS(Y, Y) stepperY;
118
+  static constexpr chopper_timing_t chopper_timing_Y = CHOPPER_TIMING_Y;
106 119
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
107 120
     #define Y_ENABLE_INIT() NOOP
108
-    #define Y_ENABLE_WRITE(STATE) stepperY.toff((STATE)==Y_ENABLE_ON ? chopper_timing.toff : 0)
121
+    #define Y_ENABLE_WRITE(STATE) stepperY.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y.toff : 0)
109 122
     #define Y_ENABLE_READ() stepperY.isEnabled()
110 123
   #endif
111 124
   #if AXIS_HAS_SQUARE_WAVE(Y)
@@ -116,9 +129,10 @@ void reset_trinamic_drivers();
116 129
 // Z Stepper
117 130
 #if AXIS_IS_TMC(Z)
118 131
   extern TMC_CLASS(Z, Z) stepperZ;
132
+  static constexpr chopper_timing_t chopper_timing_Z = CHOPPER_TIMING_Z;
119 133
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
120 134
     #define Z_ENABLE_INIT() NOOP
121
-    #define Z_ENABLE_WRITE(STATE) stepperZ.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
135
+    #define Z_ENABLE_WRITE(STATE) stepperZ.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z.toff : 0)
122 136
     #define Z_ENABLE_READ() stepperZ.isEnabled()
123 137
   #endif
124 138
   #if AXIS_HAS_SQUARE_WAVE(Z)
@@ -129,9 +143,13 @@ void reset_trinamic_drivers();
129 143
 // X2 Stepper
130 144
 #if HAS_X2_ENABLE && AXIS_IS_TMC(X2)
131 145
   extern TMC_CLASS(X2, X) stepperX2;
146
+  #ifndef CHOPPER_TIMING_X2
147
+    #define CHOPPER_TIMING_X2 CHOPPER_TIMING_E
148
+  #endif
149
+  static constexpr chopper_timing_t chopper_timing_X2 = CHOPPER_TIMING_X2;
132 150
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
133 151
     #define X2_ENABLE_INIT() NOOP
134
-    #define X2_ENABLE_WRITE(STATE) stepperX2.toff((STATE)==X_ENABLE_ON ? chopper_timing.toff : 0)
152
+    #define X2_ENABLE_WRITE(STATE) stepperX2.toff((STATE)==X_ENABLE_ON ? chopper_timing_X2.toff : 0)
135 153
     #define X2_ENABLE_READ() stepperX2.isEnabled()
136 154
   #endif
137 155
   #if AXIS_HAS_SQUARE_WAVE(X2)
@@ -142,9 +160,13 @@ void reset_trinamic_drivers();
142 160
 // Y2 Stepper
143 161
 #if HAS_Y2_ENABLE && AXIS_IS_TMC(Y2)
144 162
   extern TMC_CLASS(Y2, Y) stepperY2;
163
+  #ifndef CHOPPER_TIMING_Y2
164
+    #define CHOPPER_TIMING_Y2 CHOPPER_TIMING_E
165
+  #endif
166
+  static constexpr chopper_timing_t chopper_timing_Y2 = CHOPPER_TIMING_Y2;
145 167
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
146 168
     #define Y2_ENABLE_INIT() NOOP
147
-    #define Y2_ENABLE_WRITE(STATE) stepperY2.toff((STATE)==Y_ENABLE_ON ? chopper_timing.toff : 0)
169
+    #define Y2_ENABLE_WRITE(STATE) stepperY2.toff((STATE)==Y_ENABLE_ON ? chopper_timing_Y2.toff : 0)
148 170
     #define Y2_ENABLE_READ() stepperY2.isEnabled()
149 171
   #endif
150 172
   #if AXIS_HAS_SQUARE_WAVE(Y2)
@@ -155,9 +177,13 @@ void reset_trinamic_drivers();
155 177
 // Z2 Stepper
156 178
 #if HAS_Z2_ENABLE && AXIS_IS_TMC(Z2)
157 179
   extern TMC_CLASS(Z2, Z) stepperZ2;
180
+  #ifndef CHOPPER_TIMING_Z2
181
+    #define CHOPPER_TIMING_Z2 CHOPPER_TIMING_E
182
+  #endif
183
+  static constexpr chopper_timing_t chopper_timing_Z2 = CHOPPER_TIMING_Z2;
158 184
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(Z2)
159 185
     #define Z2_ENABLE_INIT() NOOP
160
-    #define Z2_ENABLE_WRITE(STATE) stepperZ2.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
186
+    #define Z2_ENABLE_WRITE(STATE) stepperZ2.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z2.toff : 0)
161 187
     #define Z2_ENABLE_READ() stepperZ2.isEnabled()
162 188
   #endif
163 189
   #if AXIS_HAS_SQUARE_WAVE(Z2)
@@ -168,9 +194,13 @@ void reset_trinamic_drivers();
168 194
 // Z3 Stepper
169 195
 #if HAS_Z3_ENABLE && AXIS_IS_TMC(Z3)
170 196
   extern TMC_CLASS(Z3, Z) stepperZ3;
197
+  #ifndef CHOPPER_TIMING_Z3
198
+    #define CHOPPER_TIMING_Z3 CHOPPER_TIMING_E
199
+  #endif
200
+  static constexpr chopper_timing_t chopper_timing_Z3 = CHOPPER_TIMING_Z3;
171 201
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
172 202
     #define Z3_ENABLE_INIT() NOOP
173
-    #define Z3_ENABLE_WRITE(STATE) stepperZ3.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
203
+    #define Z3_ENABLE_WRITE(STATE) stepperZ3.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z3.toff : 0)
174 204
     #define Z3_ENABLE_READ() stepperZ3.isEnabled()
175 205
   #endif
176 206
   #if AXIS_HAS_SQUARE_WAVE(Z3)
@@ -181,9 +211,13 @@ void reset_trinamic_drivers();
181 211
 // Z4 Stepper
182 212
 #if HAS_Z4_ENABLE && AXIS_IS_TMC(Z4)
183 213
   extern TMC_CLASS(Z4, Z) stepperZ4;
214
+  #ifndef CHOPPER_TIMING_Z4
215
+    #define CHOPPER_TIMING_Z4 CHOPPER_TIMING_E
216
+  #endif
217
+  static constexpr chopper_timing_t chopper_timing_Z4 = CHOPPER_TIMING_Z4;
184 218
   #if ENABLED(SOFTWARE_DRIVER_ENABLE)
185 219
     #define Z4_ENABLE_INIT() NOOP
186
-    #define Z4_ENABLE_WRITE(STATE) stepperZ4.toff((STATE)==Z_ENABLE_ON ? chopper_timing.toff : 0)
220
+    #define Z4_ENABLE_WRITE(STATE) stepperZ4.toff((STATE)==Z_ENABLE_ON ? chopper_timing_Z4.toff : 0)
187 221
     #define Z4_ENABLE_READ() stepperZ4.isEnabled()
188 222
   #endif
189 223
   #if AXIS_HAS_SQUARE_WAVE(Z4)
@@ -194,9 +228,13 @@ void reset_trinamic_drivers();
194 228
 // E0 Stepper
195 229
 #if AXIS_IS_TMC(E0)
196 230
   extern TMC_CLASS_E(0) stepperE0;
231
+  #ifndef CHOPPER_TIMING_E0
232
+    #define CHOPPER_TIMING_E0 CHOPPER_TIMING_E
233
+  #endif
234
+  static constexpr chopper_timing_t chopper_timing_E0 = CHOPPER_TIMING_E0;
197 235
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E0)
198 236
     #define E0_ENABLE_INIT() NOOP
199
-    #define E0_ENABLE_WRITE(STATE) stepperE0.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
237
+    #define E0_ENABLE_WRITE(STATE) stepperE0.toff((STATE)==E_ENABLE_ON ? chopper_timing_E0.toff : 0)
200 238
     #define E0_ENABLE_READ() stepperE0.isEnabled()
201 239
   #endif
202 240
   #if AXIS_HAS_SQUARE_WAVE(E0)
@@ -207,9 +245,13 @@ void reset_trinamic_drivers();
207 245
 // E1 Stepper
208 246
 #if AXIS_IS_TMC(E1)
209 247
   extern TMC_CLASS_E(1) stepperE1;
248
+  #ifndef CHOPPER_TIMING_E1
249
+    #define CHOPPER_TIMING_E1 CHOPPER_TIMING_E
250
+  #endif
251
+  static constexpr chopper_timing_t chopper_timing_E1 = CHOPPER_TIMING_E1;
210 252
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E1)
211 253
     #define E1_ENABLE_INIT() NOOP
212
-    #define E1_ENABLE_WRITE(STATE) stepperE1.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
254
+    #define E1_ENABLE_WRITE(STATE) stepperE1.toff((STATE)==E_ENABLE_ON ? chopper_timing_E1.toff : 0)
213 255
     #define E1_ENABLE_READ() stepperE1.isEnabled()
214 256
   #endif
215 257
   #if AXIS_HAS_SQUARE_WAVE(E1)
@@ -220,9 +262,13 @@ void reset_trinamic_drivers();
220 262
 // E2 Stepper
221 263
 #if AXIS_IS_TMC(E2)
222 264
   extern TMC_CLASS_E(2) stepperE2;
265
+  #ifndef CHOPPER_TIMING_E2
266
+    #define CHOPPER_TIMING_E2 CHOPPER_TIMING_E
267
+  #endif
268
+  static constexpr chopper_timing_t chopper_timing_E2 = CHOPPER_TIMING_E2;
223 269
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E2)
224 270
     #define E2_ENABLE_INIT() NOOP
225
-    #define E2_ENABLE_WRITE(STATE) stepperE2.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
271
+    #define E2_ENABLE_WRITE(STATE) stepperE2.toff((STATE)==E_ENABLE_ON ? chopper_timing_E2.toff : 0)
226 272
     #define E2_ENABLE_READ() stepperE2.isEnabled()
227 273
   #endif
228 274
   #if AXIS_HAS_SQUARE_WAVE(E2)
@@ -233,9 +279,13 @@ void reset_trinamic_drivers();
233 279
 // E3 Stepper
234 280
 #if AXIS_IS_TMC(E3)
235 281
   extern TMC_CLASS_E(3) stepperE3;
282
+  #ifndef CHOPPER_TIMING_E3
283
+    #define CHOPPER_TIMING_E3 CHOPPER_TIMING_E
284
+  #endif
285
+  static constexpr chopper_timing_t chopper_timing_E3 = CHOPPER_TIMING_E3;
236 286
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E3)
237 287
     #define E3_ENABLE_INIT() NOOP
238
-    #define E3_ENABLE_WRITE(STATE) stepperE3.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
288
+    #define E3_ENABLE_WRITE(STATE) stepperE3.toff((STATE)==E_ENABLE_ON ? chopper_timing_E3.toff : 0)
239 289
     #define E3_ENABLE_READ() stepperE3.isEnabled()
240 290
   #endif
241 291
   #if AXIS_HAS_SQUARE_WAVE(E3)
@@ -246,9 +296,13 @@ void reset_trinamic_drivers();
246 296
 // E4 Stepper
247 297
 #if AXIS_IS_TMC(E4)
248 298
   extern TMC_CLASS_E(4) stepperE4;
299
+  #ifndef CHOPPER_TIMING_E4
300
+    #define CHOPPER_TIMING_E4 CHOPPER_TIMING_E
301
+  #endif
302
+  static constexpr chopper_timing_t chopper_timing_E4 = CHOPPER_TIMING_E4;
249 303
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E4)
250 304
     #define E4_ENABLE_INIT() NOOP
251
-    #define E4_ENABLE_WRITE(STATE) stepperE4.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
305
+    #define E4_ENABLE_WRITE(STATE) stepperE4.toff((STATE)==E_ENABLE_ON ? chopper_timing_E4.toff : 0)
252 306
     #define E4_ENABLE_READ() stepperE4.isEnabled()
253 307
   #endif
254 308
   #if AXIS_HAS_SQUARE_WAVE(E4)
@@ -259,9 +313,13 @@ void reset_trinamic_drivers();
259 313
 // E5 Stepper
260 314
 #if AXIS_IS_TMC(E5)
261 315
   extern TMC_CLASS_E(5) stepperE5;
316
+  #ifndef CHOPPER_TIMING_E5
317
+    #define CHOPPER_TIMING_E5 CHOPPER_TIMING_E
318
+  #endif
319
+  static constexpr chopper_timing_t chopper_timing_E5 = CHOPPER_TIMING_E5;
262 320
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E5)
263 321
     #define E5_ENABLE_INIT() NOOP
264
-    #define E5_ENABLE_WRITE(STATE) stepperE5.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
322
+    #define E5_ENABLE_WRITE(STATE) stepperE5.toff((STATE)==E_ENABLE_ON ? chopper_timing_E5.toff : 0)
265 323
     #define E5_ENABLE_READ() stepperE5.isEnabled()
266 324
   #endif
267 325
   #if AXIS_HAS_SQUARE_WAVE(E5)
@@ -272,9 +330,13 @@ void reset_trinamic_drivers();
272 330
 // E6 Stepper
273 331
 #if AXIS_IS_TMC(E6)
274 332
   extern TMC_CLASS_E(6) stepperE6;
333
+  #ifndef CHOPPER_TIMING_E6
334
+    #define CHOPPER_TIMING_E6 CHOPPER_TIMING_E
335
+  #endif
336
+  static constexpr chopper_timing_t chopper_timing_E6 = CHOPPER_TIMING_E6;
275 337
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E6)
276 338
     #define E6_ENABLE_INIT() NOOP
277
-    #define E6_ENABLE_WRITE(STATE) stepperE6.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
339
+    #define E6_ENABLE_WRITE(STATE) stepperE6.toff((STATE)==E_ENABLE_ON ? chopper_timing_E6.toff : 0)
278 340
     #define E6_ENABLE_READ() stepperE6.isEnabled()
279 341
   #endif
280 342
   #if AXIS_HAS_SQUARE_WAVE(E6)
@@ -285,9 +347,13 @@ void reset_trinamic_drivers();
285 347
 // E7 Stepper
286 348
 #if AXIS_IS_TMC(E7)
287 349
   extern TMC_CLASS_E(7) stepperE7;
350
+  #ifndef CHOPPER_TIMING_E7
351
+    #define CHOPPER_TIMING_E7 CHOPPER_TIMING_E
352
+  #endif
353
+  static constexpr chopper_timing_t chopper_timing_E7 = CHOPPER_TIMING_E7;
288 354
   #if ENABLED(SOFTWARE_DRIVER_ENABLE) && AXIS_IS_TMC(E7)
289 355
     #define E7_ENABLE_INIT() NOOP
290
-    #define E7_ENABLE_WRITE(STATE) stepperE7.toff((STATE)==E_ENABLE_ON ? chopper_timing.toff : 0)
356
+    #define E7_ENABLE_WRITE(STATE) stepperE7.toff((STATE)==E_ENABLE_ON ? chopper_timing_E7.toff : 0)
291 357
     #define E7_ENABLE_READ() stepperE7.isEnabled()
292 358
   #endif
293 359
   #if AXIS_HAS_SQUARE_WAVE(E7)

Ładowanie…
Anuluj
Zapisz