Browse Source

Merge pull request #6811 from thinkyhead/bf_temp_float_stuff

Restore current temp accessors to float
Scott Lahteine 8 years ago
parent
commit
c2ca85aeb2
3 changed files with 31 additions and 52 deletions
  1. 4
    4
      Marlin/Marlin_main.cpp
  2. 21
    42
      Marlin/temperature.cpp
  3. 6
    6
      Marlin/temperature.h

+ 4
- 4
Marlin/Marlin_main.cpp View File

6684
       }
6684
       }
6685
     #endif
6685
     #endif
6686
 
6686
 
6687
-    if (code_value_temp_abs() > thermalManager.degHotend(target_extruder)) lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
6687
+    if (code_value_temp_abs() > thermalManager.degHotend(target_extruder))
6688
+      lcd_status_printf_P(0, PSTR("E%i %s"), target_extruder + 1, MSG_HEATING);
6688
   }
6689
   }
6689
 
6690
 
6690
   #if ENABLED(AUTOTEMP)
6691
   #if ENABLED(AUTOTEMP)
8290
       // Report current state
8291
       // Report current state
8291
       SERIAL_ECHO_START;
8292
       SERIAL_ECHO_START;
8292
       SERIAL_ECHOPAIR("Cold extrudes are ", (thermalManager.allow_cold_extrude ? "en" : "dis"));
8293
       SERIAL_ECHOPAIR("Cold extrudes are ", (thermalManager.allow_cold_extrude ? "en" : "dis"));
8293
-      SERIAL_ECHOPAIR("abled (min temp ", int(thermalManager.extrude_min_temp + 0.5));
8294
+      SERIAL_ECHOPAIR("abled (min temp ", thermalManager.extrude_min_temp);
8294
       SERIAL_ECHOLNPGM("C)");
8295
       SERIAL_ECHOLNPGM("C)");
8295
     }
8296
     }
8296
   }
8297
   }
11909
       #if HAS_TEMP_BED
11910
       #if HAS_TEMP_BED
11910
         max_temp = MAX3(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
11911
         max_temp = MAX3(max_temp, thermalManager.degTargetBed(), thermalManager.degBed());
11911
       #endif
11912
       #endif
11912
-      HOTEND_LOOP() {
11913
+      HOTEND_LOOP()
11913
         max_temp = MAX3(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
11914
         max_temp = MAX3(max_temp, thermalManager.degHotend(e), thermalManager.degTargetHotend(e));
11914
-      }
11915
       bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
11915
       bool new_led = (max_temp > 55.0) ? true : (max_temp < 54.0) ? false : red_led;
11916
       if (new_led != red_led) {
11916
       if (new_led != red_led) {
11917
         red_led = new_led;
11917
         red_led = new_led;

+ 21
- 42
Marlin/temperature.cpp View File

103
 #endif
103
 #endif
104
 
104
 
105
 #if WATCH_HOTENDS
105
 #if WATCH_HOTENDS
106
-  int Temperature::watch_target_temp[HOTENDS] = { 0 };
106
+  uint16_t Temperature::watch_target_temp[HOTENDS] = { 0 };
107
   millis_t Temperature::watch_heater_next_ms[HOTENDS] = { 0 };
107
   millis_t Temperature::watch_heater_next_ms[HOTENDS] = { 0 };
108
 #endif
108
 #endif
109
 
109
 
110
 #if WATCH_THE_BED
110
 #if WATCH_THE_BED
111
-  int Temperature::watch_target_bed_temp = 0;
111
+  uint16_t Temperature::watch_target_bed_temp = 0;
112
   millis_t Temperature::watch_bed_next_ms = 0;
112
   millis_t Temperature::watch_bed_next_ms = 0;
113
 #endif
113
 #endif
114
 
114
 
115
 #if ENABLED(PREVENT_COLD_EXTRUSION)
115
 #if ENABLED(PREVENT_COLD_EXTRUSION)
116
   bool Temperature::allow_cold_extrude = false;
116
   bool Temperature::allow_cold_extrude = false;
117
-  float Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
117
+  uint16_t Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
118
 #endif
118
 #endif
119
 
119
 
120
 // private:
120
 // private:
121
 
121
 
122
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
122
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
123
-  int Temperature::redundant_temperature_raw = 0;
123
+  uint16_t Temperature::redundant_temperature_raw = 0;
124
   float Temperature::redundant_temperature = 0.0;
124
   float Temperature::redundant_temperature = 0.0;
125
 #endif
125
 #endif
126
 
126
 
695
   updateTemperaturesFromRawValues(); // also resets the watchdog
695
   updateTemperaturesFromRawValues(); // also resets the watchdog
696
 
696
 
697
   #if ENABLED(HEATER_0_USES_MAX6675)
697
   #if ENABLED(HEATER_0_USES_MAX6675)
698
-    if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1)) max_temp_error(0);
699
-    if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + 0.01)) min_temp_error(0);
698
+    if (current_temperature[0] > min(HEATER_0_MAXTEMP, MAX6675_TMAX - 1.0)) max_temp_error(0);
699
+    if (current_temperature[0] < max(HEATER_0_MINTEMP, MAX6675_TMIN + .01)) min_temp_error(0);
700
   #endif
