|
@@ -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());
|