Browse Source

🐛 Fix Bed Distance Sensor reading (#24649)

Mark 1 year ago
parent
commit
42f8cc4606
No account linked to committer's email address
2 changed files with 20 additions and 17 deletions
  1. 17
    16
      Marlin/src/feature/bedlevel/bdl/bdl.cpp
  2. 3
    1
      Marlin/src/module/probe.cpp

+ 17
- 16
Marlin/src/feature/bedlevel/bdl/bdl.cpp View File

@@ -96,22 +96,23 @@ void BDS_Leveling::process() {
96 96
       const float z_sensor = (tmp & 0x3FF) / 100.0f;
97 97
       if (cur_z < 0) config_state = 0;
98 98
       //float abs_z = current_position.z > cur_z ? (current_position.z - cur_z) : (cur_z - current_position.z);
99
-      if ( cur_z < config_state * 0.1f
100
-        && config_state > 0
101
-        && old_cur_z == cur_z
102
-        && old_buf_z == current_position.z
103
-        && z_sensor < (MAX_BD_HEIGHT)
104
-      ) {
105
-        babystep.set_mm(Z_AXIS, cur_z - z_sensor);
106
-        #if ENABLED(DEBUG_OUT_BD)
107
-          SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z);
108
-        #endif
109
-      }
110
-      else {
111
-        babystep.set_mm(Z_AXIS, 0);
112
-        //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR);
113
-        stepper.set_directions();
114
-      }
99
+      #if ENABLED(BABYSTEPPING)
100
+        if (cur_z < config_state * 0.1f
101
+          && config_state > 0
102
+          && old_cur_z == cur_z
103
+          && old_buf_z == current_position.z
104
+          && z_sensor < (MAX_BD_HEIGHT)
105
+        ) {
106
+          babystep.set_mm(Z_AXIS, cur_z - z_sensor);
107
+          #if ENABLED(DEBUG_OUT_BD)
108
+            SERIAL_ECHOLNPGM("BD:", z_sensor, ", Z:", cur_z, "|", current_position.z);
109
+          #endif
110
+        }
111
+        else {
112
+          babystep.set_mm(Z_AXIS, 0);          //if (old_cur_z <= cur_z) Z_DIR_WRITE(!INVERT_Z_DIR);
113
+          stepper.set_directions();
114
+        }
115
+      #endif
115 116
       old_cur_z = cur_z;
116 117
       old_buf_z = current_position.z;
117 118
       endstops.bdp_state_update(z_sensor <= 0.01f);

+ 3
- 1
Marlin/src/module/probe.cpp View File

@@ -882,7 +882,9 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
882 882
   // Move the probe to the starting XYZ
883 883
   do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
884 884
 
885
-  TERN_(BD_SENSOR, return bdl.read());
885
+  #if ENABLED(BD_SENSOR)
886
+    return current_position.z - bdl.read(); // Difference between Z-home-relative Z and sensor reading
887
+  #endif
886 888
 
887 889
   float measured_z = NAN;
888 890
   if (!deploy()) {

Loading…
Cancel
Save