Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use SoC temperature sensor #25642

12 changes: 12 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,18 @@
*
* Temperature sensors available:
*
* Board (SoC) Internal Temperature Sensor - IMPORTANT: Only available for TEMP_SENSOR_BOARD
* -------
* -100 : Use chip internal temperature sensor
*
* NOTE: The use of the chip internal temperature sensor is to measure the silicon temperature.
* It is in NO WAY meant to be an accurate reading of the ambient temperature.
* Can only be used with TEMP_SENSOR_BOARD.
*
* NOTE: Requires TEMP_INTERNAL_SENSOR(RAW) macro to convert the ADC value of the TEMP_BOARD_PIN to the temperature.
* HAL\STM32\internal_temp.h provides this macro for STM32 HAL using ATEMP pin and the specs of various STM32 chips.
* Therefore, defining TEMP_SENSOR_BOARD -100 on stm32_variant boards is the only step required to use the internal sensor of the STM32.
*
* SPI RTD/Thermocouple Boards - IMPORTANT: Read the NOTE below!
* -------
* -5 : MAX31865 with Pt100/Pt1000, 2, 3, or 4-wire (only for sensors 0-1)
Expand Down
4 changes: 1 addition & 3 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,7 @@
#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

/**
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/HAL/STM32/HAL.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "../shared/Marduino.h"
#include "../shared/math_32bit.h"
#include "../shared/HAL_SPI.h"
#include "internal_temp.h"
#include "fastio.h"
#include "Servo.h"
#include "MarlinSerial.h"
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/HAL/STM32/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_BOARD_IS_INTERNAL && defined(ATEMP) && TEMP_BOARD_PIN != ATEMP
#error "TEMP_SENSOR_BOARD -100 requires 'TEMP_BOARD_PIN ATEMP' on STM32."
#endif

/**
* Check for common serial pin conflicts
*/
Expand Down
351 changes: 351 additions & 0 deletions Marlin/src/HAL/STM32/internal_temp.h

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,9 +280,9 @@
#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_EXT_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) )
#define ANY_THERMISTOR_IS(N) ( ANY_EXT_THERMISTOR_IS(N) _SENSOR_IS(N,BOARD) )

#if ANY_THERMISTOR_IS(1000)
#define HAS_USER_THERMISTORS 1
Expand Down Expand Up @@ -740,7 +740,9 @@
#endif
#endif

#if TEMP_SENSOR_BOARD == -4
#if TEMP_SENSOR_BOARD == -100
#define TEMP_SENSOR_BOARD_IS_INTERNAL 1
#elif TEMP_SENSOR_BOARD == -4
#define TEMP_SENSOR_BOARD_IS_AD8495 1
#elif TEMP_SENSOR_BOARD == -3
#error "MAX31855 Thermocouples (-3) not supported for TEMP_SENSOR_BOARD."
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,11 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#undef _ISMAX_1
#undef _ISSNS_1

// Internal Temperature Sensor
#if ANY_EXT_THERMISTOR_IS(-100)
#error "Board Internal Temperature Sensor (-100) is only supported for TEMP_SENSOR_BOARD."
#endif

/**
* Hephestos 2 Heated Bed Kit requirements
*/
Expand Down Expand Up @@ -2727,6 +2732,8 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#error "TEMP_SENSOR_BOARD requires TEMP_BOARD_PIN."
#elif ENABLED(THERMAL_PROTECTION_BOARD) && (!defined(BOARD_MINTEMP) || !defined(BOARD_MAXTEMP))
#error "THERMAL_PROTECTION_BOARD requires BOARD_MINTEMP and BOARD_MAXTEMP."
#elif TEMP_SENSOR_BOARD_IS_INTERNAL && !defined(TEMP_INTERNAL_SENSOR)
#error "TEMP_SENSOR_BOARD -100 requires TEMP_INTERNAL_SENSOR(RAW) to be defined. It may not be implemented for your specific board."
#endif
#elif CONTROLLER_FAN_MIN_BOARD_TEMP
#error "CONTROLLER_FAN_MIN_BOARD_TEMP requires TEMP_SENSOR_BOARD."
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2360,6 +2360,8 @@ void Temperature::task() {
return TEMP_AD595(raw);
#elif TEMP_SENSOR_BOARD_IS_AD8495
return TEMP_AD8495(raw);
#elif TEMP_SENSOR_BOARD_IS_INTERNAL
return TEMP_INTERNAL_SENSOR(raw);
#else
UNUSED(raw);
return 0;
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/pins/lpc1769/pins_BTT_SKR_E3_TURBO.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/pins/rambo/pins_EINSY_RAMBO.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/pins/sam/pins_DUE3DOM_MINI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 DISABLED(SDSUPPORT)
Expand Down
18 changes: 11 additions & 7 deletions Marlin/src/pins/stm32f1/pins_ERYONE_ERY32_MINI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/pins/stm32f4/pins_BTT_BTT002_V1_0.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down