🚩 MPC update (#24253)

This commit is contained in:
tombrazier
2022-05-28 23:40:08 +01:00
committed by Scott Lahteine
parent 9799907dc9
commit fc1a620b87
6 changed files with 23 additions and 14 deletions

View File

@ -3266,6 +3266,7 @@ void MarlinSettings::reset() {
#if ENABLED(MPC_INCLUDE_FAN)
constexpr float _mpc_ambient_xfer_coeff_fan255[] = MPC_AMBIENT_XFER_COEFF_FAN255;
#endif
constexpr float _filament_heat_capacity_permm[] = FILAMENT_HEAT_CAPACITY_PERMM;
static_assert(COUNT(_mpc_heater_power) == HOTENDS, "MPC_HEATER_POWER must have HOTENDS items.");
static_assert(COUNT(_mpc_block_heat_capacity) == HOTENDS, "MPC_BLOCK_HEAT_CAPACITY must have HOTENDS items.");
@ -3274,6 +3275,7 @@ void MarlinSettings::reset() {
#if ENABLED(MPC_INCLUDE_FAN)
static_assert(COUNT(_mpc_ambient_xfer_coeff_fan255) == HOTENDS, "MPC_AMBIENT_XFER_COEFF_FAN255 must have HOTENDS items.");
#endif
static_assert(COUNT(_filament_heat_capacity_permm) == HOTENDS, "FILAMENT_HEAT_CAPACITY_PERMM must have HOTENDS items.");
HOTEND_LOOP() {
thermalManager.temp_hotend[e].constants.heater_power = _mpc_heater_power[e];
@ -3283,6 +3285,7 @@ void MarlinSettings::reset() {
#if ENABLED(MPC_INCLUDE_FAN)
thermalManager.temp_hotend[e].constants.fan255_adjustment = _mpc_ambient_xfer_coeff_fan255[e] - _mpc_ambient_xfer_coeff[e];
#endif
thermalManager.temp_hotend[e].constants.filament_heat_capacity_permm = _filament_heat_capacity_permm[e];
}
#endif

View File

@ -998,7 +998,7 @@ volatile bool Temperature::raw_temps_ready = false;
float asymp_temp = (t2 * t2 - t1 * t3) / (2 * t2 - t1 - t3),
block_responsiveness = -log((t2 - asymp_temp) / (t1 - asymp_temp)) / (sample_distance * (sample_count >> 1));
constants.ambient_xfer_coeff_fan0 = constants.heater_power * MPC_MAX / 255 / (asymp_temp - ambient_temp);
constants.ambient_xfer_coeff_fan0 = constants.heater_power * (MPC_MAX) / 255 / (asymp_temp - ambient_temp);
constants.fan255_adjustment = 0.0f;
constants.block_heat_capacity = constants.ambient_xfer_coeff_fan0 / block_responsiveness;
constants.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp));
@ -1062,7 +1062,7 @@ volatile bool Temperature::raw_temps_ready = false;
#endif
// Calculate a new and better asymptotic temperature and re-evaluate the other constants
asymp_temp = ambient_temp + constants.heater_power / constants.ambient_xfer_coeff_fan0;
asymp_temp = ambient_temp + constants.heater_power * (MPC_MAX) / 255 / constants.ambient_xfer_coeff_fan0;
block_responsiveness = -log((t2 - asymp_temp) / (t1 - asymp_temp)) / (sample_distance * (sample_count >> 1));
constants.block_heat_capacity = constants.ambient_xfer_coeff_fan0 / block_responsiveness;
constants.sensor_responsiveness = block_responsiveness / (1.0f - (ambient_temp - asymp_temp) * exp(-block_responsiveness * t1_time) / (t1 - asymp_temp));
@ -1446,7 +1446,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) {
if (fabs(e_speed) > planner.settings.max_feedrate_mm_s[E_AXIS])
mpc_e_position = e_position;
else if (e_speed > 0.0f) { // Ignore retract/recover moves
ambient_xfer_coeff += e_speed * FILAMENT_HEAT_CAPACITY_PERMM;
ambient_xfer_coeff += e_speed * constants.filament_heat_capacity_permm;
mpc_e_position = e_position;
}
}

View File

@ -96,13 +96,14 @@ hotend_pid_t;
#if ENABLED(MPCTEMP)
typedef struct {
float heater_power; // M306 P
float block_heat_capacity; // M306 C
float sensor_responsiveness; // M306 R
float ambient_xfer_coeff_fan0; // M306 A
float heater_power; // M306 P
float block_heat_capacity; // M306 C
float sensor_responsiveness; // M306 R
float ambient_xfer_coeff_fan0; // M306 A
#if ENABLED(MPC_INCLUDE_FAN)
float fan255_adjustment; // M306 F
float fan255_adjustment; // M306 F
#endif
float filament_heat_capacity_permm; // M306 M
} MPC_t;
#endif