Skip to content

Commit

Permalink
✨ Add TEMP_SENSOR_BOARD (MarlinFirmware#22279)
Browse files Browse the repository at this point in the history
  • Loading branch information
slowbro authored and ptoal committed Dec 16, 2021
1 parent c4ce942 commit c7098ed
Show file tree
Hide file tree
Showing 16 changed files with 378 additions and 157 deletions.
15 changes: 5 additions & 10 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@
* 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
*
* Custom/Dummy/Other Thermos
* Custom/Dummy/Other Thermal Sensors
* ------
* 0 : not used
* 1000 : Custom - Specify parameters in Configuration_adv.h
Expand All @@ -498,6 +498,7 @@
#define TEMP_SENSOR_PROBE 0
#define TEMP_SENSOR_CHAMBER 0
#define TEMP_SENSOR_COOLER 0
#define TEMP_SENSOR_BOARD 0
#define TEMP_SENSOR_REDUNDANT 0

// Dummy thermistor constant temperature readings, for use with 998 and 999
Expand Down Expand Up @@ -530,17 +531,11 @@
* the print will be aborted. Whichever sensor is selected will have its normal functions disabled; i.e. selecting
* the Bed sensor (-1) will disable bed heating/monitoring.
*
* Use the following to select temp sensors:
* -5 : Cooler
* -4 : Probe
* -3 : not used
* -2 : Chamber
* -1 : Bed
* 0-7 : E0 through E7
* For selecting source/target use: COOLER, PROBE, BOARD, CHAMBER, BED, E0, E1, E2, E3, E4, E5, E6, E7
*/
#if TEMP_SENSOR_REDUNDANT
#define TEMP_SENSOR_REDUNDANT_SOURCE 1 // The sensor that will provide the redundant reading.
#define TEMP_SENSOR_REDUNDANT_TARGET 0 // The sensor that we are providing a redundant reading for.
#define TEMP_SENSOR_REDUNDANT_SOURCE E1 // The sensor that will provide the redundant reading.
#define TEMP_SENSOR_REDUNDANT_TARGET E0 // The sensor that we are providing a redundant reading for.
#define TEMP_SENSOR_REDUNDANT_MAX_DIFF 10 // (°C) Temperature difference that will trigger a print abort.
#endif

Expand Down
40 changes: 31 additions & 9 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
#define PROBE_BETA 3950 // Beta value
#endif

#if TEMP_SENSOR_BOARD == 1000
#define BOARD_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define BOARD_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
#define BOARD_BETA 3950 // Beta value
#endif

#if TEMP_SENSOR_REDUNDANT == 1000
#define REDUNDANT_PULLUP_RESISTOR_OHMS 4700 // Pullup resistor
#define REDUNDANT_RESISTANCE_25C_OHMS 100000 // Resistance at 25C
Expand Down Expand Up @@ -226,6 +232,18 @@
#endif
#endif

//
// Motherboard Sensor options
//
#if TEMP_SENSOR_BOARD
#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
#endif

//
// Laser Coolant Flow Meter
//
Expand Down Expand Up @@ -482,16 +500,20 @@
*/
//#define USE_CONTROLLER_FAN
#if ENABLED(USE_CONTROLLER_FAN)
//#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan
//#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered
//#define CONTROLLER_FAN_IGNORE_Z // Ignore Z stepper. Useful when stepper timeout is disabled.
#define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.)
#define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled
#define CONTROLLERFAN_SPEED_IDLE 0 // (0-255) Idle speed, used when motors are disabled
#define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors
//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
//#define CONTROLLER_FAN_PIN -1 // Set a custom pin for the controller fan
//#define CONTROLLER_FAN_USE_Z_ONLY // With this option only the Z axis is considered
//#define CONTROLLER_FAN_IGNORE_Z // Ignore Z stepper. Useful when stepper timeout is disabled.
#define CONTROLLERFAN_SPEED_MIN 0 // (0-255) Minimum speed. (If set below this value the fan is turned off.)
#define CONTROLLERFAN_SPEED_ACTIVE 255 // (0-255) Active speed, used when any motor is enabled
#define CONTROLLERFAN_SPEED_IDLE 0 // (0-255) Idle speed, used when motors are disabled
#define CONTROLLERFAN_IDLE_TIME 60 // (seconds) Extra time to keep the fan running after disabling motors

// 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

//#define CONTROLLER_FAN_EDITABLE // Enable M710 configurable settings
#if ENABLED(CONTROLLER_FAN_EDITABLE)
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
#define CONTROLLER_FAN_MENU // Enable the Controller Fan submenu
#endif
#endif

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,10 +1168,10 @@ void setup() {
SETUP_RUN(HAL_init());

// Init and disable SPI thermocouples; this is still needed
#if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 0)
#if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0))
OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable
#endif
#if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && TEMP_SENSOR_REDUNDANT_SOURCE == 1)
#if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1))
OUT_WRITE(TEMP_1_CS_PIN, HIGH);
#endif

Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@
#define STR_HEATER_BED "bed"
#define STR_HEATER_CHAMBER "chamber"
#define STR_COOLER "cooler"
#define STR_MOTHERBOARD "motherboard"
#define STR_PROBE "probe"
#define STR_REDUNDANT "redundant "
#define STR_LASER_TEMP "laser temperature"

#define STR_STOPPED_HEATER ", system stopped! Heater_ID: "
Expand Down
11 changes: 8 additions & 3 deletions Marlin/src/feature/controllerfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ void ControllerFan::update() {
)
);

// If any of the drivers or the heated bed are enabled...
if (motor_on || TERN0(HAS_HEATED_BED, thermalManager.temp_bed.soft_pwm_amount > 0))
lastMotorOn = ms; //... set time to NOW so the fan will turn on
// If any triggers for the controller fan are true...
// - At least one stepper driver is enabled
// - The heated bed is enabled
// - TEMP_SENSOR_BOARD is reporting >= CONTROLLER_FAN_MIN_BOARD_TEMP
if ( motor_on
|| 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)
) lastMotorOn = ms; //... set time to NOW so the fan will turn on

// Fan Settings. Set fan > 0:
// - If AutoMode is on and steppers have been enabled for CONTROLLERFAN_IDLE_TIME seconds.
Expand Down
23 changes: 23 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,29 @@
#undef THERMAL_PROTECTION_COOLER
#endif

// Usurp a sensor to do redundant readings
#if TEMP_SENSOR_REDUNDANT
#define REDUNDANT_TEMP_MATCH(M,N) (TEMP_SENSOR_REDUNDANT_##M == HID_##N)
#else
#define REDUNDANT_TEMP_MATCH(...) 0
#endif

// Temperature sensor IDs
#define HID_REDUNDANT -6
#define HID_COOLER -5
#define HID_PROBE -4
#define HID_BOARD -3
#define HID_CHAMBER -2
#define HID_BED -1
#define HID_E0 0
#define HID_E1 1
#define HID_E2 2
#define HID_E3 3
#define HID_E4 4
#define HID_E5 5
#define HID_E6 6
#define HID_E7 7

#if ENABLED(MIXING_EXTRUDER) && (ENABLED(RETRACT_SYNC_MIXING) || BOTH(FILAMENT_LOAD_UNLOAD_GCODES, FILAMENT_UNLOAD_ALL_EXTRUDERS))
#define HAS_MIXER_SYNC_CHANNEL 1
#endif
Expand Down
Loading

0 comments on commit c7098ed

Please sign in to comment.