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

Small PID / MPC related fixes #25314

Merged
merged 8 commits into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@
#define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius

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

/**
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -3054,7 +3054,7 @@
*/
#if !HAS_FAN
#undef ADAPTIVE_FAN_SLOWING
#undef NO_FAN_SLOWING_IN_PID_TUNING
#undef TEMP_TUNING_MAINTAIN_FAN
#endif
#if !BOTH(HAS_BED_PROBE, HAS_FAN)
#undef PROBING_FANS_OFF
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
#error "Thermal Runaway Protection for hotends is now enabled with THERMAL_PROTECTION_HOTENDS."
#elif DISABLED(THERMAL_PROTECTION_BED) && defined(THERMAL_PROTECTION_BED_PERIOD)
#error "Thermal Runaway Protection for the bed is now enabled with THERMAL_PROTECTION_BED."
#elif defined(NO_FAN_SLOWING_IN_PID_TUNING)
#error "NO_FAN_SLOWING_IN_PID_TUNING is now TEMP_TUNING_MAINTAIN_FAN."
#elif (CORE_IS_XZ || CORE_IS_YZ) && ENABLED(Z_LATE_ENABLE)
#error "Z_LATE_ENABLE can't be used with COREXZ, COREZX, COREYZ, or COREZY."
#elif defined(X_HOME_RETRACT_MM)
Expand Down
21 changes: 16 additions & 5 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
* public:
*/

#if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
#if ENABLED(TEMP_TUNING_MAINTAIN_FAN)
bool Temperature::adaptive_fan_slowing = true;
#endif

Expand Down Expand Up @@ -688,7 +688,7 @@ volatile bool Temperature::raw_temps_ready = false;
LEDColor color = ONHEATINGSTART();
#endif

TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = false);
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = false);

LCD_MESSAGE(MSG_HEATING);

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

EXIT_M303:
TERN_(NO_FAN_SLOWING_IN_PID_TUNING, adaptive_fan_slowing = true);
TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true);
return;
}

Expand Down Expand Up @@ -910,6 +910,7 @@ volatile bool Temperature::raw_temps_ready = false;
return false;
}

wait_for_heatup = false;
return true;
};

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

do_z_clearance(MPC_TUNING_END_Z);

TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = true);
}
} on_exit;

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

TERN_(TEMP_TUNING_MAINTAIN_FAN, adaptive_fan_slowing = false);

// Move to center of bed, just above bed height and cool with max fan
gcode.home_all_axes(true);
disable_all_heaters();
Expand Down Expand Up @@ -970,7 +975,6 @@ volatile bool Temperature::raw_temps_ready = false;
next_test_ms += 10000UL;
}
}
wait_for_heatup = false;

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

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

Expand Down Expand Up @@ -1045,6 +1050,7 @@ volatile bool Temperature::raw_temps_ready = false;
#endif
float last_temp = current_temp;

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

Expand Down Expand Up @@ -4124,6 +4130,7 @@ void Temperature::isr() {

} while (wait_for_heatup && TEMP_CONDITIONS);

// If wait_for_heatup is set, temperature was reached, no cancel
if (wait_for_heatup) {
wait_for_heatup = false;
#if HAS_DWIN_E3V2_BASIC
Expand Down Expand Up @@ -4262,6 +4269,7 @@ void Temperature::isr() {

} while (wait_for_heatup && TEMP_BED_CONDITIONS);

// If wait_for_heatup is set, temperature was reached, no cancel
if (wait_for_heatup) {
wait_for_heatup = false;
ui.reset_status();
Expand Down Expand Up @@ -4340,6 +4348,7 @@ void Temperature::isr() {
}
}

// If wait_for_heatup is set, temperature was reached, no cancel
if (wait_for_heatup) {
wait_for_heatup = false;
ui.reset_status();
Expand Down Expand Up @@ -4439,6 +4448,7 @@ void Temperature::isr() {
}
} while (wait_for_heatup && TEMP_CHAMBER_CONDITIONS);

// If wait_for_heatup is set, temperature was reached, no cancel
if (wait_for_heatup) {
wait_for_heatup = false;
ui.reset_status();
Expand Down Expand Up @@ -4525,6 +4535,7 @@ void Temperature::isr() {
first_loop = false;
#endif // TEMP_COOLER_RESIDENCY_TIME > 0

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

} while (wait_for_heatup && TEMP_COOLER_CONDITIONS);

// Prevent a wait-forever situation if R is misused i.e. M191 R0
// If wait_for_heatup is set, temperature was reached, no cancel
if (wait_for_heatup) {
wait_for_heatup = false;
ui.reset_status();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ class Temperature {

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

#if ENABLED(NO_FAN_SLOWING_IN_PID_TUNING)
#if ENABLED(TEMP_TUNING_MAINTAIN_FAN)
static bool adaptive_fan_slowing;
#elif ENABLED(ADAPTIVE_FAN_SLOWING)
static constexpr bool adaptive_fan_slowing = true;
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/LPC1768
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EEB \
NOZZLE_CLEAN_MIN_TEMP 170 \
NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \
NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }"
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER ADAPTIVE_FAN_SLOWING TEMP_TUNING_MAINTAIN_FAN \
FILAMENT_WIDTH_SENSOR FILAMENT_LCD_DISPLAY PID_EXTRUSION_SCALING SOUND_MENU_ITEM \
NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR PREHEAT_BEFORE_LEVELING G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
ASSISTED_TRAMMING ASSISTED_TRAMMING_WIZARD REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/LPC1769
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ opt_set MOTHERBOARD BOARD_SMOOTHIEBOARD \
GRID_MAX_POINTS_X 16 \
NOZZLE_CLEAN_START_POINT "{ { 10, 10, 3 }, { 10, 10, 3 } }" \
NOZZLE_CLEAN_END_POINT "{ { 10, 20, 3 }, { 10, 20, 3 } }"
opt_enable TFTGLCD_PANEL_SPI SDSUPPORT ADAPTIVE_FAN_SLOWING NO_FAN_SLOWING_IN_PID_TUNING \
opt_enable TFTGLCD_PANEL_SPI SDSUPPORT ADAPTIVE_FAN_SLOWING TEMP_TUNING_MAINTAIN_FAN \
MAX31865_SENSOR_OHMS_0 MAX31865_CALIBRATION_OHMS_0 \
FIX_MOUNTED_PROBE AUTO_BED_LEVELING_BILINEAR G29_RETRY_AND_RECOVER Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET BED_TRAMMING_USE_PROBE BED_TRAMMING_VERIFY_RAISED \
Expand Down