diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 6e2f409613..047beac89c 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -432,78 +432,67 @@ // @section temperature /** - * --NORMAL IS 4.7kΩ PULLUP!-- 1kΩ pullup can be used on hotend sensor, using correct resistor and table + * Temperature Sensors: * - * Temperature sensors available: - * - * SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below! - * ------- - * -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1) - * NOTE: You must uncomment/set the MAX31865_*_OHMS_n defines below. - * -3 : MAX31855 with Thermocouple, -200°C to +700°C (only for sensors 0-1) - * -2 : MAX6675 with Thermocouple, 0°C to +700°C (only for sensors 0-1) - * - * NOTE: Ensure TEMP_n_CS_PIN is set in your pins file for each TEMP_SENSOR_n using an SPI Thermocouple. By default, - * Hardware SPI on the default serial bus is used. If you have also set TEMP_n_SCK_PIN and TEMP_n_MISO_PIN, - * Software SPI will be used on those ports instead. You can force Hardware SPI on the default bus in the - * Configuration_adv.h file. At this time, separate Hardware SPI buses for sensors are not supported. - * - * Analog Themocouple Boards - * ------- - * -4 : AD8495 with Thermocouple - * -1 : AD595 with Thermocouple + * NORMAL IS 4.7kΩ PULLUP! Hotend sensors can use 1kΩ pullup with correct resistor and table. * + * ================================================================ * Analog Thermistors - 4.7kΩ pullup - Normal - * ------- - * 1 : 100kΩ EPCOS - Best choice for EPCOS thermistors - * 331 : 100kΩ Same as #1, but 3.3V scaled for MEGA - * 332 : 100kΩ Same as #1, but 3.3V scaled for DUE - * 2 : 200kΩ ATC Semitec 204GT-2 - * 202 : 200kΩ Copymaster 3D - * 3 : ???Ω Mendel-parts thermistor - * 4 : 10kΩ Generic Thermistor !! DO NOT use for a hotend - it gives bad resolution at high temp. !! - * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C - * 501 : 100kΩ Zonestar - Tronxy X3A - * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M - * 503 : 100kΩ Zonestar (Z8XM2) Heated Bed thermistor - * 504 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-B3950) Hotend Thermistor - * 505 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-3950) Bed Thermistor - * 512 : 100kΩ RPW-Ultra hotend - * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple) - * 7 : 100kΩ Honeywell 135-104LAG-J01 - * 71 : 100kΩ Honeywell 135-104LAF-J01 - * 8 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT - * 9 : 100kΩ GE Sensing AL03006-58.2K-97-G1 - * 10 : 100kΩ RS PRO 198-961 - * 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1% - * 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed - * 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1% - * 15 : 100kΩ Calibrated for JGAurora A5 hotend - * 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327 - * 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input - * 23 : 100kΩ GTM32 Pro vB - bed - 4.7kΩ pullup to 3.3v and 220Ω to analog input - * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950 - * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950 - * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 - * 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor - * 67 : 500kΩ SliceEngineering 450°C Thermistor - * 68 : PT100 amplifier board from Dyze Design - * 70 : 100kΩ bq Hephestos 2 - * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32 - * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor + * ================================================================ + * 1 : 100kΩ EPCOS - Best choice for EPCOS thermistors + * 331 : 100kΩ Same as #1, but 3.3V scaled for MEGA + * 332 : 100kΩ Same as #1, but 3.3V scaled for DUE + * 2 : 200kΩ ATC Semitec 204GT-2 + * 202 : 200kΩ Copymaster 3D + * 3 : ???Ω Mendel-parts thermistor + * 4 : 10kΩ Generic Thermistor !! DO NOT use for a hotend - it gives bad resolution at high temp. !! + * 5 : 100kΩ ATC Semitec 104GT-2/104NT-4-R025H42G - Used in ParCan, J-Head, and E3D, SliceEngineering 300°C + * 501 : 100kΩ Zonestar - Tronxy X3A + * 502 : 100kΩ Zonestar - used by hot bed in Zonestar Průša P802M + * 503 : 100kΩ Zonestar (Z8XM2) Heated Bed thermistor + * 504 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-B3950) Hotend Thermistor + * 505 : 100kΩ Zonestar P802QR2 (Part# QWG-104F-3950) Bed Thermistor + * 512 : 100kΩ RPW-Ultra hotend + * 6 : 100kΩ EPCOS - Not as accurate as table #1 (created using a fluke thermocouple) + * 7 : 100kΩ Honeywell 135-104LAG-J01 + * 71 : 100kΩ Honeywell 135-104LAF-J01 + * 8 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT + * 9 : 100kΩ GE Sensing AL03006-58.2K-97-G1 + * 10 : 100kΩ RS PRO 198-961 + * 11 : 100kΩ Keenovo AC silicone mats, most Wanhao i3 machines - beta 3950, 1% + * 12 : 100kΩ Vishay 0603 SMD NTCS0603E3104FXT (#8) - calibrated for Makibox hot bed + * 13 : 100kΩ Hisens up to 300°C - for "Simple ONE" & "All In ONE" hotend - beta 3950, 1% + * 15 : 100kΩ Calibrated for JGAurora A5 hotend + * 18 : 200kΩ ATC Semitec 204GT-2 Dagoma.Fr - MKS_Base_DKU001327 + * 22 : 100kΩ GTM32 Pro vB - hotend - 4.7kΩ pullup to 3.3V and 220Ω to analog input + * 23 : 100kΩ GTM32 Pro vB - bed - 4.7kΩ pullup to 3.3v and 220Ω to analog input + * 30 : 100kΩ Kis3d Silicone heating mat 200W/300W with 6mm precision cast plate (EN AW 5083) NTC100K - beta 3950 + * 60 : 100kΩ Maker's Tool Works Kapton Bed Thermistor - beta 3950 + * 61 : 100kΩ Formbot/Vivedino 350°C Thermistor - beta 3950 + * 66 : 4.7MΩ Dyze Design / Trianglelab T-D500 500°C High Temperature Thermistor + * 67 : 500kΩ SliceEngineering 450°C Thermistor + * 68 : PT100 Smplifier board from Dyze Design + * 70 : 100kΩ bq Hephestos 2 + * 75 : 100kΩ Generic Silicon Heat Pad with NTC100K MGB18-104F39050L32 + * 2000 : 100kΩ Ultimachine Rambo TDK NTCG104LH104KT1 NTC100K motherboard Thermistor * - * Analog Thermistors - 1kΩ pullup - Atypical, and requires changing out the 4.7kΩ pullup for 1kΩ. - * ------- (but gives greater accuracy and more stable PID) - * 51 : 100kΩ EPCOS (1kΩ pullup) - * 52 : 200kΩ ATC Semitec 204GT-2 (1kΩ pullup) - * 55 : 100kΩ ATC Semitec 104GT-2 - Used in ParCan & J-Head (1kΩ pullup) + * ================================================================ + * Analog Thermistors - 1kΩ pullup + * Atypical, and requires changing out the 4.7kΩ pullup for 1kΩ. + * (but gives greater accuracy and more stable PID) + * ================================================================ + * 51 : 100kΩ EPCOS (1kΩ pullup) + * 52 : 200kΩ ATC Semitec 204GT-2 (1kΩ pullup) + * 55 : 100kΩ ATC Semitec 104GT-2 - Used in ParCan & J-Head (1kΩ pullup) * + * ================================================================ * Analog Thermistors - 10kΩ pullup - Atypical - * ------- - * 99 : 100kΩ Found on some Wanhao i3 machines with a 10kΩ pull-up resistor + * ================================================================ + * 99 : 100kΩ Found on some Wanhao i3 machines with a 10kΩ pull-up resistor * + * ================================================================ * Analog RTDs (Pt100/Pt1000) - * ------- + * ================================================================ * 110 : Pt100 with 1kΩ pullup (atypical) * 147 : Pt100 with 4.7kΩ pullup * 1010 : Pt1000 with 1kΩ pullup (atypical) @@ -515,15 +504,34 @@ * NOTE: ADC pins are not 5V tolerant. Not recommended because it's possible to damage the CPU by going over 500°C. * 201 : Pt100 with circuit in Overlord, similar to Ultimainboard V2.x * + * ================================================================ + * SPI RTD/Thermocouple Boards + * ================================================================ + * -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1) + * NOTE: You must uncomment/set the MAX31865_*_OHMS_n defines below. + * -3 : MAX31855 with Thermocouple, -200°C to +700°C (only for sensors 0-1) + * -2 : MAX6675 with Thermocouple, 0°C to +700°C (only for sensors 0-1) + * + * NOTE: Ensure TEMP_n_CS_PIN is set in your pins file for each TEMP_SENSOR_n using an SPI Thermocouple. By default, + * Hardware SPI on the default serial bus is used. If you have also set TEMP_n_SCK_PIN and TEMP_n_MISO_PIN, + * Software SPI will be used on those ports instead. You can force Hardware SPI on the default bus in the + * Configuration_adv.h file. At this time, separate Hardware SPI buses for sensors are not supported. + * + * ================================================================ + * Analog Thermocouple Boards + * ================================================================ + * -4 : AD8495 with Thermocouple + * -1 : AD595 with Thermocouple + * + * ================================================================ * Custom/Dummy/Other Thermal Sensors - * ------ + * ================================================================ * 0 : not used * 1000 : Custom - Specify parameters in Configuration_adv.h * * !!! Use these for Testing or Development purposes. NEVER for production machine. !!! * 998 : Dummy Table that ALWAYS reads 25°C or the temperature defined below. * 999 : Dummy Table that ALWAYS reads 100°C or the temperature defined below. - * */ #define TEMP_SENSOR_0 1 #define TEMP_SENSOR_1 0 @@ -538,6 +546,7 @@ #define TEMP_SENSOR_CHAMBER 0 #define TEMP_SENSOR_COOLER 0 #define TEMP_SENSOR_BOARD 0 +#define TEMP_SENSOR_SOC 0 #define TEMP_SENSOR_REDUNDANT 0 // Dummy thermistor constant temperature readings, for use with 998 and 999 diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 22c97c3b8c..f0c4975d5d 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -276,9 +276,15 @@ #define THERMAL_PROTECTION_BOARD // Halt the printer if the board sensor leaves the temp range below. #define BOARD_MINTEMP 8 // (°C) #define BOARD_MAXTEMP 70 // (°C) - #ifndef TEMP_BOARD_PIN - //#define TEMP_BOARD_PIN -1 // Board temp sensor pin, if not set in pins file. - #endif + //#define TEMP_BOARD_PIN -1 // Board temp sensor pin override. +#endif + +// +// SoC Sensor options +// +#if TEMP_SENSOR_SOC + #define THERMAL_PROTECTION_SOC // Halt the printer if the SoC sensor leaves the temp range below. + #define SOC_MAXTEMP 85 // (°C) #endif /** @@ -579,6 +585,9 @@ // Use TEMP_SENSOR_BOARD as a trigger for enabling the controller fan //#define CONTROLLER_FAN_MIN_BOARD_TEMP 40 // (°C) Turn on the fan if the board reaches this temperature + // Use TEMP_SENSOR_SOC as a trigger for enabling the controller fan + //#define CONTROLLER_FAN_MIN_SOC_TEMP 40 // (°C) Turn on the fan if the SoC reaches this temperature + //#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings #if ENABLED(CONTROLLER_FAN_EDITABLE) #define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 61569c7937..26fcc2a2e1 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -28,6 +28,7 @@ #include "../shared/Marduino.h" #include "../shared/math_32bit.h" #include "../shared/HAL_SPI.h" +#include "temp_soc.h" #include "fastio.h" #include "Servo.h" #include "MarlinSerial.h" diff --git a/Marlin/src/HAL/STM32/inc/SanityCheck.h b/Marlin/src/HAL/STM32/inc/SanityCheck.h index 9b0c232bdf..80d0314dbb 100644 --- a/Marlin/src/HAL/STM32/inc/SanityCheck.h +++ b/Marlin/src/HAL/STM32/inc/SanityCheck.h @@ -51,6 +51,10 @@ #error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware." #endif +#if TEMP_SENSOR_SOC && defined(ATEMP) && TEMP_SOC_PIN != ATEMP + #error "TEMP_SENSOR_SOC requires 'TEMP_SOC_PIN ATEMP' on STM32." +#endif + /** * Check for common serial pin conflicts */ diff --git a/Marlin/src/HAL/STM32/temp_soc.h b/Marlin/src/HAL/STM32/temp_soc.h new file mode 100644 index 0000000000..05262eab8b --- /dev/null +++ b/Marlin/src/HAL/STM32/temp_soc.h @@ -0,0 +1,346 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#ifdef STM32F0xx + /* + STM32F030x4 STM32F030x6 STM32F030x8 STM32F030xC https://www.st.com/resource/en/datasheet/stm32f030f4.pdf + --> TS_CAL2 not defined in datasheet + STM32F031x4 STM32F031x6 https://www.st.com/resource/en/datasheet/stm32f031c4.pdf + STM32F038x6 https://www.st.com/resource/en/datasheet/stm32f038c6.pdf + STM32F042x4 STM32F042x6 https://www.st.com/resource/en/datasheet/stm32f042c4.pdf + STM32F048C6 STM32F048G6 STM32F048T6 https://www.st.com/resource/en/datasheet/stm32f048c6.pdf + STM32F051x4 STM32F051x6 STM32F051x8 https://www.st.com/resource/en/datasheet/dm00039193.pdf + STM32F058C8 STM32F058R8 STM32F058T8 https://www.st.com/resource/en/datasheet/stm32f058c8.pdf + STM32F070CB STM32F070RB STM32F070C6 STM32F070F6 https://www.st.com/resource/en/datasheet/stm32f070c6.pdf + --> TS_CAL2 not defined in datasheet + STM32F071x8 STM32F071xB https://www.st.com/resource/en/datasheet/stm32f071cb.pdf + STM32F072x8 STM32F072xB https://www.st.com/resource/en/datasheet/stm32f072c8.pdf + STM32F078CB STM32F078RB STM32F078VB https://www.st.com/resource/en/datasheet/stm32f078cb.pdf + STM32F091xB STM32F091xC https://www.st.com/resource/en/datasheet/stm32f091cc.pdf + STM32F098CC STM32F098RC STM32F098VC https://www.st.com/resource/en/datasheet/stm32f098cc.pdf + */ + #define TS_CAL1_TEMP 30 // Calibration temperature of TS_CAL1 (see specific SoC datasheet) + #define TS_CAL1_REGOFFSET 0x1FFFF7B8 // Memory address of TS_CAL1 for STM32F030x4/x6/x8/xC (see specific SoC datasheet) + #define TS_CAL2_TEMP 110 // Calibration temperature of TS_CAL2 (see specific SoC datasheet) + #define TS_CAL2_REGOFFSET 0x1FFFF7C2 // Memory address of TS_CAL2 for STM32F030x4/x6/x8/xC (see specific SoC datasheet) + +#elif defined(STM32F1xx) + /* + STM32F100xC STM32F100xD STM32F100xE https://www.st.com/resource/en/datasheet/stm32f100rc.pdf + --> V=1.41 + STM32F100x4 STM32F100x6 STM32F100x8 STM32F100xB https://www.st.com/resource/en/datasheet/stm32f100cb.pdf + --> V=1.41 + STM32F101x8 STM32F101xB https://www.st.com/resource/en/datasheet/stm32f101r8.pdf + STM32F101xC STM32F101xD STM32F101xE https://www.st.com/resource/en/datasheet/stm32f101rc.pdf + STM32F101x4 STM32F101x6 https://www.st.com/resource/en/datasheet/stm32f101c4.pdf + STM32F101xF STM32F101xG https://www.st.com/resource/en/datasheet/stm32f101vf.pdf + STM32F102x8 STM32F102xB https://www.st.com/resource/en/datasheet/stm32f102c8.pdf + --> V=1.42 / Slope=4.35 + STM32F102x4 STM32F102x6 https://www.st.com/resource/en/datasheet/stm32f102c4.pdf + --> V=1.42 / Slope=4.35 + STM32F103x8 STM32F103xB https://www.st.com/resource/en/datasheet/stm32f103c8.pdf + STM32F103xC STM32F103xD STM32F103xE https://www.st.com/resource/en/datasheet/stm32f103rc.pdf + STM32F103x4 STM32F103x6 https://www.st.com/resource/en/datasheet/stm32f103c4.pdf + STM32F103xF STM32F103xG https://www.st.com/resource/en/datasheet/stm32f103rg.pdf + STM32F105xx STM32F107xx https://www.st.com/resource/en/datasheet/stm32f105r8.pdf + */ + #define TS_TYPICAL_V 1.43 + #define TS_TYPICAL_TEMP 25 + #define TS_TYPICAL_SLOPE 4.3 + +#elif defined(STM32F2xx) + /* + STM32F205xx STM32F207xx https://www.st.com/resource/en/datasheet/stm32f205rb.pdf + STM32F215xx STM32F217xx https://www.st.com/resource/en/datasheet/stm32f215re.pdf + */ + #define TS_TYPICAL_V 0.76 + #define TS_TYPICAL_TEMP 25 + #define TS_TYPICAL_SLOPE 2.5 + +#elif defined(STM32F3xx) + /* + STM32F301x6 STM32F301x8 https://www.st.com/resource/en/datasheet/stm32f301c6.pdf + STM32F302xD STM32F302xE https://www.st.com/resource/en/datasheet/stm32f302re.pdf + STM32F302x6 STM32F302x8 https://www.st.com/resource/en/datasheet/stm32f302r6.pdf + STM32F302xB STM32F302xC https://www.st.com/resource/en/datasheet/stm32f302cb.pdf + STM32F303xD STM32F303xE https://www.st.com/resource/en/datasheet/stm32f303re.pdf + STM32F303xB STM32F303xC https://www.st.com/resource/en/datasheet/stm32f303cb.pdf + STM32F303x6/x8 https://www.st.com/resource/en/datasheet/stm32f303c6.pdf + STM32F334x4 STM32F334x6 STM32F334x8 https://www.st.com/resource/en/datasheet/stm32f334k4.pdf + STM32F373xx https://www.st.com/resource/en/datasheet/stm32f373cc.pdf + STM32F358xC https://www.st.com/resource/en/datasheet/stm32f358cc.pdf + STM32F378xx https://www.st.com/resource/en/datasheet/stm32f378cc.pdf + STM32F318C8 STM32F318K8 https://www.st.com/resource/en/datasheet/stm32f318c8.pdf + STM32F328C8 https://www.st.com/resource/en/datasheet/stm32f328c8.pdf + STM32F398VE https://www.st.com/resource/en/datasheet/stm32f398ve.pdf + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FFFF7B8 + #define TS_CAL2_TEMP 110 + #define TS_CAL2_REGOFFSET 0x1FFFF7C2 + +#elif defined(STM32F4xx) + /* + STM32F401xD STM32F401xE https://www.st.com/resource/en/datasheet/stm32f401re.pdf + STM32F411xC STM32F411xE https://www.st.com/resource/en/datasheet/stm32f411ce.pdf + STM32F446xC/E https://www.st.com/resource/en/datasheet/stm32f446mc.pdf + STM32F479xx https://www.st.com/resource/en/datasheet/stm32f479ai.pdf + STM32F412xE STM32F412xG https://www.st.com/resource/en/datasheet/stm32f412ce.pdf + STM32F410x8 STM32F410xB https://www.st.com/resource/en/datasheet/stm32f410cb.pdf + STM32F469xx https://www.st.com/resource/en/datasheet/stm32f469ae.pdf + STM32F423xH https://www.st.com/resource/en/datasheet/stm32f423ch.pdf + STM32F413xG STM32F413xH https://www.st.com/resource/en/datasheet/stm32f413cg.pdf + STM32F415xx STM32F417xx https://www.st.com/resource/en/datasheet/stm32f415rg.pdf + STM32F405xx STM32F407xx https://www.st.com/resource/en/datasheet/stm32f405rg.pdf + STM32F427xx STM32F429xx https://www.st.com/resource/en/datasheet/stm32f427vg.pdf + STM32F437xx STM32F439xx https://www.st.com/resource/en/datasheet/stm32f437vg.pdf + STM32F401xB STM32F401xC https://www.st.com/resource/en/datasheet/stm32f401cb.pdf + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FFF7A2C + #define TS_CAL2_TEMP 110 + #define TS_CAL2_REGOFFSET 0x1FFF7A2E + +#elif defined(STM32F7xx) + /* + STM32F756xx https://www.st.com/resource/en/datasheet/stm32f756bg.pdf + STM32F745xx STM32F746xx https://www.st.com/resource/en/datasheet/stm32f745ie.pdf + STM32F777xx STM32F778Ax STM32F779xx https://www.st.com/resource/en/datasheet/stm32f777bi.pdf + STM32F765xx STM32F767xx STM32F768Ax STM32F769xx https://www.st.com/resource/en/datasheet/stm32f765bi.pdf + STM32F722xx STM32F723xx https://www.st.com/resource/en/datasheet/stm32f722ic.pdf + --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E + STM32F732xx STM32F733xx https://www.st.com/resource/en/datasheet/stm32f732ie.pdf + --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E + STM32F750x8 https://www.st.com/resource/en/datasheet/stm32f750n8.pdf + STM32F730x8 https://www.st.com/resource/en/datasheet/stm32f730i8.pdf + --> TS_CAL1/2 = 0x1FF07A2C / 0x1FF07A2E + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FF0F44C + #define TS_CAL2_TEMP 110 + #define TS_CAL2_REGOFFSET 0x1FF0F44E + +#elif defined(STM32G0xx) + /* + STM32G030x6/x8 https://www.st.com/resource/en/datasheet/stm32g030c6.pdf + --> TS_CAL2 not defined in datasheet + STM32G050x6/x8 https://www.st.com/resource/en/datasheet/stm32g050c6.pdf + STM32G0B0KE/CE/RE/VE https://www.st.com/resource/en/datasheet/stm32g0b0ce.pdf + --> TS_CAL2 not defined in datasheet + STM32G081xB https://www.st.com/resource/en/datasheet/stm32g081cb.pdf + STM32G071x8/xB https://www.st.com/resource/en/datasheet/stm32g071c8.pdf + STM32G031x4/x6/x8 https://www.st.com/resource/en/datasheet/stm32g031c6.pdf + STM32G041x6/x8 https://www.st.com/resource/en/datasheet/stm32g041c8.pdf + STM32G051x6/x8 https://www.st.com/resource/en/datasheet/stm32g051c6.pdf + STM32G061x6/x8 https://www.st.com/resource/en/datasheet/stm32g061c6.pdf + STM32G0B1xB/xC/xE https://www.st.com/resource/en/datasheet/stm32g0b1cc.pdf + STM32G0C1xC/xE https://www.st.com/resource/en/datasheet/stm32g0c1cc.pdf + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FFF75A8 + #define TS_CAL2_TEMP 130 + #define TS_CAL2_REGOFFSET 0x1FFF75CA + +#elif defined(STM32G4xx) + /* + STM32G431x6 STM32G431x8 STM32G431xB https://www.st.com/resource/en/datasheet/stm32g431c6.pdf + STM32G441xB https://www.st.com/resource/en/datasheet/stm32g441cb.pdf + STM32G491xC STM32G491xE https://www.st.com/resource/en/datasheet/stm32g491cc.pdf + STM32G4A1xE https://www.st.com/resource/en/datasheet/stm32g4a1ce.pdf + STM32G473xB STM32G473xC STM32G473xE https://www.st.com/resource/en/datasheet/stm32g473cb.pdf + STM32G483xE https://www.st.com/resource/en/datasheet/stm32g483ce.pdf + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32G474xB STM32G474xC STM32G474xE https://www.st.com/resource/en/datasheet/stm32g474cb.pdf + STM32G484xE https://www.st.com/resource/en/datasheet/stm32g484ce.pdf + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FFF75A8 + #define TS_CAL2_TEMP 130 + #define TS_CAL2_REGOFFSET 0x1FFF75CA + +#elif defined(STM32H7xx) + /* + STM32H7A3xI/G + --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818 + STM32H7B0xB + --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818 + STM32H7B3xI + --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818 + STM32H725xE/G + STM32H735xG + STM32H723VE STM32H723VG STM32H723ZE STM32H723ZG + STM32H730AB STM32H730IB STM32H730VB STM32H730ZB + STM32H733VG STM32H733ZG + STM32H742xI/G STM32H743xI/G + --> CAL2_TEMP = 110 + STM32H745xI/G + STM32H747xI/G + STM32H753xI + STM32H755xI + STM32H757xI + STM32H750VB STM32H750ZB STM32H750IB STM32H750XB + --> CAL2_TEMP = 110 + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FF1E820 + #define TS_CAL2_TEMP 130 + #define TS_CAL2_REGOFFSET 0x1FF1E840 + +#elif defined(STM32L0xx) + /* + STM32L010RB + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32L010F4 STM32L010K4 + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32L010C6 + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32L010K8 STM32L010R8 + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32L011x3 STM32L011x4 + --> TS_CAL1 not defined in datasheet + STM32L021D4 STM32L021F4 STM32L021G4 STM32L021K4 + --> TS_CAL1 not defined in datasheet + STM32L031x4 STM32L031x6 + STM32L041x6 + STM32L051x6 STM32L051x8 + STM32L071x8 STM32L071xB STM32L071xZ + STM32L081CB STM32L081CZ STM32L081KZ + STM32L052x6 STM32L052x8 + STM32L062K8 STM32L062T8 STM32L062C8 + STM32L072x8 STM32L072xB STM32L072xZ + STM32L082KB STM32L082KZ STM32L082CZ + STM32L053C6 STM32L053C8 STM32L053R6 STM32L053R8 + STM32L063C8 STM32L063R8 + STM32L073x8 STM32L073xB STM32L073xZ + STM32L083x8 STM32L083xB STM32L083xZ + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FF8007A + #define TS_CAL2_TEMP 130 + #define TS_CAL2_REGOFFSET 0x1FF8007E + +#elif defined(STM32L1xx) + /* + STM32L100x6/8/B-A + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32L100RC + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32L100C6 STM32L100R8/RB + --> TS_CAL1/TS_CAL2 not defined in datasheet + STM32L151x6/8/B-A STM32L152x6/8/B-A + --> TS_CAL1/2 = 0x08FFF814 / 0x08FFF818 + STM32L151xD STM32L152xD + STM32L151VD-X STM32L152VD-X + STM32L15xCC STM32L15xRC STM32L15xUC STM32L15xVC + STM32L15xQC STM32L15xRC-A STM32L15xVC-A STM32L15xZC + STM32L162xE + STM32L162VD STM32L162ZD STM32L162QD STM32L162RD + STM32L162VC STM32L162RC + STM32L162VD-X + STM32L162QC STM32L162VC-A STM32L162ZC STM32L162RC-A + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FF800FA + #define TS_CAL2_TEMP 110 + #define TS_CAL2_REGOFFSET 0x1FF800FE + +#elif defined(STM32L4xx) + /* + STM32L431xx + STM32L451xx + STM32L471xx + --> CAL2_TEMP = 110 + STM32L412xx + STM32L422xx + STM32L432KB STM32L432KC + STM32L442KC + STM32L452xx + STM32L462CE STM32L462RE STM32L462VE + STM32L433xx + STM32L443CC STM32L443RC STM32L443VC + STM32L475xx + --> CAL2_TEMP = 110 + STM32L476xx + --> CAL2_TEMP = 110 + STM32L486xx : + --> CAL2_TEMP = 110 + STM32L496xx + STM32L4A6xG + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FFF75A8 + #define TS_CAL2_TEMP 130 + #define TS_CAL2_REGOFFSET 0x1FFF75CA + +#elif defined(STM32MP1xx) + /* + STM32MP131A STM32MP131D + STM32MP131C STM32MP131F + STM32MP133A STM32MP133D + STM32MP133C STM32MP133F + STM32MP135A STM32MP135D + STM32MP135C STM32MP135F + STM32MP151A/D + STM32MP151C/F + STM32MP153A/D + STM32MP153C/F + STM32MP157A/D + STM32MP157C/F + */ + // BSEC -> RCC + //#define TS_CAL1_TEMP 30 + //#define TS_CAL1_REGOFFSET 0x5C00 525C[15:0] + //#define TS_CAL2_TEMP 130 + //#define TS_CAL2_REGOFFSET 0x5C00 525C[31:16] + +#elif defined(STM32WBxx) + /* + STM32WB10CC + STM32WB50CG STM32WB30CE + STM32WB15CC + STM32WB55xx STM32WB35xx + */ + #define TS_CAL1_TEMP 30 + #define TS_CAL1_REGOFFSET 0x1FFF75A8 + #define TS_CAL2_TEMP 130 + #define TS_CAL2_REGOFFSET 0x1FFF75CA +#endif + +// TODO implement voltage scaling (calibrated Vrefint) and ADC resolution scaling (when applicable) + +/** + * When provided in datasheet, the use of calibrated values (TS_CAL1, TS_CAL2) should always be preferred over typical values. + * Typical values may result in important variation from the actual temperature. + * + * If calibrated values are not provided in datasheet, it is encouraged to calibrate your specific chip yourself. + */ +#if defined(TS_CAL1_TEMP) && defined(TS_CAL1_REGOFFSET) && defined(TS_CAL2_TEMP) && defined(TS_CAL2_REGOFFSET) + + #define READMEMORY(ADDR) (*((uint16_t const *)(ADDR))) + #define TEMP_SOC_SENSOR(RAW) (float((TS_CAL2_TEMP) - (TS_CAL1_TEMP)) / (READMEMORY(TS_CAL2_REGOFFSET) - READMEMORY(TS_CAL1_REGOFFSET)) * ((RAW) / float(OVERSAMPLENR) - READMEMORY(TS_CAL1_REGOFFSET)) + (TS_CAL1_TEMP)) + +#elif defined(TS_TYPICAL_V) && defined(TS_TYPICAL_SLOPE) && defined(TS_TYPICAL_TEMP) + + #define TEMP_SOC_SENSOR(RAW) ((TS_TYPICAL_V - (RAW) / float(OVERSAMPLENR) / float(HAL_ADC_RANGE) * float(ADC_VREF)) / (TS_TYPICAL_SLOPE/1000) + TS_TYPICAL_TEMP) + +#endif diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 4d3140001e..a0cdda3b4f 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -307,6 +307,7 @@ enum ADCIndex : uint8_t { OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE) OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER) OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD) + OPTITEM(HAS_TEMP_SOC, TEMP_SOC) OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH) OPTITEM(HAS_ADC_BUTTONS, ADC_KEY) OPTITEM(HAS_JOY_ADC_X, JOY_X) @@ -335,6 +336,7 @@ void MarlinHAL::adc_init() { OPTITEM(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN) OPTITEM(HAS_TEMP_COOLER, TEMP_COOLER_PIN) OPTITEM(HAS_TEMP_BOARD, TEMP_BOARD_PIN) + OPTITEM(HAS_TEMP_SOC, TEMP_SOC_PIN) OPTITEM(FILAMENT_WIDTH_SENSOR, FILWIDTH_PIN) OPTITEM(HAS_ADC_BUTTONS, ADC_KEYPAD_PIN) OPTITEM(HAS_JOY_ADC_X, JOY_X_PIN) @@ -373,6 +375,7 @@ void MarlinHAL::adc_start(const pin_t pin) { _TCASE(HAS_TEMP_ADC_PROBE, TEMP_PROBE_PIN, TEMP_PROBE) _TCASE(HAS_TEMP_COOLER, TEMP_COOLER_PIN, TEMP_COOLER) _TCASE(HAS_TEMP_BOARD, TEMP_BOARD_PIN, TEMP_BOARD) + _TCASE(HAS_TEMP_SOC, TEMP_SOC_PIN, TEMP_SOC) _TCASE(HAS_JOY_ADC_X, JOY_X_PIN, JOY_X) _TCASE(HAS_JOY_ADC_Y, JOY_Y_PIN, JOY_Y) _TCASE(HAS_JOY_ADC_Z, JOY_Z_PIN, JOY_Z) diff --git a/Marlin/src/core/language.h b/Marlin/src/core/language.h index bf309293ac..0c5bc0af9b 100644 --- a/Marlin/src/core/language.h +++ b/Marlin/src/core/language.h @@ -242,6 +242,7 @@ #define STR_HEATER_CHAMBER "chamber" #define STR_COOLER "cooler" #define STR_MOTHERBOARD "motherboard" +#define STR_SOC "soc" #define STR_PROBE "probe" #define STR_REDUNDANT "redundant " #define STR_LASER_TEMP "laser temperature" diff --git a/Marlin/src/feature/controllerfan.cpp b/Marlin/src/feature/controllerfan.cpp index 6e5278ce74..4b3d9f5501 100644 --- a/Marlin/src/feature/controllerfan.cpp +++ b/Marlin/src/feature/controllerfan.cpp @@ -61,10 +61,16 @@ void ControllerFan::update() { // - At least one stepper driver is enabled // - The heated bed is enabled // - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_MIN_BOARD_TEMP + // - TEMP_SENSOR_SOC is reporting >= CONTROLLER_FAN_MIN_SOC_TEMP const ena_mask_t axis_mask = TERN(CONTROLLER_FAN_USE_Z_ONLY, _BV(Z_AXIS), (ena_mask_t)~TERN0(CONTROLLER_FAN_IGNORE_Z, _BV(Z_AXIS))); if ( (stepper.axis_enabled.bits & axis_mask) || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0) - || TERN0(HAS_CONTROLLER_FAN_MIN_BOARD_TEMP, thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP) + #ifdef CONTROLLER_FAN_MIN_BOARD_TEMP + || thermalManager.wholeDegBoard() >= CONTROLLER_FAN_MIN_BOARD_TEMP + #endif + #ifdef CONTROLLER_FAN_MIN_SOC_TEMP + || thermalManager.wholeDegSoc() >= CONTROLLER_FAN_MIN_SOC_TEMP + #endif ) lastMotorOn = ms; //... set time to NOW so the fan will turn on // Fan Settings. Set fan > 0: diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 119d69ee3d..1772430dc4 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -288,7 +288,8 @@ */ // Temperature sensor IDs -#define HID_REDUNDANT -6 +#define HID_REDUNDANT -7 +#define HID_SOC -6 #define HID_BOARD -5 #define HID_COOLER -4 #define HID_PROBE -3 @@ -306,9 +307,8 @@ #define _SENSOR_IS(I,N) || (TEMP_SENSOR(N) == I) #define _E_SENSOR_IS(I,N) _SENSOR_IS(N,I) #define ANY_E_SENSOR_IS(N) (0 REPEAT2(HOTENDS, _E_SENSOR_IS, N)) -#define ANY_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) \ - _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) \ - _SENSOR_IS(N,COOLER) _SENSOR_IS(N,BOARD) _SENSOR_IS(N,REDUNDANT) ) +#define ANY_THERMISTOR_IS(N) ( ANY_E_SENSOR_IS(N) _SENSOR_IS(N,REDUNDANT) \ + _SENSOR_IS(N,BED) _SENSOR_IS(N,PROBE) _SENSOR_IS(N,CHAMBER) _SENSOR_IS(N,COOLER) _SENSOR_IS(N,BOARD) ) #if ANY_THERMISTOR_IS(1000) #define HAS_USER_THERMISTORS 1 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 30c2613b03..ac701c4570 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2216,6 +2216,9 @@ #if HAS_ADC_TEST(BOARD) #define HAS_TEMP_ADC_BOARD 1 #endif +#if HAS_ADC_TEST(SOC) + #define HAS_TEMP_ADC_SOC 1 +#endif #if HAS_ADC_TEST(REDUNDANT) #define HAS_TEMP_ADC_REDUNDANT 1 #endif @@ -2239,6 +2242,9 @@ #if HAS_TEMP(BOARD) #define HAS_TEMP_BOARD 1 #endif +#if HAS_TEMP(SOC) + #define HAS_TEMP_SOC 1 +#endif #if HAS_TEMP(REDUNDANT) #define HAS_TEMP_REDUNDANT 1 #endif @@ -2312,7 +2318,7 @@ #define BED_OR_CHAMBER 1 #endif -#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD +#if HAS_TEMP_HOTEND || BED_OR_CHAMBER || HAS_TEMP_PROBE || HAS_TEMP_COOLER || HAS_TEMP_BOARD || HAS_TEMP_SOC #define HAS_TEMP_SENSOR 1 #endif @@ -2548,9 +2554,6 @@ */ #if PIN_EXISTS(CONTROLLER_FAN) #define HAS_CONTROLLER_FAN 1 - #if CONTROLLER_FAN_MIN_BOARD_TEMP - #define HAS_CONTROLLER_FAN_MIN_BOARD_TEMP 1 - #endif #endif #if HAS_CONTROLLER_FAN diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 2c2e17f4e3..a5244636dc 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1976,6 +1976,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be PROBE. TEMP_SENSOR_PROBE is in use." #elif REDUNDANT_TEMP_MATCH(SOURCE, BOARD) && HAS_TEMP_BOARD #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be BOARD. TEMP_SENSOR_BOARD is in use." + #elif REDUNDANT_TEMP_MATCH(SOURCE, SOC) + #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be SOC." #elif REDUNDANT_TEMP_MATCH(SOURCE, CHAMBER) && HAS_TEMP_CHAMBER #error "TEMP_SENSOR_REDUNDANT_SOURCE can't be CHAMBER. TEMP_SENSOR_CHAMBER is in use." #elif REDUNDANT_TEMP_MATCH(SOURCE, BED) && HAS_TEMP_BED @@ -2004,6 +2006,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #error "TEMP_SENSOR_REDUNDANT_TARGET can't be CHAMBER without TEMP_CHAMBER_PIN defined." #elif REDUNDANT_TEMP_MATCH(TARGET, BOARD) && !PIN_EXISTS(TEMP_BOARD) #error "TEMP_SENSOR_REDUNDANT_TARGET can't be BOARD without TEMP_BOARD_PIN defined." + #elif REDUNDANT_TEMP_MATCH(TARGET, SOC) + #error "TEMP_SENSOR_REDUNDANT_TARGET can't be SOC." #elif REDUNDANT_TEMP_MATCH(TARGET, PROBE) && !PIN_EXISTS(TEMP_PROBE) #error "TEMP_SENSOR_REDUNDANT_TARGET can't be PROBE without TEMP_PROBE_PIN defined." #elif REDUNDANT_TEMP_MATCH(TARGET, COOLER) && !PIN_EXISTS(TEMP_COOLER) @@ -2135,8 +2139,14 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD." #endif -#if TEMP_SENSOR_BOARD && !PIN_EXISTS(TEMP_BOARD) - #error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN." +#if TEMP_SENSOR_SOC + #if !PIN_EXISTS(TEMP_SOC) + #error "TEMP_SENSOR_SOC requires TEMP_SOC_PIN." + #elif ENABLED(THERMAL_PROTECTION_SOC) && !defined(SOC_MAXTEMP) + #error "THERMAL_PROTECTION_SOC requires SOC_MAXTEMP." + #endif +#elif CONTROLLER_FAN_MIN_SOC_TEMP + #error "CONTROLLER_FAN_MIN_SOC_TEMP requires TEMP_SENSOR_SOC." #endif #if ENABLED(LASER_COOLANT_FLOW_METER) && !(PIN_EXISTS(FLOWMETER) && ENABLED(LASER_FEATURE)) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 3274136f41..b4b1ba6372 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -564,6 +564,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED); #endif #endif +#if HAS_TEMP_SOC + soc_info_t Temperature::temp_soc; // = { 0 } + raw_adc_t Temperature::maxtemp_raw_SOC = TEMP_SENSOR_SOC_RAW_HI_TEMP; +#endif + #if BOTH(HAS_MARLINUI_MENU, PREVENT_COLD_EXTRUSION) && E_MANUAL > 0 bool Temperature::allow_cold_extrude_override = false; #else @@ -1356,6 +1361,7 @@ void Temperature::_temp_error(const heater_id_t heater_id, FSTR_P const serial_m OPTCODE(HAS_TEMP_COOLER, case H_COOLER: SERIAL_ECHOPGM(STR_COOLER); break) OPTCODE(HAS_TEMP_PROBE, case H_PROBE: SERIAL_ECHOPGM(STR_PROBE); break) OPTCODE(HAS_TEMP_BOARD, case H_BOARD: SERIAL_ECHOPGM(STR_MOTHERBOARD); break) + OPTCODE(HAS_TEMP_SOC, case H_SOC: SERIAL_ECHOPGM(STR_SOC); break) OPTCODE(HAS_TEMP_CHAMBER, case H_CHAMBER: SERIAL_ECHOPGM(STR_HEATER_CHAMBER); break) OPTCODE(HAS_TEMP_BED, case H_BED: SERIAL_ECHOPGM(STR_HEATER_BED); break) default: @@ -2368,6 +2374,20 @@ void Temperature::task() { } #endif // HAS_TEMP_BOARD +#if HAS_TEMP_SOC + // For SoC temperature measurement. + celsius_float_t Temperature::analog_to_celsius_soc(const raw_adc_t raw) { + return ( + #ifdef TEMP_SOC_SENSOR + TEMP_SOC_SENSOR(raw) + #else + 0 + #error "TEMP_SENSOR_SOC requires the TEMP_SOC_SENSOR(RAW) macro to be defined for your board." + #endif + ); + } +#endif + #if HAS_TEMP_REDUNDANT // For redundant temperature measurement. celsius_float_t Temperature::analog_to_celsius_redundant(const raw_adc_t raw) { @@ -2430,6 +2450,7 @@ void Temperature::updateTemperaturesFromRawValues() { TERN_(HAS_TEMP_COOLER, temp_cooler.celsius = analog_to_celsius_cooler(temp_cooler.getraw())); TERN_(HAS_TEMP_PROBE, temp_probe.celsius = analog_to_celsius_probe(temp_probe.getraw())); TERN_(HAS_TEMP_BOARD, temp_board.celsius = analog_to_celsius_board(temp_board.getraw())); + TERN_(HAS_TEMP_SOC, temp_soc.celsius = analog_to_celsius_soc(temp_soc.getraw())); TERN_(HAS_TEMP_REDUNDANT, temp_redundant.celsius = analog_to_celsius_redundant(temp_redundant.getraw())); TERN_(FILAMENT_WIDTH_SENSOR, filwidth.update_measured_mm()); @@ -2507,6 +2528,10 @@ void Temperature::updateTemperaturesFromRawValues() { if (TP_CMP(BOARD, temp_board.getraw(), maxtemp_raw_BOARD)) maxtemp_error(H_BOARD); if (TP_CMP(BOARD, mintemp_raw_BOARD, temp_board.getraw())) mintemp_error(H_BOARD); #endif + + #if BOTH(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC) + if (TP_CMP(SOC, temp_soc.getraw(), maxtemp_raw_SOC)) maxtemp_error(H_SOC); + #endif #undef TP_CMP } // Temperature::updateTemperaturesFromRawValues @@ -2722,6 +2747,7 @@ void Temperature::init() { TERN_(HAS_TEMP_ADC_PROBE, hal.adc_enable(TEMP_PROBE_PIN)); TERN_(HAS_TEMP_ADC_COOLER, hal.adc_enable(TEMP_COOLER_PIN)); TERN_(HAS_TEMP_ADC_BOARD, hal.adc_enable(TEMP_BOARD_PIN)); + TERN_(HAS_TEMP_ADC_SOC, hal.adc_enable(TEMP_SOC_PIN)); TERN_(HAS_TEMP_ADC_REDUNDANT, hal.adc_enable(TEMP_REDUNDANT_PIN)); TERN_(FILAMENT_WIDTH_SENSOR, hal.adc_enable(FILWIDTH_PIN)); TERN_(HAS_ADC_BUTTONS, hal.adc_enable(ADC_KEYPAD_PIN)); @@ -2858,6 +2884,10 @@ void Temperature::init() { while (analog_to_celsius_board(maxtemp_raw_BOARD) > BOARD_MAXTEMP) maxtemp_raw_BOARD -= TEMPDIR(BOARD) * (OVERSAMPLENR); #endif + #if BOTH(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC) + while (analog_to_celsius_soc(maxtemp_raw_SOC) > SOC_MAXTEMP) maxtemp_raw_SOC -= OVERSAMPLENR; + #endif + #if HAS_TEMP_REDUNDANT temp_redundant.target = &( #if REDUNDANT_TEMP_MATCH(TARGET, COOLER) && HAS_TEMP_COOLER @@ -3340,6 +3370,7 @@ void Temperature::update_raw_temperatures() { TERN_(HAS_TEMP_ADC_PROBE, temp_probe.update()); TERN_(HAS_TEMP_ADC_COOLER, temp_cooler.update()); TERN_(HAS_TEMP_ADC_BOARD, temp_board.update()); + TERN_(HAS_TEMP_ADC_SOC, temp_soc.update()); TERN_(HAS_JOY_ADC_X, joystick.x.update()); TERN_(HAS_JOY_ADC_Y, joystick.y.update()); @@ -3370,6 +3401,7 @@ void Temperature::readings_ready() { TERN_(HAS_TEMP_PROBE, temp_probe.reset()); TERN_(HAS_TEMP_COOLER, temp_cooler.reset()); TERN_(HAS_TEMP_BOARD, temp_board.reset()); + TERN_(HAS_TEMP_SOC, temp_soc.reset()); TERN_(HAS_TEMP_REDUNDANT, temp_redundant.reset()); TERN_(HAS_JOY_ADC_X, joystick.x.reset()); @@ -3828,6 +3860,11 @@ void Temperature::isr() { case MeasureTemp_BOARD: ACCUMULATE_ADC(temp_board); break; #endif + #if HAS_TEMP_ADC_SOC + case PrepareTemp_SOC: hal.adc_start(TEMP_SOC_PIN); break; + case MeasureTemp_SOC: ACCUMULATE_ADC(temp_soc); break; + #endif + #if HAS_TEMP_ADC_REDUNDANT case PrepareTemp_REDUNDANT: hal.adc_start(TEMP_REDUNDANT_PIN); break; case MeasureTemp_REDUNDANT: ACCUMULATE_ADC(temp_redundant); break; @@ -3967,8 +4004,10 @@ void Temperature::isr() { * Print a single heater state in the form: * Bed: " B:nnn.nn /nnn.nn" * Chamber: " C:nnn.nn /nnn.nn" - * Probe: " P:nnn.nn /nnn.nn" + * Probe: " P:nnn.nn" * Cooler: " L:nnn.nn /nnn.nn" + * Board: " M:nnn.nn" + * SoC: " S:nnn.nn" * Redundant: " R:nnn.nn /nnn.nn" * Extruder: " T0:nnn.nn /nnn.nn" * With ADC: " T0:nnn.nn /nnn.nn (nnn.nn)" @@ -3977,6 +4016,7 @@ void Temperature::isr() { OPTARG(SHOW_TEMP_ADC_VALUES, const float r) ) { char k; + bool show_t = true; switch (e) { default: #if HAS_TEMP_HOTEND @@ -3989,13 +4029,16 @@ void Temperature::isr() { case H_CHAMBER: k = 'C'; break; #endif #if HAS_TEMP_PROBE - case H_PROBE: k = 'P'; break; + case H_PROBE: k = 'P'; show_t = false; break; #endif #if HAS_TEMP_COOLER case H_COOLER: k = 'L'; break; #endif #if HAS_TEMP_BOARD - case H_BOARD: k = 'M'; break; + case H_BOARD: k = 'M'; show_t = false; break; + #endif + #if HAS_TEMP_SOC + case H_SOC: k = 'S'; show_t = false; break; #endif #if HAS_TEMP_REDUNDANT case H_REDUNDANT: k = 'R'; break; @@ -4010,10 +4053,8 @@ void Temperature::isr() { #else #define SFP 2 #endif - SERIAL_CHAR(':'); - SERIAL_PRINT(c, SFP); - SERIAL_ECHOPGM(" /"); - SERIAL_PRINT(t, SFP); + SERIAL_CHAR(':'); SERIAL_PRINT(c, SFP); + if (show_t) { SERIAL_ECHOPGM(" /"); SERIAL_PRINT(t, SFP); } #if ENABLED(SHOW_TEMP_ADC_VALUES) // Temperature MAX SPI boards do not have an OVERSAMPLENR defined SERIAL_ECHOPGM(" (", TERN(HAS_MAXTC_LIBRARIES, k == 'T', false) ? r : r * RECIPROCAL(OVERSAMPLENR)); @@ -4043,6 +4084,9 @@ void Temperature::isr() { #if HAS_TEMP_BOARD print_heater_state(H_BOARD, degBoard(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawBoardTemp())); #endif + #if HAS_TEMP_SOC + print_heater_state(H_SOC, degSoc(), 0 OPTARG(SHOW_TEMP_ADC_VALUES, rawSocTemp())); + #endif #if HAS_TEMP_REDUNDANT if (include_r) print_heater_state(H_REDUNDANT, degRedundant(), degRedundantTarget() OPTARG(SHOW_TEMP_ADC_VALUES, rawRedundantTemp())); #endif diff --git a/Marlin/src/module/temperature.h b/Marlin/src/module/temperature.h index 4bf76e5d48..2fdd1f02c8 100644 --- a/Marlin/src/module/temperature.h +++ b/Marlin/src/module/temperature.h @@ -54,6 +54,7 @@ typedef enum : int_fast8_t { H_COOLER = HID_COOLER, H_PROBE = HID_PROBE, H_BOARD = HID_BOARD, + H_SOC = HID_SOC, H_CHAMBER = HID_CHAMBER, H_BED = HID_BED, H_E0 = HID_E0, H_E1, H_E2, H_E3, H_E4, H_E5, H_E6, H_E7, @@ -83,6 +84,9 @@ enum ADCSensorState : char { #if HAS_TEMP_ADC_BOARD PrepareTemp_BOARD, MeasureTemp_BOARD, #endif + #if HAS_TEMP_ADC_SOC + PrepareTemp_SOC, MeasureTemp_SOC, + #endif #if HAS_TEMP_ADC_REDUNDANT PrepareTemp_REDUNDANT, MeasureTemp_REDUNDANT, #endif @@ -480,6 +484,9 @@ struct PIDHeaterInfo : public HeaterInfo { #if HAS_TEMP_BOARD typedef temp_info_t board_info_t; #endif +#if HAS_TEMP_SOC + typedef temp_info_t soc_info_t; +#endif // Heater watch handling template @@ -607,6 +614,9 @@ class Temperature { #if HAS_TEMP_BOARD static board_info_t temp_board; #endif + #if HAS_TEMP_SOC + static soc_info_t temp_soc; + #endif #if HAS_TEMP_REDUNDANT static redundant_info_t temp_redundant; #endif @@ -754,6 +764,10 @@ class Temperature { static raw_adc_t mintemp_raw_BOARD, maxtemp_raw_BOARD; #endif + #if BOTH(HAS_TEMP_SOC, THERMAL_PROTECTION_SOC) + static raw_adc_t maxtemp_raw_SOC; + #endif + #if MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED > 1 static uint8_t consecutive_low_temperature_error[HOTENDS]; #endif @@ -846,6 +860,9 @@ class Temperature { #if HAS_TEMP_BOARD static celsius_float_t analog_to_celsius_board(const raw_adc_t raw); #endif + #if HAS_TEMP_SOC + static celsius_float_t analog_to_celsius_soc(const raw_adc_t raw); + #endif #if HAS_TEMP_REDUNDANT static celsius_float_t analog_to_celsius_redundant(const raw_adc_t raw); #endif @@ -1119,6 +1136,14 @@ class Temperature { static celsius_t wholeDegBoard() { return static_cast(temp_board.celsius + 0.5f); } #endif + #if HAS_TEMP_SOC + #if ENABLED(SHOW_TEMP_ADC_VALUES) + static raw_adc_t rawSocTemp() { return temp_soc.getraw(); } + #endif + static celsius_float_t degSoc() { return temp_soc.celsius; } + static celsius_t wholeDegSoc() { return static_cast(temp_soc.celsius + 0.5f); } + #endif + #if HAS_TEMP_REDUNDANT #if ENABLED(SHOW_TEMP_ADC_VALUES) static raw_adc_t rawRedundantTemp() { return temp_redundant.getraw(); } diff --git a/Marlin/src/module/thermistor/thermistors.h b/Marlin/src/module/thermistor/thermistors.h index c596d746f7..53ca609f68 100644 --- a/Marlin/src/module/thermistor/thermistors.h +++ b/Marlin/src/module/thermistor/thermistors.h @@ -532,6 +532,10 @@ static_assert(255 > TEMPTABLE_0_LEN || 255 > TEMPTABLE_1_LEN || 255 > TEMPTABLE_ #define TEMP_SENSOR_BOARD_RAW_LO_TEMP MAX_RAW_THERMISTOR_VALUE #endif #endif +#ifndef TEMP_SENSOR_SOC_RAW_HI_TEMP + #define TEMP_SENSOR_SOC_RAW_LO_TEMP 0 + #define TEMP_SENSOR_SOC_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE +#endif #ifndef TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP #if TT_REVRAW(REDUNDANT) #define TEMP_SENSOR_REDUNDANT_RAW_HI_TEMP MAX_RAW_THERMISTOR_VALUE diff --git a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h index 3793f65bfa..8c32202d4d 100644 --- a/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h +++ b/Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h @@ -171,7 +171,10 @@ #define TEMP_0_PIN P0_24 #define TEMP_1_PIN P0_23 #define TEMP_BED_PIN P0_25 -#define TEMP_BOARD_PIN P1_30 // Onboard thermistor, NTC100K + +#ifndef TEMP_BOARD_PIN + #define TEMP_BOARD_PIN P1_30 // Onboard thermistor, NTC100K +#endif // // Heaters / Fans diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index 6ae99d2f57..cf64b28cd5 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -456,6 +456,11 @@ #define TEMP_BED_PIN -1 #endif +// Use ATEMP if TEMP_SOC_PIN is not defined +#if !defined(TEMP_SOC_PIN) && defined(ATEMP) + #define TEMP_SOC_PIN ATEMP +#endif + #ifndef SD_DETECT_PIN #define SD_DETECT_PIN -1 #endif diff --git a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h index ced9c722f4..531739ca16 100644 --- a/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/rambo/pins_EINSY_RAMBO.h @@ -118,10 +118,13 @@ // #define TEMP_0_PIN 0 // Analog Input, Header J2 #define TEMP_1_PIN 1 // Analog Input, Header J3 -#define TEMP_BOARD_PIN 91 // Onboard thermistor, 100k TDK NTCG104LH104JT1 #define TEMP_BED_PIN 2 // Analog Input, Header J6 #define TEMP_PROBE_PIN 3 // Analog Input, Header J15 +#ifndef TEMP_BOARD_PIN + #define TEMP_BOARD_PIN 91 // Onboard thermistor, 100k TDK NTCG104LH104JT1 +#endif + // // Heaters / Fans // diff --git a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h index 41d43c0b04..8ad5e2229c 100644 --- a/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h +++ b/Marlin/src/pins/sam/pins_DUE3DOM_MINI.h @@ -69,7 +69,10 @@ #define TEMP_0_PIN 0 // Analog Input (HOTEND0 thermistor) #define TEMP_1_PIN 2 // Analog Input (unused) #define TEMP_BED_PIN 1 // Analog Input (BED thermistor) -#define TEMP_BOARD_PIN 5 // Analog Input (OnBoard thermistor beta 3950) + +#ifndef TEMP_BOARD_PIN + #define TEMP_BOARD_PIN 5 // Analog Input (OnBoard thermistor beta 3950) +#endif // SPI for MAX Thermocouple #if !HAS_MEDIA diff --git a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h index de85484eae..7a1f1e6cce 100644 --- a/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h +++ b/Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h @@ -148,18 +148,22 @@ #define E0_SLAVE_ADDRESS 0 #endif #endif + // // Temperature Sensors // -#define TEMP_BED_PIN PC2 //TB -#define TEMP_0_PIN PC1 //TH1 -//#define TEMP_1_PIN PC3 //TH2 -#define TEMP_BOARD_PIN PC3 -#ifndef TEMP_SENSOR_BOARD - #define TEMP_SENSOR_BOARD 13 -#endif +#define TEMP_BED_PIN PC2 // TB +#define TEMP_0_PIN PC1 // TH1 +//#define TEMP_1_PIN PC3 // TH2 #define FIL_RUNOUT_PIN PA10 // MT_DET +#ifndef TEMP_BOARD_PIN + #define TEMP_BOARD_PIN PC3 +#endif +#if TEMP_BOARD_PIN == PC3 && TEMP_SENSOR_BOARD != 13 + #warning "The built-in TEMP_SENSOR_BOARD is 13 for ERYONE Ery32 mini." +#endif + // // LCD Pins // diff --git a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h index 73af02d3ab..f40e6c2d69 100644 --- a/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h +++ b/Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h @@ -160,10 +160,13 @@ // #define TEMP_0_PIN PA2 // T0 <-> E0 #define TEMP_1_PIN PA0 // T1 <-> E1 -#define TEMP_BOARD_PIN PC2 // Onboard thermistor, NTC100K #define TEMP_BED_PIN PA1 // T2 <-> Bed #define TEMP_PROBE_PIN PC3 // Shares J4 connector with PD1 +#ifndef TEMP_BOARD_PIN + #define TEMP_BOARD_PIN PC2 // Onboard thermistor, NTC100K +#endif + // // Heaters / Fans // diff --git a/buildroot/share/PlatformIO/scripts/schema.py b/buildroot/share/PlatformIO/scripts/schema.py index 103aa1f072..afac7b5d27 100755 --- a/buildroot/share/PlatformIO/scripts/schema.py +++ b/buildroot/share/PlatformIO/scripts/schema.py @@ -190,7 +190,7 @@ def extract(): elif state == Parse.BLOCK_COMMENT: # Look for temperature sensors - if cline == "Temperature sensors available:": + if re.match(r'temperature sensors.*:', cline, re.IGNORECASE): state, cline = Parse.GET_SENSORS, "Temperature Sensors" options_json, section = use_comment(cline, options_json, section, comment_buff) diff --git a/buildroot/tests/STM32F103RC_btt_USB b/buildroot/tests/STM32F103RC_btt_USB index 8381de0ea6..3981466c46 100755 --- a/buildroot/tests/STM32F103RC_btt_USB +++ b/buildroot/tests/STM32F103RC_btt_USB @@ -10,8 +10,8 @@ set -e # Build with the default configurations # restore_configs -opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 -exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - Basic Configuration" "$3" +opt_set MOTHERBOARD BOARD_BTT_SKR_MINI_V1_1 SERIAL_PORT 1 SERIAL_PORT_2 -1 TEMP_SENSOR_SOC 1 +exec_test $1 $2 "BigTreeTech SKR Mini v1.1 - SOC Temperature" "$3" # clean up restore_configs