🔧 Optional MPC_AUTOTUNE to save 5.5 - 5.8KB

This commit is contained in:
Scott Lahteine 2023-03-17 20:12:36 -05:00
parent 6f5b7a8b26
commit b5836b243a
12 changed files with 109 additions and 79 deletions

View file

@ -691,6 +691,7 @@
* @section mpctemp * @section mpctemp
*/ */
#if ENABLED(MPCTEMP) #if ENABLED(MPCTEMP)
//#define MPC_AUTOTUNE // Include a method to do MPC auto-tuning (~5664-5882 bytes of flash)
//#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash) //#define MPC_EDIT_MENU // Add MPC editing to the "Advanced Settings" menu. (~1300 bytes of flash)
//#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash) //#define MPC_AUTOTUNE_MENU // Add MPC auto-tuning to the "Advanced Settings" menu. (~350 bytes of flash)

View file

@ -230,10 +230,9 @@
#define STR_PID_DEBUG_INPUT ": Input " #define STR_PID_DEBUG_INPUT ": Input "
#define STR_PID_DEBUG_OUTPUT " Output " #define STR_PID_DEBUG_OUTPUT " Output "
#define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !" #define STR_INVALID_EXTRUDER_NUM " - Invalid extruder number !"
#define STR_MPC_AUTOTUNE "MPC Autotune" #define STR_MPC_AUTOTUNE_START "MPC Autotune start for " STR_E
#define STR_MPC_AUTOTUNE_START " start for " STR_E #define STR_MPC_AUTOTUNE_INTERRUPTED "MPC Autotune interrupted!"
#define STR_MPC_AUTOTUNE_INTERRUPTED " interrupted!" #define STR_MPC_AUTOTUNE_FINISHED "MPC Autotune finished! Put the constants below into Configuration.h"
#define STR_MPC_AUTOTUNE_FINISHED " finished! Put the constants below into Configuration.h"
#define STR_MPC_COOLING_TO_AMBIENT "Cooling to ambient" #define STR_MPC_COOLING_TO_AMBIENT "Cooling to ambient"
#define STR_MPC_HEATING_PAST_200 "Heating to over 200C" #define STR_MPC_HEATING_PAST_200 "Heating to over 200C"
#define STR_MPC_MEASURING_AMBIENT "Measuring ambient heatloss at " #define STR_MPC_MEASURING_AMBIENT "Measuring ambient heatloss at "

View file

