Browse Source

Prevent damage if DELTA_HEIGHT is incorrect

Thomas Moore 8 years ago
parent
commit
f54e0fc90f
4 changed files with 166 additions and 91 deletions
  1. 132
    80
      Marlin/Marlin_main.cpp
  2. 5
    5
      Marlin/endstops.cpp
  3. 16
    1
      Marlin/language_en.h
  4. 13
    5
      Marlin/ultralcd.cpp

+ 132
- 80
Marlin/Marlin_main.cpp View File

1409
           soft_endstop_max[axis] = base_max_pos(axis) + offs;
1409
           soft_endstop_max[axis] = base_max_pos(axis) + offs;
1410
         }
1410
         }
1411
       }
1411
       }
1412
+    #elif ENABLED(DELTA)
1413
+      soft_endstop_min[axis] = base_min_pos(axis) + (axis == Z_AXIS ? 0 : offs);
1414
+      soft_endstop_max[axis] = base_max_pos(axis) + offs;
1412
     #else
1415
     #else
1413
       soft_endstop_min[axis] = base_min_pos(axis) + offs;
1416
       soft_endstop_min[axis] = base_min_pos(axis) + offs;
1414
       soft_endstop_max[axis] = base_max_pos(axis) + offs;
1417
       soft_endstop_max[axis] = base_max_pos(axis) + offs;
1806
       }
1809
       }
1807
     #endif
1810
     #endif
1808
 
1811
 
1809
-    float z_dest = LOGICAL_Z_POSITION(z_raise);
1812
+    float z_dest = z_raise;
1810
     if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
1813
     if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
1811
 
1814
 
1812
-    #if ENABLED(DELTA)
1813
-      z_dest -= home_offset[Z_AXIS]; // Account for delta height adjustment
1814
-    #endif
1815
-
1816
     if (z_dest > current_position[Z_AXIS])
1815
     if (z_dest > current_position[Z_AXIS])
1817
       do_blocking_move_to_z(z_dest);
1816
       do_blocking_move_to_z(z_dest);
1818
   }
1817
   }
2106
       safe_delay(BLTOUCH_DELAY);
2105
       safe_delay(BLTOUCH_DELAY);
2107
     }
2106
     }
2108
 
2107
 
2109
-    void set_bltouch_deployed(const bool deploy) {
2108
+    bool set_bltouch_deployed(const bool deploy) {
2110
       if (deploy && TEST_BLTOUCH()) {      // If BL-Touch says it's triggered
2109
       if (deploy && TEST_BLTOUCH()) {      // If BL-Touch says it's triggered
2111
         bltouch_command(BLTOUCH_RESET);    //  try to reset it.
2110
         bltouch_command(BLTOUCH_RESET);    //  try to reset it.
2112
         bltouch_command(BLTOUCH_DEPLOY);   // Also needs to deploy and stow to
2111
         bltouch_command(BLTOUCH_DEPLOY);   // Also needs to deploy and stow to
2118
           SERIAL_ERROR_START();
2117
           SERIAL_ERROR_START();
2119
           SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH);
2118
           SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH);
2120
           stop();                          // punt!
2119
           stop();                          // punt!
2120
+          return true;
2121
         }
2121
         }
2122
       }
2122
       }
2123
 
2123
 
2130
           SERIAL_EOL();
2130
           SERIAL_EOL();
2131
         }
2131
         }
2132
       #endif
2132
       #endif
2133
+
2134
+      return false;
2133
     }
2135
     }
2134
 
2136
 
2135
   #endif // BLTOUCH
2137
   #endif // BLTOUCH
2149
     // Make room for probe
2151
     // Make room for probe
2150
     do_probe_raise(_Z_CLEARANCE_DEPLOY_PROBE);
2152
     do_probe_raise(_Z_CLEARANCE_DEPLOY_PROBE);
2151
 
2153
 
2152
-    // When deploying make sure BLTOUCH is not already triggered
2153
-    #if ENABLED(BLTOUCH)
2154
-      if (deploy && TEST_BLTOUCH()) {      // If BL-Touch says it's triggered
2155
-        bltouch_command(BLTOUCH_RESET);    // try to reset it.
2156
-        bltouch_command(BLTOUCH_DEPLOY);   // Also needs to deploy and stow to
2157
-        bltouch_command(BLTOUCH_STOW);     // clear the triggered condition.
2158
-        safe_delay(1500);                  // wait for internal self test to complete
2159
-                                           //   measured completion time was 0.65 seconds
2160
-                                           //   after reset, deploy & stow sequence
2161
-        if (TEST_BLTOUCH()) {              // If it still claims to be triggered...
2162
-          SERIAL_ERROR_START();
2163
-          SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH);
2164
-          stop();                          // punt!
2165
-          return true;
2166
-        }
2167
-      }
2168
-    #elif ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
2154
+    #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
2169
       #if ENABLED(Z_PROBE_SLED)
2155
       #if ENABLED(Z_PROBE_SLED)
2170
         #define _AUE_ARGS true, false, false
