Selaa lähdekoodia

Do sanity checking on LRFB values

- Setting boundaries based on configured limits, contrasting with G28
(which forgets these limits?)
Scott Lahteine 10 vuotta sitten
vanhempi
commit
32744d41a9
2 muutettua tiedostoa jossa 56 lisäystä ja 15 poistoa
  1. 3
    3
      Marlin/Configuration.h
  2. 53
    12
      Marlin/Marlin_main.cpp

+ 3
- 3
Marlin/Configuration.h Näytä tiedosto

@@ -428,9 +428,9 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
428 428
 
429 429
   // these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
430 430
   // X and Y offsets must be integers
431
-  #define X_PROBE_OFFSET_FROM_EXTRUDER -25
432
-  #define Y_PROBE_OFFSET_FROM_EXTRUDER -29
433
-  #define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35
431
+  #define X_PROBE_OFFSET_FROM_EXTRUDER -25     // -left  +right
432
+  #define Y_PROBE_OFFSET_FROM_EXTRUDER -29     // -front +behind
433
+  #define Z_PROBE_OFFSET_FROM_EXTRUDER -12.35  // -below (always!)
434 434
 
435 435
   #define Z_RAISE_BEFORE_HOMING 4       // (in mm) Raise Z before homing (G28) for Probe Clearance.
436 436
                                         // Be sure you have this distance over your Z_MAX_POS in case

+ 53
- 12
Marlin/Marlin_main.cpp Näytä tiedosto

@@ -1669,10 +1669,10 @@ void process_commands()
1669 1669
                                                 // Let's see if X and Y are homed and probe is inside bed area.
