🐛 Prevent MPC E-permm overrun in Load Filament (#25531)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
committed by
Scott Lahteine
parent
927915a4e6
commit
fbb1c82bc2
@@ -319,6 +319,11 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
|
||||
hotend_info_t Temperature::temp_hotend[HOTENDS];
|
||||
constexpr celsius_t Temperature::hotend_maxtemp[HOTENDS];
|
||||
|
||||
#if ENABLED(MPCTEMP)
|
||||
bool MPC::e_paused; // = false
|
||||
int32_t MPC::e_position; // = 0
|
||||
#endif
|
||||
|
||||
// Sanity-check max readable temperatures
|
||||
#define CHECK_MAXTEMP_(N,M,S) static_assert( \
|
||||
S >= 998 || M <= _MAX(TT_NAME(S)[0].celsius, TT_NAME(S)[COUNT(TT_NAME(S)) - 1].celsius) - HOTEND_OVERSHOOT, \
|
||||
@@ -588,10 +593,6 @@ PGMSTR(str_t_heating_failed, STR_T_HEATING_FAILED);
|
||||
|
||||
volatile bool Temperature::raw_temps_ready = false;
|
||||
|
||||
#if ENABLED(MPCTEMP)
|
||||
int32_t Temperature::mpc_e_position; // = 0
|
||||
#endif
|
||||
|
||||
#define TEMPDIR(N) ((TEMP_SENSOR_##N##_RAW_LO_TEMP) < (TEMP_SENSOR_##N##_RAW_HI_TEMP) ? 1 : -1)
|
||||
#define TP_CMP(S,A,B) (TEMPDIR(S) < 0 ? ((A)<(B)) : ((A)>(B)))
|
||||
|
||||
@@ -1511,14 +1512,14 @@ void Temperature::mintemp_error(const heater_id_t heater_id) {
|
||||
|
||||
if (this_hotend) {
|
||||
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
|
||||
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
|
||||
ambient_xfer_coeff += e_speed * mpc.filament_heat_capacity_permm;
|
||||
mpc_e_position = e_position;
|
||||
if (!MPC::e_paused) ambient_xfer_coeff += e_speed * mpc.filament_heat_capacity_permm;
|
||||
MPC::e_position = e_position;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user