2156
         #define _AUE_ARGS true, false, false
2171
       #else
2157
       #else
2236
     return false;
2222
     return false;
2237
   }
2223
   }
2238
 
2224
 
2239
-  static void do_probe_move(float z, float fr_mm_m) {
2225
+  static bool do_probe_move(float z, float fr_mm_m) {
2240
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2226
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2241
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
2227
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
2242
     #endif
2228
     #endif
2243
 
2229
 
2244
     // Deploy BLTouch at the start of any probe
2230
     // Deploy BLTouch at the start of any probe
2245
     #if ENABLED(BLTOUCH)
2231
     #if ENABLED(BLTOUCH)
2246
-      set_bltouch_deployed(true);
2232
+      if (set_bltouch_deployed(true)) return true;
2247
     #endif
2233
     #endif
2248
 
2234
 
2249
     #if QUIET_PROBING
2235
     #if QUIET_PROBING
2251
     #endif
2237
     #endif
2252
 
2238
 
2253
     // Move down until probe triggered
2239
     // Move down until probe triggered
2254
-    do_blocking_move_to_z(LOGICAL_Z_POSITION(z), MMM_TO_MMS(fr_mm_m));
2240
+    do_blocking_move_to_z(z, MMM_TO_MMS(fr_mm_m));
2241
+
2242
+    // Check to see if the probe was triggered
2243
+    const bool probe_triggered = TEST(Endstops::endstop_hit_bits,
2244
+      #ifdef Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN
2245
+        Z_MIN
2246
+      #else
2247
+        Z_MIN_PROBE
2248
+      #endif
2249
+    );
2255
 
2250
 
2256
     #if QUIET_PROBING
2251
     #if QUIET_PROBING
2257
       probing_pause(false);
2252
       probing_pause(false);
2258
     #endif
2253
     #endif
2259
 
2254
 
2260
-    // Retract BLTouch immediately after a probe
2255
+    // Retract BLTouch immediately after a probe if it was triggered
2261
     #if ENABLED(BLTOUCH)
2256
     #if ENABLED(BLTOUCH)
2262
-      set_bltouch_deployed(false);
2257
+      if (probe_triggered && set_bltouch_deployed(false)) return true;
2263
     #endif
2258
     #endif
2264
 
2259
 
2265
     // Clear endstop flags
2260
     // Clear endstop flags
2274
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2269
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2275
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
2270
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
2276
     #endif
2271
     #endif
2272
+
2273
+    return !probe_triggered;
2277
   }
2274
   }
2278
 
2275
 
2279
   // Do a single Z probe and return with current_position[Z_AXIS]
2276
   // Do a single Z probe and return with current_position[Z_AXIS]
2280
   // at the height where the probe triggered.
2277
   // at the height where the probe triggered.
