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

Fan tacho check #23086

Merged
merged 13 commits into from
Nov 23, 2021
1 change: 1 addition & 0 deletions Marlin/src/core/language.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
#define STR_RESEND "Resend: "
#define STR_UNKNOWN_COMMAND "Unknown command: \""
#define STR_ACTIVE_EXTRUDER "Active Extruder: "
#define STR_ERR_FANSPEED "Fan speed error Extruder: "

#define STR_PROBE_OFFSET "Probe Offset"
#define STR_SKEW_MIN "min_skew_factor: "
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/language/language_en.h
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ namespace Language_en {
LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Runaway Watch: OFF");
LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Runaway Watch: ON");
LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Hotend Idle Timeout");
LSTR MSG_FAN_SPEED_FAULT = _UxGT("Fan speed fault");

LSTR MSG_CASE_LIGHT = _UxGT("Case Light");
LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Light Brightness");
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/language/language_it.h
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,7 @@ namespace Language_it {
LSTR MSG_INFO_RUNAWAY_OFF = _UxGT("Controllo fuga: OFF");
LSTR MSG_INFO_RUNAWAY_ON = _UxGT("Controllo fuga: ON");
LSTR MSG_HOTEND_IDLE_TIMEOUT = _UxGT("Timeout inatt.ugello");
LSTR MSG_FAN_SPEED_FAULT = _UxGT("Err.vel.della ventola");

LSTR MSG_CASE_LIGHT = _UxGT("Luci Case");
LSTR MSG_CASE_LIGHT_BRIGHTNESS = _UxGT("Luminosità Luci");
Expand Down
34 changes: 21 additions & 13 deletions Marlin/src/module/fancheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void FanCheck::update_tachometers() {

void FanCheck::compute_speed(int elapsedTime) {
static uint8_t errors_count[TACHO_COUNT];
static uint8_t fan_reported_errors_msk = 0;

uint8_t fan_error_msk = 0;
LOOP_L_N(f, TACHO_COUNT) {
Expand Down Expand Up @@ -144,31 +145,38 @@ void FanCheck::compute_speed(int elapsedTime) {
// Drop the error when all fans are ok
if (!fan_error_msk && error == TachoError::REPORTED) error = TachoError::FIXED;

if (error == TachoError::FIXED && !printJobOngoing()) {
if (error == TachoError::FIXED && !printJobOngoing() && !printingIsPaused()) {
error = TachoError::NONE; // if the issue has been fixed while the printer is idle, reenable immediately
ui.reset_alert_level();
}

LOOP_L_N(f, TACHO_COUNT) if (TEST(fan_error_msk, f) && report_speed_error(f)) errors_count[f] = 0;
if (!enabled) return;

if (fan_error_msk & ~fan_reported_errors_msk) {
// Handle new faults only
LOOP_L_N(f, TACHO_COUNT) if (TEST(fan_error_msk, f)) report_speed_error(f);
}
fan_reported_errors_msk = fan_error_msk;
}

bool FanCheck::report_speed_error(uint8_t fan) {
void FanCheck::report_speed_error(uint8_t fan) {
if (printJobOngoing()) {
if (error != TachoError::NONE) return false; // Keep error pending (another fan fault message is already signaled)
if (thermalManager.degTargetHotend(fan) != 0) {
TERN_(HAS_DISPLAY, ui.abort_print());
if (error == TachoError::NONE) {
if (thermalManager.degTargetHotend(fan) != 0) {
TERN(HAS_DISPLAY, ui.abort_print(), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)));
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
error = TachoError::REPORTED;
}
else
error = TachoError::DETECTED; // Plans error for next processed command
}
else
error = TachoError::DETECTED; // Plans error for next processed command
}
else {
else if (!printingIsPaused()) {
thermalManager.setTargetHotend(0, fan); // Always disable heating
if (error != TachoError::NONE) return false; // Keep error pending (another fan fault message is already signaled)
error = TachoError::REPORTED;
if (error == TachoError::NONE) error = TachoError::REPORTED;
}
// TODO display error and send it also to serial...maybe some beep?

return true;
SERIAL_ERROR_MSG(STR_ERR_FANSPEED, fan);
LCD_ALERTMESSAGE(MSG_FAN_SPEED_FAULT);
}

void FanCheck::print_fan_states() {
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/fancheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class FanCheck {
static uint8_t rps[TACHO_COUNT];
static TachoError error;

static inline bool report_speed_error(uint8_t fan);
static inline void report_speed_error(uint8_t fan);

public:

Expand All @@ -67,7 +67,7 @@ class FanCheck {
static inline void check_deferred_error() {
if (error == TachoError::DETECTED) {
error = TachoError::REPORTED;
TERN_(HAS_DISPLAY, ui.pause_print());
TERN(HAS_DISPLAY, ui.pause_print(), kill(GET_TEXT_F(MSG_FAN_SPEED_FAULT)));
}
};

Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -661,8 +661,8 @@ volatile bool Temperature::raw_temps_ready = false;
#if HAS_AUTO_FAN || HAS_FANCHECK
if (ELAPSED(ms, autofan_update_ms)) {
const millis_t next_ms = ms + autofan_update_interval_ms;
TERN_(HAS_FANCHECK, fan_check.compute_speed(next_ms - autofan_update_ms));
TERN_(HAS_AUTO_FAN, update_autofans());
TERN_(HAS_FANCHECK, fan_check.compute_speed(next_ms - autofan_update_ms));
autofan_update_ms = next_ms;
}
#endif
Expand Down Expand Up @@ -1372,8 +1372,8 @@ void Temperature::manage_heater() {
#if HAS_AUTO_FAN || HAS_FANCHECK
if (ELAPSED(ms, autofan_update_ms)) { // only need to check fan state very infrequently
const millis_t next_ms = ms + autofan_update_interval_ms;
TERN_(HAS_FANCHECK, fan_check.compute_speed(next_ms - autofan_update_ms));
TERN_(HAS_AUTO_FAN, update_autofans());
TERN_(HAS_FANCHECK, fan_check.compute_speed(next_ms - autofan_update_ms));
autofan_update_ms = next_ms;
}
#endif
Expand Down