Browse Source

Shut down heaters during BL-Touch probe event

The electro-magnetic interference from the bed and nozzle are affecting
the BL-Touch repeatability for some users.   This problem can be helped
by shutting down the heaters during the actual probe event and then
quickly turning them back on.

Because this code is messing with the heaters, it is written in a
paranoid manner.  It only turns the heaters back on if everything is
EXACTLY as it expects things to be.  The BL-Touch probe must have been
put into a deployed state less than 20 seconds prior, or the stow()
function will NOT turn the heaters on.

This code has been tested and works for both G28 and probing functions.
Roxy-3D 8 years ago
parent
commit
6e8ecb908a
1 changed files with 46 additions and 0 deletions
  1. 46
    0
      Marlin/Marlin_main.cpp

+ 46
- 0
Marlin/Marlin_main.cpp View File

2065
       safe_delay(BLTOUCH_DELAY);
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
     void set_bltouch_deployed(const bool deploy) {
2109
     void set_bltouch_deployed(const bool deploy) {
2110
+      turn_heaters_on_or_off_for_bltouch(deploy);
2069
       if (deploy && TEST_BLTOUCH()) {      // If BL-Touch says it's triggered
2111
       if (deploy && TEST_BLTOUCH()) {      // If BL-Touch says it's triggered
2070
         bltouch_command(BLTOUCH_RESET);    // try to reset it.
2112
         bltouch_command(BLTOUCH_RESET);    // try to reset it.
2071
         bltouch_command(BLTOUCH_DEPLOY);   // Also needs to deploy and stow to
2113
         bltouch_command(BLTOUCH_DEPLOY);   // Also needs to deploy and stow to
2100
       }
2142
       }
2101
     #endif
2143
     #endif
2102
 
2144
 
2145
+    #if ENABLED(BLTOUCH)
2146
+      turn_heaters_on_or_off_for_bltouch(deploy);
2147
+    #endif
2148
+
2103
     if (endstops.z_probe_enabled == deploy) return false;
2149
     if (endstops.z_probe_enabled == deploy) return false;
2104
 
2150
 
2105
     // Make room for probe
2151
     // Make room for probe

Loading…
Cancel
Save