Browse Source

Merge pull request #1707 from thinkyhead/fixup_temperature

Always 4 temp sensors
Scott Lahteine 9 years ago
parent
commit
4385ac4f9d
1 changed files with 13 additions and 20 deletions
  1. 13
    20
      Marlin/temperature.cpp

+ 13
- 20
Marlin/temperature.cpp View File

@@ -226,7 +226,7 @@ void PID_autotune(float temp, int extruder, int ncycles)
226 226
 
227 227
     unsigned long ms = millis();
228 228
 
229
-    if (temp_meas_ready == true) { // temp sample ready
229
+    if (temp_meas_ready) { // temp sample ready
230 230
       updateTemperaturesFromRawValues();
231 231
 
232 232
       input = (extruder<0)?current_temperature_bed:current_temperature[extruder];
@@ -1172,32 +1172,27 @@ enum TempState {
1172 1172
   StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
1173 1173
 };
1174 1174
 
1175
-#ifdef TEMP_SENSOR_1_AS_REDUNDANT
1176
-  #define TEMP_SENSOR_COUNT 2
1177
-#else
1178
-  #define TEMP_SENSOR_COUNT EXTRUDERS
1179
-#endif
1180
-
1181
-static unsigned long raw_temp_value[TEMP_SENSOR_COUNT] = { 0 };
1175
+static unsigned long raw_temp_value[4] = { 0 };
1182 1176
 static unsigned long raw_temp_bed_value = 0;
1183 1177
 
1184 1178
 static void set_current_temp_raw() {
1185
-  #ifndef HEATER_0_USES_MAX6675
1179
+  #if HAS_TEMP_0 && !defined(HEATER_0_USES_MAX6675)
1186 1180
     current_temperature_raw[0] = raw_temp_value[0];
1187 1181
   #endif
1188
-  #if EXTRUDERS > 1
1182
+  #if HAS_TEMP_1
1183
+    #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1184
+      redundant_temperature_raw =
1185
+    #endif
1189 1186
     current_temperature_raw[1] = raw_temp_value[1];
1190
-    #if EXTRUDERS > 2
1187
+    #if HAS_TEMP_2
1191 1188
       current_temperature_raw[2] = raw_temp_value[2];
1192
-      #if EXTRUDERS > 3
1189
+      #if HAS_TEMP_3
1193 1190
         current_temperature_raw[3] = raw_temp_value[3];
1194 1191
       #endif
1195 1192
     #endif
1196 1193
   #endif
1197
-  #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1198
-    redundant_temperature_raw = raw_temp_value[1];
1199
-  #endif
1200 1194
   current_temperature_bed_raw = raw_temp_bed_value;
1195
+  temp_meas_ready = true;
1201 1196
 }
1202 1197
 
1203 1198
 //
@@ -1507,18 +1502,16 @@ ISR(TIMER0_COMPB_vect) {
1507 1502
   } // switch(temp_state)
1508 1503
 
1509 1504
   if (temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256)  = 164ms.
1510
-    if (!temp_meas_ready) { //Only update the raw values if they have been read. Else we could be updating them during reading.
1511
-      set_current_temp_raw();
1512
-    } //!temp_meas_ready
1505
+    // Update the raw values if they've been read. Else we could be updating them during reading.
1506
+    if (!temp_meas_ready) set_current_temp_raw();
1513 1507
 
1514 1508
     // Filament Sensor - can be read any time since IIR filtering is used
1515 1509
     #if HAS_FILAMENT_SENSOR
1516 1510
       current_raw_filwidth = raw_filwidth_value >> 10;  // Divide to get to 0-16384 range since we used 1/128 IIR filter approach
1517 1511
     #endif
1518 1512
 
1519
-    temp_meas_ready = true;
1520 1513
     temp_count = 0;
1521
-    for (int i = 0; i < TEMP_SENSOR_COUNT; i++) raw_temp_value[i] = 0;
1514
+    for (int i = 0; i < 4; i++) raw_temp_value[i] = 0;
1522 1515
     raw_temp_bed_value = 0;
1523 1516
 
1524 1517
     #ifndef HEATER_0_USES_MAX6675

Loading…
Cancel
Save