Browse Source

Merge pull request #4918 from thinkyhead/rc_abl_patchups

Fix up ABL - Add PROBE_Y_FIRST option. Arduino 1.6.8 required.
Scott Lahteine 8 years ago
parent
commit
3bbdd48a4d
30 changed files with 264 additions and 92 deletions
  1. 6
    1
      Marlin/Conditionals_post.h
  2. 3
    0
      Marlin/Configuration.h
  3. 169
    78
      Marlin/Marlin_main.cpp
  4. 2
    2
      Marlin/SanityCheck.h
  5. 2
    0
      Marlin/enum.h
  6. 3
    0
      Marlin/example_configurations/Cartesio/Configuration.h
  7. 3
    0
      Marlin/example_configurations/Felix/Configuration.h
  8. 3
    0
      Marlin/example_configurations/Felix/DUAL/Configuration.h
  9. 3
    0
      Marlin/example_configurations/Hephestos/Configuration.h
  10. 3
    0
      Marlin/example_configurations/Hephestos_2/Configuration.h
  11. 3
    0
      Marlin/example_configurations/K8200/Configuration.h
  12. 3
    0
      Marlin/example_configurations/K8400/Configuration.h
  13. 3
    0
      Marlin/example_configurations/K8400/Dual-head/Configuration.h
  14. 3
    0
      Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h
  15. 3
    0
      Marlin/example_configurations/RigidBot/Configuration.h
  16. 3
    0
      Marlin/example_configurations/SCARA/Configuration.h
  17. 3
    0
      Marlin/example_configurations/TAZ4/Configuration.h
  18. 3
    0
      Marlin/example_configurations/WITBOX/Configuration.h
  19. 3
    0
      Marlin/example_configurations/adafruit/ST7565/Configuration.h
  20. 3
    0
      Marlin/example_configurations/delta/biv2.5/Configuration.h
  21. 3
    0
      Marlin/example_configurations/delta/generic/Configuration.h
  22. 3
    0
      Marlin/example_configurations/delta/kossel_mini/Configuration.h
  23. 3
    0
      Marlin/example_configurations/delta/kossel_pro/Configuration.h
  24. 3
    0
      Marlin/example_configurations/delta/kossel_xl/Configuration.h
  25. 3
    0
      Marlin/example_configurations/makibox/Configuration.h
  26. 3
    0
      Marlin/example_configurations/tvrrug/Round2/Configuration.h
  27. 7
    6
      Marlin/planner.cpp
  28. 5
    5
      Marlin/planner.h
  29. 6
    0
      Marlin/stepper.cpp
  30. 1
    0
      Marlin/stepper.h

+ 6
- 1
Marlin/Conditionals_post.h View File

@@ -648,8 +648,13 @@
648 648
   #define ABL_GRID   (ENABLED(AUTO_BED_LEVELING_LINEAR) || ENABLED(AUTO_BED_LEVELING_BILINEAR))
649 649
   #define HAS_ABL    (ABL_PLANAR || ABL_GRID)
650 650
 
651
-  #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
652 651
   #define PLANNER_LEVELING      (HAS_ABL || ENABLED(MESH_BED_LEVELING))
652
+  #define HAS_PROBING_PROCEDURE (HAS_ABL || ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST))
653
+
654
+  #if HAS_PROBING_PROCEDURE
655
+    #define PROBE_BED_WIDTH abs(RIGHT_PROBE_BED_POSITION - (LEFT_PROBE_BED_POSITION))
656
+    #define PROBE_BED_HEIGHT abs(BACK_PROBE_BED_POSITION - (FRONT_PROBE_BED_POSITION))
657
+  #endif
653 658
 
