mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-02-26 02:49:51 +00:00
🐛 Prevent MPC E-permm overrun in Load Filament (#25531)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
parent
927915a4e6
commit
fbb1c82bc2
3 changed files with 17 additions and 13 deletions
|
@ -234,6 +234,8 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
|
|||
|
||||
TERN_(BELTPRINTER, do_blocking_move_to_xy(0.00, 50.00));
|
||||
|
||||
TERN_(MPCTEMP, MPC::e_paused = true);
|
||||
|
||||
// Slow Load filament
|
||||
if (slow_load_length) unscaled_e_move(slow_load_length, FILAMENT_CHANGE_SLOW_LOAD_FEEDRATE);
|
||||
|
||||
|
@ -297,6 +299,9 @@ bool load_filament(const_float_t slow_load_length/*=0*/, const_float_t fast_load
|
|||
} while (TERN0(M600_PURGE_MORE_RESUMABLE, pause_menu_response == PAUSE_RESPONSE_EXTRUDE_MORE));
|
||||
|
||||
#endif
|
||||
|
||||
TERN_(MPCTEMP, MPC::e_paused = false);
|
||||
|
||||
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_end());
|
||||
|
||||
return true;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -377,7 +377,9 @@ typedef struct { float p, i, d, c, f; } raw_pidcf_t;
|
|||
|
||||
#elif ENABLED(MPCTEMP)
|
||||
|
||||
typedef struct {
|
||||
typedef struct MPC {
|
||||
static bool e_paused; // Pause E filament permm tracking
|
||||
static int32_t e_position; // For E tracking
|
||||
float heater_power; // M306 P
|
||||
float block_heat_capacity; // M306 C
|
||||
float sensor_responsiveness; // M306 R
|
||||
|
@ -716,10 +718,6 @@ class Temperature {
|
|||
static hotend_watch_t watch_hotend[HOTENDS];
|
||||
#endif
|
||||
|
||||
#if ENABLED(MPCTEMP)
|
||||
static int32_t mpc_e_position;
|
||||
#endif
|
||||
|
||||
#if HAS_HOTEND
|
||||
static temp_range_t temp_range[HOTENDS];
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue