[2.0.x] Enable AD595 and AD8495 in concert (#10693)
* Allow both AD595 and AD8495 in concert * General temperature code tweaks
This commit is contained in:
parent
c43235dd39
commit
325bbbc8c2
|
@ -329,9 +329,9 @@
|
||||||
#if TEMP_SENSOR_1 == -4
|
#if TEMP_SENSOR_1 == -4
|
||||||
#define HEATER_1_USES_AD8495
|
#define HEATER_1_USES_AD8495
|
||||||
#elif TEMP_SENSOR_1 == -3
|
#elif TEMP_SENSOR_1 == -3
|
||||||
#error "MAX31855 Thermocouples not supported for TEMP_SENSOR_1"
|
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_1."
|
||||||
#elif TEMP_SENSOR_1 == -2
|
#elif TEMP_SENSOR_1 == -2
|
||||||
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_1"
|
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_1."
|
||||||
#elif TEMP_SENSOR_1 == -1
|
#elif TEMP_SENSOR_1 == -1
|
||||||
#define HEATER_1_USES_AD595
|
#define HEATER_1_USES_AD595
|
||||||
#elif TEMP_SENSOR_1 == 0
|
#elif TEMP_SENSOR_1 == 0
|
||||||
|
@ -345,9 +345,9 @@
|
||||||
#if TEMP_SENSOR_2 == -4
|
#if TEMP_SENSOR_2 == -4
|
||||||
#define HEATER_2_USES_AD8495
|
#define HEATER_2_USES_AD8495
|
||||||
#elif TEMP_SENSOR_2 == -3
|
#elif TEMP_SENSOR_2 == -3
|
||||||
#error "MAX31855 Thermocouples not supported for TEMP_SENSOR_2"
|
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_2."
|
||||||
#elif TEMP_SENSOR_2 == -2
|
#elif TEMP_SENSOR_2 == -2
|
||||||
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_2"
|
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_2."
|
||||||
#elif TEMP_SENSOR_2 == -1
|
#elif TEMP_SENSOR_2 == -1
|
||||||
#define HEATER_2_USES_AD595
|
#define HEATER_2_USES_AD595
|
||||||
#elif TEMP_SENSOR_2 == 0
|
#elif TEMP_SENSOR_2 == 0
|
||||||
|
@ -361,9 +361,9 @@
|
||||||
#if TEMP_SENSOR_3 == -4
|
#if TEMP_SENSOR_3 == -4
|
||||||
#define HEATER_3_USES_AD8495
|
#define HEATER_3_USES_AD8495
|
||||||
#elif TEMP_SENSOR_3 == -3
|
#elif TEMP_SENSOR_3 == -3
|
||||||
#error "MAX31855 Thermocouples not supported for TEMP_SENSOR_3"
|
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_3."
|
||||||
#elif TEMP_SENSOR_3 == -2
|
#elif TEMP_SENSOR_3 == -2
|
||||||
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_3"
|
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_3."
|
||||||
#elif TEMP_SENSOR_3 == -1
|
#elif TEMP_SENSOR_3 == -1
|
||||||
#define HEATER_3_USES_AD595
|
#define HEATER_3_USES_AD595
|
||||||
#elif TEMP_SENSOR_3 == 0
|
#elif TEMP_SENSOR_3 == 0
|
||||||
|
@ -377,9 +377,9 @@
|
||||||
#if TEMP_SENSOR_4 == -4
|
#if TEMP_SENSOR_4 == -4
|
||||||
#define HEATER_4_USES_AD8495
|
#define HEATER_4_USES_AD8495
|
||||||
#elif TEMP_SENSOR_4 == -3
|
#elif TEMP_SENSOR_4 == -3
|
||||||
#error "MAX31855 Thermocouples not supported for TEMP_SENSOR_4"
|
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_4."
|
||||||
#elif TEMP_SENSOR_4 == -2
|
#elif TEMP_SENSOR_4 == -2
|
||||||
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_4"
|
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_4."
|
||||||
#elif TEMP_SENSOR_4 == -1
|
#elif TEMP_SENSOR_4 == -1
|
||||||
#define HEATER_4_USES_AD595
|
#define HEATER_4_USES_AD595
|
||||||
#elif TEMP_SENSOR_4 == 0
|
#elif TEMP_SENSOR_4 == 0
|
||||||
|
@ -391,39 +391,35 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TEMP_SENSOR_BED == -4
|
#if TEMP_SENSOR_BED == -4
|
||||||
#define BED_USES_AD8495
|
#define HEATER_BED_USES_AD8495
|
||||||
#elif TEMP_SENSOR_BED == -3
|
#elif TEMP_SENSOR_BED == -3
|
||||||
#error "MAX31855 Thermocouples not supported for TEMP_SENSOR_BED"
|
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BED."
|
||||||
#elif TEMP_SENSOR_BED == -2
|
#elif TEMP_SENSOR_BED == -2
|
||||||
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_BED"
|
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_BED."
|
||||||
#elif TEMP_SENSOR_BED == -1
|
#elif TEMP_SENSOR_BED == -1
|
||||||
#define BED_USES_AD595
|
#define HEATER_BED_USES_AD595
|
||||||
#elif TEMP_SENSOR_BED == 0
|
#elif TEMP_SENSOR_BED == 0
|
||||||
#undef BED_MINTEMP
|
#undef BED_MINTEMP
|
||||||
#undef BED_MAXTEMP
|
#undef BED_MAXTEMP
|
||||||
#elif TEMP_SENSOR_BED > 0
|
#elif TEMP_SENSOR_BED > 0
|
||||||
#define THERMISTORBED TEMP_SENSOR_BED
|
#define THERMISTORBED TEMP_SENSOR_BED
|
||||||
#define BED_USES_THERMISTOR
|
#define HEATER_BED_USES_THERMISTOR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TEMP_SENSOR_CHAMBER == -4
|
#if TEMP_SENSOR_CHAMBER == -4
|
||||||
#define CHAMBER_USES_AD8495
|
#define HEATER_CHAMBER_USES_AD8495
|
||||||
#elif TEMP_SENSOR_CHAMBER == -3
|
#elif TEMP_SENSOR_CHAMBER == -3
|
||||||
#error "MAX31855 Thermocouples not supported for TEMP_SENSOR_CHAMBER"
|
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_CHAMBER."
|
||||||
#elif TEMP_SENSOR_CHAMBER == -2
|
#elif TEMP_SENSOR_CHAMBER == -2
|
||||||
#error "MAX6675 Thermocouples not supported for TEMP_SENSOR_CHAMBER"
|
#error "MAX6675 Thermocouples (-2) not supported for TEMP_SENSOR_CHAMBER."
|
||||||
#elif TEMP_SENSOR_CHAMBER == -1
|
#elif TEMP_SENSOR_CHAMBER == -1
|
||||||
#define CHAMBER_USES_AD595
|
#define HEATER_CHAMBER_USES_AD595
|
||||||
#elif TEMP_SENSOR_CHAMBER > 0
|
#elif TEMP_SENSOR_CHAMBER > 0
|
||||||
#define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
|
#define THERMISTORCHAMBER TEMP_SENSOR_CHAMBER
|
||||||
#define CHAMBER_USES_THERMISTOR
|
#define HEATER_CHAMBER_USES_THERMISTOR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HEATER_USES_AD8495 (ENABLED(HEATER_0_USES_AD8495) || ENABLED(HEATER_1_USES_AD8495) || ENABLED(HEATER_2_USES_AD8495) || ENABLED(HEATER_3_USES_AD8495) || ENABLED(HEATER_4_USES_AD8495))
|
#define HOTEND_USES_THERMISTOR (ENABLED(HEATER_0_USES_THERMISTOR) || ENABLED(HEATER_1_USES_THERMISTOR) || ENABLED(HEATER_2_USES_THERMISTOR) || ENABLED(HEATER_3_USES_THERMISTOR) || ENABLED(HEATER_4_USES_THERMISTOR))
|
||||||
|
|
||||||
#ifdef __SAM3X8E__
|
|
||||||
#define HEATER_USES_AD595 (ENABLED(HEATER_0_USES_AD595) || ENABLED(HEATER_1_USES_AD595) || ENABLED(HEATER_2_USES_AD595) || ENABLED(HEATER_3_USES_AD595) || ENABLED(HEATER_4_USES_AD595))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default hotend offsets, if not defined
|
* Default hotend offsets, if not defined
|
||||||
|
@ -773,9 +769,9 @@
|
||||||
#define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
|
#define HAS_Z2_MAX (PIN_EXISTS(Z2_MAX))
|
||||||
#define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
|
#define HAS_Z_MIN_PROBE_PIN (PIN_EXISTS(Z_MIN_PROBE))
|
||||||
|
|
||||||
// Thermistors
|
// ADC Temp Sensors (Thermistor or Thermocouple with amplifier ADC interface)
|
||||||
#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && TEMP_SENSOR_##P > -2)
|
#define HAS_ADC_TEST(P) (PIN_EXISTS(TEMP_##P) && TEMP_SENSOR_##P != 0 && DISABLED(HEATER_##P##_USES_MAX6675))
|
||||||
#define HAS_TEMP_ADC_0 (HAS_ADC_TEST(0) && DISABLED(HEATER_0_USES_MAX6675))
|
#define HAS_TEMP_ADC_0 HAS_ADC_TEST(0)
|
||||||
#define HAS_TEMP_ADC_1 HAS_ADC_TEST(1)
|
#define HAS_TEMP_ADC_1 HAS_ADC_TEST(1)
|
||||||
#define HAS_TEMP_ADC_2 HAS_ADC_TEST(2)
|
#define HAS_TEMP_ADC_2 HAS_ADC_TEST(2)
|
||||||
#define HAS_TEMP_ADC_3 HAS_ADC_TEST(3)
|
#define HAS_TEMP_ADC_3 HAS_ADC_TEST(3)
|
||||||
|
|
|
@ -3539,7 +3539,7 @@ void lcd_quick_feedback(const bool clear_buttons) {
|
||||||
//
|
//
|
||||||
// Autotemp, Min, Max, Fact
|
// Autotemp, Min, Max, Fact
|
||||||
//
|
//
|
||||||
#if ENABLED(AUTOTEMP) && (HAS_TEMP_HOTEND)
|
#if ENABLED(AUTOTEMP) && HAS_TEMP_HOTEND
|
||||||
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
|
MENU_ITEM_EDIT(bool, MSG_AUTOTEMP, &planner.autotemp_enabled);
|
||||||
MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15);
|
MENU_ITEM_EDIT(float3, MSG_MIN, &planner.autotemp_min, 0, HEATER_0_MAXTEMP - 15);
|
||||||
MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, HEATER_0_MAXTEMP - 15);
|
MENU_ITEM_EDIT(float3, MSG_MAX, &planner.autotemp_max, 0, HEATER_0_MAXTEMP - 15);
|
||||||
|
|
|
@ -53,12 +53,14 @@
|
||||||
#include "../feature/emergency_parser.h"
|
#include "../feature/emergency_parser.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
#if HOTEND_USES_THERMISTOR
|
||||||
static void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
|
#if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
|
||||||
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
|
static void* heater_ttbl_map[2] = { (void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE };
|
||||||
#else
|
static uint8_t heater_ttbllen_map[2] = { HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN };
|
||||||
static void* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS((void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE, (void*)HEATER_2_TEMPTABLE, (void*)HEATER_3_TEMPTABLE, (void*)HEATER_4_TEMPTABLE);
|
#else
|
||||||
static uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN, HEATER_3_TEMPTABLE_LEN, HEATER_4_TEMPTABLE_LEN);
|
static void* heater_ttbl_map[HOTENDS] = ARRAY_BY_HOTENDS((void*)HEATER_0_TEMPTABLE, (void*)HEATER_1_TEMPTABLE, (void*)HEATER_2_TEMPTABLE, (void*)HEATER_3_TEMPTABLE, (void*)HEATER_4_TEMPTABLE);
|
||||||
|
static uint8_t heater_ttbllen_map[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN, HEATER_3_TEMPTABLE_LEN, HEATER_4_TEMPTABLE_LEN);
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Temperature thermalManager;
|
Temperature thermalManager;
|
||||||
|
@ -930,7 +932,21 @@ void Temperature::manage_heater() {
|
||||||
#endif // HAS_HEATED_BED
|
#endif // HAS_HEATED_BED
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PGM_RD_W(x) (short)pgm_read_word(&x)
|
#define TEMP_AD595(RAW) ((RAW) * 5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET)
|
||||||
|
#define TEMP_AD8495(RAW) ((RAW) * 6.6 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET)
|
||||||
|
|
||||||
|
#define SCAN_THERMISTOR_TABLE(TBL,LEN) do{ \
|
||||||
|
for (uint8_t i = 1; i < LEN; i++) { \
|
||||||
|
const short entry10 = (short)pgm_read_word(&TBL[i][0]); \
|
||||||
|
if (entry10 > raw) { \
|
||||||
|
const short entry00 = (short)pgm_read_word(&TBL[i-1][0]), \
|
||||||
|
entry01 = (short)pgm_read_word(&TBL[i-1][1]), \
|
||||||
|
entry11 = (short)pgm_read_word(&TBL[i][1]); \
|
||||||
|
return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00); \
|
||||||
|
} \
|
||||||
|
} \
|
||||||
|
return (short)pgm_read_word(&TBL[LEN-1][1]); \
|
||||||
|
}while(0)
|
||||||
|
|
||||||
// Derived from RepRap FiveD extruder::getTemperature()
|
// Derived from RepRap FiveD extruder::getTemperature()
|
||||||
// For hot end temperature measurement.
|
// For hot end temperature measurement.
|
||||||
|
@ -948,68 +964,61 @@ float Temperature::analog2temp(const int raw, const uint8_t e) {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(HEATER_0_USES_MAX6675)
|
switch (e) {
|
||||||
if (e == 0) return 0.25 * raw;
|
case 0:
|
||||||
#endif
|
#if ENABLED(HEATER_0_USES_MAX6675)
|
||||||
|
return raw * 0.25;
|
||||||
// Thermistor with conversion table?
|
#elif ENABLED(HEATER_0_USES_AD595)
|
||||||
if (heater_ttbl_map[e] != NULL) {
|
return TEMP_AD595(raw);
|
||||||
short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]);
|
#elif ENABLED(HEATER_0_USES_AD8495)
|
||||||
for (uint8_t i = 1; i < heater_ttbllen_map[e]; i++) {
|
return TEMP_AD8495(raw);
|
||||||
const short entry10 = PGM_RD_W((*tt)[i][0]);
|
#endif
|
||||||
if (entry10 > raw) {
|
case 1:
|
||||||
const short entry00 = PGM_RD_W((*tt)[i - 1][0]),
|
#if ENABLED(HEATER_1_USES_AD595)
|
||||||
entry01 = PGM_RD_W((*tt)[i - 1][1]),
|
return TEMP_AD595(raw);
|
||||||
entry11 = PGM_RD_W((*tt)[i][1]);
|
#elif ENABLED(HEATER_1_USES_AD8495)
|
||||||
return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
|
return TEMP_AD8495(raw);
|
||||||
}
|
#endif
|
||||||
}
|
case 2:
|
||||||
return PGM_RD_W((*tt)[heater_ttbllen_map[e] - 1][1]); // Overflow: Return last value in the table
|
#if ENABLED(HEATER_2_USES_AD595)
|
||||||
|
return TEMP_AD595(raw);
|
||||||
|
#elif ENABLED(HEATER_2_USES_AD8495)
|
||||||
|
return TEMP_AD8495(raw);
|
||||||
|
#endif
|
||||||
|
case 3:
|
||||||
|
#if ENABLED(HEATER_3_USES_AD595)
|
||||||
|
return TEMP_AD595(raw);
|
||||||
|
#elif ENABLED(HEATER_3_USES_AD8495)
|
||||||
|
return TEMP_AD8495(raw);
|
||||||
|
#endif
|
||||||
|
case 4:
|
||||||
|
#if ENABLED(HEATER_4_USES_AD595)
|
||||||
|
return TEMP_AD595(raw);
|
||||||
|
#elif ENABLED(HEATER_4_USES_AD8495)
|
||||||
|
return TEMP_AD8495(raw);
|
||||||
|
#endif
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Thermocouple with amplifier ADC interface
|
#if HOTEND_USES_THERMISTOR
|
||||||
return (raw *
|
// Thermistor with conversion table?
|
||||||
#if HEATER_USES_AD8495
|
const short(*tt)[][2] = (short(*)[][2])(heater_ttbl_map[e]);
|
||||||
660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
|
SCAN_THERMISTOR_TABLE((*tt), heater_ttbllen_map[e]);
|
||||||
#elif HEATER_USES_AD595
|
#endif
|
||||||
5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
|
|
||||||
#else
|
|
||||||
0
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
// Derived from RepRap FiveD extruder::getTemperature()
|
// Derived from RepRap FiveD extruder::getTemperature()
|
||||||
// For bed temperature measurement.
|
// For bed temperature measurement.
|
||||||
float Temperature::analog2tempBed(const int raw) {
|
float Temperature::analog2tempBed(const int raw) {
|
||||||
#if ENABLED(BED_USES_THERMISTOR)
|
#if ENABLED(HEATER_BED_USES_THERMISTOR)
|
||||||
|
SCAN_THERMISTOR_TABLE(BEDTEMPTABLE, BEDTEMPTABLE_LEN);
|
||||||
// Thermistor with conversion table
|
#elif ENABLED(HEATER_BED_USES_AD595)
|
||||||
for (uint8_t i = 1; i < BEDTEMPTABLE_LEN; i++) {
|
return TEMP_AD595(raw);
|
||||||
const short entry10 = PGM_RD_W(BEDTEMPTABLE[i][0]);
|
#elif ENABLED(HEATER_BED_USES_AD8495)
|
||||||
if (entry10 > raw) {
|
return TEMP_AD8495(raw);
|
||||||
const short entry00 = PGM_RD_W(BEDTEMPTABLE[i - 1][0]),
|
|
||||||
entry01 = PGM_RD_W(BEDTEMPTABLE[i - 1][1]),
|
|
||||||
entry11 = PGM_RD_W(BEDTEMPTABLE[i][1]);
|
|
||||||
return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PGM_RD_W(BEDTEMPTABLE[BEDTEMPTABLE_LEN - 1][1]); // Overflow: Return last value in the table
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
return 0;
|
||||||
// Thermocouple with amplifier ADC interface
|
|
||||||
return (raw *
|
|
||||||
#if ENABLED(BED_USES_AD595)
|
|
||||||
5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
|
|
||||||
#elif ENABLED(BED_USES_AD8495)
|
|
||||||
660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
|
|
||||||
#else
|
|
||||||
0
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // HAS_HEATED_BED
|
#endif // HAS_HEATED_BED
|
||||||
|
@ -1018,33 +1027,14 @@ float Temperature::analog2temp(const int raw, const uint8_t e) {
|
||||||
// Derived from RepRap FiveD extruder::getTemperature()
|
// Derived from RepRap FiveD extruder::getTemperature()
|
||||||
// For chamber temperature measurement.
|
// For chamber temperature measurement.
|
||||||
float Temperature::analog2tempChamber(const int raw) {
|
float Temperature::analog2tempChamber(const int raw) {
|
||||||
#if ENABLED(CHAMBER_USES_THERMISTOR)
|
#if ENABLED(HEATER_CHAMBER_USES_THERMISTOR)
|
||||||
|
SCAN_THERMISTOR_TABLE(CHAMBERTEMPTABLE, CHAMBERTEMPTABLE_LEN);
|
||||||
// Thermistor with conversion table
|
#elif ENABLED(HEATER_CHAMBER_USES_AD595)
|
||||||
for (uint8_t i = 1; i < CHAMBERTEMPTABLE_LEN; i++) {
|
return TEMP_AD595(raw);
|
||||||
const short entry10 = PGM_RD_W(CHAMBERTEMPTABLE[i][0]);
|
#elif ENABLED(HEATER_CHAMBER_USES_AD8495)
|
||||||
if (entry10 > raw) {
|
return TEMP_AD8495(raw);
|
||||||
const short entry00 = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][0]),
|
|
||||||
entry01 = PGM_RD_W(CHAMBERTEMPTABLE[i - 1][1]),
|
|
||||||
entry11 = PGM_RD_W(CHAMBERTEMPTABLE[i][1]);
|
|
||||||
return entry01 + (raw - entry00) * float(entry11 - entry01) / float(entry10 - entry00);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return PGM_RD_W(CHAMBERTEMPTABLE[CHAMBERTEMPTABLE_LEN - 1][1]); // Overflow: Return last value in the table
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
return 0;
|
||||||
// Thermocouple with amplifier ADC interface
|
|
||||||
return (raw *
|
|
||||||
#if ENABLED(CHAMBER_USES_AD595)
|
|
||||||
5.0 * 100.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET
|
|
||||||
#elif ENABLED(CHAMBER_USES_AD8495)
|
|
||||||
660.0 / 1024.0 / (OVERSAMPLENR) * (TEMP_SENSOR_AD8495_GAIN) + TEMP_SENSOR_AD8495_OFFSET
|
|
||||||
#else
|
|
||||||
0
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif // HAS_TEMP_CHAMBER
|
#endif // HAS_TEMP_CHAMBER
|
||||||
|
@ -1059,8 +1049,7 @@ void Temperature::updateTemperaturesFromRawValues() {
|
||||||
#if ENABLED(HEATER_0_USES_MAX6675)
|
#if ENABLED(HEATER_0_USES_MAX6675)
|
||||||
current_temperature_raw[0] = read_max6675();
|
current_temperature_raw[0] = read_max6675();
|
||||||
#endif
|
#endif
|
||||||
HOTEND_LOOP()
|
HOTEND_LOOP() current_temperature[e] = Temperature::analog2temp(current_temperature_raw[e], e);
|
||||||
current_temperature[e] = Temperature::analog2temp(current_temperature_raw[e], e);
|
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
current_temperature_bed = Temperature::analog2tempBed(current_temperature_bed_raw);
|
current_temperature_bed = Temperature::analog2tempBed(current_temperature_bed_raw);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -131,7 +131,7 @@
|
||||||
#define _TT_NAME(_N) temptable_ ## _N
|
#define _TT_NAME(_N) temptable_ ## _N
|
||||||
#define TT_NAME(_N) _TT_NAME(_N)
|
#define TT_NAME(_N) _TT_NAME(_N)
|
||||||
|
|
||||||
#ifdef THERMISTORHEATER_0
|
#if THERMISTORHEATER_0
|
||||||
#define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0)
|
#define HEATER_0_TEMPTABLE TT_NAME(THERMISTORHEATER_0)
|
||||||
#define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
|
#define HEATER_0_TEMPTABLE_LEN COUNT(HEATER_0_TEMPTABLE)
|
||||||
#elif defined(HEATER_0_USES_THERMISTOR)
|
#elif defined(HEATER_0_USES_THERMISTOR)
|
||||||
|
@ -141,7 +141,7 @@
|
||||||
#define HEATER_0_TEMPTABLE_LEN 0
|
#define HEATER_0_TEMPTABLE_LEN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef THERMISTORHEATER_1
|
#if THERMISTORHEATER_1
|
||||||
#define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1)
|
#define HEATER_1_TEMPTABLE TT_NAME(THERMISTORHEATER_1)
|
||||||
#define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
|
#define HEATER_1_TEMPTABLE_LEN COUNT(HEATER_1_TEMPTABLE)
|
||||||
#elif defined(HEATER_1_USES_THERMISTOR)
|
#elif defined(HEATER_1_USES_THERMISTOR)
|
||||||
|
@ -151,7 +151,7 @@
|
||||||
#define HEATER_1_TEMPTABLE_LEN 0
|
#define HEATER_1_TEMPTABLE_LEN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef THERMISTORHEATER_2
|
#if THERMISTORHEATER_2
|
||||||
#define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2)
|
#define HEATER_2_TEMPTABLE TT_NAME(THERMISTORHEATER_2)
|
||||||
#define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
|
#define HEATER_2_TEMPTABLE_LEN COUNT(HEATER_2_TEMPTABLE)
|
||||||
#elif defined(HEATER_2_USES_THERMISTOR)
|
#elif defined(HEATER_2_USES_THERMISTOR)
|
||||||
|
@ -161,7 +161,7 @@
|
||||||
#define HEATER_2_TEMPTABLE_LEN 0
|
#define HEATER_2_TEMPTABLE_LEN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef THERMISTORHEATER_3
|
#if THERMISTORHEATER_3
|
||||||
#define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3)
|
#define HEATER_3_TEMPTABLE TT_NAME(THERMISTORHEATER_3)
|
||||||
#define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
|
#define HEATER_3_TEMPTABLE_LEN COUNT(HEATER_3_TEMPTABLE)
|
||||||
#elif defined(HEATER_3_USES_THERMISTOR)
|
#elif defined(HEATER_3_USES_THERMISTOR)
|
||||||
|
@ -171,7 +171,7 @@
|
||||||
#define HEATER_3_TEMPTABLE_LEN 0
|
#define HEATER_3_TEMPTABLE_LEN 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef THERMISTORHEATER_4
|
#if THERMISTORHEATER_4
|
||||||
#define HEATER_4_TEMPTABLE TT_NAME(THERMISTORHEATER_4)
|
#define HEATER_4_TEMPTABLE TT_NAME(THERMISTORHEATER_4)
|
||||||
#define HEATER_4_TEMPTABLE_LEN COUNT(HEATER_4_TEMPTABLE)
|
#define HEATER_4_TEMPTABLE_LEN COUNT(HEATER_4_TEMPTABLE)
|
||||||
#elif defined(HEATER_4_USES_THERMISTOR)
|
#elif defined(HEATER_4_USES_THERMISTOR)
|
||||||
|
@ -185,7 +185,7 @@
|
||||||
#define BEDTEMPTABLE TT_NAME(THERMISTORBED)
|
#define BEDTEMPTABLE TT_NAME(THERMISTORBED)
|
||||||
#define BEDTEMPTABLE_LEN COUNT(BEDTEMPTABLE)
|
#define BEDTEMPTABLE_LEN COUNT(BEDTEMPTABLE)
|
||||||
#else
|
#else
|
||||||
#ifdef BED_USES_THERMISTOR
|
#ifdef HEATER_BED_USES_THERMISTOR
|
||||||
#error "No bed thermistor table specified"
|
#error "No bed thermistor table specified"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -194,7 +194,7 @@
|
||||||
#define CHAMBERTEMPTABLE TT_NAME(THERMISTORCHAMBER)
|
#define CHAMBERTEMPTABLE TT_NAME(THERMISTORCHAMBER)
|
||||||
#define CHAMBERTEMPTABLE_LEN COUNT(CHAMBERTEMPTABLE)
|
#define CHAMBERTEMPTABLE_LEN COUNT(CHAMBERTEMPTABLE)
|
||||||
#else
|
#else
|
||||||
#ifdef CHAMBER_USES_THERMISTOR
|
#ifdef HEATER_CHAMBER_USES_THERMISTOR
|
||||||
#error "No chamber thermistor table specified"
|
#error "No chamber thermistor table specified"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -248,7 +248,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef HEATER_BED_RAW_HI_TEMP
|
#ifndef HEATER_BED_RAW_HI_TEMP
|
||||||
#ifdef BED_USES_THERMISTOR
|
#ifdef HEATER_BED_USES_THERMISTOR
|
||||||
#define HEATER_BED_RAW_HI_TEMP 0
|
#define HEATER_BED_RAW_HI_TEMP 0
|
||||||
#define HEATER_BED_RAW_LO_TEMP 16383
|
#define HEATER_BED_RAW_LO_TEMP 16383
|
||||||
#else
|
#else
|
||||||
|
@ -257,7 +257,7 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef HEATER_CHAMBER_RAW_HI_TEMP
|
#ifndef HEATER_CHAMBER_RAW_HI_TEMP
|
||||||
#ifdef CHAMBER_USES_THERMISTOR
|
#ifdef HEATER_CHAMBER_USES_THERMISTOR
|
||||||
#define HEATER_CHAMBER_RAW_HI_TEMP 0
|
#define HEATER_CHAMBER_RAW_HI_TEMP 0
|
||||||
#define HEATER_CHAMBER_RAW_LO_TEMP 16383
|
#define HEATER_CHAMBER_RAW_LO_TEMP 16383
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Reference in a new issue