From 87cde777e38d295b96e1ada3694da6840372a111 Mon Sep 17 00:00:00 2001 From: Tor-p <63096807+Tor-p@users.noreply.github.com> Date: Fri, 3 Apr 2020 15:12:59 +0200 Subject: [PATCH 01/14] Fix probe height and position Fix probe height for heating which had got lost during code cleanup. Also added Z_SAFE_HOMING support --- Marlin/Configuration_adv.h | 2 +- Marlin/src/gcode/calibrate/G76_M871.cpp | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 7d1547c0d027..6a7b3b362a4d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1602,7 +1602,7 @@ #if ENABLED(PROBE_TEMP_COMPENSATION) // Max temperature that can be reached by heated bed. // This is required only for the calibration process. - #define PTC_MAX_BED_TEMP BED_MAXTEMP + #define PTC_MAX_BED_TEMP BED_MAXTEMP - 10 // Park position to wait for probe cooldown #define PTC_PARK_POS_X 0.0F diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index c878f83a17f2..df6c22c2353f 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -126,7 +126,14 @@ void GcodeSuite::G76() { planner.synchronize(); const xyz_pos_t parkpos = { temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z }; - const xy_pos_t ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y }; + const xyz_pos_t ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5 }; + // Nozzle position based on probe position + const xyz_pos_t noz_pos = ppos - probe.offset_xy; +#if ENABLED(Z_SAFE_HOMING) + const xy_pos_t probe_pos = { Z_SAFE_HOMING_X_POINT - probe.offset_xy.x, Z_SAFE_HOMING_Y_POINT - probe.offset_xy.y }; +#else + const xy_pos_t probe_pos = { noz_pos.x, noz_pos.y } +#endif if (do_bed_cal || do_probe_cal) { // Ensure park position is reachable @@ -149,8 +156,6 @@ void GcodeSuite::G76() { remember_feedrate_scaling_off(); - // Nozzle position based on probe position - const xy_pos_t noz_pos = ppos - probe.offset_xy; /****************************************** * Calibrate bed temperature offsets @@ -188,12 +193,12 @@ void GcodeSuite::G76() { } // Move the nozzle to the probing point and wait for the probe to reach target temp - do_blocking_move_to_xy(noz_pos); + do_blocking_move_to(noz_pos); SERIAL_ECHOLNPGM("Waiting for probe heating."); while (thermalManager.degProbe() < target_probe) report_temps(next_temp_report); - const float measured_z = g76_probe(noz_pos); + const float measured_z = g76_probe(probe_pos); if (isnan(measured_z)) break; if (target_bed == temp_comp.cali_info_init[TSI_BED].start_temp) @@ -232,6 +237,8 @@ void GcodeSuite::G76() { thermalManager.setTargetBed(target_bed); uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp; + + SERIAL_ECHOLNPAIR("Target Bed:", target_bed, " Probe:", target_probe); // Wait for heatbed to reach target temp and probe to cool below target temp wait_for_temps(target_bed, target_probe, next_temp_report); @@ -244,7 +251,7 @@ void GcodeSuite::G76() { bool timeout = false; for (;;) { // Move probe to probing point and wait for it to reach target temperature - do_blocking_move_to_xy(noz_pos); + do_blocking_move_to(noz_pos); SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe); const millis_t probe_timeout_ms = millis() + 900UL * 1000UL; @@ -257,7 +264,7 @@ void GcodeSuite::G76() { } if (timeout) break; - const float measured_z = g76_probe(noz_pos); + const float measured_z = g76_probe(probe_pos); if (isnan(measured_z)) break; if (target_probe == temp_comp.cali_info_init[TSI_PROBE].start_temp) From f2079bc1b1b939c87fff5e90c6c90ed6caf86e8a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 15:26:38 -0500 Subject: [PATCH 02/14] Reduce string storage cost --- Marlin/src/gcode/calibrate/G76_M871.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index df6c22c2353f..dd49fac4874c 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -125,15 +125,11 @@ void GcodeSuite::G76() { // Synchronize with planner planner.synchronize(); - const xyz_pos_t parkpos = { temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z }; - const xyz_pos_t ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5 }; - // Nozzle position based on probe position - const xyz_pos_t noz_pos = ppos - probe.offset_xy; -#if ENABLED(Z_SAFE_HOMING) - const xy_pos_t probe_pos = { Z_SAFE_HOMING_X_POINT - probe.offset_xy.x, Z_SAFE_HOMING_Y_POINT - probe.offset_xy.y }; -#else - const xy_pos_t probe_pos = { noz_pos.x, noz_pos.y } -#endif + const xyz_pos_t parkpos = { temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z }, + ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5 }, + noz_pos = ppos - probe.offset_xy; // Nozzle position based on probe position + + const xy_pos_t probe_pos = TERN(Z_SAFE_HOMING, safe_homing_xy - probe.offset_xy, noz_pos); if (do_bed_cal || do_probe_cal) { // Ensure park position is reachable @@ -164,6 +160,10 @@ void GcodeSuite::G76() { // Report temperatures every second and handle heating timeouts millis_t next_temp_report = millis() + 1000; + auto report_targets = [&](const uint16_t tb, const uint16_t tp) { + SERIAL_ECHOLNPAIR("Target Bed:", tb, " Probe:", tp); + }; + if (do_bed_cal) { uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp, @@ -181,7 +181,7 @@ void GcodeSuite::G76() { for (;;) { thermalManager.setTargetBed(target_bed); - SERIAL_ECHOLNPAIR("Target Bed:", target_bed, " Probe:", target_probe); + report_targets(target_bed, target_probe); // Park nozzle do_blocking_move_to(parkpos); @@ -237,8 +237,8 @@ void GcodeSuite::G76() { thermalManager.setTargetBed(target_bed); uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp; - - SERIAL_ECHOLNPAIR("Target Bed:", target_bed, " Probe:", target_probe); + + report_targets(target_bed, target_probe); // Wait for heatbed to reach target temp and probe to cool below target temp wait_for_temps(target_bed, target_probe, next_temp_report); From 606b3d9d130aa214513f60a1369520584a8338dd Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 15:33:57 -0500 Subject: [PATCH 03/14] =?UTF-8?q?Consider=2010=C2=B0C=20overshoot=20margin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/Configuration_adv.h | 2 +- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 6a7b3b362a4d..7d1547c0d027 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1602,7 +1602,7 @@ #if ENABLED(PROBE_TEMP_COMPENSATION) // Max temperature that can be reached by heated bed. // This is required only for the calibration process. - #define PTC_MAX_BED_TEMP BED_MAXTEMP - 10 + #define PTC_MAX_BED_TEMP BED_MAXTEMP // Park position to wait for probe cooldown #define PTC_PARK_POS_X 0.0F diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index dd49fac4874c..8f9dad75b328 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -207,7 +207,7 @@ void GcodeSuite::G76() { temp_comp.push_back_new_measurement(TSI_BED, measured_z); target_bed += temp_comp.cali_info_init[TSI_BED].temp_res; - if (target_bed > temp_comp.max_bed_temp) break; + if (target_bed > temp_comp.max_bed_temp - 10) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); From a0488e9b53edaab28d7d521e2301a0d2f1c5dac5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 15:54:00 -0500 Subject: [PATCH 04/14] Add more to g76_probe --- Marlin/src/gcode/calibrate/G76_M871.cpp | 40 ++++++++++--------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 8f9dad75b328..e2f820712455 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -103,13 +103,19 @@ void GcodeSuite::G76() { return false; }; - auto g76_probe = [](const xy_pos_t &xypos) { + auto g76_probe = [](const TempSensorID sid, uint16_t &targ, const xy_pos_t &nozpos) { do_blocking_move_to_z(5.0); // Raise nozzle before probing - const float measured_z = probe.probe_at_point(xypos, PROBE_PT_NONE, 0, false); // verbose=0, probe_relative=false + const float measured_z = probe.probe_at_point(nozpos, PROBE_PT_NONE, 0, false); // verbose=0, probe_relative=false if (isnan(measured_z)) SERIAL_ECHOLNPGM("!Received NAN. Aborting."); - else + else { SERIAL_ECHOLNPAIR_F("Measured: ", measured_z); + if (targ == temp_comp.cali_info_init[sid].start_temp) + temp_comp.prepare_new_calibration(measured_z); + else + temp_comp.push_back_new_measurement(sid, measured_z); + targ += temp_comp.cali_info_init[sid].temp_res; + } return measured_z; }; @@ -126,10 +132,10 @@ void GcodeSuite::G76() { planner.synchronize(); const xyz_pos_t parkpos = { temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z }, - ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5 }, + ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5 }, noz_pos = ppos - probe.offset_xy; // Nozzle position based on probe position - const xy_pos_t probe_pos = TERN(Z_SAFE_HOMING, safe_homing_xy - probe.offset_xy, noz_pos); + const xy_pos_t probe_noz_pos = TERN(Z_SAFE_HOMING, safe_homing_xy - probe.offset_xy, noz_pos); if (do_bed_cal || do_probe_cal) { // Ensure park position is reachable @@ -198,16 +204,8 @@ void GcodeSuite::G76() { while (thermalManager.degProbe() < target_probe) report_temps(next_temp_report); - const float measured_z = g76_probe(probe_pos); - if (isnan(measured_z)) break; - - if (target_bed == temp_comp.cali_info_init[TSI_BED].start_temp) - temp_comp.prepare_new_calibration(measured_z); - else - temp_comp.push_back_new_measurement(TSI_BED, measured_z); - - target_bed += temp_comp.cali_info_init[TSI_BED].temp_res; - if (target_bed > temp_comp.max_bed_temp - 10) break; + const float measured_z = g76_probe(TSI_BED, target_bed, probe_noz_pos); + if (isnan(measured_z) || target_bed > temp_comp.max_bed_temp - 10) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); @@ -264,16 +262,8 @@ void GcodeSuite::G76() { } if (timeout) break; - const float measured_z = g76_probe(probe_pos); - if (isnan(measured_z)) break; - - if (target_probe == temp_comp.cali_info_init[TSI_PROBE].start_temp) - temp_comp.prepare_new_calibration(measured_z); - else - temp_comp.push_back_new_measurement(TSI_PROBE, measured_z); - - target_probe += temp_comp.cali_info_init[TSI_PROBE].temp_res; - if (target_probe > temp_comp.cali_info_init[TSI_PROBE].end_temp) break; + const float measured_z = g76_probe(TSI_PROBE, target_probe, probe_noz_pos); + if (isnan(measured_z) || target_probe > temp_comp.cali_info_init[TSI_PROBE].end_temp) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); From 4fb7cbcc659dc3bf830284c4f501c7cb7f510343 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 16:13:52 -0500 Subject: [PATCH 05/14] PTC settings as arrays --- Marlin/Configuration_adv.h | 7 ++----- Marlin/src/feature/probe_temp_comp.h | 13 +++++-------- Marlin/src/gcode/calibrate/G76_M871.cpp | 4 ++-- Marlin/src/inc/SanityCheck.h | 15 +++++++++++++++ 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 7d1547c0d027..3f79f28af0fa 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1605,13 +1605,10 @@ #define PTC_MAX_BED_TEMP BED_MAXTEMP // Park position to wait for probe cooldown - #define PTC_PARK_POS_X 0.0F - #define PTC_PARK_POS_Y 0.0F - #define PTC_PARK_POS_Z 100.0F + #define PTC_PARK_POS { 0, 0, 100 } // Probe position to probe and wait for probe to reach target temperature - #define PTC_PROBE_POS_X 90.0F - #define PTC_PROBE_POS_Y 100.0F + #define PTC_PROBE_POS { 90, 100 } // Enable additional compensation using hotend temperature // Note: this values cannot be calibrated automatically but have to be set manually diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 2ed10eeb990a..25c28b9a4a44 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -57,14 +57,11 @@ class ProbeTempComp { static const temp_calib_t cali_info[TSI_COUNT]; // Where to park nozzle to wait for probe cooldown - static constexpr float park_point_x = PTC_PARK_POS_X, - park_point_y = PTC_PARK_POS_Y, - park_point_z = PTC_PARK_POS_Z, - // XY coordinates of nozzle for probing the bed - measure_point_x = PTC_PROBE_POS_X, // Coordinates to probe - measure_point_y = PTC_PROBE_POS_Y; - //measure_point_x = 12.0f, // Coordinates to probe on MK52 magnetic heatbed - //measure_point_y = 7.3f; + static constexpr xyz_pos_t park_point = PTC_PARK_POS; + + // XY coordinates of nozzle for probing the bed + static constexpr xy_pos_t measure_point = PTC_PROBE_POS; // Coordinates to probe + //measure_point = { 12.0f, 7.3f }; // Coordinates for the MK52 magnetic heatbed static constexpr int max_bed_temp = PTC_MAX_BED_TEMP, // Max temperature to avoid heating errors probe_calib_bed_temp = max_bed_temp, // Bed temperature while calibrating probe diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index e2f820712455..90b1ef8b6484 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -131,8 +131,8 @@ void GcodeSuite::G76() { // Synchronize with planner planner.synchronize(); - const xyz_pos_t parkpos = { temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z }, - ppos = { temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5 }, + const xyz_pos_t parkpos = temp_comp.park_point, + ppos = temp_comp.measure_point + xyz_pos_t({ 0.0f, 0.0f, 0.5f }), noz_pos = ppos - probe.offset_xy; // Nozzle position based on probe position const xy_pos_t probe_noz_pos = TERN(Z_SAFE_HOMING, safe_homing_xy - probe.offset_xy, noz_pos); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 088ad098db92..185f5c0b4dce 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -491,6 +491,21 @@ #error "DUGS_UI_MOVE_DIS_OPTION is spelled DGUS_UI_MOVE_DIS_OPTION. Please update Configuration_adv.h." #endif +/** + * Probe temp compensation requirements + */ +#if ENABLED(PROBE_TEMP_COMPENSATION) + #if defined(PTC_PARK_POS_X) || defined(PTC_PARK_POS_Y) || defined(PTC_PARK_POS_Z) + #error "PTC_PARK_POS_[XYZ] is now PTC_PARK_POS (array). Please update Configuration_adv.h." + #elif !defined(PTC_PARK_POS) + #error "PROBE_TEMP_COMPENSATION requires PTC_PARK_POS." + #elif defined(PTC_PROBE_POS_X) || defined(PTC_PROBE_POS_Y) + #error "PTC_PROBE_POS_[XY] is now PTC_PROBE_POS (array). Please update Configuration_adv.h." + #elif !defined(PTC_PROBE_POS) + #error "PROBE_TEMP_COMPENSATION requires PTC_PROBE_POS." + #endif +#endif + /** * Marlin release, version and default string */ From e4a6df811f23b178abe1d80ea2d588386ca62ae2 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 16:14:02 -0500 Subject: [PATCH 06/14] Add a test for PTC --- buildroot/share/tests/rambo-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot/share/tests/rambo-tests b/buildroot/share/tests/rambo-tests index 8092059627ea..57c363c3a467 100644 --- a/buildroot/share/tests/rambo-tests +++ b/buildroot/share/tests/rambo-tests @@ -50,7 +50,7 @@ opt_set GRID_MAX_POINTS_X 16 opt_set FANMUX0_PIN 53 opt_disable USE_WATCHDOG opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \ - FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING PIDTEMPBED \ + FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING PIDTEMPBED PROBE_TEMP_COMPENSATION \ PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \ EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \ BLINKM PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \ From 649cce0e721031fcb910b848b3dcee99b0a6ea90 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 16:28:31 -0500 Subject: [PATCH 07/14] Move cali_info_init up --- Marlin/src/feature/probe_temp_comp.cpp | 10 +++++----- Marlin/src/feature/probe_temp_comp.h | 16 +++++++++------- Marlin/src/gcode/calibrate/G76_M871.cpp | 10 +++++----- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Marlin/src/feature/probe_temp_comp.cpp b/Marlin/src/feature/probe_temp_comp.cpp index 6b787f420a33..b773536a5d54 100644 --- a/Marlin/src/feature/probe_temp_comp.cpp +++ b/Marlin/src/feature/probe_temp_comp.cpp @@ -29,11 +29,11 @@ ProbeTempComp temp_comp; -int16_t ProbeTempComp::z_offsets_probe[ProbeTempComp::cali_info_init[TSI_PROBE].measurements], // = {0} - ProbeTempComp::z_offsets_bed[ProbeTempComp::cali_info_init[TSI_BED].measurements]; // = {0} +int16_t ProbeTempComp::z_offsets_probe[cali_info_init[TSI_PROBE].measurements], // = {0} + ProbeTempComp::z_offsets_bed[cali_info_init[TSI_BED].measurements]; // = {0} #if ENABLED(USE_TEMP_EXT_COMPENSATION) - int16_t ProbeTempComp::z_offsets_ext[ProbeTempComp::cali_info_init[TSI_EXT].measurements]; // = {0} + int16_t ProbeTempComp::z_offsets_ext[cali_info_init[TSI_EXT].measurements]; // = {0} #endif int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = { @@ -44,9 +44,9 @@ int16_t *ProbeTempComp::sensor_z_offsets[TSI_COUNT] = { }; const temp_calib_t ProbeTempComp::cali_info[TSI_COUNT] = { - ProbeTempComp::cali_info_init[TSI_PROBE], ProbeTempComp::cali_info_init[TSI_BED] + cali_info_init[TSI_PROBE], cali_info_init[TSI_BED] #if ENABLED(USE_TEMP_EXT_COMPENSATION) - , ProbeTempComp::cali_info_init[TSI_EXT] + , cali_info_init[TSI_EXT] #endif }; diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 25c28b9a4a44..e505e0f1d3c3 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -44,16 +44,18 @@ typedef struct { * Z-probes like the P.I.N.D.A V2 allow for compensation of * measurement errors/shifts due to changed temperature. */ + +static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { + { 10, 5, 30, 30 + 10 * 5 }, // Probe + { 10, 5, 60, 60 + 10 * 5 }, // Bed + #if ENABLED(USE_TEMP_EXT_COMPENSATION) + { 20, 5, 180, 180 + 5 * 20 } // Extruder + #endif +}; + class ProbeTempComp { public: - static constexpr temp_calib_t cali_info_init[TSI_COUNT] = { - { 10, 5, 30, 30 + 10 * 5 }, // Probe - { 10, 5, 60, 60 + 10 * 5 }, // Bed - #if ENABLED(USE_TEMP_EXT_COMPENSATION) - { 20, 5, 180, 180 + 5 * 20 } // Extruder - #endif - }; static const temp_calib_t cali_info[TSI_COUNT]; // Where to park nozzle to wait for probe cooldown diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 90b1ef8b6484..4c5d5fb81dc8 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -110,11 +110,11 @@ void GcodeSuite::G76() { SERIAL_ECHOLNPGM("!Received NAN. Aborting."); else { SERIAL_ECHOLNPAIR_F("Measured: ", measured_z); - if (targ == temp_comp.cali_info_init[sid].start_temp) + if (targ == cali_info_init[sid].start_temp) temp_comp.prepare_new_calibration(measured_z); else temp_comp.push_back_new_measurement(sid, measured_z); - targ += temp_comp.cali_info_init[sid].temp_res; + targ += cali_info_init[sid].temp_res; } return measured_z; }; @@ -172,7 +172,7 @@ void GcodeSuite::G76() { if (do_bed_cal) { - uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp, + uint16_t target_bed = cali_info_init[TSI_BED].start_temp, target_probe = temp_comp.bed_calib_probe_temp; SERIAL_ECHOLNPGM("Waiting for cooling."); @@ -234,7 +234,7 @@ void GcodeSuite::G76() { const uint16_t target_bed = temp_comp.probe_calib_bed_temp; thermalManager.setTargetBed(target_bed); - uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp; + uint16_t target_probe = cali_info_init[TSI_PROBE].start_temp; report_targets(target_bed, target_probe); @@ -263,7 +263,7 @@ void GcodeSuite::G76() { if (timeout) break; const float measured_z = g76_probe(TSI_PROBE, target_probe, probe_noz_pos); - if (isnan(measured_z) || target_probe > temp_comp.cali_info_init[TSI_PROBE].end_temp) break; + if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); From a927777c6add31abd4a60886648dae7932e1e607 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 19:11:40 -0500 Subject: [PATCH 08/14] Use the limited temp for testing --- Marlin/src/feature/probe_temp_comp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index e505e0f1d3c3..92689e1d689e 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -66,7 +66,7 @@ class ProbeTempComp { //measure_point = { 12.0f, 7.3f }; // Coordinates for the MK52 magnetic heatbed static constexpr int max_bed_temp = PTC_MAX_BED_TEMP, // Max temperature to avoid heating errors - probe_calib_bed_temp = max_bed_temp, // Bed temperature while calibrating probe + probe_calib_bed_temp = max_bed_temp - 10, // Bed temperature while calibrating probe bed_calib_probe_temp = 30; // Probe temperature while calibrating bed static int16_t *sensor_z_offsets[TSI_COUNT], From 9a1e5786b139136090ac22742120b3e096cfe81b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 3 Apr 2020 19:21:48 -0500 Subject: [PATCH 09/14] Wait for heating at probing position --- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 4c5d5fb81dc8..50d36ded4368 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -249,7 +249,7 @@ void GcodeSuite::G76() { bool timeout = false; for (;;) { // Move probe to probing point and wait for it to reach target temperature - do_blocking_move_to(noz_pos); + do_blocking_move_to(probe_noz_pos); SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe); const millis_t probe_timeout_ms = millis() + 900UL * 1000UL; From 3668455967217a12faab3809b6c4c2a795aebee5 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 4 Apr 2020 00:22:46 -0500 Subject: [PATCH 10/14] Don't override PTC probe position --- Marlin/src/gcode/calibrate/G76_M871.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index 50d36ded4368..b9bf970d20b6 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -132,10 +132,8 @@ void GcodeSuite::G76() { planner.synchronize(); const xyz_pos_t parkpos = temp_comp.park_point, - ppos = temp_comp.measure_point + xyz_pos_t({ 0.0f, 0.0f, 0.5f }), - noz_pos = ppos - probe.offset_xy; // Nozzle position based on probe position - - const xy_pos_t probe_noz_pos = TERN(Z_SAFE_HOMING, safe_homing_xy - probe.offset_xy, noz_pos); + probe_pos_xyz = temp_comp.measure_point + xyz_pos_t({ 0.0f, 0.0f, 0.5f }), + noz_pos_xyz = probe_pos_xyz - probe.offset_xy; // Nozzle position based on probe position if (do_bed_cal || do_probe_cal) { // Ensure park position is reachable @@ -144,7 +142,7 @@ void GcodeSuite::G76() { SERIAL_ECHOLNPGM("!Park"); else { // Ensure probe position is reachable - reachable = probe.can_reach(ppos); + reachable = probe.can_reach(probe_pos_xyz); if (!reachable) SERIAL_ECHOLNPGM("!Probe"); } @@ -199,12 +197,12 @@ void GcodeSuite::G76() { } // Move the nozzle to the probing point and wait for the probe to reach target temp - do_blocking_move_to(noz_pos); + do_blocking_move_to(noz_pos_xyz); SERIAL_ECHOLNPGM("Waiting for probe heating."); while (thermalManager.degProbe() < target_probe) report_temps(next_temp_report); - const float measured_z = g76_probe(TSI_BED, target_bed, probe_noz_pos); + const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); if (isnan(measured_z) || target_bed > temp_comp.max_bed_temp - 10) break; } @@ -249,7 +247,7 @@ void GcodeSuite::G76() { bool timeout = false; for (;;) { // Move probe to probing point and wait for it to reach target temperature - do_blocking_move_to(probe_noz_pos); + do_blocking_move_to(noz_pos_xyz); SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe); const millis_t probe_timeout_ms = millis() + 900UL * 1000UL; @@ -262,7 +260,7 @@ void GcodeSuite::G76() { } if (timeout) break; - const float measured_z = g76_probe(TSI_PROBE, target_probe, probe_noz_pos); + const float measured_z = g76_probe(TSI_PROBE, target_probe, noz_pos_xyz); if (isnan(measured_z) || target_probe > cali_info_init[TSI_PROBE].end_temp) break; } From b9a5e84c0f7d09c34ad6b6c5654441b0bd2d3bbb Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 4 Apr 2020 00:24:58 -0500 Subject: [PATCH 11/14] Update Configuration_adv.h --- Marlin/Configuration_adv.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 3f79f28af0fa..c715fe333298 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1600,10 +1600,6 @@ // Add additional compensation depending on hotend temperature // Note: this values cannot be calibrated and have to be set manually #if ENABLED(PROBE_TEMP_COMPENSATION) - // Max temperature that can be reached by heated bed. - // This is required only for the calibration process. - #define PTC_MAX_BED_TEMP BED_MAXTEMP - // Park position to wait for probe cooldown #define PTC_PARK_POS { 0, 0, 100 } From 69cf0ecf27694feeaec2e2d3e406779ed677755a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 4 Apr 2020 00:26:48 -0500 Subject: [PATCH 12/14] Update probe_temp_comp.h --- Marlin/src/feature/probe_temp_comp.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Marlin/src/feature/probe_temp_comp.h b/Marlin/src/feature/probe_temp_comp.h index 92689e1d689e..dff21b92ad6a 100644 --- a/Marlin/src/feature/probe_temp_comp.h +++ b/Marlin/src/feature/probe_temp_comp.h @@ -65,8 +65,7 @@ class ProbeTempComp { static constexpr xy_pos_t measure_point = PTC_PROBE_POS; // Coordinates to probe //measure_point = { 12.0f, 7.3f }; // Coordinates for the MK52 magnetic heatbed - static constexpr int max_bed_temp = PTC_MAX_BED_TEMP, // Max temperature to avoid heating errors - probe_calib_bed_temp = max_bed_temp - 10, // Bed temperature while calibrating probe + static constexpr int probe_calib_bed_temp = BED_MAXTEMP - 10, // Bed temperature while calibrating probe bed_calib_probe_temp = 30; // Probe temperature while calibrating bed static int16_t *sensor_z_offsets[TSI_COUNT], From 199dfe60efce446bc4d910db941f979122644ab0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 4 Apr 2020 00:27:24 -0500 Subject: [PATCH 13/14] Update G76_M871.cpp --- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index b9bf970d20b6..f2719098cde6 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -203,7 +203,7 @@ void GcodeSuite::G76() { report_temps(next_temp_report); const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); - if (isnan(measured_z) || target_bed > temp_comp.max_bed_temp - 10) break; + if (isnan(measured_z) || target_bed > MAX_BED_TEMP - 10) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index()); From d3c339006776f61cdedc39de9f5a8d973ff06f00 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Mon, 6 Apr 2020 15:24:59 -0500 Subject: [PATCH 14/14] Update G76_M871.cpp --- Marlin/src/gcode/calibrate/G76_M871.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/gcode/calibrate/G76_M871.cpp b/Marlin/src/gcode/calibrate/G76_M871.cpp index f2719098cde6..0a352cebba2a 100644 --- a/Marlin/src/gcode/calibrate/G76_M871.cpp +++ b/Marlin/src/gcode/calibrate/G76_M871.cpp @@ -203,7 +203,7 @@ void GcodeSuite::G76() { report_temps(next_temp_report); const float measured_z = g76_probe(TSI_BED, target_bed, noz_pos_xyz); - if (isnan(measured_z) || target_bed > MAX_BED_TEMP - 10) break; + if (isnan(measured_z) || target_bed > BED_MAXTEMP - 10) break; } SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());