@ -33,8 +33,6 @@
* *
* E<extruder> Extruder index. (Default: Active Extruder) * E<extruder> Extruder index. (Default: Active Extruder)
* *
* T Autotune the specified or active extruder.
*
* Set MPC values manually for the specified or active extruder: * Set MPC values manually for the specified or active extruder:
* A<watts/kelvin> Ambient heat transfer coefficient (no fan). * A<watts/kelvin> Ambient heat transfer coefficient (no fan).
* C<joules/kelvin> Block heat capacity. * C<joules/kelvin> Block heat capacity.
@ -42,6 +40,9 @@
* H<joules/kelvin/mm> Filament heat capacity per mm. * H<joules/kelvin/mm> Filament heat capacity per mm.
* P<watts> Heater power. * P<watts> Heater power.
* R<kelvin/second/kelvin> Sensor responsiveness (= transfer coefficient / heat capcity). * R<kelvin/second/kelvin> Sensor responsiveness (= transfer coefficient / heat capcity).
*
* With MPC_AUTOTUNE:
* T Autotune the specified or active extruder.
*/ */
void GcodeSuite::M306() { void GcodeSuite::M306() {
@ -51,12 +52,14 @@ void GcodeSuite::M306() {
return; return;
} }
if (parser.seen_test('T')) { #if ENABLED(MPC_AUTOTUNE)
LCD_MESSAGE(MSG_MPC_AUTOTUNE); if (parser.seen_test('T')) {
thermalManager.MPC_autotune(e); LCD_MESSAGE(MSG_MPC_AUTOTUNE);
ui.reset_status(); thermalManager.MPC_autotune(e);
return; ui.reset_status();
} return;
}
#endif
if (parser.seen("ACFPRH")) { if (parser.seen("ACFPRH")) {
MPC_t &mpc = thermalManager.temp_hotend[e].mpc; MPC_t &mpc = thermalManager.temp_hotend[e].mpc;

View file

@ -1471,6 +1471,10 @@
#define HAS_PID_DEBUG 1 #define HAS_PID_DEBUG 1
#endif #endif
#if DISABLED(MPC_AUTOTUNE)
#undef MPC_AUTOTUNE_MENU
#endif
/** /**
* TFT Displays * TFT Displays
* *

View file

@ -2499,7 +2499,7 @@
#if EITHER(PIDTEMP, PIDTEMPBED) #if EITHER(PIDTEMP, PIDTEMPBED)
#define DWIN_PID_TUNE 1 #define DWIN_PID_TUNE 1
#endif #endif
#if EITHER(DWIN_PID_TUNE, MPCTEMP) && DISABLED(DISABLE_TUNING_GRAPH) #if EITHER(DWIN_PID_TUNE, MPC_AUTOTUNE) && DISABLED(DISABLE_TUNING_GRAPH)
#define SHOW_TUNING_GRAPH 1 #define SHOW_TUNING_GRAPH 1
#endif #endif
#endif #endif

View file

@ -1560,6 +1560,10 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
*/ */
#if BOTH(PIDTEMP, MPCTEMP) #if BOTH(PIDTEMP, MPCTEMP)
#error "Only enable PIDTEMP or MPCTEMP, but not both." #error "Only enable PIDTEMP or MPCTEMP, but not both."
#undef MPCTEMP
#undef MPC_AUTOTUNE
#undef MPC_EDIT_MENU
#undef MPC_AUTOTUNE_MENU
#endif #endif
#if ENABLED(MPC_INCLUDE_FAN) #if ENABLED(MPC_INCLUDE_FAN)

View file

@ -266,7 +266,7 @@ MenuClass *MaxAccelMenu = nullptr;
MenuClass *MaxJerkMenu = nullptr; MenuClass *MaxJerkMenu = nullptr;
#endif #endif
MenuClass *StepsMenu = nullptr; MenuClass *StepsMenu = nullptr;
#if ENABLED(MPCTEMP) #if EITHER(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
MenuClass *HotendMPCMenu = nullptr; MenuClass *HotendMPCMenu = nullptr;
#endif #endif
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
@ -1480,46 +1480,59 @@ void DWIN_LevelingDone() {
DWINUI::ClearMainArea(); DWINUI::ClearMainArea();
Draw_Popup_Bkgd(); Draw_Popup_Bkgd();
#if ENABLED(MPCTEMP) switch (HMI_value.pidresult) {
default: return;
#if ENABLED(MPC_AUTOTUNE)
case MPCTEMP_START:
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_MPC_AUTOTUNE));
DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("MPC target: Celsius"));
break;
#endif
#if EITHER(PIDTEMP, PIDTEMPBED)
TERN_(PIDTEMP, case PIDTEMP_START:)
TERN_(PIDTEMPBED, case PIDTEMPBED_START:)
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE));
DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius"));
break;
#endif
}
switch (HMI_value.pidresult) { switch (HMI_value.pidresult) {
default: break;
#if EITHER(PIDTEMP, MPC_AUTOTUNE)
TERN_(PIDTEMP, case PIDTEMP_START:)
TERN_(MPC_AUTOTUNE, case MPCTEMP_START:)
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running."));
break;
#endif
#if ENABLED(PIDTEMPBED)
case PIDTEMPBED_START:
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running."));
break;
#endif
}
switch (HMI_value.pidresult) {
default: break;
#if ENABLED(MPC_AUTOTUNE)
case MPCTEMP_START: case MPCTEMP_START:
_maxtemp = thermalManager.hotend_maxtemp[0]; _maxtemp = thermalManager.hotend_maxtemp[0];
_target = 200; _target = 200;
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_MPC_AUTOTUNE));
DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("MPC target: Celsius"));
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running."));
break; break;
case PIDTEMPBED_START: #endif
_maxtemp = BED_MAXTEMP; #if ENABLED(PIDTEMP)
_target = HMI_data.BedPidT;
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE));
DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius"));
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running."));
break;
default: return;
}
#else // PID
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 100, GET_TEXT_F(MSG_PID_AUTOTUNE));
DWINUI::Draw_String(HMI_data.PopupTxt_Color, gfrm.x, gfrm.y - DWINUI::fontHeight() - 4, F("PID target: Celsius"));
switch (HMI_value.pidresult) {
case PIDTEMP_START: case PIDTEMP_START:
_maxtemp = thermalManager.hotend_maxtemp[0]; _maxtemp = thermalManager.hotend_maxtemp[0];
_target = HMI_data.HotendPidT; _target = HMI_data.HotendPidT;
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for Nozzle is running."));
break; break;
#endif
#if ENABLED(PIDTEMPBED)
case PIDTEMPBED_START: case PIDTEMPBED_START:
_maxtemp = BED_MAXTEMP; _maxtemp = BED_MAXTEMP;
_target = HMI_data.BedPidT; _target = HMI_data.BedPidT;
DWINUI::Draw_CenteredString(HMI_data.PopupTxt_Color, 120, F("for BED is running."));
break; break;
default: return; #endif
} }
#endif // PID
plot.Draw(gfrm, _maxtemp, _target); plot.Draw(gfrm, _maxtemp, _target);
DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, _target); DWINUI::Draw_Int(HMI_data.PopupTxt_Color, 3, gfrm.x + 90, gfrm.y - DWINUI::fontHeight() - 4, _target);
@ -1587,7 +1600,7 @@ void DWIN_LevelingDone() {
#endif // DWIN_PID_TUNE #endif // DWIN_PID_TUNE
#if ENABLED(MPCTEMP) #if ENABLED(MPC_AUTOTUNE)
void DWIN_MPCTuning(tempcontrol_t result) { void DWIN_MPCTuning(tempcontrol_t result) {
HMI_value.pidresult = result; HMI_value.pidresult = result;
@ -1607,7 +1620,7 @@ void DWIN_LevelingDone() {
break; break;
case MPC_INTERRUPTED: case MPC_INTERRUPTED:
checkkey = last_checkkey; checkkey = last_checkkey;
DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), F(STR_MPC_AUTOTUNE STR_MPC_AUTOTUNE_INTERRUPTED)); DWIN_Popup_Confirm(ICON_TempTooHigh, GET_TEXT_F(MSG_ERROR), F(STR_MPC_AUTOTUNE_INTERRUPTED));
ui.reset_alert_level(); ui.reset_alert_level();
break; break;
case MPC_DONE: case MPC_DONE:
@ -1622,7 +1635,7 @@ void DWIN_LevelingDone() {
} }
} }
#endif // MPCTEMP #endif // MPC_AUTOTUNE
// Started a Print Job // Started a Print Job
void DWIN_Print_Started() { void DWIN_Print_Started() {
@ -3090,8 +3103,8 @@ void Draw_AdvancedSettings_Menu() {
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID " Settings", onDrawSubMenu, Draw_HotendPID_Menu); MENU_ITEM_F(ICON_PIDNozzle, STR_HOTEND_PID " Settings", onDrawSubMenu, Draw_HotendPID_Menu);
#endif #endif
#if ENABLED(MPCTEMP) #if EITHER(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
MENU_ITEM_F(ICON_MPCNozzle, STR_MPC_AUTOTUNE " Settings", onDrawSubMenu, Draw_HotendMPC_Menu); MENU_ITEM_F(ICON_MPCNozzle, "MPC Settings", onDrawSubMenu, Draw_HotendMPC_Menu);
#endif #endif
#if ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPBED)
MENU_ITEM_F(ICON_PIDBed, STR_BED_PID " Settings", onDrawSubMenu, Draw_BedPID_Menu); MENU_ITEM_F(ICON_PIDBed, STR_BED_PID " Settings", onDrawSubMenu, Draw_BedPID_Menu);
@ -3524,37 +3537,45 @@ void Draw_Steps_Menu() {
#endif #endif
#if ENABLED(MPCTEMP) #if EITHER(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
void HotendMPC() { thermalManager.MPC_autotune(active_extruder); } #if ENABLED(MPC_AUTOTUNE_MENU)
void SetHeaterPower() { SetPFloatOnClick(1, 200, 1); } void HotendMPC() { thermalManager.MPC_autotune(active_extruder); }
void SetBlkHeatCapacity() { SetPFloatOnClick(0, 40, 2); } #endif
void SetSensorRespons() { SetPFloatOnClick(0, 1, 4); } #if ENABLED(MPC_EDIT_MENU)
void SetAmbientXfer() { SetPFloatOnClick(0, 1, 4); } void SetHeaterPower() { SetPFloatOnClick(1, 200, 1); }
#if ENABLED(MPC_INCLUDE_FAN) void SetBlkHeatCapacity() { SetPFloatOnClick(0, 40, 2); }
void onDrawFanAdj(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 4, thermalManager.temp_hotend[0].fanCoefficient()); } void SetSensorResponse() { SetPFloatOnClick(0, 1, 4); }
void ApplyFanAdj() { thermalManager.temp_hotend[0].applyFanAdjustment(MenuData.Value / POW(10, 4)); } void SetAmbientXfer() { SetPFloatOnClick(0, 1, 4); }
void SetFanAdj() { SetFloatOnClick(0, 1, 4, thermalManager.temp_hotend[0].fanCoefficient(), ApplyFanAdj); } #if ENABLED(MPC_INCLUDE_FAN)
void onDrawFanAdj(MenuItemClass* menuitem, int8_t line) { onDrawFloatMenu(menuitem, line, 4, thermalManager.temp_hotend[0].fanCoefficient()); }
void ApplyFanAdj() { thermalManager.temp_hotend[0].applyFanAdjustment(MenuData.Value / POW(10, 4)); }
void SetFanAdj() { SetFloatOnClick(0, 1, 4, thermalManager.temp_hotend[0].fanCoefficient(), ApplyFanAdj); }
#endif
#endif #endif
void Draw_HotendMPC_Menu() { void Draw_HotendMPC_Menu() {
checkkey = Menu; checkkey = Menu;
if (SET_MENU_F(HotendMPCMenu, STR_MPC_AUTOTUNE " Settings", 7)) { if (SET_MENU_F(HotendMPCMenu, "MPC Settings", 7)) {
MPC_t &mpc = thermalManager.temp_hotend[0].mpc; MPC_t &mpc = thermalManager.temp_hotend[0].mpc;
BACK_ITEM(Draw_AdvancedSettings_Menu); BACK_ITEM(Draw_AdvancedSettings_Menu);
MENU_ITEM(ICON_MPCNozzle, MSG_MPC_AUTOTUNE, onDrawMenuItem, HotendMPC); #if ENABLED(MPC_AUTOTUNE_MENU)
EDIT_ITEM(ICON_MPCHeater, MSG_MPC_POWER, onDrawPFloatMenu, SetHeaterPower, &mpc.heater_power); MENU_ITEM(ICON_MPCNozzle, MSG_MPC_AUTOTUNE, onDrawMenuItem, HotendMPC);
EDIT_ITEM(ICON_MPCHeatCap, MSG_MPC_BLOCK_HEAT_CAPACITY, onDrawPFloat2Menu, SetBlkHeatCapacity, &mpc.block_heat_capacity); #endif
EDIT_ITEM(ICON_MPCValue, MSG_SENSOR_RESPONSIVENESS, onDrawPFloat4Menu, SetSensorRespons, &mpc.sensor_responsiveness); #if ENABLED(MPC_EDIT_MENU)
EDIT_ITEM(ICON_MPCValue, MSG_MPC_AMBIENT_XFER_COEFF, onDrawPFloat4Menu, SetAmbientXfer, &mpc.ambient_xfer_coeff_fan0); EDIT_ITEM(ICON_MPCHeater, MSG_MPC_POWER, onDrawPFloatMenu, SetHeaterPower, &mpc.heater_power);
#if ENABLED(MPC_INCLUDE_FAN) EDIT_ITEM(ICON_MPCHeatCap, MSG_MPC_BLOCK_HEAT_CAPACITY, onDrawPFloat2Menu, SetBlkHeatCapacity, &mpc.block_heat_capacity);
EDIT_ITEM(ICON_MPCFan, MSG_MPC_AMBIENT_XFER_COEFF_FAN, onDrawFanAdj, SetFanAdj, &mpc.fan255_adjustment); EDIT_ITEM(ICON_MPCValue, MSG_SENSOR_RESPONSIVENESS, onDrawPFloat4Menu, SetSensorResponse, &mpc.sensor_responsiveness);
EDIT_ITEM(ICON_MPCValue, MSG_MPC_AMBIENT_XFER_COEFF, onDrawPFloat4Menu, SetAmbientXfer, &mpc.ambient_xfer_coeff_fan0);
#if ENABLED(MPC_INCLUDE_FAN)
EDIT_ITEM(ICON_MPCFan, MSG_MPC_AMBIENT_XFER_COEFF_FAN, onDrawFanAdj, SetFanAdj, &mpc.fan255_adjustment);
#endif
#endif #endif
} }
UpdateMenu(HotendMPCMenu); UpdateMenu(HotendMPCMenu);
} }
#endif // MPCTEMP #endif // MPC_EDIT_MENU || MPC_AUTOTUNE_MENU
#if ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPBED)

View file

@ -74,7 +74,7 @@ enum processID : uint8_t {
NothingToDo NothingToDo
}; };
#if EITHER(DWIN_PID_TUNE, MPCTEMP) #if EITHER(DWIN_PID_TUNE, MPC_AUTOTUNE)
enum tempcontrol_t : uint8_t { enum tempcontrol_t : uint8_t {
#if DWIN_PID_TUNE #if DWIN_PID_TUNE
@ -85,7 +85,7 @@ enum processID : uint8_t {
PID_TEMP_TOO_HIGH, PID_TEMP_TOO_HIGH,
PID_TUNING_TIMEOUT, PID_TUNING_TIMEOUT,
#endif #endif
#if ENABLED(MPCTEMP) #if ENABLED(MPC_AUTOTUNE)
MPC_DONE, MPC_DONE,
MPCTEMP_START, MPCTEMP_START,
MPC_TEMP_ERROR, MPC_TEMP_ERROR,
@ -384,7 +384,9 @@ void Draw_Steps_Menu();
#endif #endif
// MPC // MPC
#if ENABLED(MPCTEMP) #if EITHER(MPC_EDIT_MENU, MPC_AUTOTUNE_MENU)
void DWIN_MPCTuning(tempcontrol_t result);
void Draw_HotendMPC_Menu(); void Draw_HotendMPC_Menu();
#endif #endif
#if ENABLED(MPC_AUTOTUNE)
void DWIN_MPCTuning(tempcontrol_t result);
#endif

View file

@ -580,7 +580,6 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
volatile bool Temperature::raw_temps_ready = false; volatile bool Temperature::raw_temps_ready = false;
#if ENABLED(MPCTEMP) #if ENABLED(MPCTEMP)
int32_t Temperature::mpc_e_position; // = 0 int32_t Temperature::mpc_e_position; // = 0
#endif #endif
@ -925,7 +924,7 @@ volatile bool Temperature::raw_temps_ready = false;
#endif // HAS_PID_HEATING #endif // HAS_PID_HEATING
#if ENABLED(MPCTEMP) #if ENABLED(MPC_AUTOTUNE)
#if EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND) #if EITHER(MPC_FAN_0_ALL_HOTENDS, MPC_FAN_0_ACTIVE_HOTEND)
#define SINGLEFAN 1 #define SINGLEFAN 1
@ -951,7 +950,6 @@ volatile bool Temperature::raw_temps_ready = false;
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update()); TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
if (!wait_for_heatup) { if (!wait_for_heatup) {
SERIAL_ECHOPGM(STR_MPC_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED); SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_INTERRUPTED);
TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_INTERRUPTED)); TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_INTERRUPTED));
return true; return true;
@ -981,7 +979,6 @@ volatile bool Temperature::raw_temps_ready = false;
} }
} on_exit(e); } on_exit(e);
SERIAL_ECHOPGM(STR_MPC_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_START, e); SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_START, e);
MPCHeaterInfo &hotend = temp_hotend[e]; MPCHeaterInfo &hotend = temp_hotend[e];
MPC_t &mpc = hotend.mpc; MPC_t &mpc = hotend.mpc;
@ -1150,7 +1147,6 @@ volatile bool Temperature::raw_temps_ready = false;
mpc.block_heat_capacity = mpc.ambient_xfer_coeff_fan0 / block_responsiveness; mpc.block_heat_capacity = mpc.ambient_xfer_coeff_fan0 / block_responsiveness;
mpc.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp)); mpc.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp));
SERIAL_ECHOPGM(STR_MPC_AUTOTUNE);
SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_FINISHED); SERIAL_ECHOLNPGM(STR_MPC_AUTOTUNE_FINISHED);
TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_DONE)); TERN_(DWIN_LCD_PROUI, DWIN_MPCTuning(MPC_DONE));
@ -1171,7 +1167,7 @@ volatile bool Temperature::raw_temps_ready = false;
TERN_(HAS_FAN, SERIAL_ECHOLNPAIR_F("MPC_AMBIENT_XFER_COEFF_FAN255 ", ambient_xfer_coeff_fan255, 4)); TERN_(HAS_FAN, SERIAL_ECHOLNPAIR_F("MPC_AMBIENT_XFER_COEFF_FAN255 ", ambient_xfer_coeff_fan255, 4));
} }
#endif // MPCTEMP #endif // MPC_AUTOTUNE
int16_t Temperature::getHeaterPower(const heater_id_t heater_id) { int16_t Temperature::getHeaterPower(const heater_id_t heater_id) {
switch (heater_id) { switch (heater_id) {
@ -1509,7 +1505,7 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
const int32_t e_position = stepper.position(E_AXIS); const int32_t e_position = stepper.position(E_AXIS);
const float e_speed = (e_position - mpc_e_position) * planner.mm_per_step[E_AXIS] / MPC_dT; const float e_speed = (e_position - mpc_e_position) * planner.mm_per_step[E_AXIS] / MPC_dT;
// The position can appear to make big jumps when, e.g. homing // The position can appear to make big jumps when, e.g., homing
if (fabs(e_speed) > planner.settings.max_feedrate_mm_s[E_AXIS]) if (fabs(e_speed) > planner.settings.max_feedrate_mm_s[E_AXIS])
mpc_e_position = e_position; mpc_e_position = e_position;
else if (e_speed > 0.0f) { // Ignore retract/recover moves else if (e_speed > 0.0f) { // Ignore retract/recover moves

View file

@ -1194,7 +1194,7 @@ class Temperature {
#endif #endif
#if ENABLED(MPCTEMP) #if ENABLED(MPC_AUTOTUNE)
void MPC_autotune(const uint8_t e); void MPC_autotune(const uint8_t e);
#endif #endif

View file

@ -40,7 +40,7 @@ opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT -1 \
MPC_AMBIENT_XFER_COEFF '{ 0.068f, 0.068f, 0.068f }' \ MPC_AMBIENT_XFER_COEFF '{ 0.068f, 0.068f, 0.068f }' \
MPC_AMBIENT_XFER_COEFF_FAN255 '{ 0.097f, 0.097f, 0.097f }' \ MPC_AMBIENT_XFER_COEFF_FAN255 '{ 0.097f, 0.097f, 0.097f }' \
FILAMENT_HEAT_CAPACITY_PERMM '{ 5.6e-3f, 3.6e-3f, 5.6e-3f }' FILAMENT_HEAT_CAPACITY_PERMM '{ 5.6e-3f, 3.6e-3f, 5.6e-3f }'
opt_enable SWITCHING_TOOLHEAD TOOL_SENSOR MPCTEMP MPC_EDIT_MENU MPC_AUTOTUNE_MENU opt_enable SWITCHING_TOOLHEAD TOOL_SENSOR MPCTEMP MPC_EDIT_MENU MPC_AUTOTUNE MPC_AUTOTUNE_MENU
opt_disable PIDTEMP opt_disable PIDTEMP
exec_test $1 $2 "BigTreeTech GTR | MPC | Switching Toolhead | Tool Sensors" "$3" exec_test $1 $2 "BigTreeTech GTR | MPC | Switching Toolhead | Tool Sensors" "$3"

View file

@ -28,7 +28,7 @@ opt_set PREHEAT_3_LABEL '"CUSTOM"' PREHEAT_3_TEMP_HOTEND 240 PREHEAT_3_TEMP_BED
exec_test $1 $2 "Ender-3 S1 with ProUI (PIDTEMP)" "$3" exec_test $1 $2 "Ender-3 S1 with ProUI (PIDTEMP)" "$3"
opt_disable PIDTEMP opt_disable PIDTEMP
opt_enable MPCTEMP opt_enable MPCTEMP MPC_AUTOTUNE
exec_test $1 $2 "Ender-3 S1 with ProUI (MPCTEMP)" "$3" exec_test $1 $2 "Ender-3 S1 with ProUI (MPCTEMP)" "$3"
restore_configs restore_configs