654 659
   /**
655 660
    * Buzzer/Speaker

+ 3
- 0
Marlin/Configuration.h View File

@@ -789,6 +789,9 @@
789 789
   // The Z probe minimum outer margin (to validate G29 parameters).
790 790
   #define MIN_PROBE_EDGE 10
791 791
 
792
+  // Probe along the Y axis, advancing X after each column
793
+  //#define PROBE_Y_FIRST
794
+
792 795
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
793 796
 
794 797
   // 3 arbitrary points to probe.

+ 169
- 78
Marlin/Marlin_main.cpp View File

@@ -225,7 +225,7 @@
225 225
  * M406 - Disable Filament Sensor flow control. (Requires FILAMENT_WIDTH_SENSOR)
226 226
  * M407 - Display measured filament diameter in millimeters. (Requires FILAMENT_WIDTH_SENSOR)
227 227
  * M410 - Quickstop. Abort all planned moves.
228
- * M420 - Enable/Disable Mesh Leveling (with current values) S1=enable S0=disable (Requires MESH_BED_LEVELING)
228
+ * M420 - Enable/Disable Leveling (with current values) S1=enable S0=disable (Requires MESH_BED_LEVELING or ABL)
229 229
  * M421 - Set a single Z coordinate in the Mesh Leveling grid. X<units> Y<units> Z<units> (Requires MESH_BED_LEVELING)
230 230
  * M428 - Set the home_offset based on the current_position. Nearest edge applies.
231 231
  * M500 - Store parameters in EEPROM. (Requires EEPROM_SETTINGS)
@@ -2027,6 +2027,12 @@ static void clean_up_after_endstop_or_probe_move() {
2027 2027
       // Do a first probe at the fast speed
2028 2028
       do_probe_move(-(Z_MAX_LENGTH) - 10, Z_PROBE_SPEED_FAST);
2029 2029
 
2030
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2031
+        float first_probe_z = current_position[Z_AXIS];
2032
+        if (DEBUGGING(LEVELING))
2033
+          SERIAL_ECHOPAIR("1st Probe Z:", first_probe_z);
2034
+      #endif
2035
+
2030 2036
       // move up by the bump distance
2031 2037
       do_blocking_move_to_z(current_position[Z_AXIS] + home_bump_mm(Z_AXIS), MMM_TO_MMS(Z_PROBE_SPEED_FAST));
2032 2038
 
@@ -2047,6 +2053,13 @@ static void clean_up_after_endstop_or_probe_move() {
2047 2053
       if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
2048 2054
     #endif
2049 2055
 
2056
+    // Debug: compare probe heights
2057
+    #if ENABLED(PROBE_DOUBLE_TOUCH) && ENABLED(DEBUG_LEVELING_FEATURE)
2058
+      if (DEBUGGING(LEVELING)) {
2059
+        SERIAL_ECHOPAIR("2nd Probe Z:", current_position[Z_AXIS]);
2060
+        SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
2061
+      }
2062
+    #endif
2050 2063
     return current_position[Z_AXIS];
2051 2064
   }
2052 2065
 
@@ -2119,30 +2132,69 @@ static void clean_up_after_endstop_or_probe_move() {
2119 2132
 
2120 2133
 #endif // HAS_BED_PROBE
2121 2134
 
2122
-#if HAS_ABL
2135
+#if PLANNER_LEVELING
2136
+  /**
2137
+   * Turn bed leveling on or off, fixing the current
2138
+   * position as-needed.
2139
+   *
2140
+   * Disable: Current position = physical position
2141
+   *  Enable: Current position = "unleveled" physical position
2142
+   */
2143
+  void set_bed_leveling_enabled(bool enable=true) {
2144
+    #if ENABLED(MESH_BED_LEVELING)
2145
+
2146
+      if (!enable && mbl.active())
2147
+        current_position[Z_AXIS] +=
2148
+          mbl.get_z(RAW_CURRENT_POSITION(X_AXIS), RAW_CURRENT_POSITION(Y_AXIS)) - (MESH_HOME_SEARCH_Z);
2149
+
2150
+      mbl.set_active(enable && mbl.has_mesh()); // was set_has_mesh(). Is this not correct?
2151
+
2152
+    #elif HAS_ABL
2153
+
2154
+      if (enable != planner.abl_enabled) {
2155
+        planner.abl_enabled = !planner.abl_enabled;
2156
+        if (!planner.abl_enabled)
2157
+          set_current_from_steppers_for_axis(
2158
+            #if ABL_PLANAR
2159
+              ALL_AXES
2160
+            #else
2161
+              Z_AXIS
2162
+            #endif
2163
+          );
2164
+        else
2165
+          planner.unapply_leveling(current_position);
2166
+      }
2167
+
2168
+    #endif
2169
+  }
2170
+
2123 2171
 
2124 2172
   /**
2125 2173
    * Reset calibration results to zero.
2126
-   *
2127
-   * TODO: Proper functions to disable / enable
2128
-   *       bed leveling via a flag, correcting the
2129
-   *       current position in each case.
2130 2174
    */
2131 2175
   void reset_bed_level() {
2132
-    planner.abl_enabled = false;
2133
-    #if ENABLED(DEBUG_LEVELING_FEATURE)
2134
-      if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
2135
-    #endif
2136
-    #if ABL_PLANAR
2137
-      planner.bed_level_matrix.set_to_identity();
2138
-    #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
2139
-      for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++)
2140
-        for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++)
2141
-          bed_level_grid[x][y] = 1000.0;
2176
+    #if ENABLED(MESH_BED_LEVELING)
2177
+      if (mbl.has_mesh()) {
2178
+        set_bed_leveling_enabled(false);
2179
+        mbl.reset();
2180
+        mbl.set_has_mesh(false);
2181
+      }
2182
+    #else
2183
+      planner.abl_enabled = false;
2184
+      #if ENABLED(DEBUG_LEVELING_FEATURE)
2185
+        if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("reset_bed_level");
2186
+      #endif
2187
+      #if ABL_PLANAR
2188
+        planner.bed_level_matrix.set_to_identity();
2189
+      #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
2190
+        for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++)
2191
+          for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++)
2192
+            bed_level_grid[x][y] = 1000.0;
2193
+      #endif
2142 2194
     #endif
2143 2195
   }
2144 2196
 
2145
-#endif // HAS_ABL
2197
+#endif // PLANNER_LEVELING
2146 2198
 
2147 2199
 #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
2148 2200
 