2281
-  static float run_z_probe() {
2278
+  static float run_z_probe(bool printable=true) {
2282
 
2279
 
2283
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2280
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2284
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
2281
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
2290
     #if ENABLED(PROBE_DOUBLE_TOUCH)
2287
     #if ENABLED(PROBE_DOUBLE_TOUCH)
2291
 
2288
 
2292
       // Do a first probe at the fast speed
2289
       // Do a first probe at the fast speed
2293
-      do_probe_move(-(Z_MAX_LENGTH) - 10, Z_PROBE_SPEED_FAST);
2290
+      if (do_probe_move(-10, Z_PROBE_SPEED_FAST)) return NAN;
2294
 
2291
 
2295
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2292
       #if ENABLED(DEBUG_LEVELING_FEATURE)
2296
         float first_probe_z = current_position[Z_AXIS];
2293
         float first_probe_z = current_position[Z_AXIS];
2297
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("1st Probe Z:", first_probe_z);
2294
         if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("1st Probe Z:", first_probe_z);
2298
       #endif
2295
       #endif
2299
 
2296
 
2300
-      // move up by the bump distance
2301
-      do_blocking_move_to_z(current_position[Z_AXIS] + home_bump_mm(Z_AXIS), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2297
+      // move up to make clearance for the probe
2298
+      do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2302
 
2299
 
2303
     #else
2300
     #else
2304
 
2301
 
2305
       // If the nozzle is above the travel height then
2302
       // If the nozzle is above the travel height then
2306
       // move down quickly before doing the slow probe
2303
       // move down quickly before doing the slow probe
2307
-      float z = LOGICAL_Z_POSITION(Z_CLEARANCE_BETWEEN_PROBES);
2304
+      float z = Z_CLEARANCE_DEPLOY_PROBE;
2308
       if (zprobe_zoffset < 0) z -= zprobe_zoffset;
2305
       if (zprobe_zoffset < 0) z -= zprobe_zoffset;
2309
 
2306
 
2310
-      #if ENABLED(DELTA)
2311
-        z -= home_offset[Z_AXIS]; // Account for delta height adjustment
2312
-      #endif
2313
-
2314
-      if (z < current_position[Z_AXIS])
2315
-        do_blocking_move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2307
+      if (z < current_position[Z_AXIS]) {
2316
 
2308
 
2309
+        // If we don't make it to the z position (i.e. the probe triggered), move up to make clearance for the probe
2310
+        if (!do_probe_move(z, Z_PROBE_SPEED_FAST))
2311
+          do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2312
+      }
2317
     #endif
2313
     #endif
2318
 
2314
 
2319
     // move down slowly to find bed
2315
     // move down slowly to find bed
2320
-    do_probe_move(-(Z_MAX_LENGTH) - 10, Z_PROBE_SPEED_SLOW);
2316
+    if (do_probe_move(-10 + (printable ? 0 : -(Z_MAX_LENGTH)), Z_PROBE_SPEED_SLOW)) return NAN;
2321
 
2317
 
2322
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2318
     #if ENABLED(DEBUG_LEVELING_FEATURE)
2323
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
2319
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
2330
         SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
2326
         SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
2331
       }
2327
       }
2332
     #endif
2328
     #endif
2329
+
2333
     return RAW_CURRENT_POSITION(Z) + zprobe_zoffset
2330
     return RAW_CURRENT_POSITION(Z) + zprobe_zoffset
2334
       #if ENABLED(DELTA)
2331
       #if ENABLED(DELTA)
2335
         + home_offset[Z_AXIS] // Account for delta height adjustment
2332
         + home_offset[Z_AXIS] // Account for delta height adjustment
2371
         do_blocking_move_to_z(delta_clip_start_height);
2368
         do_blocking_move_to_z(delta_clip_start_height);
2372
     #endif
2369
     #endif
2373
 
2370
 
2374
-    // Ensure a minimum height before moving the probe
2375
-    do_probe_raise(Z_CLEARANCE_BETWEEN_PROBES);
2371
+    #if HAS_SOFTWARE_ENDSTOPS
2372
+      // Store the status of the soft endstops and disable if we're probing a non-printable location
2373
+      static bool enable_soft_endstops = soft_endstops_enabled;
2374
+      if (!printable) soft_endstops_enabled = false;
2375
+    #endif
2376
 
2376
 
2377
     feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
2377
     feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
2378
 
2378
 
2379
     // Move the probe to the given XY
2379
     // Move the probe to the given XY
2380
     do_blocking_move_to_xy(nx, ny);
2380
     do_blocking_move_to_xy(nx, ny);
2381
 
2381
 
2382
-    if (DEPLOY_PROBE()) return NAN;
2382
+    float measured_z = NAN;
2383
+    if (!DEPLOY_PROBE()) {
2384
+      measured_z = run_z_probe(printable);
2383
 
2385
 
2384
-    const float measured_z = run_z_probe();
2386
+      if (!stow)
2387
+        do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2388
+      else
2389
+        if (STOW_PROBE()) measured_z = NAN;
2390
+    }
2385
 
2391
 
2386
-    if (!stow)
2387
-      do_probe_raise(Z_CLEARANCE_BETWEEN_PROBES);
2388
-    else
2389
-      if (STOW_PROBE()) return NAN;
2392
+    #if HAS_SOFTWARE_ENDSTOPS
2393
+      // Restore the soft endstop status
2394
+      soft_endstops_enabled = enable_soft_endstops;
2395
+    #endif
2390
 
2396
 
2391
     if (verbose_level > 2) {
2397
     if (verbose_level > 2) {
2392
       SERIAL_PROTOCOLPGM("Bed X: ");
2398
       SERIAL_PROTOCOLPGM("Bed X: ");
3752
    * A delta can only safely home all axes at the same time
3758
    * A delta can only safely home all axes at the same time
3753
    * This is like quick_home_xy() but for 3 towers.
3759
    * This is like quick_home_xy() but for 3 towers.
3754
    */
3760
    */
3755
-  inline void home_delta() {
3761
+  inline bool home_delta() {
3756
     #if ENABLED(DEBUG_LEVELING_FEATURE)
3762
     #if ENABLED(DEBUG_LEVELING_FEATURE)
3757
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
3763
       if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
3758
     #endif
3764
     #endif
3761
     sync_plan_position();
3767
     sync_plan_position();
3762
 
3768
 
3763
     // Move all carriages together linearly until an endstop is hit.
3769
     // Move all carriages together linearly until an endstop is hit.
3764
-    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (Z_MAX_LENGTH + 10);
3770
+    current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
3765
     feedrate_mm_s = homing_feedrate(X_AXIS);
3771
     feedrate_mm_s = homing_feedrate(X_AXIS);
3766
     line_to_current_position();
3772
     line_to_current_position();
3767
     stepper.synchronize();
3773
     stepper.synchronize();
3774
+
3775
+    // If an endstop was not hit, then damage can occur if homing is continued.
3776
+    // This can occur if the delta height (DELTA_HEIGHT + home_offset[Z_AXIS]) is
3777
+    // not set correctly.
3778
+    if (!(TEST(Endstops::endstop_hit_bits, X_MAX) ||
3779
+          TEST(Endstops::endstop_hit_bits, Y_MAX) ||
3780
+          TEST(Endstops::endstop_hit_bits, Z_MAX))) {
3781
+      LCD_MESSAGEPGM(MSG_ERR_HOMING_FAILED);
3782
+      SERIAL_ERROR_START();
3783
+      SERIAL_ERRORLNPGM(MSG_ERR_HOMING_FAILED);
3784
+      return false;
3785
+    }
3786
+
3768
     endstops.hit_on_purpose(); // clear endstop hit flags
3787
     endstops.hit_on_purpose(); // clear endstop hit flags
3769
 
3788
 
3770
     // At least one carriage has reached the top.
3789
     // At least one carriage has reached the top.
3784
     #if ENABLED(DEBUG_LEVELING_FEATURE)
3803
     #if ENABLED(DEBUG_LEVELING_FEATURE)
3785
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
3804
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
3786
     #endif
3805
     #endif
3806
+
3807
+    return true;
3787
   }
3808
   }
3788
 
3809
 
3789
 #endif // DELTA
3810
 #endif // DELTA
4105
 
4126
 
4106
 #endif
4127
 #endif
4107
 
4128
 
4129
+#if HAS_BED_PROBE
4130
+
4131
+  static bool nan_error(const float v) {
4132
+    const bool is_nan = isnan(v);
4133
+    if (is_nan) {
4134
+      LCD_MESSAGEPGM(MSG_ERR_PROBING_FAILED);
4135
+      SERIAL_ERROR_START();
4136
+      SERIAL_ERRORLNPGM(MSG_ERR_PROBING_FAILED);
4137
+    }
4138
+    return is_nan;
4139
+  }
4140
+
4141
+#endif // HAS_BED_PROBE
4142
+
4108
 #if ENABLED(MESH_BED_LEVELING)
4143
 #if ENABLED(MESH_BED_LEVELING)
4109
 
4144
 
4110
   // Save 130 bytes with non-duplication of PSTR
4145
   // Save 130 bytes with non-duplication of PSTR
4648
         // Deploy the probe. Probe will raise if needed.
4683
         // Deploy the probe. Probe will raise if needed.
4649
         if (DEPLOY_PROBE()) {
4684
         if (DEPLOY_PROBE()) {
4650
           planner.abl_enabled = abl_should_enable;
4685
           planner.abl_enabled = abl_should_enable;
4651
-          return;
4686
+          goto FAIL;
4652
         }
4687
         }
4653
       #endif
4688
       #endif
4654
 
4689
 
4864
       #endif // AUTO_BED_LEVELING_3POINT
4899
       #endif // AUTO_BED_LEVELING_3POINT
4865
 
4900
 
4866
     #else // !PROBE_MANUALLY
4901
     #else // !PROBE_MANUALLY
4867
-
4902
+    {
4868
       const bool stow_probe_after_each = parser.boolval('E');
4903
       const bool stow_probe_after_each = parser.boolval('E');
4869
 
4904
 
4870
       #if ABL_GRID
4905
       #if ABL_GRID
4909
 
4944
 
4910
             measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
4945
             measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
4911
 
4946
 
4912
-            if (isnan(measured_z)) {
4947
+            if (nan_error(measured_z)) {
4913
               planner.abl_enabled = abl_should_enable;
4948
               planner.abl_enabled = abl_should_enable;
4914
-              return;
4949
+              goto FAIL;
4915
             }
4950
             }
4916
 
4951
 
4917
             #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4952
             #if ENABLED(AUTO_BED_LEVELING_LINEAR)
4945
           xProbe = LOGICAL_X_POSITION(points[i].x);
4980
           xProbe = LOGICAL_X_POSITION(points[i].x);
4946
           yProbe = LOGICAL_Y_POSITION(points[i].y);
4981
           yProbe = LOGICAL_Y_POSITION(points[i].y);
4947
           measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
4982
           measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
4948
-          if (isnan(measured_z)) {
4983
+          if (nan_error(measured_z)) {
4949
             planner.abl_enabled = abl_should_enable;
4984
             planner.abl_enabled = abl_should_enable;
4950
-            return;
4985
+            goto FAIL;
4951
           }
4986
           }
4952
           points[i].z = measured_z;
4987
           points[i].z = measured_z;
4953
         }
4988
         }
4970
       // Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe.
5005
       // Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe.
4971
       if (STOW_PROBE()) {
5006
       if (STOW_PROBE()) {
4972
         planner.abl_enabled = abl_should_enable;
5007
         planner.abl_enabled = abl_should_enable;
4973
-        return;
5008
+        goto FAIL;
4974
       }
5009
       }
4975
-
5010
+    }
4976
     #endif // !PROBE_MANUALLY
5011
     #endif // !PROBE_MANUALLY
4977
 
5012
 
4978
     //
5013
     //
4985
     // return or loop before this point.
5020
     // return or loop before this point.
4986
     //
5021
     //
4987
 
5022
 
4988
-    // Restore state after probing
4989
-    if (!faux) clean_up_after_endstop_or_probe_move();
4990
-
4991
     #if ENABLED(DEBUG_LEVELING_FEATURE)
5023
     #if ENABLED(DEBUG_LEVELING_FEATURE)
4992
       if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
5024
       if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
4993
     #endif
5025
     #endif
5192
       stepper.synchronize();
5224
       stepper.synchronize();
5193
     #endif
5225
     #endif
5194
 
5226
 
5227
+    // Auto Bed Leveling is complete! Enable if possible.
5228
+    planner.abl_enabled = dryrun ? abl_should_enable : true;
5229
+
5230
+    FAIL:
5231
+
5232
+    // Restore state after probing
5233
+    if (!faux) clean_up_after_endstop_or_probe_move();
5234
+
5195
     #if ENABLED(DEBUG_LEVELING_FEATURE)
5235
     #if ENABLED(DEBUG_LEVELING_FEATURE)
5196
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29");
5236
       if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29");
5197
     #endif
5237
     #endif
5200
 
5240
 
5201
     KEEPALIVE_STATE(IN_HANDLER);
5241
     KEEPALIVE_STATE(IN_HANDLER);
5202
 
5242
 
5203
-    // Auto Bed Leveling is complete! Enable if possible.
5204
-    planner.abl_enabled = dryrun ? abl_should_enable : true;
5205
-
5206
     if (planner.abl_enabled)
5243
     if (planner.abl_enabled)
5207
       SYNC_PLAN_POSITION_KINEMATIC();
5244
       SYNC_PLAN_POSITION_KINEMATIC();
5208
   }
