Browse Source

Cn negative : no tower angle calibration

Giving a negative number of probe points disables the tower angle
correction calibration ('4point' instead of '7point' solution)

EEPROM version updated
LVD-AC 8 years ago
parent
commit
d8102aeca8
2 changed files with 65 additions and 49 deletions
  1. 64
    48
      Marlin/Marlin_main.cpp
  2. 1
    1
      Marlin/ultralcd.cpp

+ 64
- 48
Marlin/Marlin_main.cpp View File

@@ -4993,15 +4993,18 @@ inline void gcode_G28() {
4993 4993
      * Usage:
4994 4994
      *   G33 <Cn> <Vn>
4995 4995
      *   
4996
-     *     Cn = (default) = calibrates height ('1 point'), endstops, and delta radius with '4 point' 
4997
-     *                      and calibrates tower angles with '7+ point'
4998
-     *          n= -2, 1-7 : n*n probe points
4999
-     *          n=1  probes center - sets height only - usefull when z_offset is changed
5000
-     *          n=2  probes center and towers
5001
-     *          n=-2 probes center and opposite towers
5002
-     *          n=3 probes all points: center, towers and opposite towers
5003
-     *          n>3 probes all points multiple times and averages
5004
-     *     Vn = verbose level (n=0-3 default 1)
4996
+     *     Cn = n=-7 -> +7 : n*n probe points
4997
+     *          calibrates height ('1 point'), endstops, and delta radius ('4 points') 
4998
+     *          and calibrates tower angles with n >= 3 ('7+ points')
4999
+     *          n=0  <default>
5000
+     *          n=1  probes center / sets height only
5001
+     *          n=-1 same but 1 iteration only
5002
+     *          n=2  probes center and towers / sets height, endstops and delta radius
5003
+     *          n=-2 same but opposite towers
5004
+     *          n=3  probes all points: center, towers and opposite towers / sets all
5005
+     *          n>3  probes all points multiple times and averages
5006
+     *          n<=3 same but tower angle calibration disabled
5007
+     *     Vn = verbose level (n=0-2 default 1)
5005 5008
      *          n=0 dry-run mode: no calibration
5006 5009
      *          n=1 settings 
5007 5010
      *          n=2 setting + probe results 
@@ -5015,13 +5018,13 @@ inline void gcode_G28() {
5015 5018
       #endif
5016 5019
 
5017 5020
       const int8_t pp = code_seen('C') ? code_value_int() : DELTA_CALIBRATION_DEFAULT_POINTS,
5018
-                   probe_points = (WITHIN(pp, 1, 7) || pp == -2) ? pp : DELTA_CALIBRATION_DEFAULT_POINTS;
5021
+                   probe_points = (WITHIN(pp, -7, -1) || WITHIN(pp, 1, 7)) ? pp : DELTA_CALIBRATION_DEFAULT_POINTS;
5019 5022
 
5020 5023
       int8_t verbose_level = code_seen('V') ? code_value_byte() : 1;
5021 5024
 
5022 5025
       if (!WITHIN(verbose_level, 0, 2)) verbose_level = 1;
5023 5026
 
5024
-      float zero_std_dev = verbose_level ? 999.0 : 0.0; // 0.0 in dry-run mode : forced end
5027
+      float zero_std_dev = verbose_level ? 999.0 : 0.0;                                          // 0.0 in dry-run mode : forced end
5025 5028
 
5026 5029
       gcode_G28();
5027 5030
 
@@ -5084,54 +5087,54 @@ inline void gcode_G28() {
5084 5087
 
5085 5088
         int16_t center_points = 0;
5086 5089
 
5087
-        if (probe_points != 3 &&  probe_points != 6) {                                 // probe centre
5090
+        if (abs(probe_points) != 3 &&  abs(probe_points != 6)) {                                 // probe centre
5088 5091
           z_at_pt[0] += probe_pt(0.0, 0.0 , true, 1);
5089 5092
           center_points = 1;
5090 5093
         }
5091 5094
 
5092
-        int16_t step_axis = (probe_points > 4) ? 2 : 4;                                              
5093
-        if (probe_points >= 3) {                                                       // probe extra 3 or 6 centre points
5094
-          for (int8_t axis = (probe_points > 4) ? 11 : 9; axis > 0; axis -= step_axis) {              
5095
+        int16_t step_axis = (abs(probe_points) > 4) ? 2 : 4;                                              
5096
+        if (abs(probe_points) >= 3) {                                                            // probe extra 3 or 6 centre points
5097
+          for (int8_t axis = (abs(probe_points) > 4) ? 11 : 9; axis > 0; axis -= step_axis) {              
5095 5098
             z_at_pt[0] += probe_pt(
5096 5099
               cos(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius),
5097 5100
               sin(RADIANS(180 + 30 * axis)) * (0.1 * delta_calibration_radius), true, 1);
5098 5101
           }
5099
-          center_points += (probe_points > 4) ? 6 : 3;                                  // average centre points
5102
+          center_points += (abs(probe_points) > 4) ? 6 : 3;                                       // average centre points
5100 5103
           z_at_pt[0] /= center_points;
5101 5104
         }
5102 5105
 
5103 5106
         float S1 = z_at_pt[0], S2 = sq(S1);
5104 5107
 
5105 5108
         int16_t N = 1, start = (probe_points == -2) ? 3 : 1;
5106
-        step_axis = (abs(probe_points) == 2) ? 4 : (probe_points == 4 || probe_points > 5) ? 1 : 2;
5107
-        float start_circles = (probe_points > 6) ? -1.5 : (probe_points > 4) ? -1 : 0,  // one or multi radius points
5108
-              end_circles = (probe_points > 6) ? 1.5 : (probe_points > 4) ? 1 : 0;      // one or multi radius points
5109
+        step_axis = (abs(probe_points) == 2) ? 4 : (abs(probe_points) == 4 || abs(probe_points) > 5) ? 1 : 2;
5110
+        float start_circles = (abs(probe_points) > 6) ? -1.5 : (abs(probe_points) > 4) ? -1 : 0, // one or multi radius points
5111
+              end_circles = (abs(probe_points) > 6) ? 1.5 : (abs(probe_points) > 4) ? 1 : 0;     // one or multi radius points
5109 5112
         int8_t zig_zag = 1;
5110 5113
 
5111
-        if (probe_points != 1) {
5112
-          for (uint8_t axis = start; axis < 13; axis += step_axis) { // probes 3, 6 or 12 points on the calibration radius
5113
-            for (float circles = start_circles ; circles <= end_circles; circles++)     // one or multi radius points
5114
+        if (abs(probe_points) > 1) {
5115
+          for (uint8_t axis = start; axis < 13; axis += step_axis) {                             // probes 3, 6 or 12 points on the calibration radius
5116
+            for (float circles = start_circles ; circles <= end_circles; circles++)              // one or multi radius points
5114 5117
               z_at_pt[axis] += probe_pt(
5115 5118
                 cos(RADIANS(180 + 30 * axis)) * ((1 + circles * 0.1 * zig_zag) * delta_calibration_radius), 
5116 5119
                 sin(RADIANS(180 + 30 * axis)) * ((1 + circles * 0.1 * zig_zag) * delta_calibration_radius), true, 1);
5117 5120
 
5118
-            if (probe_points > 5) start_circles += (zig_zag == 1) ? +0.5 : -0.5;        // opposite one radius point less
5119
-            if (probe_points > 5) end_circles += (zig_zag == 1) ? -0.5 : +0.5;
5121
+            if (abs(probe_points) > 5) start_circles += (zig_zag == 1) ? +0.5 : -0.5;            // opposites: one radius point less
5122
+            if (abs(probe_points) > 5) end_circles += (zig_zag == 1) ? -0.5 : +0.5;
5120 5123
             zig_zag = -zig_zag;
5121
-            if (probe_points > 4) z_at_pt[axis] /= (zig_zag == 1) ? 3.0 : 2.0;          // average between radius points
5124
+            if (abs(probe_points) > 4) z_at_pt[axis] /= (zig_zag == 1) ? 3.0 : 2.0;              // average between radius points
5122 5125
           }
5123 5126
         }
5124
-        if (probe_points == 4 || probe_points > 5) step_axis = 2;
5127
+        if (abs(probe_points) == 4 || abs(probe_points) > 5) step_axis = 2;
5125 5128
 
5126
-        for (uint8_t axis = start; axis < 13; axis += step_axis) {                      // average half intermediates to tower and opposite
5127
-          if (probe_points == 4 || probe_points > 5)
5129
+        for (uint8_t axis = start; axis < 13; axis += step_axis) {                               // average half intermediates to towers and opposites
5130
+          if (abs(probe_points) == 4 || abs(probe_points) > 5)
5128 5131
             z_at_pt[axis] = (z_at_pt[axis] + (z_at_pt[axis + 1] + z_at_pt[(axis + 10) % 12 + 1]) / 2.0) / 2.0;
5129 5132
 
5130 5133
           S1 += z_at_pt[axis];
5131 5134
           S2 += sq(z_at_pt[axis]);
5132 5135
           N++;
5133 5136
         }
5134
-        zero_std_dev = round(sqrt(S2 / N) * 1000.0) / 1000.0 + 0.00001; // deviation from zero plane
5137
+        zero_std_dev = round(sqrt(S2 / N) * 1000.0) / 1000.0 + 0.00001;                          // deviation from zero plane
5135 5138
 
5136 5139
         // Solve matrices
5137 5140
 
@@ -5145,9 +5148,9 @@ inline void gcode_G28() {
5145 5148
           float e_delta[XYZ] = { 0.0 }, r_delta = 0.0,
5146 5149
                 t_alpha = 0.0, t_beta = 0.0;
5147 5150
           const float r_diff = delta_radius - delta_calibration_radius,
5148
-                      h_factor = 1.00 + r_diff * 0.001,
5149
-                      r_factor = -(1.75 + 0.005 * r_diff + 0.001 * sq(r_diff)), //2.25 for r_diff = 20mm
5150
-                      a_factor = 100.0 / delta_calibration_radius;
5151
+                      h_factor = 1.00 + r_diff * 0.001,                                          //1.02 for r_diff = 20mm
5152
+                      r_factor = -(1.75 + 0.005 * r_diff + 0.001 * sq(r_diff)),                  //2.25 for r_diff = 20mm
5153
+                      a_factor = 100.0 / delta_calibration_radius;                               //1.25 for cal_rd = 80mm
5151 5154
 
5152 5155
           #define ZP(N,I) ((N) * z_at_pt[I])
5153 5156
           #define Z1000(I) ZP(1.00, I)
@@ -5162,9 +5165,10 @@ inline void gcode_G28() {
5162 5165
           #define Z0888(I) ZP(a_factor * 8.0 / 9.0, I)
5163 5166
 
5164 5167
           switch (probe_points) {
5168
+            case -1:
5169
+              test_precision = 0.00;
5165 5170
             case 1:
5166 5171
               LOOP_XYZ(i) e_delta[i] = Z1000(0);
5167
-              r_delta = 0.00;
5168 5172
               break;
5169 5173
 
5170 5174
             case 2:
@@ -5186,8 +5190,11 @@ inline void gcode_G28() {
5186 5190
               e_delta[Y_AXIS] = Z1050(0) - Z0175(1) + Z0350(5) - Z0175(9) + Z0175(7) - Z0350(11) + Z0175(3);
5187 5191
               e_delta[Z_AXIS] = Z1050(0) - Z0175(1) - Z0175(5) + Z0350(9) + Z0175(7) + Z0175(11) - Z0350(3);
5188 5192
               r_delta         = Z2250(0) - Z0375(1) - Z0375(5) - Z0375(9) - Z0375(7) - Z0375(11) - Z0375(3);
5189
-              t_alpha         =          + Z0444(1) - Z0888(5) + Z0444(9) + Z0444(7) - Z0888(11) + Z0444(3);
5190
-              t_beta          =          - Z0888(1) + Z0444(5) + Z0444(9) - Z0888(7) + Z0444(11) + Z0444(3);
5193
+              
5194
+              if (probe_points > 0) {                                                            //probe points negative disables tower angles
5195
+                t_alpha         =          + Z0444(1) - Z0888(5) + Z0444(9) + Z0444(7) - Z0888(11) + Z0444(3);
5196
+                t_beta          =          - Z0888(1) + Z0444(5) + Z0444(9) - Z0888(7) + Z0444(11) + Z0444(3);
5197
+              }
5191 5198
               break;
5192 5199
           }
5193 5200
 
@@ -5221,7 +5228,7 @@ inline void gcode_G28() {
5221 5228
           SERIAL_PROTOCOLPGM(".     c:");
5222 5229
           if (z_at_pt[0] > 0) SERIAL_CHAR('+');
5223 5230
           SERIAL_PROTOCOL_F(z_at_pt[0], 2);
5224
-          if (probe_points > 1) {
5231
+          if (abs(probe_points) > 2 || probe_points == 2) {
5225 5232
             SERIAL_PROTOCOLPGM("     x:");
5226 5233
             if (z_at_pt[1] >= 0) SERIAL_CHAR('+');
5227 5234
             SERIAL_PROTOCOL_F(z_at_pt[1], 2);
@@ -5232,9 +5239,9 @@ inline void gcode_G28() {
5232 5239
             if (z_at_pt[9] >= 0) SERIAL_CHAR('+');
5233 5240
             SERIAL_PROTOCOL_F(z_at_pt[9], 2);
5234 5241
           }
5235
-          if (probe_points > 0) SERIAL_EOL;
5236
-          if (probe_points > 2 || probe_points == -2) {
5237
-            if (probe_points > 2) SERIAL_PROTOCOLPGM(".            ");
5242
+          if (probe_points != -2) SERIAL_EOL;
5243
+          if (abs(probe_points) > 2 || probe_points == -2) {
5244
+            if (abs(probe_points) > 2) SERIAL_PROTOCOLPGM(".            ");
5238 5245
             SERIAL_PROTOCOLPGM("    yz:");
5239 5246
             if (z_at_pt[7] >= 0) SERIAL_CHAR('+');
5240 5247
             SERIAL_PROTOCOL_F(z_at_pt[7], 2);
@@ -5247,14 +5254,14 @@ inline void gcode_G28() {
5247 5254
             SERIAL_EOL;
5248 5255
           }
5249 5256
         }
5250
-        if (test_precision != 0.0) {            // !forced end
5251
-          if (zero_std_dev >= test_precision) { // end iterations
5257
+        if (test_precision != 0.0) {                                                             // !forced end
5258
+          if (zero_std_dev >= test_precision) {                                                  // end iterations
5252 5259
             SERIAL_PROTOCOLPGM("Calibration OK");
5253
-            SERIAL_PROTOCOLLNPGM("                                    rolling back.");
5254
-            LCD_MESSAGEPGM("Calibration OK");
5260
+            SERIAL_PROTOCOLPGM("                                    rolling back.");
5255 5261
             SERIAL_EOL;
5262
+            LCD_MESSAGEPGM("Calibration OK");
5256 5263
           }
5257
-          else {                                // !end iterations
5264
+          else {                                                                                 // !end iterations
5258 5265
             char mess[15] = "No convergence";
5259 5266
             if (iterations < 31)
5260 5267
               sprintf_P(mess, PSTR("Iteration : %02i"), (int)iterations);
@@ -5291,10 +5298,19 @@ inline void gcode_G28() {
5291 5298
           if (zero_std_dev >= test_precision)
5292 5299
             SERIAL_PROTOCOLLNPGM("save with M500 and/or copy to configuration.h");
5293 5300
         }
5294
-        else {                                  // forced end
5295
-          SERIAL_PROTOCOLPGM("End DRY-RUN                                      std dev:");
5296
-          SERIAL_PROTOCOL_F(zero_std_dev, 3);
5297
-          SERIAL_EOL;
5301
+        else {                                                                                   // forced end
5302
+          if (verbose_level == 0) {
5303
+            SERIAL_PROTOCOLPGM("End DRY-RUN                                       std dev:");
5304
+            SERIAL_PROTOCOL_F(zero_std_dev, 3);
5305
+            SERIAL_EOL;
5306
+          }
5307
+          else {
5308
+            SERIAL_PROTOCOLLNPGM("Calibration OK");
5309
+            LCD_MESSAGEPGM("Calibration OK");
5310
+            SERIAL_PROTOCOLPAIR(".Height:", DELTA_HEIGHT + home_offset[Z_AXIS]);
5311
+            SERIAL_EOL;
5312
+            SERIAL_PROTOCOLLNPGM("save with M500 and/or copy to configuration.h");
5313
+          }
5298 5314
         }
5299 5315
 
5300 5316
         clean_up_after_endstop_or_probe_move();

+ 1
- 1
Marlin/ultralcd.cpp View File

@@ -1834,7 +1834,7 @@ void kill_screen(const char* lcd_msg) {
1834 1834
       MENU_BACK(MSG_MAIN);
1835 1835
       #if ENABLED(DELTA_AUTO_CALIBRATION)
1836 1836
         MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33 C"));
1837
-        MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 C1"));
1837
+        MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 C-1"));
1838 1838
       #endif
1839 1839
       MENU_ITEM(submenu, MSG_AUTO_HOME, _lcd_delta_calibrate_home);
1840 1840
       if (axis_homed[Z_AXIS]) {

Loading…
Cancel
Save