From e787111922b361b7c2fc7411df936381d7e8a7f4 Mon Sep 17 00:00:00 2001 From: DRracer Date: Wed, 8 Mar 2023 15:42:25 +0100 Subject: [PATCH] Add MMU error code: MCU_UNDERVOLTAGE_VCC (#4069) + read bandgap voltage periodically + correct wording of ERR_ELECTRICAL_MCU_UNDERVOLTAGE_VCC (as requested in Prusa-Error-Codes PR#81) --- Firmware/mmu2/error_codes.h | 2 ++ Firmware/mmu2/errors_list.h | 10 +++++++++- Firmware/mmu2_error_converter.cpp | 3 +++ Firmware/mmu2_protocol_logic.cpp | 1 + Firmware/mmu2_protocol_logic.h | 4 ++-- Firmware/mmu2_supported_version.h | 2 +- 6 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Firmware/mmu2/error_codes.h b/Firmware/mmu2/error_codes.h index 130e3beeb..971f36bb8 100644 --- a/Firmware/mmu2/error_codes.h +++ b/Firmware/mmu2/error_codes.h @@ -56,6 +56,8 @@ enum class ErrorCode : uint_fast16_t { FILAMENT_EJECTED = 0x800c, ///< Filament was ejected, waiting for user input - technically, this is not an error + MCU_UNDERVOLTAGE_VCC = 0x800d, ///< MCU VCC rail undervoltage. + LOAD_TO_EXTRUDER_FAILED = 0x802a, ///< E32811 internal error of the printer - try-load-unload sequence detected missing filament -> failed load into the nozzle QUEUE_FULL = 0x802b, ///< E32811 internal logic error - attempt to move with a full queue VERSION_MISMATCH = 0x802c, ///< E32812 internal error of the printer - incompatible version of the MMU FW diff --git a/Firmware/mmu2/errors_list.h b/Firmware/mmu2/errors_list.h index 525bd78df..b51b89cba 100644 --- a/Firmware/mmu2/errors_list.h +++ b/Firmware/mmu2/errors_list.h @@ -62,6 +62,8 @@ typedef enum : uint16_t { ERR_ELECTRICAL_SELECTOR_SELFTEST_FAILED = 315, ERR_ELECTRICAL_IDLER_SELFTEST_FAILED = 325, + ERR_ELECTRICAL_MCU_UNDERVOLTAGE_VCC = 306, + ERR_CONNECT = 400, ERR_CONNECT_MMU_NOT_RESPONDING = 401, ERR_CONNECT_COMMUNICATION_ERROR = 402, @@ -117,6 +119,7 @@ static const constexpr uint16_t errorCodes[] PROGMEM = { ERR_ELECTRICAL_PULLEY_SELFTEST_FAILED, ERR_ELECTRICAL_SELECTOR_SELFTEST_FAILED, ERR_ELECTRICAL_IDLER_SELFTEST_FAILED, + ERR_ELECTRICAL_MCU_UNDERVOLTAGE_VCC, ERR_CONNECT_MMU_NOT_RESPONDING, ERR_CONNECT_COMMUNICATION_ERROR, ERR_SYSTEM_FILAMENT_ALREADY_LOADED, @@ -160,6 +163,7 @@ static const char MSG_TITLE_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("TMC DRI //static const char MSG_TITLE_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("TMC DRIVER SHORTED"); //static const char MSG_TITLE_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("TMC DRIVER SHORTED"); static const char MSG_TITLE_SELFTEST_FAILED[] PROGMEM_I1 = ISTR("MMU SELFTEST FAILED"); ////MSG_TITLE_SELFTEST_FAILED c=20 +static const char MSG_TITLE_MCU_UNDERVOLTAGE_VCC[] PROGMEM_I1 = ISTR("MCU UNDERVOLTAGE VCC"); ////MSG_TITLE_MCU_UNDERVOLTAGE_VCC c=20 static const char MSG_TITLE_MMU_NOT_RESPONDING[] PROGMEM_I1 = ISTR("MMU NOT RESPONDING"); ////MSG_TITLE_MMU_NOT_RESPONDING c=20 static const char MSG_TITLE_COMMUNICATION_ERROR[] PROGMEM_I1 = ISTR("COMMUNICATION ERROR"); ////MSG_TITLE_COMMUNICATION_ERROR c=20 static const char MSG_TITLE_FIL_ALREADY_LOADED[] PROGMEM_I1 = ISTR("FILAMENT ALREADY LOA"); ////MSG_TITLE_FIL_ALREADY_LOADED c=20 @@ -204,6 +208,7 @@ static const char * const errorTitles [] PROGMEM = { _R(MSG_TITLE_SELFTEST_FAILED), _R(MSG_TITLE_SELFTEST_FAILED), _R(MSG_TITLE_SELFTEST_FAILED), + _R(MSG_TITLE_MCU_UNDERVOLTAGE_VCC), _R(MSG_TITLE_MMU_NOT_RESPONDING), _R(MSG_TITLE_COMMUNICATION_ERROR), _R(MSG_TITLE_FIL_ALREADY_LOADED), @@ -249,6 +254,7 @@ static const char MSG_DESC_TMC[] PROGMEM_I1 = ISTR("More details online."); //// //static const char MSG_DESC_PULLEY_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("Short circuit on the Pulley TMC driver. Check the wiring and connectors. If the issue persists contact support."); //static const char MSG_DESC_SELECTOR_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("Short circuit on the Selector TMC driver. Check the wiring and connectors. If the issue persists contact support."); //static const char MSG_DESC_IDLER_TMC_DRIVER_SHORTED[] PROGMEM_I1 = ISTR("Short circuit on the Idler TMC driver. Check the wiring and connectors. If the issue persists contact support."); +//static const char MSG_DESC_MCU_UNDERVOLTAGE_VCC[] PROGMEM_I1 = ISTR("MMU MCU detected a 5V undervoltage. There might be an issue with the electronics. Check the wiring and connectors"); ////MSG_DESC_MCU_UNDERVOLTAGE_VCC c=20 r=8 static const char MSG_DESC_MMU_NOT_RESPONDING[] PROGMEM_I1 = ISTR("MMU unit not responding. Check the wiring and connectors. If the issue persists, contact support."); ////MSG_DESC_MMU_NOT_RESPONDING c=20 r=8 static const char MSG_DESC_COMMUNICATION_ERROR[] PROGMEM_I1 = ISTR("MMU unit not responding correctly. Check the wiring and connectors. If the issue persists, contact support."); ////MSG_DESC_COMMUNICATION_ERROR c=20 r=9 static const char MSG_DESC_FILAMENT_ALREADY_LOADED[] PROGMEM_I1 = ISTR("Cannot perform the action, filament is already loaded. Unload it first."); ////MSG_DESC_FILAMENT_ALREADY_LOADED c=20 r=8 @@ -259,7 +265,7 @@ static const char MSG_DESC_UNLOAD_MANUALLY[] PROGMEM_I1 = ISTR("Filament detecte static const char MSG_DESC_FILAMENT_EJECTED[] PROGMEM_I1 = ISTR("Remove the ejected filament from the front of the MMU unit."); ////MSG_DESC_FILAMENT_EJECTED c=20 r=8 // Read explanation in mmu2_protocol_logic.cpp -> supportedMmuFWVersion -static constexpr char MSG_DESC_FW_UPDATE_NEEDED[] PROGMEM_I1 = ISTR("The MMU unit firmware version incompatible with the printer's FW. Update to version 2.1.8."); ////MSG_DESC_FW_UPDATE_NEEDED c=20 r=9 +static constexpr char MSG_DESC_FW_UPDATE_NEEDED[] PROGMEM_I1 = ISTR("The MMU unit firmware version incompatible with the printer's FW. Update to version 2.1.9."); ////MSG_DESC_FW_UPDATE_NEEDED c=20 r=9 static constexpr uint8_t szFWUN = sizeof(MSG_DESC_FW_UPDATE_NEEDED); // at least check the individual version characters in MSG_DESC_FW_UPDATE_NEEDED static_assert(MSG_DESC_FW_UPDATE_NEEDED[szFWUN - 7] == ('0' + mmuVersionMajor)); @@ -300,6 +306,7 @@ static const char * const errorDescs[] PROGMEM = { _R(MSG_DESC_TMC), // descPULLEY_SELFTEST_FAILED _R(MSG_DESC_TMC), // descSELECTOR_SELFTEST_FAILED _R(MSG_DESC_TMC), // descIDLER_SELFTEST_FAILED + _R(MSG_DESC_TMC), // descMSG_DESC_MCU_UNDERVOLTAGE_VCC _R(MSG_DESC_MMU_NOT_RESPONDING), _R(MSG_DESC_COMMUNICATION_ERROR), _R(MSG_DESC_FILAMENT_ALREADY_LOADED), @@ -381,6 +388,7 @@ static const uint8_t errorButtons[] PROGMEM = { Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//PULLEY_SELFTEST_FAILED Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//SELECTOR_SELFTEST_FAILED Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//IDLER_SELFTEST_FAILED + Btns(ButtonOperations::RestartMMU, ButtonOperations::NoOperation),//MCU_UNDERVOLTAGE_VCC Btns(ButtonOperations::RestartMMU, ButtonOperations::DisableMMU),//MMU_NOT_RESPONDING Btns(ButtonOperations::RestartMMU, ButtonOperations::DisableMMU),//COMMUNICATION_ERROR diff --git a/Firmware/mmu2_error_converter.cpp b/Firmware/mmu2_error_converter.cpp index 3bf4ed649..15c66bb83 100644 --- a/Firmware/mmu2_error_converter.cpp +++ b/Firmware/mmu2_error_converter.cpp @@ -84,6 +84,8 @@ uint8_t PrusaErrorCodeIndex(uint16_t ec) { return FindErrorIndex(ERR_SYSTEM_FW_RUNTIME_ERROR); case (uint16_t)ErrorCode::FINDA_VS_EEPROM_DISREPANCY: return FindErrorIndex(ERR_SYSTEM_UNLOAD_MANUALLY); + case (uint16_t)ErrorCode::MCU_UNDERVOLTAGE_VCC: + return FindErrorIndex(ERR_ELECTRICAL_MCU_UNDERVOLTAGE_VCC); } // Electrical issues which can be detected somehow. @@ -265,6 +267,7 @@ Buttons ButtonAvailable(uint16_t ec) { case ERR_SYSTEM_QUEUE_FULL: case ERR_SYSTEM_FW_RUNTIME_ERROR: + case ERR_ELECTRICAL_MCU_UNDERVOLTAGE_VCC: switch (buttonSelectedOperation) { case ButtonOperations::RestartMMU: // "Restart MMU" return RestartMMU; diff --git a/Firmware/mmu2_protocol_logic.cpp b/Firmware/mmu2_protocol_logic.cpp index 9c91776a0..58f34a31d 100644 --- a/Firmware/mmu2_protocol_logic.cpp +++ b/Firmware/mmu2_protocol_logic.cpp @@ -35,6 +35,7 @@ const uint8_t ProtocolLogic::regs8Addrs[ProtocolLogic::regs8Count] PROGMEM = { const uint8_t ProtocolLogic::regs16Addrs[ProtocolLogic::regs16Count] PROGMEM = { 4, // MMU errors - aka statistics 0x1a, // Pulley position [mm] + 0x21, // MCU bandgap voltage }; const uint8_t ProtocolLogic::initRegs8Addrs[ProtocolLogic::initRegs8Count] PROGMEM = { diff --git a/Firmware/mmu2_protocol_logic.h b/Firmware/mmu2_protocol_logic.h index 53ec0002a..b7128806b 100644 --- a/Firmware/mmu2_protocol_logic.h +++ b/Firmware/mmu2_protocol_logic.h @@ -365,10 +365,10 @@ private: uint8_t regs8[regs8Count] = { 0, 0, 0 }; // 16bit registers - static constexpr uint8_t regs16Count = 2; + static constexpr uint8_t regs16Count = 3; static_assert(regs16Count > 0); // code is not ready for empty lists of registers static const uint8_t regs16Addrs[regs16Count] PROGMEM; - uint16_t regs16[regs16Count] = { 0, 0 }; + uint16_t regs16[regs16Count] = { 0, 0, 0 }; // 8bit init values to be sent to the MMU after line up static constexpr uint8_t initRegs8Count = 2; diff --git a/Firmware/mmu2_supported_version.h b/Firmware/mmu2_supported_version.h index 0cd2c9f53..26683174b 100644 --- a/Firmware/mmu2_supported_version.h +++ b/Firmware/mmu2_supported_version.h @@ -5,6 +5,6 @@ namespace MMU2 { static constexpr uint8_t mmuVersionMajor = 2; static constexpr uint8_t mmuVersionMinor = 1; -static constexpr uint8_t mmuVersionPatch = 8; +static constexpr uint8_t mmuVersionPatch = 9; } // namespace MMU2