Browse Source

Multi-Z stepper inverting (#20678)

Co-authored-by: Scott Lahteine <github@thinkyhead.com>
wilbur4321 3 years ago
parent
commit
e3831c146d
No account linked to committer's email address

+ 2
- 2
Marlin/Configuration.h View File

@@ -1089,7 +1089,7 @@
1089 1089
 //#define PROBING_STEPPERS_OFF      // Turn steppers off (unless needed to hold position) when probing
1090 1090
 //#define DELAY_BEFORE_PROBING 200  // (ms) To prevent vibrations from triggering piezo sensors
1091 1091
 
1092
-// Require minimum nozzle and/or bed temperature for probing.
1092
+// Require minimum nozzle and/or bed temperature for probing
1093 1093
 //#define PREHEAT_BEFORE_PROBING
1094 1094
 #if ENABLED(PREHEAT_BEFORE_PROBING)
1095 1095
   #define PROBING_NOZZLE_TEMP 120   // (°C) Only applies to E0 at this time
@@ -2428,7 +2428,7 @@
2428 2428
   //#define TOUCH_CALIBRATION_Y -8981
2429 2429
   //#define TOUCH_OFFSET_X        -43
2430 2430
   //#define TOUCH_OFFSET_Y        257
2431
-  //#define TOUCH_ORIENTATION   TOUCH_LANDSCAPE
2431
+  //#define TOUCH_ORIENTATION TOUCH_LANDSCAPE
2432 2432
 
2433 2433
   #if ENABLED(TFT_COLOR_UI)
2434 2434
     //#define SINGLE_TOUCH_NAVIGATION

+ 7
- 2
Marlin/Configuration_adv.h View File

@@ -552,7 +552,7 @@
552 552
 
553 553
 //#define X_DUAL_STEPPER_DRIVERS
554 554
 #if ENABLED(X_DUAL_STEPPER_DRIVERS)
555
-  #define INVERT_X2_VS_X_DIR true   // Set 'true' if X motors should rotate in opposite directions
555
+  //#define INVERT_X2_VS_X_DIR    // Enable if X2 direction signal is opposite to X
556 556
   //#define X_DUAL_ENDSTOPS
557 557
   #if ENABLED(X_DUAL_ENDSTOPS)
558 558
     #define X2_USE_ENDSTOP _XMAX_
@@ -562,7 +562,7 @@
562 562
 
563 563
 //#define Y_DUAL_STEPPER_DRIVERS
564 564
 #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
565
-  #define INVERT_Y2_VS_Y_DIR true   // Set 'true' if Y motors should rotate in opposite directions
565
+  //#define INVERT_Y2_VS_Y_DIR   // Enable if Y2 direction signal is opposite to Y
566 566
   //#define Y_DUAL_ENDSTOPS
567 567
   #if ENABLED(Y_DUAL_ENDSTOPS)
568 568
     #define Y2_USE_ENDSTOP _YMAX_
@@ -576,6 +576,11 @@
576 576
 #define NUM_Z_STEPPER_DRIVERS 1   // (1-4) Z options change based on how many
577 577
 
578 578
 #if NUM_Z_STEPPER_DRIVERS > 1
579
+  // Enable if Z motor direction signals are the opposite of Z1
580
+  //#define INVERT_Z2_VS_Z_DIR
581
+  //#define INVERT_Z3_VS_Z_DIR
582
+  //#define INVERT_Z4_VS_Z_DIR
583
+
579 584
   //#define Z_MULTI_ENDSTOPS
580 585
   #if ENABLED(Z_MULTI_ENDSTOPS)
581 586
     #define Z2_USE_ENDSTOP          _XMAX_

+ 10
- 6
Marlin/src/inc/Conditionals_adv.h View File

@@ -211,14 +211,18 @@
211 211
 #if DISABLED(Y_DUAL_STEPPER_DRIVERS)
212 212
   #undef Y2_DRIVER_TYPE
213 213
 #endif
214
-#if NUM_Z_STEPPER_DRIVERS < 2
215
-  #undef Z2_DRIVER_TYPE
216
-#endif
217
-#if NUM_Z_STEPPER_DRIVERS < 3
218
-  #undef Z3_DRIVER_TYPE
219
-#endif
214
+
220 215
 #if NUM_Z_STEPPER_DRIVERS < 4
221 216
   #undef Z4_DRIVER_TYPE
217
+  #undef INVERT_Z4_VS_Z_DIR
218
+  #if NUM_Z_STEPPER_DRIVERS < 3
219
+    #undef Z3_DRIVER_TYPE
220
+    #undef INVERT_Z3_VS_Z_DIR
221
+    #if NUM_Z_STEPPER_DRIVERS < 2
222
+      #undef Z2_DRIVER_TYPE
223
+      #undef INVERT_Z2_VS_Z_DIR
224
+    #endif
225
+  #endif
222 226
 #endif
223 227
 
224 228
 //

+ 5
- 10
Marlin/src/libs/L64XX/L64XX_Marlin.cpp View File

@@ -60,16 +60,11 @@ uint8_t L64XX_Marlin::dir_commands[MAX_L64XX];  // array to hold direction comma
60 60
 
61 61
 const uint8_t L64XX_Marlin::index_to_dir[MAX_L64XX] = {
62 62
   INVERT_X_DIR, INVERT_Y_DIR, INVERT_Z_DIR
63
-  , (INVERT_X_DIR)                            // X2
64
-    #if ENABLED(X_DUAL_STEPPER_DRIVERS)
65
-      ^ ENABLED(INVERT_X2_VS_X_DIR)
66
-    #endif
67
-  , (INVERT_Y_DIR)                            // Y2
68
-    #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
69
-      ^ ENABLED(INVERT_Y2_VS_Y_DIR)
70
-    #endif
71
-  , INVERT_Z_DIR, INVERT_Z_DIR, INVERT_Z_DIR  // Z2,Z3,Z4
72
-
63
+  , (INVERT_X_DIR) ^ BOTH(X_DUAL_STEPPER_DRIVERS, INVERT_X2_VS_X_DIR) // X2
64
+  , (INVERT_Y_DIR) ^ BOTH(Y_DUAL_STEPPER_DRIVERS, INVERT_Y2_VS_Y_DIR) // Y2
65
+  , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z2_VS_Z_DIR) // Z2
66
+  , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z3_VS_Z_DIR) // Z3
67
+  , (INVERT_Z_DIR) ^ ENABLED(INVERT_Z4_VS_Z_DIR) // Z4
73 68
   , INVERT_E0_DIR, INVERT_E1_DIR, INVERT_E2_DIR, INVERT_E3_DIR
