Skip to content

Commit d6f4f24

Browse files
🩹 Fix PID / MPC heating flags (MarlinFirmware#25314)
Co-authored-by: Scott Lahteine <[email protected]>
1 parent aae103e commit d6f4f24

File tree

7 files changed

+24
-11
lines changed

7 files changed

+24
-11
lines changed

Marlin/Configuration_adv.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@
304304
#define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius
305305

306306
//#define ADAPTIVE_FAN_SLOWING // Slow part cooling fan if temperature drops
307-
#if BOTH(ADAPTIVE_FAN_SLOWING, PIDTEMP)
308-
//#define NO_FAN_SLOWING_IN_PID_TUNING // Don't slow fan speed during M303
307+
#if ENABLED(ADAPTIVE_FAN_SLOWING) && EITHER(MPCTEMP, PIDTEMP)
308+
//#define TEMP_TUNING_MAINTAIN_FAN // Don't slow fan speed during M303 or M306 T
309309
#endif
310310

311311
/**

Marlin/src/inc/Conditionals_post.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -3054,7 +3054,7 @@
30543054
*/
30553055
#if !HAS_FAN
30563056
#undef ADAPTIVE_FAN_SLOWING
3057-
#undef NO_FAN_SLOWING_IN_PID_TUNING
3057+
#undef TEMP_TUNING_MAINTAIN_FAN
30583058
#endif
30593059
#if !BOTH(HAS_BED_PROBE, HAS_FAN)
30603060
#undef PROBING_FANS_OFF

Marlin/src/inc/SanityCheck.h

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
#error "Thermal Runaway Protection for hotends is now enabled with THERMAL_PROTECTION_HOTENDS."
9898
#elif DISABLED(THERMAL_PROTECTION_BED) && defined(THERMAL_PROTECTION_BED_PERIOD)
9999
#error "Thermal Runaway Protection for the bed is now enabled with THERMAL_PROTECTION_BED."
100+
#elif defined(NO_FAN_SLOWING_IN_PID_TUNING)
101+
#error "NO_FAN_SLOWING_IN_PID_TUNING is now TEMP_TUNING_MAINTAIN_FAN."
100102
#elif (CORE_IS_XZ || CORE_IS_YZ) && ENABLED(Z_LATE_ENABLE)
101103
#error "Z_LATE_ENABLE can't be used with COREXZ, COREZX, COREYZ, or COREZY."
102104
#elif defined(X_HOME_RETRACT_MM)

Marlin/src/module/temperature.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
311311
* public:
312312
*/
313313

314-
#if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
314+
#if ENABLED(TEMP_TUNING_MAINTAIN_FAN)
315315
bool Temperature::adaptive_fan_slowing = true;
316316
#endif
317317

@@ -688,7 +688,7 @@ volatile bool Temperature::raw_temps_ready = false;
688688
LEDColor color = ONHEATINGSTART();
689689
#endif
690690

691-
TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = false);
691+
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = false);
692692

693693
LCD_MESSAGE(MSG_HEATING);
694694

@@ -876,7 +876,7 @@ volatile bool Temperature::raw_temps_ready = false;
876876
TERN_(DWIN_PID_TUNE, DWIN_PidTuning(PID_DONE));
877877

878878
EXIT_M303:
879-
TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true);
879+
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true);
880880
return;
881881
}
882882

@@ -910,6 +910,7 @@ volatile bool Temperature::raw_temps_ready = false;
910910
return false;
911911
}
912912

913+
wait_for_heatup = false;
913914
return true;
914915
};
915916

@@ -927,6 +928,8 @@ volatile bool Temperature::raw_temps_ready = false;
927928
#endif
928929

929930
do_z_clearance(MPC_TUNING_END_Z);
931+
932+
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true);
930933
}
931934
} on_exit;
932935

@@ -935,6 +938,8 @@ volatile bool Temperature::raw_temps_ready = false;
935938
MPCHeaterInfo &hotend = temp_hotend[active_extruder];
936939
MPC_t &mpc = hotend.mpc;
937940

941+
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = false);
942+
938943
// Move to center of bed, just above bed height and cool with max fan
939944
gcode.home_all_axes(true);
940945
disable_all_heaters();
@@ -970,7 +975,6 @@ volatile bool Temperature::raw_temps_ready = false;
970975
next_test_ms += 10000UL;
971976
}
972977
}
973-
wait_for_heatup = false;
974978

975979
#if HAS_FAN
976980
set_fan_speed(EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) ? 0 : active_extruder, 0);
@@ -989,6 +993,7 @@ volatile bool Temperature::raw_temps_ready = false;
989993
uint16_t sample_distance = 1;
990994
float t1_time = 0;
991995

