Browse Source

🚸 Fix extra Z raises (#27395)

Scott Lahteine 6 months ago
parent
commit
2c6f8a30f3

+ 1 - 1
Marlin/src/gcode/calibrate/G28.cpp

@@ -371,7 +371,7 @@ void GcodeSuite::G28() {
           bool with_probe = ENABLED(HOMING_Z_WITH_PROBE);
           // Raise above the current Z (which should be synced in the planner)
           // The "height" for Z is a coordinate. But if Z is not trusted/homed make it relative.
-          if (seenR || !TERN(HOME_AFTER_DEACTIVATE, axis_is_trusted, axis_was_homed)(Z_AXIS)) {
+          if (seenR || !(z_min_trusted || axis_should_home(Z_AXIS))) {
             z_homing_height += current_position.z;
             with_probe = false;
           }

+ 3 - 0
Marlin/src/inc/Conditionals-3-etc.h

@@ -652,6 +652,9 @@
 #if DISABLED(DELTA)
   #undef DELTA_HOME_TO_SAFE_ZONE
 #endif
+#if ANY(DELTA, AXEL_TPARA)
+  #define Z_CAN_FALL_DOWN
+#endif
 
 /**
  * This setting is also used by M109 when trying to calculate

+ 5 - 0
Marlin/src/module/motion.cpp

@@ -80,6 +80,11 @@
 // Relative Mode. Enable with G91, disable with G90.
 bool relative_mode; // = false
 
+#if HAS_Z_AXIS
+  // If Z has been powered on trust that the real Z is >= current_position.z
+  bool z_min_trusted; // = false
+#endif
+
 /**
  * Cartesian Current Position
  *   Used to track the native machine position as moves are queued.

+ 4 - 0
Marlin/src/module/motion.h

@@ -433,6 +433,10 @@ void restore_feedrate_and_scaling();
 typedef bits_t(NUM_AXES) main_axes_bits_t;
 constexpr main_axes_bits_t main_axes_mask = _BV(NUM_AXES) - 1;
 
+#if HAS_Z_AXIS
+  extern bool z_min_trusted; // If Z has been powered on trust that the real Z is >= current_position.z
+#endif
+
 void set_axis_is_at_home(const AxisEnum axis);
 
 #if HAS_ENDSTOPS

+ 1 - 0
Marlin/src/module/stepper.cpp

@@ -580,6 +580,7 @@ bool Stepper::disable_axis(const AxisEnum axis) {
   // and keep a count of how many times each ENA pin has been set.
 
   // If all the axes that share the enabled bit are disabled
+  // toggle the ENA state that they all share.
   const bool can_disable = can_axis_disable(axis);
   if (can_disable) {
     #define _CASE_DISABLE(N) case N##_AXIS: DISABLE_AXIS_##N(); break;

+ 10 - 0
Marlin/src/module/stepper.h

@@ -44,6 +44,7 @@
 #include "../inc/MarlinConfig.h"
 
 #include "planner.h"
+#include "motion.h"
 #include "stepper/indirection.h"
 #include "stepper/cycles.h"
 #ifdef __AVR__
@@ -633,9 +634,18 @@ class Stepper {
     }
     static void mark_axis_enabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
       SBI(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex));
+      TERN_(HAS_Z_AXIS, if (axis == Z_AXIS) z_min_trusted = true);
+      // TODO: DELTA should have "Z" state affect all (ABC) motors and treat "XY" on/off as meaningless
     }
     static void mark_axis_disabled(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
       CBI(axis_enabled.bits, INDEX_OF_AXIS(axis, eindex));
+      #if HAS_Z_AXIS
+        if (TERN0(Z_CAN_FALL_DOWN, axis == Z_AXIS)) {
+          z_min_trusted = false;
+          current_position.z = 0;
+        }
+      #endif
+      // TODO: DELTA should have "Z" state affect all (ABC) motors and treat "XY" on/off as meaningless
     }
     static bool can_axis_disable(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
       return !any_enable_overlap() || !(axis_enabled.bits & enable_overlap[INDEX_OF_AXIS(axis, eindex)]);