Skip to content

Commit

Permalink
Add MMU error code: MCU_UNDERVOLTAGE_VCC (MarlinFirmware#4069)
Browse files Browse the repository at this point in the history
+ read bandgap voltage periodically
+ correct wording of ERR_ELECTRICAL_MCU_UNDERVOLTAGE_VCC (as requested in Prusa-Error-Codes PR#81)
  • Loading branch information
DRracer authored Mar 8, 2023
1 parent a20a723 commit e787111
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Firmware/mmu2/error_codes.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion Firmware/mmu2/errors_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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
Expand All @@ -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));
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions Firmware/mmu2_error_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Firmware/mmu2_protocol_logic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions Firmware/mmu2_protocol_logic.h
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,10 @@ class ProtocolLogic {
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;
Expand Down
2 changes: 1 addition & 1 deletion Firmware/mmu2_supported_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e787111

Please sign in to comment.