diff --git a/Firmware/Configuration_adv.h b/Firmware/Configuration_adv.h index 5386c281..f206c43c 100644 --- a/Firmware/Configuration_adv.h +++ b/Firmware/Configuration_adv.h @@ -436,6 +436,10 @@ const unsigned int dropsegments=5; //everything with less than this number of st #undef BED_MINTEMP #undef BED_MAXTEMP #endif +#if TEMP_SENSOR_AMBIENT == 0 + #undef AMBIENT_MINTEMP + #undef AMBIENT_MAXTEMP +#endif #endif //__CONFIGURATION_ADV_H diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 7f293f2e..75d52817 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -180,6 +180,12 @@ static int bed_minttemp_raw = HEATER_BED_RAW_LO_TEMP; #ifdef BED_MAXTEMP static int bed_maxttemp_raw = HEATER_BED_RAW_HI_TEMP; #endif +#ifdef AMBIENT_MINTEMP +static int ambient_minttemp_raw = AMBIENT_RAW_LO_TEMP; +#endif +#ifdef AMBIENT_MAXTEMP +static int ambient_maxttemp_raw = AMBIENT_RAW_HI_TEMP; +#endif static void *heater_ttbl_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( (void *)HEATER_0_TEMPTABLE, (void *)HEATER_1_TEMPTABLE, (void *)HEATER_2_TEMPTABLE ); static uint8_t heater_ttbllen_map[EXTRUDERS] = ARRAY_BY_EXTRUDERS( HEATER_0_TEMPTABLE_LEN, HEATER_1_TEMPTABLE_LEN, HEATER_2_TEMPTABLE_LEN ); @@ -1183,6 +1189,25 @@ void tp_init() #endif } #endif //BED_MAXTEMP + +#ifdef AMBIENT_MINTEMP + while(analog2tempAmbient(ambient_minttemp_raw) < AMBIENT_MINTEMP) { +#if HEATER_AMBIENT_RAW_LO_TEMP < HEATER_AMBIENT_RAW_HI_TEMP + ambient_minttemp_raw += OVERSAMPLENR; +#else + ambient_minttemp_raw -= OVERSAMPLENR; +#endif + } +#endif //AMBIENT_MINTEMP +#ifdef AMBIENT_MAXTEMP + while(analog2tempAmbient(ambient_maxttemp_raw) > AMBIENT_MAXTEMP) { +#if HEATER_AMBIENT_RAW_LO_TEMP < HEATER_AMBIENT_RAW_HI_TEMP + ambient_maxttemp_raw -= OVERSAMPLENR; +#else + ambient_maxttemp_raw += OVERSAMPLENR; +#endif + } +#endif //AMBIENT_MAXTEMP } #if (defined (TEMP_RUNAWAY_BED_HYSTERESIS) && TEMP_RUNAWAY_BED_TIMEOUT > 0) || (defined (TEMP_RUNAWAY_EXTRUDER_HYSTERESIS) && TEMP_RUNAWAY_EXTRUDER_TIMEOUT > 0) @@ -1509,6 +1534,35 @@ void bed_min_temp_error(void) { #endif } + +#ifdef AMBIENT_THERMISTOR +void ambient_max_temp_error(void) { + if(IsStopped() == false) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Heaters switched off. MAXTEMP AMBIENT triggered !"); + LCD_ALERTMESSAGEPGM("Err: MAXTEMP AMBIENT"); + } +#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE + Stop(); +#endif +} + +void ambient_min_temp_error(void) { +#ifdef DEBUG_DISABLE_MINTEMP + return; +#endif + if(IsStopped() == false) { + SERIAL_ERROR_START; + SERIAL_ERRORLNPGM("Heaters switched off. MINTEMP AMBIENT triggered !"); + LCD_ALERTMESSAGEPGM("Err: MINTEMP AMBIENT"); + } +#ifndef BOGUS_TEMPERATURE_FAILSAFE_OVERRIDE + Stop(); +#endif +} +#endif + + #ifdef HEATER_0_USES_MAX6675 #define MAX6675_HEAT_INTERVAL 250 long max6675_previous_millis = MAX6675_HEAT_INTERVAL; @@ -1994,7 +2048,16 @@ void check_max_temp() bed_max_temp_error(); } #endif - +//ambient +#if defined(AMBIENT_MAXTEMP) && (TEMP_SENSOR_AMBIENT != 0) +#if AMBIENT_RAW_LO_TEMP > AMBIENT_RAW_HI_TEMP + if (current_temperature_raw_ambient <= ambient_maxttemp_raw) { +#else + if (current_temperature_raw_ambient >= ambient_maxttemp_raw) { +#endif + ambient_max_temp_error(); + } +#endif } //! number of repeating the same state with consecutive step() calls //! used to slow down text switching @@ -2089,12 +2152,32 @@ void check_min_temp_bed() } } +#ifdef AMBIENT_MINTEMP +void check_min_temp_ambient() +{ +#if AMBIENT_RAW_LO_TEMP > AMBIENT_RAW_HI_TEMP + if (current_temperature_raw_ambient >= ambient_minttemp_raw) { +#else + if (current_temperature_raw_ambient <= ambient_minttemp_raw) { +#endif + ambient_min_temp_error(); + } +} +#endif + void check_min_temp() { static bool bCheckingOnHeater=false; // state variable, which allows to short no-checking delay (is set, when temperature is (first time) over heaterMintemp) static bool bCheckingOnBed=false; // state variable, which allows to short no-checking delay (is set, when temperature is (first time) over bedMintemp) #ifdef AMBIENT_THERMISTOR -if(current_temperature_raw_ambient>(OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW)) // thermistor is NTC type, so operator is ">" ;-) +#ifdef AMBIENT_MINTEMP +check_min_temp_ambient(); +#endif +#if AMBIENT_RAW_LO_TEMP > AMBIENT_RAW_HI_TEMP +if(current_temperature_raw_ambient>(OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW)) // thermistor is NTC type +#else +if(current_temperature_raw_ambient=<(OVERSAMPLENR*MINTEMP_MINAMBIENT_RAW)) +#endif { // ambient temperature is low #endif //AMBIENT_THERMISTOR // *** 'common' part of code for MK2.5 & MK3 diff --git a/Firmware/thermistortables.h b/Firmware/thermistortables.h index dc934ccf..721c6b35 100644 --- a/Firmware/thermistortables.h +++ b/Firmware/thermistortables.h @@ -1213,6 +1213,8 @@ const short temptable_1047[][2] PROGMEM = { #endif #if (THERMISTORAMBIENT == 2000) //100k thermistor NTCG104LH104JT1 +# define AMBIENT_RAW_HI_TEMP 0 +# define AMBIENT_RAW_LO_TEMP 16383 const short temptable_2000[][2] PROGMEM = { // Source: https://product.tdk.com/info/en/catalog/datasheets/503021/tpd_ntc-thermistor_ntcg_en.pdf // Calculated using 4.7kohm pullup, voltage divider math, and manufacturer provided temp/resistance diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index b135d8d1..04b4c526 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -296,6 +296,7 @@ #endif #define DETECT_SUPERPINDA #define PINDA_MINTEMP BED_MINTEMP +#define AMBIENT_MINTEMP -30 // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) @@ -306,6 +307,7 @@ #define HEATER_1_MAXTEMP 305 #define HEATER_2_MAXTEMP 305 #define BED_MAXTEMP 125 +#define AMBIENT_MAXTEMP 100 #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) // Define PID constants for extruder with PT100 diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index e618c54e..c869ec51 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -298,6 +298,7 @@ #endif #define DETECT_SUPERPINDA #define PINDA_MINTEMP BED_MINTEMP +#define AMBIENT_MINTEMP -30 // Maxtemps #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) @@ -308,6 +309,7 @@ #define HEATER_1_MAXTEMP 305 #define HEATER_2_MAXTEMP 305 #define BED_MAXTEMP 125 +#define AMBIENT_MAXTEMP 100 #if defined(E3D_PT100_EXTRUDER_WITH_AMP) || defined(E3D_PT100_EXTRUDER_NO_AMP) // Define PID constants for extruder with PT100