Browse Source

Ignore spurious MAX31855K / 6675 thermocouple errors (#18039)

Mobilinkd LLC 4 years ago
parent
commit
60bed3434b
No account linked to committer's email address
2 changed files with 50 additions and 23 deletions
  1. 13
    0
      Marlin/Configuration_adv.h
  2. 37
    23
      Marlin/src/module/temperature.cpp

+ 13
- 0
Marlin/Configuration_adv.h View File

@@ -39,6 +39,19 @@
39 39
 //=============================Thermal Settings  ============================
40 40
 //===========================================================================
41 41
 
42
+/**
43
+ * Thermocouple sensors are quite sensitive to noise.  Any noise induced in
44
+ * the sensor wires, such as by stepper motor wires run in parallel to them,
45
+ * may result in the thermocouple sensor reporting spurious errors.  This
46
+ * value is the number of errors which can occur in a row before the error
47
+ * is reported.  This allows us to ignore intermittent error conditions while
48
+ * still detecting an actual failure, which should result in a continuous
49
+ * stream of errors from the sensor.
50
+ * 
51
+ * Set this value to 0 to fail on the first error to occur.
52
+ */
53
+#define THERMOCOUPLE_MAX_ERRORS 15
54
+
42 55
 //
43 56
 // Custom Thermistor 1000 parameters
44 57
 //

+ 37
- 23
Marlin/src/module/temperature.cpp View File

@@ -2060,6 +2060,10 @@ void Temperature::disable_all_heaters() {
2060 2060
 
2061 2061
 #if HAS_MAX6675
2062 2062
 
2063
+  #ifndef THERMOCOUPLE_MAX_ERRORS
2064
+    #define THERMOCOUPLE_MAX_ERRORS 15
2065
+  #endif
2066
+
2063 2067
   int Temperature::read_max6675(
2064 2068
     #if COUNT_6675 > 1
2065 2069
       const uint8_t hindex
@@ -2071,6 +2075,8 @@ void Temperature::disable_all_heaters() {
2071 2075
       // Needed to return the correct temp when this is called too soon
2072 2076
       static uint16_t max6675_temp_previous[COUNT_6675] = { 0 };
2073 2077
     #endif
2078
+    
2079
+    static uint8_t max6675_errors[COUNT_6675] = { 0 };
2074 2080
 
2075 2081
     #define MAX6675_HEAT_INTERVAL 250UL
2076 2082
 
@@ -2144,33 +2150,41 @@ void Temperature::disable_all_heaters() {
2144 2150
     WRITE_MAX6675(HIGH); // disable TT_MAX6675
2145 2151
 
2146 2152
     if (max6675_temp & MAX6675_ERROR_MASK) {
2147
-      SERIAL_ERROR_START();
2148
-      SERIAL_ECHOPGM("Temp measurement error! ");
2149
-      #if MAX6675_ERROR_MASK == 7
2150
-        SERIAL_ECHOPGM("MAX31855 ");
2151
-        if (max6675_temp & 1)
2152
-          SERIAL_ECHOLNPGM("Open Circuit");
2153
-        else if (max6675_temp & 2)
2154
-          SERIAL_ECHOLNPGM("Short to GND");
2155
-        else if (max6675_temp & 4)
2156
-          SERIAL_ECHOLNPGM("Short to VCC");
2157
-      #else
2158
-        SERIAL_ECHOLNPGM("MAX6675");
2159
-      #endif
2160
-
2161
-      // Thermocouple open
2162
-      max6675_temp = 4 * (
2163
-        #if COUNT_6675 > 1
2164
-          hindex ? HEATER_1_MAX6675_TMAX : HEATER_0_MAX6675_TMAX
2165
-        #elif ENABLED(HEATER_1_USES_MAX6675)
2166
-          HEATER_1_MAX6675_TMAX
2153
+      max6675_errors[hindex] += 1;
2154
+      if (max6675_errors[hindex] > THERMOCOUPLE_MAX_ERRORS) {
2155
+        SERIAL_ERROR_START();
2156
+        SERIAL_ECHOPGM("Temp measurement error! ");
2157
+        #if MAX6675_ERROR_MASK == 7
2158
+          SERIAL_ECHOPGM("MAX31855 ");
2159
+          if (max6675_temp & 1)
2160
+            SERIAL_ECHOLNPGM("Open Circuit");
2161
+          else if (max6675_temp & 2)
2162
+            SERIAL_ECHOLNPGM("Short to GND");
2163
+          else if (max6675_temp & 4)
2164
+            SERIAL_ECHOLNPGM("Short to VCC");
2167 2165
         #else
2168
-          HEATER_0_MAX6675_TMAX
2166
+          SERIAL_ECHOLNPGM("MAX6675");
2169 2167
         #endif
2170
-      );
2168
+
2169
+        // Thermocouple open
2170
+        max6675_temp = 4 * (
2171
+          #if COUNT_6675 > 1
2172
+            hindex ? HEATER_1_MAX6675_TMAX : HEATER_0_MAX6675_TMAX
2173
+          #elif ENABLED(HEATER_1_USES_MAX6675)
2174
+            HEATER_1_MAX6675_TMAX
2175
+          #else
2176
+            HEATER_0_MAX6675_TMAX
2177
+          #endif
2178
+        );
2179
+      }
2180
+      else {
2181
+        max6675_temp >>= MAX6675_DISCARD_BITS;
2182
+      }
2171 2183
     }
2172
-    else
2184
+    else {
2173 2185
       max6675_temp >>= MAX6675_DISCARD_BITS;
2186
+      max6675_errors[hindex] = 0;
2187
+    }
2174 2188
 
2175 2189
     #if ENABLED(MAX6675_IS_MAX31855)
2176 2190
       if (max6675_temp & 0x00002000) max6675_temp |= 0xFFFFC000; // Support negative temperature

Loading…
Cancel
Save