Explorar el Código

Various cleanups of G33

- update comment section
- redefined P5 grid
- minor clean to probe radius routine
- updated EEPROM version to V37 according remark in #6517
LVD-AC hace 7 años
padre
commit
da2abad636
Se han modificado 2 ficheros con 89 adiciones y 85 borrados
  1. 87
    83
      Marlin/Marlin_main.cpp
  2. 2
    2
      Marlin/configuration_store.cpp

+ 87
- 83
Marlin/Marlin_main.cpp Ver fichero

@@ -61,7 +61,7 @@
61 61
  * G30 - Single Z probe, probes bed at X Y location (defaults to current XY location)
62 62
  * G31 - Dock sled (Z_PROBE_SLED only)
63 63
  * G32 - Undock sled (Z_PROBE_SLED only)
64
- * G33 - Delta '1-4-7-point' auto calibration : "G33 V<verbose> P<points> <A> <O> <T>" (Requires DELTA)
64
+ * G33 - Delta Auto-Calibration (Requires DELTA_AUTO_CALIBRATION)
65 65
  * G38 - Probe target - similar to G28 except it uses the Z_MIN_PROBE for all three axes
66 66
  * G90 - Use Absolute Coordinates
67 67
  * G91 - Use Relative Coordinates
@@ -3904,7 +3904,7 @@ inline void gcode_G28() {
3904 3904
   #if ENABLED(DEBUG_LEVELING_FEATURE)
3905 3905
     if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G28");
3906 3906
   #endif
3907
-}
3907
+} // G28
3908 3908
 
3909 3909
 void home_all_axes() { gcode_G28(); }
3910 3910
 
@@ -5057,46 +5057,64 @@ void home_all_axes() { gcode_G28(); }
5057 5057
 
5058 5058
   #if ENABLED(DELTA_AUTO_CALIBRATION)
5059 5059
     /**
5060
-     * G33 - Delta '1-4-7-point' auto calibration (Requires DELTA)
5061
-     * 
5062
-     * Usage:
5063
-     *   G33 <Vn> <Pn> <A> <O> <T>
5064
-     *   
5065
-     *     Vn = verbose level (n=0-2 default 1)
5066
-     *          n=0 dry-run mode: setting + probe results / no calibration
5067
-     *          n=1 settings 
5068
-     *          n=2 setting + probe results 
5069
-     *     Pn = n=-7 -> +7 : n*n probe points
5070
-     *          calibrates height ('1 point'), endstops, and delta radius ('4 points') 
5071
-     *          and tower angles with n > 2 ('7+ points')
5072
-     *          n=1  probes center / sets height only
5073
-     *          n=2  probes center and towers / sets height, endstops and delta radius
5074
-     *          n=3  probes all points: center, towers and opposite towers / sets all
5075
-     *          n>3  probes all points multiple times and averages
5076
-     *     A  = abort 1 point delta height calibration after 1 probe
5077
-     *     O  = use oposite tower points instead of tower points with 4 point calibration
5078
-     *     T  = do not calibrate tower angles with 7+ point calibration
5060
+     * G33 - Delta '1-4-7-point' Auto-Calibration
5061
+     *       Calibrate height, endstops, delta radius, and tower angles.
5062
+     *
5063
+     * Parameters:
5064
+     *
5065
+     *   P  Number of probe points:
5066
+     *
5067
+     *      P1     Probe center and set height only.
5068
+     *      P2     Probe center and towers. Set height, endstops, and delta radius.
5069
+     *      P3     Probe all positions: center, towers and opposite towers. Set all.
5070
+     *      P4-P7  Probe all positions at different locations and average them.
5071
+     *
5072
+     *   A  Abort delta height calibration after 1 probe (only P1)
5073
+     *
5074
+     *   O  Use opposite tower points instead of tower points (only P2)
5075
+     *
5076
+     *   T  Don't calibrate tower angle corrections (P3-P7)
5077
+     *
5078
+     *   V  Verbose level:
5079
+     *
5080
+     *      V0  Dry-run mode. Report settings and probe results. No calibration.
5081
+     *      V1  Report settings
5082
+     *      V2  Report settings and probe results
5079 5083
      */
