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

fix filament load temp overrun #25531

Merged
merged 3 commits into from
Mar 18, 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
5 changes: 5 additions & 0 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down Expand Up @@ -580,10 +585,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)))

Expand Down Expand Up @@ -1503,14 +1504,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;
}
}

Expand Down
8 changes: 3 additions & 5 deletions Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down