1670 1670
           if(code_seen(axis_codes[Z_AXIS])) {
1671 1671
             if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \
1672
-              && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \
1673
-              && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \
1674
-              && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \
1675
-              && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) {
1672
+              && (current_position[X_AXIS] >= X_MIN_POS - X_PROBE_OFFSET_FROM_EXTRUDER) \
1673
+              && (current_position[X_AXIS] <= X_MAX_POS - X_PROBE_OFFSET_FROM_EXTRUDER) \
1674
+              && (current_position[Y_AXIS] >= Y_MIN_POS - Y_PROBE_OFFSET_FROM_EXTRUDER) \
1675
+              && (current_position[Y_AXIS] <= Y_MAX_POS - Y_PROBE_OFFSET_FROM_EXTRUDER)) {
1676 1676
 
1677 1677
               current_position[Z_AXIS] = 0;
1678 1678
               plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
@@ -1789,26 +1789,67 @@ void process_commands()
1789 1789
         if (code_seen('V') || code_seen('v')) {
1790 1790
           verbose_level = code_value();
1791 1791
           if (verbose_level < 0 || verbose_level > 4) {
1792
-            SERIAL_PROTOCOLPGM("?Verbose Level not plausible (0-4).\n");
1792
+            SERIAL_PROTOCOLPGM("?(V)erbose Level is implausible (0-4).\n");
1793 1793
             break;
1794 1794
           }
1795 1795
           if (verbose_level > 0) {
1796
-            SERIAL_PROTOCOLPGM("Enhanced G29 Auto_Bed_Leveling Code V1.25:\n");
1797
-            SERIAL_PROTOCOLPGM("Full support at http://3dprintboard.com\n");
1796
+            SERIAL_PROTOCOLPGM("G29 Enhanced Auto Bed Leveling Code V1.25:\n");
1797
+            SERIAL_PROTOCOLPGM("Full support at: http://3dprintboard.com/forum.php\n");
1798 1798
             if (verbose_level > 2) topo_flag = true;
1799 1799
           }
1800 1800
         }
1801 1801
 
1802 1802
         int auto_bed_leveling_grid_points = code_seen('P') ? code_value_long() : AUTO_BED_LEVELING_GRID_POINTS;
1803 1803
         if (auto_bed_leveling_grid_points < 2 || auto_bed_leveling_grid_points > AUTO_BED_LEVELING_GRID_POINTS) {
1804
-          SERIAL_PROTOCOLPGM("?Number of probed points not plausible (2 minimum).\n");
1804
+          SERIAL_PROTOCOLPGM("?Number of probed (P)oints is implausible (2 minimum).\n");
1805 1805
           break;
1806 1806
         }
1807 1807
 
1808
-        int left_probe_bed_position = code_seen('L') ? code_value_long() : LEFT_PROBE_BED_POSITION;
1809
-        int right_probe_bed_position = code_seen('R') ? code_value_long() : RIGHT_PROBE_BED_POSITION;
1810
-        int back_probe_bed_position = code_seen('B') ? code_value_long() : BACK_PROBE_BED_POSITION;
1811
-        int front_probe_bed_position = code_seen('F') ? code_value_long() : FRONT_PROBE_BED_POSITION;
1808
+        // Define the possible boundaries for probing based on the set limits.
1809
+        // Code above (in G28) might have these limits wrong, or I am wrong here.
1810
+        #define MIN_PROBE_EDGE 10 // Edges of the probe square can be no less
1811
+        const int min_probe_x = max(X_MIN, X_MIN + X_PROBE_OFFSET_FROM_EXTRUDER),
1812
+                  max_probe_x = min(X_MAX, X_MAX + X_PROBE_OFFSET_FROM_EXTRUDER);
1813
+                  min_probe_y = max(Y_MIN, Y_MIN + Y_PROBE_OFFSET_FROM_EXTRUDER);
1814
+                  max_probe_y = min(Y_MAX, Y_MAX + Y_PROBE_OFFSET_FROM_EXTRUDER);
1815
+
1816
+        int left_probe_bed_position = code_seen('L') ? code_value_long() : LEFT_PROBE_BED_POSITION,
1817
+            right_probe_bed_position = code_seen('R') ? code_value_long() : RIGHT_PROBE_BED_POSITION,
1818
+            front_probe_bed_position = code_seen('F') ? code_value_long() : FRONT_PROBE_BED_POSITION,
1819
+            back_probe_bed_position = code_seen('B') ? code_value_long() : BACK_PROBE_BED_POSITION;
1820
+
1821
+        bool left_out_l = left_probe_bed_position < min_probe_x,
1822
+             left_out_r = left_probe_bed_position > right_probe_bed_position - MIN_PROBE_EDGE,
1823
+             left_out = left_out_l || left_out_r,
1824
+             right_out_r = right_probe_bed_position > max_probe_x,
1825
+             right_out_l =right_probe_bed_position < left_probe_bed_position + MIN_PROBE_EDGE,
1826
+             right_out = right_out_l || right_out_r,
1827
+             front_out_f = front_probe_bed_position < min_probe_y,
1828
+             front_out_b = front_probe_bed_position > back_probe_bed_position - MIN_PROBE_EDGE,
1829
+             front_out = front_out_f || front_out_b,
1830
+             back_out_b = back_probe_bed_position > max_probe_y,
1831
+             back_out_f = back_probe_bed_position < front_probe_bed_position + MIN_PROBE_EDGE,
1832
+             back_out = back_out_f || back_out_b;
1833
+
1834
+        if (left_out || right_out || front_out || back_out) {
1835
+          if (left_out) {
1836
+            SERIAL_PROTOCOLPGM("?Probe (L)eft position out of range.\n");
1837
+            left_probe_bed_position = left_out_l ? min_probe_x : right_probe_bed_position - MIN_PROBE_EDGE;
1838
+          }
1839
+          if (right_out) {
1840
+            SERIAL_PROTOCOLPGM("?Probe (R)ight position out of range.\n");
1841
+            right_probe_bed_position = right_out_r ? max_probe_x : left_probe_bed_position + MIN_PROBE_EDGE;
1842
+          }
1843
+          if (front_out) {
1844
+            SERIAL_PROTOCOLPGM("?Probe (F)ront position out of range.\n");
1845
+            front_probe_bed_position = front_out_f ? min_probe_y : back_probe_bed_position - MIN_PROBE_EDGE;
1846
+          }
1847
+          if (back_out) {
1848
+            SERIAL_PROTOCOLPGM("?Probe (B)ack position out of range.\n");
1849
+            back_probe_bed_position = back_out_b ? max_probe_y : front_probe_bed_position + MIN_PROBE_EDGE;
1850
+          }
1851
+          break;
1852
+        }
1812 1853
 
1813 1854
       #endif
1814 1855
 

Loading…
Peruuta
Tallenna