5245
   }
5235
 
5272
 
5236
     const float measured_z = probe_pt(xpos, ypos, parser.boolval('S', true), 1);
5273
     const float measured_z = probe_pt(xpos, ypos, parser.boolval('S', true), 1);
5237
 
5274
 
5238
-    if (!isnan(measured_z)) {
5275
+    if (!nan_error(measured_z)) {
5239
       SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
5276
       SERIAL_PROTOCOLPAIR("Bed X: ", FIXFLOAT(xpos));
5240
       SERIAL_PROTOCOLPAIR(" Y: ", FIXFLOAT(ypos));
5277
       SERIAL_PROTOCOLPAIR(" Y: ", FIXFLOAT(ypos));
5241
       SERIAL_PROTOCOLLNPAIR(" Z: ", FIXFLOAT(measured_z));
5278
       SERIAL_PROTOCOLLNPAIR(" Z: ", FIXFLOAT(measured_z));
5399
         tool_change(0, 0, true);
5436
         tool_change(0, 0, true);
5400
       #endif
5437
       #endif
5401
       setup_for_endstop_or_probe_move();
5438
       setup_for_endstop_or_probe_move();
5402
-      DEPLOY_PROBE();
5403
       endstops.enable(true);
5439
       endstops.enable(true);
5404
-      home_delta();
5440
+      if (!home_delta())
5441
+        return;
5405
       endstops.not_homing();
5442
       endstops.not_homing();
5406
 
5443
 
5407
       // print settings
5444
       // print settings
5415
       print_G33_settings(!_1p_calibration, _7p_calibration && towers_set);
5452
       print_G33_settings(!_1p_calibration, _7p_calibration && towers_set);
5416
 
5453
 
5417
       #if DISABLED(PROBE_MANUALLY)
5454
       #if DISABLED(PROBE_MANUALLY)
5418
-        home_offset[Z_AXIS] -= probe_pt(dx, dy, stow_after_each, 1, false); // 1st probe to set height
5455
+        const float measured_z = probe_pt(dx, dy, stow_after_each, 1, false); // 1st probe to set height
5456
+        if (nan_error(measured_z))
5457
+          goto FAIL;
5458
+        else
5459
+          home_offset[Z_AXIS] -= measured_z;
5419
       #endif
5460
       #endif
5420
 
5461
 
5421
       do {
5462
       do {
5433
             z_at_pt[0] += lcd_probe_pt(0, 0);
5474
             z_at_pt[0] += lcd_probe_pt(0, 0);
5434
           #else
5475
           #else
5435
             z_at_pt[0] += probe_pt(dx, dy, stow_after_each, 1, false);
5476
             z_at_pt[0] += probe_pt(dx, dy, stow_after_each, 1, false);
5477
+            if (nan_error(z_at_pt[0])) goto FAIL;
5436
           #endif
5478
           #endif
5437
         }
5479
         }
5438
         if (_7p_calibration) { // probe extra center points
5480
         if (_7p_calibration) { // probe extra center points
5441
             #if ENABLED(PROBE_MANUALLY)
5483
             #if ENABLED(PROBE_MANUALLY)
5442
               z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5484
               z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5443
             #else
5485
             #else
5444
-              z_at_pt[0] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1, false);
5486
+              z_at_pt[0] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
5487
+              if (nan_error(z_at_pt[0])) goto FAIL;
5445
             #endif
5488
             #endif
5446
           }
5489
           }
5447
           z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points);