5080 5084
     inline void gcode_G33() {
5081 5085
 
5082
-      stepper.synchronize();
5086
+      const int8_t probe_points = code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS;
5087
+      if (!WITHIN(probe_points, 1, 7)) {
5088
+        SERIAL_PROTOCOLLNPGM("?(P)oints is implausible (1 to 7).");
5089
+        return;
5090
+      }
5083 5091
 
5084
-      #if HAS_LEVELING
5085
-        set_bed_leveling_enabled(false);
5086
-      #endif
5092
+      const int8_t verbose_level = code_seen('V') ? code_value_byte() : 1;
5093
+      if (!WITHIN(verbose_level, 0, 2)) {
5094
+        SERIAL_PROTOCOLLNPGM("?(V)erbose Level is implausible (0-2).");
5095
+        return;
5096
+      }
5087 5097
 
5088
-      int8_t pp = (code_seen('P') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS),
5089
-             probe_mode = (WITHIN(pp, 1, 7) ? pp : DELTA_CALIBRATION_DEFAULT_POINTS);
5098
+      const bool do_height_only       = probe_points == 1,
5099
+                 do_center_and_towers = probe_points == 2,
5100
+                 do_all_positions     = probe_points == 3,
5101
+                 do_circle_x2         = probe_points == 5,
5102
+                 do_circle_x3         = probe_points == 6,
5103
+                 do_circle_x4         = probe_points == 7,
5104
+                 probe_center_plus_3  = probe_points >= 3,
5105
+                 point_averaging      = probe_points >= 4,
5106
+                 probe_center_plus_6  = probe_points >= 5;
5090 5107
 
5091
-      probe_mode = (code_seen('A') && probe_mode == 1 ? -probe_mode : probe_mode);
5092
-      probe_mode = (code_seen('O') && probe_mode == 2 ? -probe_mode : probe_mode);
5093
-      probe_mode = (code_seen('T') && probe_mode > 2 ? -probe_mode : probe_mode);
5094
-      
5095
-      int8_t verbose_level = (code_seen('V') ? code_value_byte() : 1);
5108
+      const char negating_parameter = do_height_only ? 'A' : do_center_and_towers ? 'O' : 'T';
5109
+      int8_t probe_mode = code_seen(negating_parameter) && code_value_bool() ? -probe_points : probe_points;
5110
+
5111
+      SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");
5096 5112
 
5097
-      if (!WITHIN(verbose_level, 0, 2)) verbose_level = 1;
5113
+      #if HAS_LEVELING
5114
+        set_bed_leveling_enabled(false);
5115
+      #endif
5098 5116
 
5099
-      gcode_G28();
5117
+      home_all_axes();
5100 5118
 
5101 5119
       const static char save_message[] PROGMEM = "Save with M500 and/or copy to Configuration.h";
5102 5120
       float test_precision,
@@ -5109,31 +5127,17 @@ void home_all_axes() { gcode_G28(); }
5109 5127
             dr_old = delta_radius,
5110 5128
             zh_old = home_offset[Z_AXIS],
5111 5129
             alpha_old = delta_tower_angle_trim[A_AXIS],
5112
-            beta_old = delta_tower_angle_trim[B_AXIS]; 
5113
-      int8_t iterations = 0,
5114
-             probe_points = abs(probe_mode);
5115
-      const bool pp_equals_1 = (probe_points == 1),
5116
-                 pp_equals_2 = (probe_points == 2),
5117
-                 pp_equals_3 = (probe_points == 3),
5118
-                 pp_equals_4 = (probe_points == 4),
5119
-                 pp_equals_5 = (probe_points == 5),
5120
-                 pp_equals_6 = (probe_points == 6),
5121
-                 pp_equals_7 = (probe_points == 7),
5122
-                 pp_greather_2 = (probe_points > 2),
5123
-                 pp_greather_3 = (probe_points > 3),
5124
-                 pp_greather_4 = (probe_points > 4),
5125
-                 pp_greather_5 = (probe_points > 5);
5126
- 
5130
+            beta_old = delta_tower_angle_trim[B_AXIS];
5131
+
5127 5132
       // print settings
5128 5133
 
5129
-      SERIAL_PROTOCOLLNPGM("G33 Auto Calibrate");
5130 5134
       SERIAL_PROTOCOLPGM("Checking... AC");
5131 5135
       if (verbose_level == 0) SERIAL_PROTOCOLPGM(" (DRY-RUN)");
5132 5136
       SERIAL_EOL;
5133 5137
       LCD_MESSAGEPGM("Checking... AC");
5134 5138
 
5135 5139
       SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5136
-      if (!pp_equals_1) {
5140
+      if (!do_height_only) {
5137 5141
         SERIAL_PROTOCOLPGM("    Ex:");
5138 5142
         if (endstop_adj[A_AXIS] >= 0) SERIAL_CHAR('+');
5139 5143
         SERIAL_PROTOCOL_F(endstop_adj[A_AXIS], 2);
@@ -5161,6 +5165,8 @@ void home_all_axes() { gcode_G28(); }
5161 5165
         DEPLOY_PROBE();
5162 5166
       #endif
5163 5167
 
5168
+      int8_t iterations = 0;
5169
+
5164 5170
       do {
5165 5171
 
5166 5172
         float z_at_pt[13] = { 0 },
@@ -5171,54 +5177,52 @@ void home_all_axes() { gcode_G28(); }
5171 5177
         test_precision = zero_std_dev;
5172 5178
         iterations++;
5173 5179
 
5174
-        // probe the points
5180
+        // Probe the points
5175 5181
 
5176
-        if (!pp_equals_3 && !pp_equals_6) { // probe the centre
5182
+        if (!do_all_positions && !do_circle_x3) { // probe the center
5177 5183
           setup_for_endstop_or_probe_move();
5178 5184
           z_at_pt[0] += probe_pt(0.0, 0.0 , true, 1);
5179 5185
           clean_up_after_endstop_or_probe_move();
5180 5186
         }
5181
-        if (pp_greather_2) { // probe extra centre points
5182
-          for (int8_t axis = (pp_greather_4 ? 11 : 9); axis > 0; axis -= (pp_greather_4 ? 2 : 4)) {              
5187
+        if (probe_center_plus_3) { // probe extra center points
5188
+          for (int8_t axis = probe_center_plus_6 ? 11 : 9; axis > 0; axis -= probe_center_plus_6 ? 2 : 4) {
5183 5189
             setup_for_endstop_or_probe_move();
5184 5190
             z_at_pt[0] += probe_pt(
5185 5191
               cos(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius),
5186 5192
               sin(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius), true, 1);
5187 5193
             clean_up_after_endstop_or_probe_move();
5188 5194
           }
5189
-          z_at_pt[0] /= (pp_equals_5 ? 7 : probe_points);
5195
+          z_at_pt[0] /= float(do_circle_x2 ? 7 : probe_points);
5190 5196
         }
5191
-        if (!pp_equals_1) {  // probe the radius
5192
-          float start_circles = (pp_equals_7 ? -1.5 : pp_equals_6 || pp_equals_5 ? -1 : 0),
5193
-                end_circles = -start_circles;
5197
+        if (!do_height_only) {  // probe the radius
5194 5198
           bool zig_zag = true;
5195
-          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13; 
5196
-               axis += (pp_equals_2 ? 4 : pp_equals_3 || pp_equals_5 ? 2 : 1)) {
5197
-            for (float circles = start_circles ; circles <= end_circles; circles++) {
5199
+          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13;
5200
+                       axis += (do_center_and_towers ? 4 : do_all_positions ? 2 : 1)) {
5201
+            float offset_circles = (do_circle_x4 ? (zig_zag ? 1.5 : 1.0) :
5202
+                                    do_circle_x3 ? (zig_zag ? 1.0 : 0.5) :
5203
+                                    do_circle_x2 ? (zig_zag ? 0.5 : 0.0) : 0);
5204
+            for (float circles = -offset_circles ; circles <= offset_circles; circles++) {
5198 5205
               setup_for_endstop_or_probe_move();
5199 5206
               z_at_pt[axis] += probe_pt(
5200
-                cos(RADIANS(180 + 30 * axis)) * 
5201
-                (1 + circles * 0.1 * (zig_zag ? 1 : -1)) * delta_calibration_radius, 
5202
-                sin(RADIANS(180 + 30 * axis)) * 
5203
-                (1 + circles * 0.1 * (zig_zag ? 1 : -1)) * delta_calibration_radius, true, 1);
5207
+                cos(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
5208
+                (1 + circles * 0.1 * (zig_zag ? 1 : -1)),
5209
+                sin(RADIANS(180 + 30 * axis)) * delta_calibration_radius *
5210
+                (1 + circles * 0.1 * (zig_zag ? 1 : -1)), true, 1);
5204 5211
               clean_up_after_endstop_or_probe_move();
5205 5212
             }
5206
-            start_circles += (pp_greather_5 ? (zig_zag ? 0.5 : -0.5) : 0);
5207
-            end_circles = -start_circles;
5208 5213
             zig_zag = !zig_zag;
5209
-            z_at_pt[axis] /= (pp_equals_7 ? (zig_zag ? 4.0 : 3.0) :
5210
-                              pp_equals_6 ? (zig_zag ? 3.0 : 2.0) : pp_equals_5 ? 3 : 1);
5214
+            z_at_pt[axis] /= (2 * offset_circles + 1);
5211 5215
           }
5212 5216
         }
5213
-        if (pp_greather_3 && !pp_equals_5) // average intermediates to tower and opposites
5214
-          for (uint8_t axis = 1; axis < 13; axis += 2)
5217
+        if (point_averaging) // average intermediates to tower and opposites
5218
+          for (uint8_t axis = 1; axis <= 11; axis += 2)
5215 5219
             z_at_pt[axis] = (z_at_pt[axis] + (z_at_pt[axis + 1] + z_at_pt[(axis + 10) % 12 + 1]) / 2.0) / 2.0;
5216 5220
 
5217 5221
         S1 += z_at_pt[0];
5218 5222
         S2 += sq(z_at_pt[0]);
5219 5223
         N++;
5220
-        if (!pp_equals_1) // std dev from zero plane
5221
-          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13; axis += (pp_equals_2 ? 4 : 2)) {
5224
+        if (!do_height_only) // std dev from zero plane
5225
+          for (uint8_t axis = (probe_mode == -2 ? 3 : 1); axis < 13; axis += (do_center_and_towers ? 4 : 2)) {
5222 5226
             S1 += z_at_pt[axis];
5223 5227
             S2 += sq(z_at_pt[axis]);
5224 5228
             N++;
@@ -5279,7 +5283,7 @@ void home_all_axes() { gcode_G28(); }
5279 5283
               e_delta[Y_AXIS] = Z1050(0) - Z0175(1) + Z0350(5) - Z0175(9) + Z0175(7) - Z0350(11) + Z0175(3);
5280 5284
               e_delta[Z_AXIS] = Z1050(0) - Z0175(1) - Z0175(5) + Z0350(9) + Z0175(7) + Z0175(11) - Z0350(3);
5281 5285
               r_delta         = Z2250(0) - Z0375(1) - Z0375(5) - Z0375(9) - Z0375(7) - Z0375(11) - Z0375(3);
5282
-              
5286
+
5283 5287
               if (probe_mode > 0) {  // negative disables tower angles
5284 5288
                 t_alpha = + Z0444(1) - Z0888(5) + Z0444(9) + Z0444(7) - Z0888(11) + Z0444(3);
5285 5289
                 t_beta  = - Z0888(1) + Z0444(5) + Z0444(9) - Z0888(7) + Z0444(11) + Z0444(3);
@@ -5315,7 +5319,7 @@ void home_all_axes() { gcode_G28(); }
5315 5319
           SERIAL_PROTOCOLPGM(".      c:");
5316 5320
           if (z_at_pt[0] > 0) SERIAL_CHAR('+');
5317 5321
           SERIAL_PROTOCOL_F(z_at_pt[0], 2);
5318
-          if (probe_mode == 2 || pp_greather_2) {
5322
+          if (probe_mode == 2 || probe_center_plus_3) {
5319 5323
             SERIAL_PROTOCOLPGM("     x:");
5320 5324
             if (z_at_pt[1] >= 0) SERIAL_CHAR('+');
5321 5325
             SERIAL_PROTOCOL_F(z_at_pt[1], 2);
@@ -5327,8 +5331,8 @@ void home_all_axes() { gcode_G28(); }
5327 5331
             SERIAL_PROTOCOL_F(z_at_pt[9], 2);
5328 5332
           }
5329 5333
           if (probe_mode != -2) SERIAL_EOL;
5330
-          if (probe_mode == -2 || pp_greather_2) {
5331
-            if (pp_greather_2) {
5334
+          if (probe_mode == -2 || probe_center_plus_3) {
5335
+            if (probe_center_plus_3) {
5332 5336
               SERIAL_CHAR('.');
5333 5337
               SERIAL_PROTOCOL_SP(13);
5334 5338
             }
@@ -5364,7 +5368,7 @@ void home_all_axes() { gcode_G28(); }
5364 5368
             lcd_setstatus(mess);
5365 5369
           }
5366 5370
           SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5367
-          if (!pp_equals_1) {
5371
+          if (!do_height_only) {
5368 5372
             SERIAL_PROTOCOLPGM("    Ex:");
5369 5373
             if (endstop_adj[A_AXIS] >= 0) SERIAL_CHAR('+');
5370 5374
             SERIAL_PROTOCOL_F(endstop_adj[A_AXIS], 2);
@@ -5411,7 +5415,7 @@ void home_all_axes() { gcode_G28(); }
5411 5415
 
5412 5416
         stepper.synchronize();
5413 5417
 
5414
-        gcode_G28();
5418
+        home_all_axes();
5415 5419
 
5416 5420
       } while (zero_std_dev < test_precision && iterations < 31);
5417 5421
 
@@ -6416,7 +6420,7 @@ inline void gcode_M42() {
6416 6420
     clean_up_after_endstop_or_probe_move();
6417 6421
 
6418 6422
     // Re-enable bed level correction if it had been on
6419
-    #if HAS_ABL
6423
+    #if HAS_LEVELING
6420 6424
       set_bed_leveling_enabled(was_enabled);
6421 6425
     #endif
6422 6426
 
@@ -8602,7 +8606,7 @@ inline void gcode_M503() {
8602 8606
       #else
8603 8607
         UNUSED(no_babystep);
8604 8608
       #endif
8605
- 
8609
+
8606 8610
       #if ENABLED(DELTA) // correct the delta_height
8607 8611
         home_offset[Z_AXIS] -= diff;
8608 8612
       #endif
@@ -9874,7 +9878,7 @@ void process_next_command() {
9874 9878
 
9875 9879
         #if ENABLED(DELTA_AUTO_CALIBRATION)
9876 9880
 
9877
-          case 33: // G33: Delta Auto Calibrate
9881
+          case 33: // G33: Delta Auto-Calibration
9878 9882
             gcode_G33();
9879 9883
             break;
9880 9884
 

+ 2
- 2
Marlin/configuration_store.cpp Ver fichero

@@ -36,13 +36,13 @@
36 36
  *
37 37
  */
38 38
 
39
-#define EEPROM_VERSION "V36"
39
+#define EEPROM_VERSION "V37"
40 40
 
41 41
 // Change EEPROM version if these are changed:
42 42
 #define EEPROM_OFFSET 100
43 43
 
44 44
 /**
45
- * V35 EEPROM Layout:
45
+ * V37 EEPROM Layout:
46 46
  *
47 47
  *  100  Version                                    (char x4)
48 48
  *  104  EEPROM Checksum                            (uint16_t)

Loading…
Cancelar
Guardar