Browse Source

Fix G76 probe height / position (#17392)

Tor-p 4 years ago
parent
commit
d6f39a69af
No account linked to committer's email address

+ 2
- 9
Marlin/Configuration_adv.h View File

@@ -1600,18 +1600,11 @@
1600 1600
   // Add additional compensation depending on hotend temperature
1601 1601
   // Note: this values cannot be calibrated and have to be set manually
1602 1602
   #if ENABLED(PROBE_TEMP_COMPENSATION)
1603
-    // Max temperature that can be reached by heated bed.
1604
-    // This is required only for the calibration process.
1605
-    #define PTC_MAX_BED_TEMP BED_MAXTEMP
1606
-
1607 1603
     // Park position to wait for probe cooldown
1608
-    #define PTC_PARK_POS_X 0.0F
1609
-    #define PTC_PARK_POS_Y 0.0F
1610
-    #define PTC_PARK_POS_Z 100.0F
1604
+    #define PTC_PARK_POS   { 0, 0, 100 }
1611 1605
 
1612 1606
     // Probe position to probe and wait for probe to reach target temperature
1613
-    #define PTC_PROBE_POS_X  90.0F
1614
-    #define PTC_PROBE_POS_Y 100.0F
1607
+    #define PTC_PROBE_POS  { 90, 100 }
1615 1608
 
1616 1609
     // Enable additional compensation using hotend temperature
1617 1610
     // Note: this values cannot be calibrated automatically but have to be set manually

+ 5
- 5
Marlin/src/feature/probe_temp_comp.cpp View File

@@ -29,11 +29,11 @@
29 29
 
30 30
 ProbeTempComp temp_comp;
31 31
 
32
-int16_t ProbeTempComp::z_offsets_probe[ProbeTempComp::cali_info_init[TSI_PROBE].measurements],  // = {0}
33
-        ProbeTempComp::z_offsets_bed[ProbeTempComp::cali_info_init[TSI_BED].measurements];      // = {0}
32
+int16_t ProbeTempComp::z_offsets_probe[cali_info_init[TSI_PROBE].measurements],  // = {0}
33
+        ProbeTempComp::z_offsets_bed[cali_info_init[TSI_BED].measurements];      // = {0}
34 34
 
35 35
 #if ENABLED(USE_TEMP_EXT_COMPENSATION)
36
-  int16_t ProbeTempComp::z_offsets_ext[ProbeTempComp::cali_info_init[TSI_EXT].measurements];    // = {0}
36
+  int16_t ProbeTempComp::z_offsets_ext[cali_info_init[TSI_EXT].measurements];    // = {0}
37 37
 #endif
38 38
 
39 39
 int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = {
@@ -44,9 +44,9 @@ int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = {
44 44
 };
45 45
 
46 46
 const temp_calib_t ProbeTempComp::cali_info[TSI_COUNT] = {
47
-  ProbeTempComp::cali_info_init[TSI_PROBE], ProbeTempComp::cali_info_init[TSI_BED]
47
+  cali_info_init[TSI_PROBE], cali_info_init[TSI_BED]
48 48
   #if ENABLED(USE_TEMP_EXT_COMPENSATION)
49
-    , ProbeTempComp::cali_info_init[TSI_EXT]
49
+    , cali_info_init[TSI_EXT]
50 50
   #endif
51 51
 };
52 52
 

+ 16
- 18
Marlin/src/feature/probe_temp_comp.h View File

@@ -44,30 +44,28 @@ typedef struct {
44 44
  * Z-probes like the P.I.N.D.A V2 allow for compensation of
45 45
  * measurement errors/shifts due to changed temperature.
46 46
  */
47
+
48
+static constexpr temp_calib_t cali_info_init[TSI_COUNT] = {
49
+    {  10,  5,  30,  30 + 10 *  5 },       // Probe
50
+    {  10,  5,  60,  60 + 10 *  5 },       // Bed
51
+  #if ENABLED(USE_TEMP_EXT_COMPENSATION)
52
+    {  20,  5, 180, 180 +  5 * 20 }        // Extruder
53
+  #endif
54
+};
55
+
47 56
 class ProbeTempComp {
48 57
   public:
49 58
 
50
-    static constexpr temp_calib_t cali_info_init[TSI_COUNT] = {
51
-        {  10,  5,  30,  30 + 10 *  5 },       // Probe
52
-        {  10,  5,  60,  60 + 10 *  5 },       // Bed
53
-      #if ENABLED(USE_TEMP_EXT_COMPENSATION)
54
-        {  20,  5, 180, 180 +  5 * 20 }        // Extruder
55
-      #endif
56
-    };
57 59
     static const temp_calib_t cali_info[TSI_COUNT];
58 60
 
59 61
     // Where to park nozzle to wait for probe cooldown
60
-    static constexpr float park_point_x = PTC_PARK_POS_X,
61
-                           park_point_y = PTC_PARK_POS_Y,
62
-                           park_point_z = PTC_PARK_POS_Z,
63
-                           // XY coordinates of nozzle for probing the bed
64
-                           measure_point_x     = PTC_PROBE_POS_X,   // Coordinates to probe
65
-                           measure_point_y     = PTC_PROBE_POS_Y;
66
-                           //measure_point_x     = 12.0f,           // Coordinates to probe on MK52 magnetic heatbed
67
-                           //measure_point_y     =  7.3f;
68
-
69
-    static constexpr int  max_bed_temp         = PTC_MAX_BED_TEMP,  // Max temperature to avoid heating errors
70
-                          probe_calib_bed_temp = max_bed_temp,      // Bed temperature while calibrating probe
62
+    static constexpr xyz_pos_t park_point = PTC_PARK_POS;
63
+
64
+    // XY coordinates of nozzle for probing the bed
65
+    static constexpr xy_pos_t measure_point    = PTC_PROBE_POS;     // Coordinates to probe
66
+                            //measure_point    = { 12.0f, 7.3f };   // Coordinates for the MK52 magnetic heatbed
67
+
68
+    static constexpr int  probe_calib_bed_temp = BED_MAXTEMP - 10,  // Bed temperature while calibrating probe
71 69
                           bed_calib_probe_temp = 30;                // Probe temperature while calibrating bed
72 70
 
73 71
     static int16_t *sensor_z_offsets[TSI_COUNT],

+ 28
- 33
Marlin/src/gcode/calibrate/G76_M871.cpp View File

@@ -103,13 +103,19 @@ void GcodeSuite::G76() {
103 103
     return false;
104 104
   };
105 105
 
106
-  auto g76_probe = [](const xy_pos_t &xypos) {
106
+  auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) {
107 107
     do_blocking_move_to_z(5.0); // Raise nozzle before probing
108
-    const float measured_z = probe.probe_at_point(xypos, PROBE_PT_NONE, 0, false);  // verbose=0, probe_relative=false
108
+    const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_NONE, 0, false);  // verbose=0, probe_relative=false
109 109
     if (isnan(measured_z))
110 110
       SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
111
-    else
111
+    else {
112 112
       SERIAL_ECHOLNPAIR_F("Measured: ", measured_z);
113
+      if (targ == cali_info_init[sid].start_temp)
114
+        temp_comp.prepare_new_calibration(measured_z);
115
+      else
116
+        temp_comp.push_back_new_measurement(sid, measured_z);
117
+      targ += cali_info_init[sid].temp_res;
118
+    }
113 119
     return measured_z;
114 120
   };
115 121
 
@@ -125,8 +131,9 @@ void GcodeSuite::G76() {
125 131
   // Synchronize with planner
126 132
   planner.synchronize();
127 133
 
128
-  const xyz_pos_t parkpos = { temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z };
129
-  const xy_pos_t ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y };
134
+  const xyz_pos_t parkpos = temp_comp.park_point,
135
+            probe_pos_xyz = temp_comp.measure_point + xyz_pos_t({ 0.0f, 0.0f, 0.5f }),
136
+              noz_pos_xyz = probe_pos_xyz - probe.offset_xy; // Nozzle position based on probe position
130 137
 
131 138
   if (do_bed_cal || do_probe_cal) {
132 139
     // Ensure park position is reachable
@@ -135,7 +142,7 @@ void GcodeSuite::G76() {
135 142
       SERIAL_ECHOLNPGM("!Park");
136 143
     else {
137 144
       // Ensure probe position is reachable
138
-      reachable = probe.can_reach(ppos);
145
+      reachable = probe.can_reach(probe_pos_xyz);
139 146
       if (!reachable) SERIAL_ECHOLNPGM("!Probe");
140 147
     }
141 148
 
@@ -149,8 +156,6 @@ void GcodeSuite::G76() {
149 156
 
150 157
   remember_feedrate_scaling_off();
151 158
 
152
-  // Nozzle position based on probe position
153
-  const xy_pos_t noz_pos = ppos - probe.offset_xy;
154 159
 
155 160
   /******************************************
156 161
    * Calibrate bed temperature offsets
@@ -159,9 +164,13 @@ void GcodeSuite::G76() {
159 164
   // Report temperatures every second and handle heating timeouts
160 165
   millis_t next_temp_report = millis() + 1000;
161 166
 
167
+  auto report_targets = [&](const uint16_t tb, const uint16_t tp) {
168
+    SERIAL_ECHOLNPAIR("Target Bed:", tb, " Probe:", tp);
169
+  };
170
+
162 171
   if (do_bed_cal) {
163 172
 
164
-    uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp,
173
+    uint16_t target_bed = cali_info_init[TSI_BED].start_temp,
165 174
              target_probe = temp_comp.bed_calib_probe_temp;
166 175
 
167 176
     SERIAL_ECHOLNPGM("Waiting for cooling.");
@@ -176,7 +185,7 @@ void GcodeSuite::G76() {
176 185
     for (;;) {
177 186
       thermalManager.setTargetBed(target_bed);
178 187
 
179
-      SERIAL_ECHOLNPAIR("Target Bed:", target_bed, " Probe:", target_probe);
188
+      report_targets(target_bed, target_probe);
180 189
 
181 190
       // Park nozzle
182 191
       do_blocking_move_to(parkpos);
@@ -188,21 +197,13 @@ void GcodeSuite::G76() {
188 197
       }
189 198
 
190 199
       // Move the nozzle to the probing point and wait for the probe to reach target temp
191
-      do_blocking_move_to_xy(noz_pos);
200
+      do_blocking_move_to(noz_pos_xyz);
192 201
       SERIAL_ECHOLNPGM("Waiting for probe heating.");
193 202
       while (thermalManager.degProbe() < target_probe)
194 203
         report_temps(next_temp_report);
195 204
 
196
-      const float measured_z = g76_probe(noz_pos);
197
-      if (isnan(measured_z)) break;
198
-
199
-      if (target_bed == temp_comp.cali_info_init[TSI_BED].start_temp)
200
-        temp_comp.prepare_new_calibration(measured_z);
201
-      else
202
-        temp_comp.push_back_new_measurement(TSI_BED, measured_z);
203
-
204
-      target_bed += temp_comp.cali_info_init[TSI_BED].temp_res;
205
-      if (target_bed > temp_comp.max_bed_temp) break;
205
+      const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz);
206
+      if (isnan(measured_z) || target_bed > BED_MAXTEMP - 10) break;
206 207
     }
207 208
 
208 209
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
@@ -231,7 +232,9 @@ void GcodeSuite::G76() {
231 232
     const uint16_t target_bed = temp_comp.probe_calib_bed_temp;
232 233
     thermalManager.setTargetBed(target_bed);
233 234
 
234
-    uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
235
+    uint16_t target_probe = cali_info_init[TSI_PROBE].start_temp;
236
+
237
+    report_targets(target_bed, target_probe);
235 238
 
236 239
     // Wait for heatbed to reach target temp and probe to cool below target temp
237 240
     wait_for_temps(target_bed, target_probe, next_temp_report);
@@ -244,7 +247,7 @@ void GcodeSuite::G76() {
244 247
     bool timeout = false;
245 248
     for (;;) {
246 249
       // Move probe to probing point and wait for it to reach target temperature
247
-      do_blocking_move_to_xy(noz_pos);
250
+      do_blocking_move_to(noz_pos_xyz);
248 251
 
249 252
       SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe);
250 253
       const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
@@ -257,16 +260,8 @@ void GcodeSuite::G76() {
257 260
       }
258 261
       if (timeout) break;
259 262
 
260
-      const float measured_z = g76_probe(noz_pos);
261
-      if (isnan(measured_z)) break;
262
-
263
-      if (target_probe == temp_comp.cali_info_init[TSI_PROBE].start_temp)
264
-        temp_comp.prepare_new_calibration(measured_z);
265
-      else
266
-        temp_comp.push_back_new_measurement(TSI_PROBE, measured_z);
267
-
268
-      target_probe += temp_comp.cali_info_init[TSI_PROBE].temp_res;
269
-      if (target_probe > temp_comp.cali_info_init[TSI_PROBE].end_temp) break;
263
+      const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz);
264
+      if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break;
270 265
     }
271 266
 
272 267
     SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());

+ 15
- 0
Marlin/src/inc/SanityCheck.h View File

@@ -492,6 +492,21 @@
492 492
 #endif
493 493
 
494 494
 /**
495
+ * Probe temp compensation requirements
496
+ */
497
+#if ENABLED(PROBE_TEMP_COMPENSATION)
498
+  #if defined(PTC_PARK_POS_X) || defined(PTC_PARK_POS_Y) || defined(PTC_PARK_POS_Z)
499
+    #error "PTC_PARK_POS_[XYZ] is now PTC_PARK_POS (array). Please update Configuration_adv.h."
500
+  #elif !defined(PTC_PARK_POS)
501
+    #error "PROBE_TEMP_COMPENSATION requires PTC_PARK_POS."
502
+  #elif defined(PTC_PROBE_POS_X) || defined(PTC_PROBE_POS_Y)
503
+    #error "PTC_PROBE_POS_[XY] is now PTC_PROBE_POS (array). Please update Configuration_adv.h."
504
+  #elif !defined(PTC_PROBE_POS)
505
+    #error "PROBE_TEMP_COMPENSATION requires PTC_PROBE_POS."
506
+  #endif
507
+#endif
508
+
509
+/**
495 510
  * Marlin release, version and default string
496 511
  */
497 512
 #ifndef SHORT_BUILD_VERSION

+ 1
- 1
buildroot/share/tests/rambo-tests View File

@@ -50,7 +50,7 @@ opt_set GRID_MAX_POINTS_X 16
50 50
 opt_set FANMUX0_PIN 53
51 51
 opt_disable USE_WATCHDOG
52 52
 opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \
53
-           FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING PIDTEMPBED \
53
+           FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING PIDTEMPBED PROBE_TEMP_COMPENSATION \
54 54
            PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \
55 55
            EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \
56 56
            BLINKM PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \

Loading…
Cancel
Save