@@ -2160,7 +2212,7 @@ static void clean_up_after_endstop_or_probe_move() {
2160 2212
         if (y < 10) SERIAL_CHAR(' ');
2161 2213
         SERIAL_ECHO((int)y);
2162 2214
         SERIAL_CHAR(ydir ? (ydir > 0 ? '+' : '-') : ' ');
2163
-        SERIAL_CHAR(']');
2215
+        SERIAL_ECHOLN(']');
2164 2216
       }
2165 2217
     #endif
2166 2218
     if (bed_level_grid[x][y] < 999.0) {
@@ -2247,7 +2299,7 @@ static void clean_up_after_endstop_or_probe_move() {
2247 2299
    */
2248 2300
   static void print_bed_level() {
2249 2301
     SERIAL_ECHOPGM("Bilinear Leveling Grid:\n ");
2250
-    for (uint8_t x = 1; x < ABL_GRID_POINTS_X + 1; x++) {
2302
+    for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++) {
2251 2303
       SERIAL_PROTOCOLPGM("    ");
2252 2304
       if (x < 10) SERIAL_PROTOCOLCHAR(' ');
2253 2305
       SERIAL_PROTOCOL((int)x);
@@ -2255,7 +2307,7 @@ static void clean_up_after_endstop_or_probe_move() {
2255 2307
     SERIAL_EOL;
2256 2308
     for (uint8_t y = 0; y < ABL_GRID_POINTS_Y; y++) {
2257 2309
       if (y < 9) SERIAL_PROTOCOLCHAR(' ');
2258
-      SERIAL_PROTOCOL(y + 1);
2310
+      SERIAL_PROTOCOL(y);
2259 2311
       for (uint8_t x = 0; x < ABL_GRID_POINTS_X; x++) {
2260 2312
         SERIAL_PROTOCOLCHAR(' ');
2261 2313
         float offset = bed_level_grid[x][y];
@@ -3583,24 +3635,31 @@ inline void gcode_G28() {
3583 3635
 
3584 3636
     #if ABL_GRID
3585 3637
 
3586
-      #if ABL_PLANAR
3587
-        bool do_topography_map = verbose_level > 2 || code_seen('T');
3588
-      #endif
3589
-
3590 3638
       if (verbose_level > 0) {
3591 3639
         SERIAL_PROTOCOLLNPGM("G29 Auto Bed Leveling");
3592 3640
         if (dryrun) SERIAL_PROTOCOLLNPGM("Running in DRY-RUN mode");
3593 3641
       }
3594 3642
 
3595
-      int abl_grid_points_x = ABL_GRID_POINTS_X,
3596
-          abl_grid_points_y = ABL_GRID_POINTS_Y;
3597
-
3598 3643
       #if ABL_PLANAR
3644
+
3645
+        bool do_topography_map = verbose_level > 2 || code_seen('T');
3646
+
3647
+        // X and Y specify points in each direction, overriding the default
3648
+        // These values may be saved with the completed mesh
3649
+        int abl_grid_points_x = code_seen('X') ? code_value_int() : ABL_GRID_POINTS_X,
3650
+            abl_grid_points_y = code_seen('Y') ? code_value_int() : ABL_GRID_POINTS_Y;
3651
+
3599 3652
         if (code_seen('P')) abl_grid_points_x = abl_grid_points_y = code_value_int();
3600
-        if (abl_grid_points_x < 2) {
3601
-          SERIAL_PROTOCOLLNPGM("?Number of probed (P)oints is implausible (2 minimum).");
3653
+
3654
+        if (abl_grid_points_x < 2 || abl_grid_points_y < 2) {
3655
+          SERIAL_PROTOCOLLNPGM("?Number of probe points is implausible (2 minimum).");
3602 3656
           return;
3603 3657
         }
3658
+
3659
+      #else
3660
+
3661
+         const int abl_grid_points_x = ABL_GRID_POINTS_X, abl_grid_points_y = ABL_GRID_POINTS_Y;
3662
+
3604 3663
       #endif
3605 3664
 
3606 3665
       xy_probe_feedrate_mm_s = MMM_TO_MMS(code_seen('S') ? code_value_linear_units() : XY_PROBE_SPEED);
@@ -3651,11 +3710,10 @@ inline void gcode_G28() {
3651 3710
     if (!dryrun) {
3652 3711
       // Re-orient the current position without leveling
3653 3712
       // based on where the steppers are positioned.
3654
-      get_cartesian_from_steppers();
3655
-      memcpy(current_position, cartes, sizeof(cartes));
3713
+      set_current_from_steppers_for_axis(ALL_AXES);
3656 3714
 
3657
-      // Inform the planner about the new coordinates
3658
-      SYNC_PLAN_POSITION_KINEMATIC();
3715
+      // Sync the planner to where the steppers stopped
3716
+      planner.sync_from_steppers();
3659 3717
     }
3660 3718
 
3661 3719
     setup_for_endstop_or_probe_move();
@@ -3713,30 +3771,48 @@ inline void gcode_G28() {
3713 3771
 
3714 3772
       #endif // AUTO_BED_LEVELING_LINEAR
3715 3773
 
3716
-      bool zig = abl_grid_points_y & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
3774
+      #if ENABLED(PROBE_Y_FIRST)
3775
+        #define PR_OUTER_VAR xCount
3776
+        #define PR_OUTER_END abl_grid_points_x
3777
+        #define PR_INNER_VAR yCount
3778
+        #define PR_INNER_END abl_grid_points_y
3779
+      #else
3780
+        #define PR_OUTER_VAR yCount
3781
+        #define PR_OUTER_END abl_grid_points_y
3782
+        #define PR_INNER_VAR xCount
3783
+        #define PR_INNER_END abl_grid_points_x
3784
+      #endif
3717 3785
 
3718
-      for (uint8_t yCount = 0; yCount < abl_grid_points_y; yCount++) {
3719
-        float yBase = front_probe_bed_position + yGridSpacing * yCount;
3720
-        yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
3786
+      #if ENABLED(MAKERARM_SCARA)
3787
+        bool zig = true;
3788
+      #else
3789
+        bool zig = PR_OUTER_END & 1; //always end at [RIGHT_PROBE_BED_POSITION, BACK_PROBE_BED_POSITION]
3790
+      #endif
3791
+
3792
+      for (uint8_t PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_END; PR_OUTER_VAR++) {
3721 3793
 
3722
-        int8_t xStart, xStop, xInc;
3794
+        int8_t inStart, inStop, inInc;
3723 3795
 
3724 3796
         if (zig) {
3725
-          xStart = 0;
3726
-          xStop = abl_grid_points_x;
3727
-          xInc = 1;
3797
+          inStart = 0;
3798
+          inStop = PR_INNER_END;
3799
+          inInc = 1;
3728 3800
         }
3729 3801
         else {
3730
-          xStart = abl_grid_points_x - 1;
3731
-          xStop = -1;
3732
-          xInc = -1;
3802
+          inStart = PR_INNER_END - 1;
3803
+          inStop = -1;
3804
+          inInc = -1;
3733 3805
         }
3734 3806
 
3735 3807
         zig = !zig;
3736 3808
 
3737
-        for (int8_t xCount = xStart; xCount != xStop; xCount += xInc) {
3738
-          float xBase = left_probe_bed_position + xGridSpacing * xCount;
3809
+        for (int8_t PR_INNER_VAR = inStart; PR_INNER_VAR != inStop; PR_INNER_VAR += inInc) {
3810
+
3811
+          float xBase = left_probe_bed_position + xGridSpacing * xCount,
3812
+                yBase = front_probe_bed_position + yGridSpacing * yCount;
3813
+
3739 3814
           xProbe = floor(xBase + (xBase < 0 ? 0 : 0.5));
3815
+          yProbe = floor(yBase + (yBase < 0 ? 0 : 0.5));
3740 3816
 
3741 3817
           #if ENABLED(AUTO_BED_LEVELING_LINEAR)
3742 3818
             indexIntoAB[xCount][yCount] = ++probePointCounter;
@@ -3992,9 +4068,6 @@ inline void gcode_G28() {
3992 4068
         #if ENABLED(DEBUG_LEVELING_FEATURE)
3993 4069
           if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
3994 4070
         #endif
3995
-
3996
-        SYNC_PLAN_POSITION_KINEMATIC();
3997
-        abl_should_enable = true;
3998 4071
       }
3999 4072
 
4000 4073
     #elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
@@ -4004,14 +4077,13 @@ inline void gcode_G28() {
4004 4077
           if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
4005 4078
         #endif
4006 4079
 
4080
+        // Unapply the offset because it is going to be immediately applied
4081
+        // and cause compensation movement in Z
4007 4082
         current_position[Z_AXIS] -= bilinear_z_offset(current_position);
4008 4083
 
4009 4084
         #if ENABLED(DEBUG_LEVELING_FEATURE)
4010 4085
           if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
4011 4086
         #endif
4012
-
4013
-        SYNC_PLAN_POSITION_KINEMATIC();
4014
-        abl_should_enable = true;
4015 4087
       }
4016 4088
 
4017 4089
     #endif // ABL_PLANAR
@@ -4034,6 +4106,9 @@ inline void gcode_G28() {
4034 4106
 
4035 4107
     // Auto Bed Leveling is complete! Enable if possible.
4036 4108
     planner.abl_enabled = dryrun ? abl_should_enable : true;
4109
+
4110
+    if (planner.abl_enabled)
4111
+      SYNC_PLAN_POSITION_KINEMATIC();
4037 4112
   }
4038 4113
 
4039 4114
 #endif // HAS_ABL
@@ -4045,13 +4120,13 @@ inline void gcode_G28() {
4045 4120
    */
4046 4121
   inline void gcode_G30() {
4047 4122
 
4048
-    #if HAS_ABL
4049
-      reset_bed_level();
4123
+    // Disable leveling so the planner won't mess with us
4124
+    #if PLANNER_LEVELING
4125
+      set_bed_leveling_enabled(false);
4050 4126
     #endif
4051 4127
 
4052 4128
     setup_for_endstop_or_probe_move();
4053 4129
 
4054
-    // TODO: clear the leveling matrix or the planner will be set incorrectly
4055 4130
     float measured_z = probe_pt(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
4056 4131
                                 current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
4057 4132
                                 true, 1);
@@ -5380,8 +5455,8 @@ static void report_current_position() {
5380 5455
   stepper.report_positions();
5381 5456
 
5382 5457
   #if IS_SCARA
5383
-    SERIAL_PROTOCOLPAIR("SCARA Theta:", stepper.get_axis_position_mm(A_AXIS));
5384
-    SERIAL_PROTOCOLLNPAIR("   Psi+Theta:", stepper.get_axis_position_mm(B_AXIS));
5458
+    SERIAL_PROTOCOLPAIR("SCARA Theta:", stepper.get_axis_position_degrees(A_AXIS));
5459
+    SERIAL_PROTOCOLLNPAIR("   Psi+Theta:", stepper.get_axis_position_degrees(B_AXIS));
5385 5460
     SERIAL_EOL;
5386 5461
   #endif
5387 5462
 }
@@ -6260,12 +6335,14 @@ void quickstop_stepper() {
6260 6335
   SYNC_PLAN_POSITION_KINEMATIC();
6261 6336
 }
6262 6337
 
6263
-#if ENABLED(MESH_BED_LEVELING)
6264
-
6338
+#if PLANNER_LEVELING
6265 6339
   /**
6266
-   * M420: Enable/Disable Mesh Bed Leveling
6340
+   * M420: Enable/Disable Bed Leveling
6267 6341
    */
6268
-  inline void gcode_M420() { if (code_seen('S')) mbl.set_has_mesh(code_value_bool()); }
6342
+  inline void gcode_M420() { if (code_seen('S')) set_bed_leveling_enabled(code_value_bool()); }
6343
+#endif
6344
+
6345
+#if ENABLED(MESH_BED_LEVELING)
6269 6346
 
6270 6347
   /**
6271 6348
    * M421: Set a single Mesh Bed Leveling Z coordinate
@@ -7291,11 +7368,11 @@ void process_next_command() {
7291 7368
         gcode_G28();
7292 7369
         break;
7293 7370
 
7294
-      #if HAS_ABL || ENABLED(MESH_BED_LEVELING)
7371
+      #if PLANNER_LEVELING
7295 7372
         case 29: // G29 Detailed Z probe, probes the bed at 3 or more points.
7296 7373
           gcode_G29();
7297 7374
           break;
7298
-      #endif // HAS_ABL
7375
+      #endif // PLANNER_LEVELING
7299 7376
 
7300 7377
       #if HAS_BED_PROBE
7301 7378
 
@@ -7945,36 +8022,50 @@ void ok_to_send() {
7945 8022
           ratio_y = y / bilinear_grid_spacing[Y_AXIS];
7946 8023
 
7947 8024
     // Whole unit is the grid box index
7948
-    int gridx = constrain(int(ratio_x), 0, ABL_GRID_POINTS_X - 2),
7949
-        gridy = constrain(int(ratio_y), 0, ABL_GRID_POINTS_Y - 2);
8025
+    const int gridx = constrain(floor(ratio_x), 0, ABL_GRID_POINTS_X - 2),
8026
+              gridy = constrain(floor(ratio_y), 0, ABL_GRID_POINTS_Y - 2),
8027
+              nextx = gridx + (x < PROBE_BED_WIDTH ? 1 : 0),
8028
+              nexty = gridy + (y < PROBE_BED_HEIGHT ? 1 : 0);
7950 8029
 
7951 8030
     // Subtract whole to get the ratio within the grid box
7952
-    ratio_x -= gridx, ratio_y -= gridy;
8031
+    ratio_x = constrain(ratio_x - gridx, 0.0, 1.0);
8032
+    ratio_y = constrain(ratio_y - gridy, 0.0, 1.0);
7953 8033
 
7954
-          // Z at the box corners
7955
-    const float z1 = bed_level_grid[gridx][gridy],         // left-front
7956
-                z2 = bed_level_grid[gridx][gridy + 1],     // left-back
7957
-                z3 = bed_level_grid[gridx + 1][gridy],     // right-front
7958
-                z4 = bed_level_grid[gridx + 1][gridy + 1], // right-back
8034
+    // Z at the box corners
8035
+    const float z1 = bed_level_grid[gridx][gridy],  // left-front
8036
+                z2 = bed_level_grid[gridx][nexty],  // left-back
8037
+                z3 = bed_level_grid[nextx][gridy],  // right-front
8038
+                z4 = bed_level_grid[nextx][nexty],  // right-back
7959 8039
 
8040
+                // Bilinear interpolate
7960 8041
                 L = z1 + (z2 - z1) * ratio_y,   // Linear interp. LF -> LB
7961
-                R = z3 + (z4 - z3) * ratio_y;   // Linear interp. RF -> RB
8042
+                R = z3 + (z4 - z3) * ratio_y,   // Linear interp. RF -> RB
8043
+                offset = L + ratio_x * (R - L);
7962 8044
 
7963 8045
     /*
7964
-      SERIAL_ECHOPAIR("gridx=", gridx);
7965
-      SERIAL_ECHOPAIR(" gridy=", gridy);
8046
+    static float last_offset = 0;
8047
+    if (fabs(last_offset - offset) > 0.2) {
8048
+      SERIAL_ECHOPGM("Sudden Shift at ");
8049
+      SERIAL_ECHOPAIR("x=", x);
8050
+      SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[X_AXIS]);
8051
+      SERIAL_ECHOLNPAIR(" -> gridx=", gridx);
8052
+      SERIAL_ECHOPAIR(" y=", y);
8053
+      SERIAL_ECHOPAIR(" / ", bilinear_grid_spacing[Y_AXIS]);
8054
+      SERIAL_ECHOLNPAIR(" -> gridy=", gridy);
7966 8055
       SERIAL_ECHOPAIR(" ratio_x=", ratio_x);
7967
-      SERIAL_ECHOPAIR(" ratio_y=", ratio_y);
8056
+      SERIAL_ECHOLNPAIR(" ratio_y=", ratio_y);
7968 8057
       SERIAL_ECHOPAIR(" z1=", z1);
7969 8058
       SERIAL_ECHOPAIR(" z2=", z2);
7970 8059
       SERIAL_ECHOPAIR(" z3=", z3);
7971
-      SERIAL_ECHOPAIR(" z4=", z4);
8060
+      SERIAL_ECHOLNPAIR(" z4=", z4);
7972 8061
       SERIAL_ECHOPAIR(" L=", L);
7973 8062
       SERIAL_ECHOPAIR(" R=", R);
7974
-      SERIAL_ECHOPAIR(" offset=", L + ratio_x * (R - L));
8063
+      SERIAL_ECHOLNPAIR(" offset=", offset);
8064
+    }
8065
+    last_offset = offset;
7975 8066
     //*/
7976 8067
 
7977
-    return L + ratio_x * (R - L);
8068
+    return offset;
7978 8069
   }
7979 8070
 
7980 8071
 #endif // AUTO_BED_LEVELING_BILINEAR

+ 2
- 2
Marlin/SanityCheck.h View File

@@ -30,8 +30,8 @@
30 30
  * Due to the high number of issues related with old versions of Arduino IDE
31 31
  * we now prevent Marlin from compiling with older toolkits.
32 32
  */
33
-#if !defined(ARDUINO) || ARDUINO < 10600
34
-  #error "Versions of Arduino IDE prior to 1.6.0 are no longer supported, please update your toolkit."
33
+#if !defined(ARDUINO) || ARDUINO < 10608
34
+  #error "Versions of Arduino IDE prior to 1.6.8 are no longer supported, please update your toolkit."
35 35
 #endif
36 36
 
37 37
 /**

+ 2
- 0
Marlin/enum.h View File

@@ -23,6 +23,8 @@
23 23
 #ifndef __ENUM_H__
24 24
 #define __ENUM_H__
25 25
 
26
+#include "MarlinConfig.h"
27
+
26 28
 /**
27 29
  * Axis indices as enumerated constants
28 30
  *

+ 3
- 0
Marlin/example_configurations/Cartesio/Configuration.h View File

@@ -789,6 +789,9 @@
789 789
   // The Z probe minimum outer margin (to validate G29 parameters).
790 790
   #define MIN_PROBE_EDGE 10
791 791
 
792
+  // Probe along the Y axis, advancing X after each column
793
+  //#define PROBE_Y_FIRST
794
+
792 795
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
793 796
 
794 797
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/Felix/Configuration.h View File

@@ -772,6 +772,9 @@
772 772
   // The Z probe minimum outer margin (to validate G29 parameters).
773 773
   #define MIN_PROBE_EDGE 10
774 774
 
775
+  // Probe along the Y axis, advancing X after each column
776
+  //#define PROBE_Y_FIRST
777
+
775 778
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
776 779
 
777 780
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/Felix/DUAL/Configuration.h View File

@@ -770,6 +770,9 @@
770 770
   // The Z probe minimum outer margin (to validate G29 parameters).
771 771
   #define MIN_PROBE_EDGE 10
772 772
 
773
+  // Probe along the Y axis, advancing X after each column
774
+  //#define PROBE_Y_FIRST
775
+
773 776
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
774 777
 
775 778
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/Hephestos/Configuration.h View File

@@ -781,6 +781,9 @@
781 781
   // The Z probe minimum outer margin (to validate G29 parameters).
782 782
   #define MIN_PROBE_EDGE 10
783 783
 
784
+  // Probe along the Y axis, advancing X after each column
785
+  //#define PROBE_Y_FIRST
786
+
784 787
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
785 788
 
786 789
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/Hephestos_2/Configuration.h View File

@@ -783,6 +783,9 @@
783 783
   // The Z probe minimum outer margin (to validate G29 parameters).
784 784
   #define MIN_PROBE_EDGE 10
785 785
 
786
+  // Probe along the Y axis, advancing X after each column
787
+  //#define PROBE_Y_FIRST
788
+
786 789
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
787 790
 
788 791
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/K8200/Configuration.h View File

@@ -806,6 +806,9 @@
806 806
   // The Z probe minimum outer margin (to validate G29 parameters).
807 807
   #define MIN_PROBE_EDGE 10
808 808
 
809
+  // Probe along the Y axis, advancing X after each column
810
+  //#define PROBE_Y_FIRST
811
+
809 812
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
810 813
 
811 814
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/K8400/Configuration.h View File

@@ -789,6 +789,9 @@
789 789
   // The Z probe minimum outer margin (to validate G29 parameters).
790 790
   #define MIN_PROBE_EDGE 10
791 791
 
792
+  // Probe along the Y axis, advancing X after each column
793
+  //#define PROBE_Y_FIRST
794
+
792 795
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
793 796
 
794 797
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/K8400/Dual-head/Configuration.h View File

@@ -789,6 +789,9 @@
789 789
   // The Z probe minimum outer margin (to validate G29 parameters).
790 790
   #define MIN_PROBE_EDGE 10
791 791
 
792
+  // Probe along the Y axis, advancing X after each column
793
+  //#define PROBE_Y_FIRST
794
+
792 795
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
793 796
 
794 797
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h View File

@@ -789,6 +789,9 @@
789 789
   // The Z probe minimum outer margin (to validate G29 parameters).
790 790
   #define MIN_PROBE_EDGE 10
791 791
 
792
+  // Probe along the Y axis, advancing X after each column
793
+  //#define PROBE_Y_FIRST
794
+
792 795
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
793 796
 
794 797
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/RigidBot/Configuration.h View File

@@ -787,6 +787,9 @@
787 787
   // The Z probe minimum outer margin (to validate G29 parameters).
788 788
   #define MIN_PROBE_EDGE 10
789 789
 
790
+  // Probe along the Y axis, advancing X after each column
791
+  //#define PROBE_Y_FIRST
792
+
790 793
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
791 794
 
792 795
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/SCARA/Configuration.h View File

@@ -804,6 +804,9 @@
804 804
   // The Z probe minimum outer margin (to validate G29 parameters).
805 805
   #define MIN_PROBE_EDGE 10
806 806
 
807
+  // Probe along the Y axis, advancing X after each column
808
+  //#define PROBE_Y_FIRST
809
+
807 810
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
808 811
 
809 812
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/TAZ4/Configuration.h View File

@@ -810,6 +810,9 @@
810 810
   // The Z probe minimum outer margin (to validate G29 parameters).
811 811
   #define MIN_PROBE_EDGE 10
812 812
 
813
+  // Probe along the Y axis, advancing X after each column
814
+  //#define PROBE_Y_FIRST
815
+
813 816
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
814 817
 
815 818
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/WITBOX/Configuration.h View File

@@ -781,6 +781,9 @@
781 781
   // The Z probe minimum outer margin (to validate G29 parameters).
782 782
   #define MIN_PROBE_EDGE 10
783 783
 
784
+  // Probe along the Y axis, advancing X after each column
785
+  //#define PROBE_Y_FIRST
786
+
784 787
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
785 788
 
786 789
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/adafruit/ST7565/Configuration.h View File

@@ -789,6 +789,9 @@
789 789
   // The Z probe minimum outer margin (to validate G29 parameters).
790 790
   #define MIN_PROBE_EDGE 10
791 791
 
792
+  // Probe along the Y axis, advancing X after each column
793
+  //#define PROBE_Y_FIRST
794
+
792 795
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
793 796
 
794 797
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/delta/biv2.5/Configuration.h View File

@@ -881,6 +881,9 @@
881 881
   // The Z probe minimum outer margin (to validate G29 parameters).
882 882
   #define MIN_PROBE_EDGE 10
883 883
 
884
+  // Probe along the Y axis, advancing X after each column
885
+  //#define PROBE_Y_FIRST
886
+
884 887
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
885 888
 
886 889
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/delta/generic/Configuration.h View File

@@ -875,6 +875,9 @@
875 875
   // The Z probe minimum outer margin (to validate G29 parameters).
876 876
   #define MIN_PROBE_EDGE 10
877 877
 
878
+  // Probe along the Y axis, advancing X after each column
879
+  //#define PROBE_Y_FIRST
880
+
878 881
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
879 882
 
880 883
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/delta/kossel_mini/Configuration.h View File

@@ -878,6 +878,9 @@
878 878
   // The Z probe minimum outer margin (to validate G29 parameters).
879 879
   #define MIN_PROBE_EDGE 10
880 880
 
881
+  // Probe along the Y axis, advancing X after each column
882
+  //#define PROBE_Y_FIRST
883
+
881 884
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
882 885
 
883 886
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/delta/kossel_pro/Configuration.h View File

@@ -879,6 +879,9 @@
879 879
   // The Z probe minimum outer margin (to validate G29 parameters).
880 880
   #define MIN_PROBE_EDGE 10
881 881
 
882
+  // Probe along the Y axis, advancing X after each column
883
+  //#define PROBE_Y_FIRST
884
+
882 885
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
883 886
 
884 887
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/delta/kossel_xl/Configuration.h View File

@@ -881,6 +881,9 @@
881 881
   // The Z probe minimum outer margin (to validate G29 parameters).
882 882
   #define MIN_PROBE_EDGE 10
883 883
 
884
+  // Probe along the Y axis, advancing X after each column
885
+  //#define PROBE_Y_FIRST
886
+
884 887
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
885 888
 
886 889
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/makibox/Configuration.h View File

@@ -792,6 +792,9 @@
792 792
   // The Z probe minimum outer margin (to validate G29 parameters).
793 793
   #define MIN_PROBE_EDGE 10
794 794
 
795
+  // Probe along the Y axis, advancing X after each column
796
+  //#define PROBE_Y_FIRST
797
+
795 798
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
796 799
 
797 800
   // 3 arbitrary points to probe.

+ 3
- 0
Marlin/example_configurations/tvrrug/Round2/Configuration.h View File

@@ -785,6 +785,9 @@
785 785
   // The Z probe minimum outer margin (to validate G29 parameters).
786 786
   #define MIN_PROBE_EDGE 10
787 787
 
788
+  // Probe along the Y axis, advancing X after each column
789
+  //#define PROBE_Y_FIRST
790
+
788 791
 #elif ENABLED(AUTO_BED_LEVELING_3POINT)
789 792
 
790 793
   // 3 arbitrary points to probe.

+ 7
- 6
Marlin/planner.cpp View File

@@ -1201,7 +1201,8 @@ void Planner::buffer_line(ARG_X, ARG_Y, ARG_Z, const float &e, float fr_mm_s, co
1201 1201
 } // buffer_line()
1202 1202
 
1203 1203
 /**
1204
- * Directly set the planner XYZ position (hence the stepper positions).
1204
+ * Directly set the planner XYZ position (and stepper positions)
1205
+ * converting mm (or angles for SCARA) into steps.
1205 1206
  *
1206 1207
  * On CORE machines stepper ABC will be translated from the given XYZ.
1207 1208
  */
@@ -1229,12 +1230,12 @@ void Planner::sync_from_steppers() {
1229 1230
 }
1230 1231
 
1231 1232
 /**
1232
- * Directly set the planner E position (hence the stepper E position).
1233
+ * Setters for planner position (also setting stepper position).
1233 1234
  */
1234
-void Planner::set_e_position_mm(const float& e) {
1235
-  position[E_AXIS] = lround(e * axis_steps_per_mm[E_AXIS]);
1236
-  stepper.set_e_position(position[E_AXIS]);
1237
-  previous_speed[E_AXIS] = 0.0;
1235
+void Planner::set_position_mm(const AxisEnum axis, const float& v) {
1236
+  position[axis] = lround(v * axis_steps_per_mm[axis]);
1237
+  stepper.set_position(axis, v);
1238
+  previous_speed[axis] = 0.0;
1238 1239
 }
1239 1240
 
1240 1241
 // Recalculate the steps/s^2 acceleration rates, based on the mm/s^2

+ 5
- 5
Marlin/planner.h View File

@@ -33,6 +33,7 @@
33 33
 #define PLANNER_H
34 34
 
35 35
 #include "types.h"
36
+#include "enum.h"
36 37
 #include "MarlinConfig.h"
37 38
 
38 39
 #if HAS_ABL
@@ -242,6 +243,10 @@ class Planner {
242 243
      * Clears previous speed values.
243 244
      */
244 245
     static void set_position_mm(ARG_X, ARG_Y, ARG_Z, const float& e);
246
+    static void set_position_mm(const AxisEnum axis, const float& v);
247
+
248
+    static FORCE_INLINE void set_z_position_mm(const float& z) { set_position_mm(Z_AXIS, z); }
249
+    static FORCE_INLINE void set_e_position_mm(const float& e) { set_position_mm(E_AXIS, e); }
245 250
 
246 251
     /**
247 252
      * Sync from the stepper positions. (e.g., after an interrupted move)
@@ -249,11 +254,6 @@ class Planner {
249 254
     static void sync_from_steppers();
250 255
 
251 256
     /**
252
-     * Set the E position (mm) of the planner (and the E stepper)
253
-     */
254
-    static void set_e_position_mm(const float& e);
255
-
256
-    /**
257 257
      * Does the buffer have any blocks queued?
258 258
      */
259 259
     static bool blocks_queued() { return (block_buffer_head != block_buffer_tail); }

+ 6
- 0
Marlin/stepper.cpp View File

@@ -970,6 +970,12 @@ void Stepper::set_position(const long& x, const long& y, const long& z, const lo
970 970
   CRITICAL_SECTION_END;
971 971
 }
972 972
 
973
+void Stepper::set_position(const AxisEnum &axis, const long& v) {
974
+  CRITICAL_SECTION_START;
975
+  count_position[axis] = v;
976
+  CRITICAL_SECTION_END;
977
+}
978
+
973 979
 void Stepper::set_e_position(const long& e) {
974 980
   CRITICAL_SECTION_START;
975 981
   count_position[E_AXIS] = e;

+ 1
- 0
Marlin/stepper.h View File

@@ -189,6 +189,7 @@ class Stepper {
189 189
     // Set the current position in steps
190 190
     //
191 191
     static void set_position(const long& x, const long& y, const long& z, const long& e);
192
+    static void set_position(const AxisEnum& a, const long& v);
192 193
     static void set_e_position(const long& e);
193 194
 
194 195
     //

Loading…
Cancel
Save