700
   #endif
701
 
701
 
702
   #if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
702
   #if WATCH_HOTENDS || WATCH_THE_BED || DISABLED(PIDTEMPBED) || HAS_AUTO_FAN
703
     millis_t ms = millis();
703
     millis_t ms = millis();
704
   #endif
704
   #endif
705
 
705
 
706
-  // Loop through all hotends
707
   HOTEND_LOOP() {
706
   HOTEND_LOOP() {
708
 
707
 
709
     #if ENABLED(THERMAL_PROTECTION_HOTENDS)
708
     #if ENABLED(THERMAL_PROTECTION_HOTENDS)
709
+      // Check for thermal runaway
710
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
710
       thermal_runaway_protection(&thermal_runaway_state_machine[e], &thermal_runaway_timer[e], current_temperature[e], target_temperature[e], e, THERMAL_PROTECTION_PERIOD, THERMAL_PROTECTION_HYSTERESIS);
711
     #endif
711
     #endif
712
 
712
 
713
-    float pid_output = get_pid_output(e);
713
+    soft_pwm_amount[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)get_pid_output(e) >> 1 : 0;
714
 
714
 
715
-    // Check if temperature is within the correct range
716
-    soft_pwm_amount[e] = (current_temperature[e] > minttemp[e] || is_preheating(e)) && current_temperature[e] < maxttemp[e] ? (int)pid_output >> 1 : 0;
717
-
718
-    // Check if the temperature is failing to increase
719
     #if WATCH_HOTENDS
715
     #if WATCH_HOTENDS
720
-
721
-      // Is it time to check this extruder's heater?
722
-      if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) {
723
-        // Has it failed to increase enough?
724
-        if (degHotend(e) < watch_target_temp[e]) {
725
-          // Stop!
716
+      // Make sure temperature is increasing
717
+      if (watch_heater_next_ms[e] && ELAPSED(ms, watch_heater_next_ms[e])) { // Time to check this extruder?
718
+        if (degHotend(e) < watch_target_temp[e])                             // Failed to increase enough?
726
           _temp_error(e, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
719
           _temp_error(e, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
727
-        }
728
-        else {
729
-          // Start again if the target is still far off
720
+        else                                                                 // Start again if the target is still far off
730
           start_watching_heater(e);
721
           start_watching_heater(e);
731
-        }
732
       }
722
       }
723
+    #endif
733
 
724
 
734
-    #endif // THERMAL_PROTECTION_HOTENDS
735
-
736
-    // Check if the temperature is failing to increase
737
     #if WATCH_THE_BED
725
     #if WATCH_THE_BED
738
-
739
-      // Is it time to check the bed?
740
-      if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {
741
-        // Has it failed to increase enough?
742
-        if (degBed() < watch_target_bed_temp) {
743
-          // Stop!
726
+      // Make sure temperature is increasing
727
+      if (watch_bed_next_ms && ELAPSED(ms, watch_bed_next_ms)) {        // Time to check the bed?
728
+        if (degBed() < watch_target_bed_temp)                           // Failed to increase enough?
744
           _temp_error(-1, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
729
           _temp_error(-1, PSTR(MSG_T_HEATING_FAILED), PSTR(MSG_HEATING_FAILED_LCD));
745
-        }
746
-        else {
747
-          // Start again if the target is still far off
730
+        else                                                            // Start again if the target is still far off
748
           start_watching_bed();
731
           start_watching_bed();
749
-        }
750
       }
732
       }
751
-
752
-    #endif // THERMAL_PROTECTION_HOTENDS
733
+    #endif
753
 
734
 
754
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
735
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
755
-      if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF) {
736
+      // Make sure measured temperatures are close together
737
+      if (fabs(current_temperature[0] - redundant_temperature) > MAX_REDUNDANT_TEMP_SENSOR_DIFF)
756
         _temp_error(0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
738
         _temp_error(0, PSTR(MSG_REDUNDANCY), PSTR(MSG_ERR_REDUNDANT_TEMP));
757
-      }
758
     #endif
739
     #endif
759
 
740
 
760
   } // HOTEND_LOOP
741
   } // HOTEND_LOOP
792
     #endif
773
     #endif
793
 
774
 
794
     #if ENABLED(PIDTEMPBED)
775
     #if ENABLED(PIDTEMPBED)
795
-      float pid_output = get_pid_output_bed();
796
-
797
-      soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)pid_output >> 1 : 0;
776
+      soft_pwm_amount_bed = WITHIN(current_temperature_bed, BED_MINTEMP, BED_MAXTEMP) ? (int)get_pid_output_bed() >> 1 : 0;
798
 
777
 
799
     #elif ENABLED(BED_LIMIT_SWITCHING)
778
     #elif ENABLED(BED_LIMIT_SWITCHING)
800
       // Check if temperature is within the correct band
779
       // Check if temperature is within the correct band

+ 6
- 6
Marlin/temperature.h View File

158
     #endif
158
     #endif
159
 
159
 
160
     #if WATCH_HOTENDS
160
     #if WATCH_HOTENDS
161
-      static int watch_target_temp[HOTENDS];
161
+      static uint16_t watch_target_temp[HOTENDS];
162
       static millis_t watch_heater_next_ms[HOTENDS];
162
       static millis_t watch_heater_next_ms[HOTENDS];
163
     #endif
163
     #endif
164
 
164
 
165
     #if WATCH_THE_BED
165
     #if WATCH_THE_BED
166
-      static int watch_target_bed_temp;
166
+      static uint16_t watch_target_bed_temp;
167
       static millis_t watch_bed_next_ms;
167
       static millis_t watch_bed_next_ms;
168
     #endif
168
     #endif
169
 
169
 
170
     #if ENABLED(PREVENT_COLD_EXTRUSION)
170
     #if ENABLED(PREVENT_COLD_EXTRUSION)
171
       static bool allow_cold_extrude;
171
       static bool allow_cold_extrude;
172
-      static float extrude_min_temp;
172
+      static uint16_t extrude_min_temp;
173
       static bool tooColdToExtrude(uint8_t e) {
173
       static bool tooColdToExtrude(uint8_t e) {
174
         #if HOTENDS == 1
174
         #if HOTENDS == 1
175
           UNUSED(e);
175
           UNUSED(e);
183
   private:
183
   private:
184
 
184
 
185
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
185
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
186
-      static int redundant_temperature_raw;
186
+      static uint16_t redundant_temperature_raw;
187
       static float redundant_temperature;
187
       static float redundant_temperature;
188
     #endif
188
     #endif
189
 
189
 
327
     //inline so that there is no performance decrease.
327
     //inline so that there is no performance decrease.
328
     //deg=degreeCelsius
328
     //deg=degreeCelsius
329
 
329
 
330
-    static int16_t degHotend(uint8_t e) {
330
+    static float degHotend(uint8_t e) {
331
       #if HOTENDS == 1
331
       #if HOTENDS == 1
332
         UNUSED(e);
332
         UNUSED(e);
333
       #endif
333
       #endif
334
       return current_temperature[HOTEND_INDEX];
334
       return current_temperature[HOTEND_INDEX];
335
     }
335
     }
336
-    static int16_t degBed() { return current_temperature_bed; }
336
+    static float degBed() { return current_temperature_bed; }
337
 
337
 
338
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
338
     #if ENABLED(SHOW_TEMP_ADC_VALUES)
339
       static int16_t rawHotendTemp(uint8_t e) {
339
       static int16_t rawHotendTemp(uint8_t e) {

Loading…
Cancel
Save