error_codes.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /// @file error_codes.h
  2. #pragma once
  3. #include <stdint.h>
  4. /// A complete set of error codes which may be a result of a high-level command/operation.
  5. /// This header file shall be included in the printer's firmware as well as a reference,
  6. /// therefore the error codes have been extracted to one place.
  7. ///
  8. /// Please note the errors are intentionally coded as "negative" values (highest bit set),
  9. /// becase they are a complement to reporting the state of the high-level state machines -
  10. /// positive values are considered as normal progress, negative values are errors.
  11. ///
  12. /// Please note, that multiple TMC errors can occur at once, thus they are defined as a bitmask of the higher byte.
  13. /// Also, as there are 3 TMC drivers on the board, each error is added a bit for the corresponding TMC -
  14. /// TMC_PULLEY_BIT, TMC_SELECTOR_BIT, TMC_IDLER_BIT,
  15. /// The resulting error is a bitwise OR over 3 TMC drivers and their status, which should cover most of the situations correctly.
  16. enum class ErrorCode : uint_fast16_t {
  17. RUNNING = 0x0000, ///< the operation is still running - keep this value as ZERO as it is used for initialization of error codes as well
  18. OK = 0x0001, ///< the operation finished OK
  19. // TMC bit masks
  20. TMC_PULLEY_BIT = 0x0040, ///< +64 TMC Pulley bit
  21. TMC_SELECTOR_BIT = 0x0080, ///< +128 TMC Pulley bit
  22. TMC_IDLER_BIT = 0x0100, ///< +256 TMC Pulley bit
  23. /// Unload Filament related error codes
  24. FINDA_DIDNT_SWITCH_ON = 0x8001, ///< E32769 FINDA didn't switch on while loading filament - either there is something blocking the metal ball or a cable is broken/disconnected
  25. FINDA_DIDNT_SWITCH_OFF = 0x8002, ///< E32770 FINDA didn't switch off while unloading filament
  26. FSENSOR_DIDNT_SWITCH_ON = 0x8003, ///< E32771 Filament sensor didn't switch on while performing LoadFilament
  27. FSENSOR_DIDNT_SWITCH_OFF = 0x8004, ///< E32772 Filament sensor didn't switch off while performing UnloadFilament
  28. FILAMENT_ALREADY_LOADED = 0x8005, ///< E32773 cannot perform operation LoadFilament or move the selector as the filament is already loaded
  29. INVALID_TOOL = 0x8006, ///< E32774 tool/slot index out of range (typically issuing T5 into an MMU with just 5 slots - valid range 0-4)
  30. HOMING_FAILED = 0x8007, ///< generic homing failed error - always reported with the corresponding axis bit set (Idler or Selector) as follows:
  31. HOMING_SELECTOR_FAILED = HOMING_FAILED | TMC_SELECTOR_BIT, ///< E32903 the Selector was unable to home properly - that means something is blocking its movement
  32. HOMING_IDLER_FAILED = HOMING_FAILED | TMC_IDLER_BIT, ///< E33031 the Idler was unable to home properly - that means something is blocking its movement
  33. STALLED_PULLEY = HOMING_FAILED | TMC_PULLEY_BIT, ///< E32839 for the Pulley "homing" means just StallGuard detected during Pulley's operation (Pulley doesn't home)
  34. FINDA_VS_EEPROM_DISREPANCY = 0x8008, ///< E32776 FINDA is pressed but we have no such record in EEPROM - this can only happen at the start of the MMU and can be resolved by issuing an Unload command
  35. FSENSOR_TOO_EARLY = 0x8009, ///< E32777 FSensor triggered while doing FastFeedToBondtech - that means either:
  36. ///< - the PTFE is too short
  37. ///< - a piece of filament was left inside - pushed in front of the loaded filament causing the fsensor trigger too early
  38. ///< - fsensor is faulty producing bogus triggers
  39. FINDA_FLICKERS = 0x800a, ///< FINDA flickers - seems to be badly calibrated and happens to be pressed at spots where it used to be not pressed before.
  40. ///< The user is obliged to inspect FINDA and tune its switching
  41. MOVE_FAILED = 0x800b, ///< generic move failed error - always reported with the corresponding axis bit set (Idler or Selector) as follows:
  42. MOVE_SELECTOR_FAILED = MOVE_FAILED | TMC_SELECTOR_BIT, ///< E32905 the Selector was unable to move to desired position properly - that means something is blocking its movement, e.g. a piece of filament got out of pulley body
  43. MOVE_IDLER_FAILED = MOVE_FAILED | TMC_IDLER_BIT, ///< E33033 the Idler was unable to move - unused at the time of creation, but added for completeness
  44. MOVE_PULLEY_FAILED = MOVE_FAILED | TMC_PULLEY_BIT, ///< E32841 the Pulley was unable to move - unused at the time of creation, but added for completeness
  45. QUEUE_FULL = 0x802b, ///< E32811 internal logic error - attempt to move with a full queue
  46. TRY_LOAD_UNLOAD_FAILED = 0x802b, ///< E32811 internal error of the printer - try-load-unload sequence detected missing filament -> failed load into the nozzle
  47. VERSION_MISMATCH = 0x802c, ///< E32812 internal error of the printer - incompatible version of the MMU FW
  48. PROTOCOL_ERROR = 0x802d, ///< E32813 internal error of the printer - communication with the MMU got garbled - protocol decoder couldn't decode the incoming messages
  49. MMU_NOT_RESPONDING = 0x802e, ///< E32814 internal error of the printer - communication with the MMU is not working
  50. INTERNAL = 0x802f, ///< E32815 internal runtime error (software)
  51. /// TMC driver init error - TMC dead or bad communication
  52. /// - E33344 Pulley TMC driver
  53. /// - E33408 Selector TMC driver
  54. /// - E33536 Idler TMC driver
  55. /// - E33728 All 3 TMC driver
  56. TMC_IOIN_MISMATCH = 0x8200,
  57. /// TMC driver reset - recoverable, we just need to rehome the axis
  58. /// Idler: can be rehomed any time
  59. /// Selector: if there is a filament, remove it and rehome, if there is no filament, just rehome
  60. /// Pulley: do nothing - for the loading sequence - just restart and move slowly, for the unload sequence just restart
  61. /// - E33856 Pulley TMC driver
  62. /// - E33920 Selector TMC driver
  63. /// - E34048 Idler TMC driver
  64. /// - E34240 All 3 TMC driver
  65. TMC_RESET = 0x8400,
  66. /// not enough current for the TMC, NOT RECOVERABLE
  67. /// - E34880 Pulley TMC driver
  68. /// - E34944 Selector TMC driver
  69. /// - E35072 Idler TMC driver
  70. /// - E35264 All 3 TMC driver
  71. TMC_UNDERVOLTAGE_ON_CHARGE_PUMP = 0x8800,
  72. /// TMC driver serious error - short to ground on coil A or coil B - dangerous to recover
  73. /// - E36928 Pulley TMC driver
  74. /// - E36992 Selector TMC driver
  75. /// - E37120 Idler TMC driver
  76. /// - E37312 All 3 TMC driver
  77. TMC_SHORT_TO_GROUND = 0x9000,
  78. /// TMC driver over temperature warning - can be recovered by restarting the driver.
  79. /// If this error happens, we should probably go into the error state as soon as the current command is finished.
  80. /// The driver technically still works at this point.
  81. /// - E41024 Pulley TMC driver
  82. /// - E41088 Selector TMC driver
  83. /// - E41216 Idler TMC driver
  84. /// - E41408 All 3 TMC driver
  85. TMC_OVER_TEMPERATURE_WARN = 0xA000,
  86. /// TMC driver over temperature error - we really shouldn't ever reach this error.
  87. /// It can still be recovered if the driver cools down below 120C.
  88. /// The driver needs to be disabled and enabled again for operation to resume after this error is cleared.
  89. /// - E49216 Pulley TMC driver
  90. /// - E49280 Selector TMC driver
  91. /// - E49408 Idler TMC driver
  92. /// - E49600 All 3 TMC driver
  93. TMC_OVER_TEMPERATURE_ERROR = 0xC000,
  94. /// TMC driver - IO pins are unreliable. While in theory it's recoverable, in practice it most likely
  95. /// means your hardware is borked (we can't command the drivers reliably via STEP/EN/DIR due to electrical
  96. /// issues or hardware fault. Possible "fixable" cause is undervoltage on the 5v logic line.
  97. /// Unfixable possible cause: bad or cracked solder joints on the PCB, failed shift register, failed driver.
  98. MMU_SOLDERING_NEEDS_ATTENTION = 0xC200,
  99. };