Browse Source

Fix MAX6675 again and introduce set_current_temp_raw()

to make the temperature-code work again with Arduino 1.0.6.

Sorry could not make an extra block on base level.
AnHardt 9 years ago
parent
commit
dd0067afa6
1 changed files with 36 additions and 29 deletions
  1. 36
    29
      Marlin/temperature.cpp

+ 36
- 29
Marlin/temperature.cpp View File

576
 
576
 
577
   updateTemperaturesFromRawValues();
577
   updateTemperaturesFromRawValues();
578
 
578
 
579
+  #ifdef HEATER_0_USES_MAX6675
580
+    float ct = current_temperature[0];
581
+    if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
582
+    if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
583
+  #endif //HEATER_0_USES_MAX6675
584
+
579
   unsigned long ms = millis();
585
   unsigned long ms = millis();
580
 
586
 
581
   // Loop through all extruders
587
   // Loop through all extruders
1162
   StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
1168
   StartupDelay // Startup, delay initial temp reading a tiny bit so the hardware can settle
1163
 };
1169
 };
1164
 
1170
 
1171
+#ifdef TEMP_SENSOR_1_AS_REDUNDANT
1172
+  #define TEMP_SENSOR_COUNT 2
1173
+#else
1174
+  #define TEMP_SENSOR_COUNT EXTRUDERS
1175
+#endif
1176
+
1177
+unsigned long raw_temp_value[TEMP_SENSOR_COUNT] = { 0 };
1178
+unsigned long raw_temp_bed_value = 0;
1179
+
1180
+void set_current_temp_raw() {
1181
+  #ifndef HEATER_0_USES_MAX6675
1182
+    current_temperature_raw[0] = raw_temp_value[0];
1183
+  #endif
1184
+  #if EXTRUDERS > 1
1185
+    current_temperature_raw[1] = raw_temp_value[1];
1186
+    #if EXTRUDERS > 2
1187
+      current_temperature_raw[2] = raw_temp_value[2];
1188
+      #if EXTRUDERS > 3
1189
+        current_temperature_raw[3] = raw_temp_value[3];
1190
+      #endif
1191
+    #endif
1192
+  #endif
1193
+  #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1194
+    redundant_temperature_raw = raw_temp_value[1];
1195
+  #endif
1196
+  current_temperature_bed_raw = raw_temp_bed_value;
1197
+}
1198
+
1165
 //
1199
 //
1166
 // Timer 0 is shared with millies
1200
 // Timer 0 is shared with millies
1167
 //
1201
 //
1168
 ISR(TIMER0_COMPB_vect) {
1202
 ISR(TIMER0_COMPB_vect) {
1169
-  #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1170
-    #define TEMP_SENSOR_COUNT 2
1171
-  #else 
1172
-    #define TEMP_SENSOR_COUNT EXTRUDERS
1173
-  #endif
1174
-
1175
   //these variables are only accesible from the ISR, but static, so they don't lose their value
1203
   //these variables are only accesible from the ISR, but static, so they don't lose their value
1176
   static unsigned char temp_count = 0;
1204
   static unsigned char temp_count = 0;
1177
-  static unsigned long raw_temp_value[TEMP_SENSOR_COUNT] = { 0 };
1178
-  static unsigned long raw_temp_bed_value = 0;
1179
   static TempState temp_state = StartupDelay;
1205
   static TempState temp_state = StartupDelay;
1180
   static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
1206
   static unsigned char pwm_count = BIT(SOFT_PWM_SCALE);
1181
 
1207
 
1478
 
1504
 
1479
   if (temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256)  = 164ms.
1505
   if (temp_count >= OVERSAMPLENR) { // 10 * 16 * 1/(16000000/64/256)  = 164ms.
1480
     if (!temp_meas_ready) { //Only update the raw values if they have been read. Else we could be updating them during reading.
1506
     if (!temp_meas_ready) { //Only update the raw values if they have been read. Else we could be updating them during reading.
1481
-      #ifndef HEATER_0_USES_MAX6675
1482
-        current_temperature_raw[0] = raw_temp_value[0];
1483
-      #endif
1484
-      #if EXTRUDERS > 1
1485
-        current_temperature_raw[1] = raw_temp_value[1];
1486
-        #if EXTRUDERS > 2
1487
-          current_temperature_raw[2] = raw_temp_value[2];
1488
-          #if EXTRUDERS > 3
1489
-            current_temperature_raw[3] = raw_temp_value[3];
1490
-          #endif
1491
-        #endif
1492
-      #endif
1493
-      #ifdef TEMP_SENSOR_1_AS_REDUNDANT
1494
-        redundant_temperature_raw = raw_temp_value[1];
1495
-      #endif
1496
-      current_temperature_bed_raw = raw_temp_bed_value;
1507
+      set_current_temp_raw();
1497
     } //!temp_meas_ready
1508
     } //!temp_meas_ready
1498
 
1509
 
1499
     // Filament Sensor - can be read any time since IIR filtering is used
1510
     // Filament Sensor - can be read any time since IIR filtering is used
1506
     for (int i = 0; i < TEMP_SENSOR_COUNT; i++) raw_temp_value[i] = 0;
1517
     for (int i = 0; i < TEMP_SENSOR_COUNT; i++) raw_temp_value[i] = 0;
1507
     raw_temp_bed_value = 0;
1518
     raw_temp_bed_value = 0;
1508
 
1519
 
1509
-    #ifdef HEATER_0_USES_MAX6675
1510
-      float ct = current_temperature[0];
1511
-      if (ct > min(HEATER_0_MAXTEMP, 1023)) max_temp_error(0);
1512
-      if (ct < max(HEATER_0_MINTEMP, 0.01)) min_temp_error(0);
1513
-    #else
1520
+    #ifndef HEATER_0_USES_MAX6675
1514
       #if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
1521
       #if HEATER_0_RAW_LO_TEMP > HEATER_0_RAW_HI_TEMP
1515
         #define GE0 <=
1522
         #define GE0 <=
1516
       #else
1523
       #else

Loading…
Cancel
Save