996+
wait_for_heatup = true;
992997
for (;;) { // Can be interrupted with M108
993998
if (!housekeeping(ms, current_temp, next_report_ms)) return;
994999

@@ -1045,6 +1050,7 @@ volatile bool Temperature::raw_temps_ready = false;
10451050
#endif
10461051
float last_temp = current_temp;
10471052

1053+
wait_for_heatup = true;
10481054
for (;;) { // Can be interrupted with M108
10491055
if (!housekeeping(ms, current_temp, next_report_ms)) return;
10501056

@@ -4124,6 +4130,7 @@ void Temperature::isr() {
41244130

41254131
} while (wait_for_heatup && TEMP_CONDITIONS);
41264132

4133+
// If wait_for_heatup is set, temperature was reached, no cancel
41274134
if (wait_for_heatup) {
41284135
wait_for_heatup = false;
41294136
#if HAS_DWIN_E3V2_BASIC
@@ -4262,6 +4269,7 @@ void Temperature::isr() {
42624269

42634270
} while (wait_for_heatup && TEMP_BED_CONDITIONS);
42644271

4272+
// If wait_for_heatup is set, temperature was reached, no cancel
42654273
if (wait_for_heatup) {
42664274
wait_for_heatup = false;
42674275
ui.reset_status();
@@ -4340,6 +4348,7 @@ void Temperature::isr() {
43404348
}
43414349
}
43424350

4351+
// If wait_for_heatup is set, temperature was reached, no cancel
43434352
if (wait_for_heatup) {
43444353
wait_for_heatup = false;
43454354
ui.reset_status();
@@ -4439,6 +4448,7 @@ void Temperature::isr() {
44394448
}
44404449
} while (wait_for_heatup && TEMP_CHAMBER_CONDITIONS);
44414450

4451+
// If wait_for_heatup is set, temperature was reached, no cancel
44424452
if (wait_for_heatup) {
44434453
wait_for_heatup = false;
44444454
ui.reset_status();
@@ -4525,6 +4535,7 @@ void Temperature::isr() {
45254535
first_loop = false;
45264536
#endif // TEMP_COOLER_RESIDENCY_TIME > 0
45274537

4538+
// Prevent a wait-forever situation if R is misused i.e. M191 R0
45284539
if (wants_to_cool) {
45294540
// Break after MIN_COOLING_SLOPE_TIME_CHAMBER seconds
45304541
// if the temperature did not drop at least MIN_COOLING_SLOPE_DEG_CHAMBER
@@ -4537,7 +4548,7 @@ void Temperature::isr() {
45374548

45384549
} while (wait_for_heatup && TEMP_COOLER_CONDITIONS);
45394550

4540-
// Prevent a wait-forever situation if R is misused i.e. M191 R0
4551+
// If wait_for_heatup is set, temperature was reached, no cancel
45414552
if (wait_for_heatup) {
45424553
wait_for_heatup = false;
45434554
ui.reset_status();

Marlin/src/module/temperature.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -1173,7 +1173,7 @@ class Temperature {
11731173

11741174
static void PID_autotune(const celsius_t target, const heater_id_t heater_id, const int8_t ncycles, const bool set_result=false);
11751175

1176-
#if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
1176+
#if ENABLED(TEMP_TUNING_MAINTAIN_FAN)
11771177
static bool adaptive_fan_slowing;
11781178
#elif ENABLED(ADAPTIVE_FAN_SLOWING)
11791179
static constexpr bool adaptive_fan_slowing = true;

buildroot/tests/LPC1768

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EEB \
4040
NOZZLE_CLEAN_MIN_TEMP 170 \
4141
NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \
4242
NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }"
43-
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
43+
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING TEMP_TUNING_MAINTAIN_FAN \
4444
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING SOUND_MENU_ITEM \
4545
NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR PREHEAT_BEFORE_LEVELING G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
4646
ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \

buildroot/tests/LPC1769

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ opt_set MOTHERBOARD BOARD_SMOOTHIEBOARD \
1818
GRID_MAX_POINTS_X 16 \
1919
NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \
2020
NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }"
21-
opt_enable TFTGLCD_PANEL_SPI SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
21+
opt_enable TFTGLCD_PANEL_SPI SDSUPPORT ADAPTIVE_FAN_SLOWING TEMP_TUNING_MAINTAIN_FAN \
2222
MAX31865_SENSOR_OHMS_0 MAX31865_CALIBRATION_OHMS_0 \
2323
FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
2424
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BED_TRAMMING_USE_PROBE BED_TRAMMING_VERIFY_RAISED \

0 commit comments

Comments
 (0)