5490
           z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points);
5461
               #if ENABLED(PROBE_MANUALLY)
5504
               #if ENABLED(PROBE_MANUALLY)
5462
                 z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5505
                 z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r);
5463
               #else
5506
               #else
5464
-                z_at_pt[axis] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1, false);
5507
+                z_at_pt[axis] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
5508
+                if (nan_error(z_at_pt[axis])) goto FAIL;
5465
               #endif
5509
               #endif
5466
             }
5510
             }
5467
             zig_zag = !zig_zag;
5511
             zig_zag = !zig_zag;
5661
       }
5705
       }
5662
       while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations);
5706
       while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations);
5663
 
5707
 
5708
+      FAIL:
5709
+
5664
       #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
5710
       #if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
5665
         do_blocking_move_to_z(delta_clip_start_height);
5711
         do_blocking_move_to_z(delta_clip_start_height);
5666
       #endif
5712
       #endif
6979
 
7025
 
6980
     setup_for_endstop_or_probe_move();
7026
     setup_for_endstop_or_probe_move();
6981
 
7027
 
7028
+    double mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
7029
+
6982
     // Move to the first point, deploy, and probe
7030
     // Move to the first point, deploy, and probe
6983
     const float t = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
7031
     const float t = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
6984
-    if (isnan(t)) return;
7032
+    if (nan_error(t)) goto FAIL;
6985
 
