MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.25k stars 19.23k forks source link

Dual Z motors, the REV setting only works on one side #25794

Closed colcolcheese closed 1 year ago

colcolcheese commented 1 year ago

Bug Description

define INVERT_Z_DIR false => Z&Z2=right rotation

define INVERT_Z_DIR true => Z=left rotation Z2=right rotation

Version of Marlin Firmware

bugfix-2.1.x

Printer model

Don't forget to include

Additional information & file uploads

Marlin.zip

ellensp commented 1 year ago

tested

./buildroot/bin/opt_enable Z2_DRIVER_TYPE A4988 ./buildroot/bin/opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ./buildroot/bin/opt_set INVERT_Z_DIR true

good 4b4d98d282f2760e760b9f2ccca8dcc8831f7f8d bad 3e9848f49c6565ea1c630c272e32e27b0858d85a

says commit d93aa0c38449bcbc38aeca7eac506297270546c8 introduced this issue.

but its not the whole story....

thisiskeithb commented 1 year ago

says commit d93aa0c introduced this issue.

That patch was pushed to fix the motion bug(s) reported in https://github.com/MarlinFirmware/Marlin/issues/25785

ellensp commented 1 year ago

Looking into the code, and getting rather confused, but I think I see the issue

The code is correct, but some defines are missing.

when #define INVERT_Z_DIR true then this should also be set

define INVERT_Z2_DIR true

same with INVERT_Z3_DIR and INVERT_Z4_DIR for when you have 3 or 4 Z's simply adding the line will fix the issue, but it should be done automatically

I purpose the following, which fixes it in my testing

diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h
index 7ea12f0493..855218ab37 100644
--- a/Marlin/src/inc/Conditionals_adv.h
+++ b/Marlin/src/inc/Conditionals_adv.h
@@ -875,6 +875,18 @@
 #endif

 // Multiple Z steppers
+#ifdef INVERT_Z_DIR
+  #if NUM_Z_STEPPERS > 3
+    #define INVERT_Z4_DIR INVERT_Z_DIR
+  #endif
+  #if NUM_Z_STEPPERS > 2
+    #define INVERT_Z3_DIR INVERT_Z_DIR
+  #endif
+  #if NUM_Z_STEPPERS > 1
+    #define INVERT_Z2_DIR INVERT_Z_DIR
+  #endif
+#endif
+
 #if NUM_Z_STEPPERS < 4
   #undef INVERT_Z4_VS_Z_DIR
   #if NUM_Z_STEPPERS < 3
ellensp commented 1 year ago

@colcolcheese can you try this on your system?

If it also fixes your issue, ill turn it into a PR to fix it for all.

colcolcheese commented 1 year ago

The test was successful. Thanks for responding.

ellensp commented 1 year ago

PR created, closing this as fixed. (as soon as its is committed)

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.