Browse Source

ABL at any points

Gabe Rosenhouse 11 years ago
parent
commit
34fd59c370
2 changed files with 63 additions and 2 deletions
  1. 16
    0
      Marlin/Configuration.h
  2. 47
    2
      Marlin/Marlin_main.cpp

+ 16
- 0
Marlin/Configuration.h View File

@@ -335,12 +335,28 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
335 335
 
336 336
 #ifdef ENABLE_AUTO_BED_LEVELING
337 337
 
338
+// Enable auto bed leveling at any 3 points that aren't colinear
339
+#define AUTO_BED_LEVELING_ANY_POINTS
340
+
341
+#ifdef AUTO_BED_LEVELING_ANY_POINTS
342
+  #define ABL_PROBE_PT_1_X -11
343
+  #define ABL_PROBE_PT_1_Y -15
344
+  #define ABL_PROBE_PT_2_X -11
345
+  #define ABL_PROBE_PT_2_Y 75
346
+  #define ABL_PROBE_PT_3_X 121
347
+  #define ABL_PROBE_PT_3_Y -15
348
+
349
+
350
+#else // not AUTO_BED_LEVELING_ANY_POINTS
351
+
338 352
   // these are the positions on the bed to do the probing
339 353
   #define LEFT_PROBE_BED_POSITION 15
340 354
   #define RIGHT_PROBE_BED_POSITION 170
341 355
   #define BACK_PROBE_BED_POSITION 180
342 356
   #define FRONT_PROBE_BED_POSITION 20
343 357
 
358
+#endif
359
+
344 360
   // these are the offsets to the probe relative to the extruder tip (Hotend - Probe)
345 361
   #define X_PROBE_OFFSET_FROM_EXTRUDER -25
346 362
   #define Y_PROBE_OFFSET_FROM_EXTRUDER -29

+ 47
- 2
Marlin/Marlin_main.cpp View File

@@ -846,7 +846,36 @@ static void set_bed_level_equation_lsq(double *plane_equation_coefficients)
846 846
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
847 847
 }
848 848
 
849
-#else
849
+#else // not ACCURATE_BED_LEVELING
850
+
851
+  #ifdef AUTO_BED_LEVELING_ANY_POINTS
852
+static void set_bed_level_equation_any_pts(float z_at_pt_1, float z_at_pt_2, float z_at_pt_3) {
853
+
854
+    plan_bed_level_matrix.set_to_identity();
855
+
856
+    vector_3 pt1 = vector_3(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, z_at_pt_1);
857
+    vector_3 pt2 = vector_3(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, z_at_pt_2);
858
+    vector_3 pt3 = vector_3(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, z_at_pt_3);
859
+
860
+    vector_3 from_2_to_1 = (pt1 - pt2).get_normal();
861
+    vector_3 from_2_to_3 = (pt3 - pt2).get_normal();
862
+    vector_3 planeNormal = vector_3::cross(from_2_to_1, from_2_to_3).get_normal();
863
+    planeNormal = vector_3(planeNormal.x, planeNormal.y, abs(planeNormal.z));
864
+
865
+    plan_bed_level_matrix = matrix_3x3::create_look_at(planeNormal);
866
+
867
+    vector_3 corrected_position = plan_get_position();
868
+    current_position[X_AXIS] = corrected_position.x;
869
+    current_position[Y_AXIS] = corrected_position.y;
870
+    current_position[Z_AXIS] = corrected_position.z;
871
+
872
+    // but the bed at 0 so we don't go below it.
873
+    current_position[Z_AXIS] = zprobe_zoffset;
874
+
875
+    plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
876
+
877
+}
878
+  #else // not AUTO_BED_LEVELING_ANY_POINTS
850 879
 static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yFront, float z_at_xLeft_yBack) {
851 880
     plan_bed_level_matrix.set_to_identity();
852 881
 
@@ -881,6 +910,7 @@ static void set_bed_level_equation(float z_at_xLeft_yFront, float z_at_xRight_yF
881 910
 
882 911
     plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
883 912
 }
913
+  #endif // AUTO_BED_LEVELING_ANY_POINTS
884 914
 #endif // ACCURATE_BED_LEVELING
885 915
 
886 916
 static void run_z_probe() {
@@ -1514,6 +1544,21 @@ void process_commands()
1514 1544
 #else // ACCURATE_BED_LEVELING not defined
1515 1545
 
1516 1546
 
1547
+  #ifdef AUTO_BED_LEVELING_ANY_POINTS
1548
+            // probe 1
1549
+            float z_at_pt_1 = probe_pt(ABL_PROBE_PT_1_X, ABL_PROBE_PT_1_Y, Z_RAISE_BEFORE_PROBING);
1550
+
1551
+            // probe 2
1552
+            float z_at_pt_2 = probe_pt(ABL_PROBE_PT_2_X, ABL_PROBE_PT_2_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1553
+
1554
+            // probe 3
1555
+            float z_at_pt_3 = probe_pt(ABL_PROBE_PT_3_X, ABL_PROBE_PT_3_Y, current_position[Z_AXIS] + Z_RAISE_BETWEEN_PROBINGS);
1556
+
1557
+            clean_up_after_endstop_move();
1558
+
1559
+            set_bed_level_equation_any_pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
1560
+  #else // not AUTO_BED_LEVELING_ANY_POINTS
1561
+
1517 1562
             // prob 1
1518 1563
             float z_at_xLeft_yBack = probe_pt(LEFT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION, Z_RAISE_BEFORE_PROBING);
1519 1564
 
@@ -1526,7 +1571,7 @@ void process_commands()
1526 1571
             clean_up_after_endstop_move();
1527 1572
 
1528 1573
             set_bed_level_equation(z_at_xLeft_yFront, z_at_xRight_yFront, z_at_xLeft_yBack);
1529
-
1574
+  #endif
1530 1575
 
1531 1576
 #endif // ACCURATE_BED_LEVELING
1532 1577
             st_synchronize();

Loading…
Cancel
Save