7033
 
6986
     randomSeed(millis());
7034
     randomSeed(millis());
6987
 
7035
 
6988
-    double mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
6989
-
6990
     for (uint8_t n = 0; n < n_samples; n++) {
7036
     for (uint8_t n = 0; n < n_samples; n++) {
6991
       if (n_legs) {
7037
       if (n_legs) {
6992
         const int dir = (random(0, 10) > 5.0) ? -1 : 1;  // clockwise or counter clockwise
7038
         const int dir = (random(0, 10) > 5.0) ? -1 : 1;  // clockwise or counter clockwise
7058
 
7104
 
7059
       // Probe a single point
7105
       // Probe a single point
7060
       sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, 0);
7106
       sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, 0);
7107
+      if (nan_error(sample_set[n])) goto FAIL;
7061
 
7108
 
7062
       /**
7109
       /**
7063
        * Get the current mean for the data points we have so far
7110
        * Get the current mean for the data points we have so far
7103
 
7150
 
7104
     } // End of probe loop
7151
     } // End of probe loop
7105
 
7152
 
7106
-    if (STOW_PROBE()) return;
7153
+    if (STOW_PROBE()) goto FAIL;
7107
 
7154
 
7108
     SERIAL_PROTOCOLPGM("Finished!");
7155
     SERIAL_PROTOCOLPGM("Finished!");
7109
     SERIAL_EOL();
7156
     SERIAL_EOL();
7125
     SERIAL_EOL();
7172
     SERIAL_EOL();
7126
     SERIAL_EOL();
7173
     SERIAL_EOL();
7127
 
7174
 
7175
+    FAIL:
7176
+
7128
     clean_up_after_endstop_or_probe_move();
7177
     clean_up_after_endstop_or_probe_move();
7129
 
7178
 
7130
     // Re-enable bed level correction if it had been on
7179
     // Re-enable bed level correction if it had been on
11452
   //       DELTA_PRINTABLE_RADIUS from center of bed, but delta
11501
   //       DELTA_PRINTABLE_RADIUS from center of bed, but delta
11453
   //       now enforces is_position_reachable for X/Y regardless
11502
   //       now enforces is_position_reachable for X/Y regardless
11454
   //       of HAS_SOFTWARE_ENDSTOPS, so that enforcement would be
11503
   //       of HAS_SOFTWARE_ENDSTOPS, so that enforcement would be
11455
-  //       redundant here.  Probably should #ifdef out the X/Y
11456
-  //       axis clamps here for delta and just leave the Z clamp.
11504
+  //       redundant here.
11457
 
11505
 
11458
   void clamp_to_software_endstops(float target[XYZ]) {
11506
   void clamp_to_software_endstops(float target[XYZ]) {
11459
     if (!soft_endstops_enabled) return;
11507
     if (!soft_endstops_enabled) return;
11460
     #if ENABLED(MIN_SOFTWARE_ENDSTOPS)
11508
     #if ENABLED(MIN_SOFTWARE_ENDSTOPS)
11461
-      NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]);
11462
-      NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]);
11509
+      #if DISABLED(DELTA)
11510
+        NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]);
11511
+        NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]);
11512
+      #endif
11463
       NOLESS(target[Z_AXIS], soft_endstop_min[Z_AXIS]);
11513
       NOLESS(target[Z_AXIS], soft_endstop_min[Z_AXIS]);
11464
     #endif
11514
     #endif
11465
     #if ENABLED(MAX_SOFTWARE_ENDSTOPS)
11515
     #if ENABLED(MAX_SOFTWARE_ENDSTOPS)
11466
-      NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]);
11467
-      NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]);
11516
+      #if DISABLED(DELTA)
11517
+        NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]);
11518
+        NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]);
11519
+      #endif
11468
       NOMORE(target[Z_AXIS], soft_endstop_max[Z_AXIS]);
11520
       NOMORE(target[Z_AXIS], soft_endstop_max[Z_AXIS]);
11469
     #endif
11521
     #endif
11470
   }
11522
   }

+ 5
- 5
Marlin/endstops.cpp View File

247
   #define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
247
   #define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
248
   #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
248
   #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
249
   #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
249
   #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
250
-  #define _ENDSTOP_HIT(AXIS) SBI(endstop_hit_bits, _ENDSTOP(AXIS, MIN))
250
+  #define _ENDSTOP_HIT(AXIS, MINMAX) SBI(endstop_hit_bits, _ENDSTOP(AXIS, MINMAX))
251
 
251
 
252
   // UPDATE_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
252
   // UPDATE_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
253
   #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
253
   #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
257
   #define UPDATE_ENDSTOP(AXIS,MINMAX) do { \
257
   #define UPDATE_ENDSTOP(AXIS,MINMAX) do { \
258
       UPDATE_ENDSTOP_BIT(AXIS, MINMAX); \
258
       UPDATE_ENDSTOP_BIT(AXIS, MINMAX); \
259
       if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && stepper.current_block->steps[_AXIS(AXIS)] > 0) { \
259
       if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && stepper.current_block->steps[_AXIS(AXIS)] > 0) { \
260
-        _ENDSTOP_HIT(AXIS); \
260
+        _ENDSTOP_HIT(AXIS, MINMAX); \
261
         stepper.endstop_triggered(_AXIS(AXIS)); \
261
         stepper.endstop_triggered(_AXIS(AXIS)); \
262
       } \
262
       } \
263
     } while(0)
263
     } while(0)
267
     if (G38_move) {
267
     if (G38_move) {
268
       UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
268
       UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
269
       if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
269
       if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
270
-        if      (stepper.current_block->steps[_AXIS(X)] > 0) { _ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X)); }
271
-        else if (stepper.current_block->steps[_AXIS(Y)] > 0) { _ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y)); }
272
-        else if (stepper.current_block->steps[_AXIS(Z)] > 0) { _ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z)); }
270
+        if      (stepper.current_block->steps[_AXIS(X)] > 0) { _ENDSTOP_HIT(X, MIN); stepper.endstop_triggered(_AXIS(X)); }
271
+        else if (stepper.current_block->steps[_AXIS(Y)] > 0) { _ENDSTOP_HIT(Y, MIN); stepper.endstop_triggered(_AXIS(Y)); }
272
+        else if (stepper.current_block->steps[_AXIS(Z)] > 0) { _ENDSTOP_HIT(Z, MIN); stepper.endstop_triggered(_AXIS(Z)); }
273
         G38_endstop_hit = true;
273
         G38_endstop_hit = true;
274
       }
274
       }
275
     }
275
     }

+ 16
- 1
Marlin/language_en.h View File

717
   #define MSG_DELTA_CALIBRATE_CENTER          _UxGT("Calibrate Center")
717
   #define MSG_DELTA_CALIBRATE_CENTER          _UxGT("Calibrate Center")
718
 #endif
718
 #endif
719
 #ifndef MSG_DELTA_SETTINGS
719
 #ifndef MSG_DELTA_SETTINGS
720
-  #define MSG_DELTA_SETTINGS                  _UxGT("Show Delta Settings")
720
+  #define MSG_DELTA_SETTINGS                  _UxGT("Delta Settings")
721
 #endif
721
 #endif
722
 #ifndef MSG_DELTA_AUTO_CALIBRATE
722
 #ifndef MSG_DELTA_AUTO_CALIBRATE
723
   #define MSG_DELTA_AUTO_CALIBRATE            _UxGT("Auto Calibration")
723
   #define MSG_DELTA_AUTO_CALIBRATE            _UxGT("Auto Calibration")
725
 #ifndef MSG_DELTA_HEIGHT_CALIBRATE
725
 #ifndef MSG_DELTA_HEIGHT_CALIBRATE
726
   #define MSG_DELTA_HEIGHT_CALIBRATE          _UxGT("Set Delta Height")
726
   #define MSG_DELTA_HEIGHT_CALIBRATE          _UxGT("Set Delta Height")
727
 #endif
727
 #endif
728
+#ifndef MSG_DELTA_DIAG_ROG
729
+  #define MSG_DELTA_DIAG_ROG                  _UxGT("Diag Rod")
730
+#endif
731
+#ifndef MSG_DELTA_HEIGHT
732
+  #define MSG_DELTA_HEIGHT                    _UxGT("Height")
733
+#endif
734
+#ifndef MSG_DELTA_RADIUS
735
+  #define MSG_DELTA_RADIUS                    _UxGT("Radius")
736
+#endif
728
 #ifndef MSG_INFO_MENU
737
 #ifndef MSG_INFO_MENU
729
   #define MSG_INFO_MENU                       _UxGT("About Printer")
738
   #define MSG_INFO_MENU                       _UxGT("About Printer")
730
 #endif
739
 #endif
840
 #ifndef MSG_FILAMENT_CHANGE_NOZZLE
849
 #ifndef MSG_FILAMENT_CHANGE_NOZZLE
841
   #define MSG_FILAMENT_CHANGE_NOZZLE          _UxGT("  Nozzle: ")
850
   #define MSG_FILAMENT_CHANGE_NOZZLE          _UxGT("  Nozzle: ")
842
 #endif
851
 #endif
852
+#ifndef MSG_ERR_HOMING_FAILED
853
+  #define MSG_ERR_HOMING_FAILED               _UxGT("Homing failed")
854
+#endif
855
+#ifndef MSG_ERR_PROBING_FAILED
856
+  #define MSG_ERR_PROBING_FAILED              _UxGT("Probing failed")
857
+#endif
843
 
858
 
844
 //
859
 //
845
 // Filament Change screens show up to 3 lines on a 4-line display
860
 // Filament Change screens show up to 3 lines on a 4-line display

+ 13
- 5
Marlin/ultralcd.cpp View File

2537
     void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); }
2537
     void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); }
2538
     void _goto_center()  { _man_probe_pt(0,0); }
2538
     void _goto_center()  { _man_probe_pt(0,0); }
2539
 
2539
 
2540
-    void lcd_delta_G33_settings() {
2540
+    static float _delta_height = DELTA_HEIGHT;
2541
+    void _lcd_set_delta_height() {
2542
+      home_offset[Z_AXIS] = _delta_height - DELTA_HEIGHT;
2543
+      update_software_endstops(Z_AXIS);
2544
+    }
2545
+
2546
+    void lcd_delta_settings() {
2541
       START_MENU();
2547
       START_MENU();
2542
       MENU_BACK(MSG_DELTA_CALIBRATE);
2548
       MENU_BACK(MSG_DELTA_CALIBRATE);
2543
-      float delta_height = DELTA_HEIGHT + home_offset[Z_AXIS], Tz = 0.00;
2544
-      MENU_ITEM_EDIT(float52, "Height", &delta_height, delta_height, delta_height);
2549
+      float Tz = 0.00;
2550
+      MENU_ITEM_EDIT(float52, MSG_DELTA_DIAG_ROG, &delta_diagonal_rod, DELTA_DIAGONAL_ROD - 5.0, DELTA_DIAGONAL_ROD + 5.0);
2551
+      _delta_height = DELTA_HEIGHT + home_offset[Z_AXIS];
2552
+      MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &_delta_height, _delta_height - 10.0, _delta_height + 10.0, _lcd_set_delta_height);
2545
       MENU_ITEM_EDIT(float43, "Ex", &endstop_adj[A_AXIS], -5.0, 5.0);
2553
       MENU_ITEM_EDIT(float43, "Ex", &endstop_adj[A_AXIS], -5.0, 5.0);
2546
       MENU_ITEM_EDIT(float43, "Ey", &endstop_adj[B_AXIS], -5.0, 5.0);
2554
       MENU_ITEM_EDIT(float43, "Ey", &endstop_adj[B_AXIS], -5.0, 5.0);
2547
       MENU_ITEM_EDIT(float43, "Ez", &endstop_adj[C_AXIS], -5.0, 5.0);
2555
       MENU_ITEM_EDIT(float43, "Ez", &endstop_adj[C_AXIS], -5.0, 5.0);
2548
-      MENU_ITEM_EDIT(float52, "Radius", &delta_radius, DELTA_RADIUS - 5.0, DELTA_RADIUS + 5.0);
2556
+      MENU_ITEM_EDIT(float52, MSG_DELTA_RADIUS, &delta_radius, DELTA_RADIUS - 5.0, DELTA_RADIUS + 5.0);
2549
       MENU_ITEM_EDIT(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5.0, 5.0);
2557
       MENU_ITEM_EDIT(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5.0, 5.0);
2550
       MENU_ITEM_EDIT(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5.0, 5.0);
2558
       MENU_ITEM_EDIT(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5.0, 5.0);
2551
       MENU_ITEM_EDIT(float43, "Tz", &Tz, -5.0, 5.0);
2559
       MENU_ITEM_EDIT(float43, "Tz", &Tz, -5.0, 5.0);
2556
       START_MENU();
2564
       START_MENU();
2557
       MENU_BACK(MSG_MAIN);
2565
       MENU_BACK(MSG_MAIN);
2558
       #if ENABLED(DELTA_AUTO_CALIBRATION)
2566
       #if ENABLED(DELTA_AUTO_CALIBRATION)
2559
-        MENU_ITEM(submenu, MSG_DELTA_SETTINGS, lcd_delta_G33_settings);
2567
+        MENU_ITEM(submenu, MSG_DELTA_SETTINGS, lcd_delta_settings);
2560
         MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
2568
         MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
2561
         MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 P1"));
2569
         MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 P1"));
2562
         #if ENABLED(EEPROM_SETTINGS)
2570
         #if ENABLED(EEPROM_SETTINGS)

Loading…
Cancel
Save