|
@@ -2065,7 +2065,49 @@ static void clean_up_after_endstop_or_probe_move() {
|
2065
|
2065
|
safe_delay(BLTOUCH_DELAY);
|
2066
|
2066
|
}
|
2067
|
2067
|
|
|
2068
|
+ //
|
|
2069
|
+ // The BL-Touch probes have a HAL effect sensor. The high currents switching
|
|
2070
|
+ // on and off cause big magnetic fields that can affect the reliability of the
|
|
2071
|
+ // sensor. So, for BL-Touch probes, we turn off the heaters during the actual probe.
|
|
2072
|
+ // And then we quickly turn them back on after we have sampled the point
|
|
2073
|
+ //
|
|
2074
|
+ void turn_heaters_on_or_off_for_bltouch(const bool deploy) {
|
|
2075
|
+ static int8_t bltouch_recursion_cnt=0;
|
|
2076
|
+ static millis_t last_emi_protection=0;
|
|
2077
|
+ static float temps_at_entry[HOTENDS];
|
|
2078
|
+ #if HAS_TEMP_BED
|
|
2079
|
+ static float bed_temp_at_entry;
|
|
2080
|
+ #endif
|
|
2081
|
+
|
|
2082
|
+ if (deploy && bltouch_recursion_cnt>0) // if already in the correct state, we don't need to do anything
|
|
2083
|
+ return; // with the heaters.
|
|
2084
|
+ if (!deploy && bltouch_recursion_cnt<1) // if already in the correct state, we don't need to do anything
|
|
2085
|
+ return; // with the heaters.
|
|
2086
|
+
|
|
2087
|
+ if (deploy) {
|
|
2088
|
+ bltouch_recursion_cnt++;
|
|
2089
|
+ last_emi_protection = millis();
|
|
2090
|
+ HOTEND_LOOP() temps_at_entry[e] = thermalManager.degTargetHotend(e); // save the current target temperatures
|
|
2091
|
+ HOTEND_LOOP() thermalManager.setTargetHotend(0, e); // so we know what to restore them to.
|
|
2092
|
+
|
|
2093
|
+ #if HAS_TEMP_BED
|
|
2094
|
+ bed_temp_at_entry = thermalManager.degTargetBed();
|
|
2095
|
+ thermalManager.setTargetBed(0.0);
|
|
2096
|
+ #endif
|
|
2097
|
+ }
|
|
2098
|
+ else {
|
|
2099
|
+ bltouch_recursion_cnt--; // the heaters are only turned back on
|
|
2100
|
+ if (bltouch_recursion_cnt==0 && ((last_emi_protection+20000L)>millis())) { // if everything is perfect. It is expected
|
|
2101
|
+ HOTEND_LOOP() thermalManager.setTargetHotend(temps_at_entry[e], e); // that the bltouch_recursion_cnt is zero and
|
|
2102
|
+ #if HAS_TEMP_BED // that the heaters were shut off less than
|
|
2103
|
+ thermalManager.setTargetBed(bed_temp_at_entry); // 20 seconds ago
|
|
2104
|
+ #endif
|
|
2105
|
+ }
|
|
2106
|
+ }
|
|
2107
|
+ }
|
|
2108
|
+
|
2068
|
2109
|
void set_bltouch_deployed(const bool deploy) {
|
|
2110
|
+ turn_heaters_on_or_off_for_bltouch(deploy);
|
2069
|
2111
|
if (deploy && TEST_BLTOUCH()) { // If BL-Touch says it's triggered
|
2070
|
2112
|
bltouch_command(BLTOUCH_RESET); // try to reset it.
|
2071
|
2113
|
bltouch_command(BLTOUCH_DEPLOY); // Also needs to deploy and stow to
|
|
@@ -2100,6 +2142,10 @@ static void clean_up_after_endstop_or_probe_move() {
|
2100
|
2142
|
}
|
2101
|
2143
|
#endif
|
2102
|
2144
|
|
|
2145
|
+ #if ENABLED(BLTOUCH)
|
|
2146
|
+ turn_heaters_on_or_off_for_bltouch(deploy);
|
|
2147
|
+ #endif
|
|
2148
|
+
|
2103
|
2149
|
if (endstops.z_probe_enabled == deploy) return false;
|
2104
|
2150
|
|
2105
|
2151
|
// Make room for probe
|