74 69
   , INVERT_E4_DIR, INVERT_E5_DIR, INVERT_E6_DIR, INVERT_E7_DIR
75 70
 };

+ 8
- 3
Marlin/src/module/stepper.cpp View File

@@ -381,7 +381,10 @@ xyze_int8_t Stepper::count_direction{0};
381 381
 #endif
382 382
 
383 383
 #if NUM_Z_STEPPER_DRIVERS == 4
384
-  #define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); Z3_DIR_WRITE(v); Z4_DIR_WRITE(v); }while(0)
384
+  #define Z_APPLY_DIR(v,Q) do{ \
385
+    Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); \
386
+    Z3_DIR_WRITE((v) ^ ENABLED(INVERT_Z3_VS_Z_DIR)); Z4_DIR_WRITE((v) ^ ENABLED(INVERT_Z4_VS_Z_DIR)); \
387
+  }while(0)
385 388
   #if ENABLED(Z_MULTI_ENDSTOPS)
386 389
     #define Z_APPLY_STEP(v,Q) QUAD_ENDSTOP_APPLY_STEP(Z,v)
387 390
   #elif ENABLED(Z_STEPPER_AUTO_ALIGN)
@@ -390,7 +393,9 @@ xyze_int8_t Stepper::count_direction{0};
390 393
     #define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); Z4_STEP_WRITE(v); }while(0)
391 394
   #endif
392 395
 #elif NUM_Z_STEPPER_DRIVERS == 3
393
-  #define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); Z3_DIR_WRITE(v); }while(0)
396
+  #define Z_APPLY_DIR(v,Q) do{ \
397
+    Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); Z3_DIR_WRITE((v) ^ ENABLED(INVERT_Z3_VS_Z_DIR)); \
398
+  }while(0)
394 399
   #if ENABLED(Z_MULTI_ENDSTOPS)
395 400
     #define Z_APPLY_STEP(v,Q) TRIPLE_ENDSTOP_APPLY_STEP(Z,v)
396 401
   #elif ENABLED(Z_STEPPER_AUTO_ALIGN)
@@ -399,7 +404,7 @@ xyze_int8_t Stepper::count_direction{0};
399 404
     #define Z_APPLY_STEP(v,Q) do{ Z_STEP_WRITE(v); Z2_STEP_WRITE(v); Z3_STEP_WRITE(v); }while(0)
400 405
   #endif
401 406
 #elif NUM_Z_STEPPER_DRIVERS == 2
402
-  #define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE(v); }while(0)
407
+  #define Z_APPLY_DIR(v,Q) do{ Z_DIR_WRITE(v); Z2_DIR_WRITE((v) ^ ENABLED(INVERT_Z2_VS_Z_DIR)); }while(0)
403 408
   #if ENABLED(Z_MULTI_ENDSTOPS)
404 409
     #define Z_APPLY_STEP(v,Q) DUAL_ENDSTOP_APPLY_STEP(Z,v)
405 410
   #elif ENABLED(Z_STEPPER_AUTO_ALIGN)

Loading…
Cancel
Save