Skip to content

Commit

Permalink
SMUFF (MMU2 clone) support (MarlinFirmware#19912)
Browse files Browse the repository at this point in the history
  • Loading branch information
GMagician authored and W4tel-BiDi committed Apr 5, 2021
1 parent bb32b58 commit 346daa2
Show file tree
Hide file tree
Showing 29 changed files with 602 additions and 596 deletions.
34 changes: 10 additions & 24 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,33 +158,19 @@
#endif

/**
* Průša MK2 Single Nozzle Multi-Material Multiplexer, and variants.
*
* This device allows one stepper driver on a control board to drive
* two to eight stepper motors, one at a time, in a manner suitable
* for extruders.
*
* This option only allows the multiplexer to switch on tool-change.
* Additional options to configure custom E moves are pending.
*/
//#define MK2_MULTIPLEXER
#if ENABLED(MK2_MULTIPLEXER)
// Override the default DIO selector pins here, if needed.
// Some pins files may provide defaults for these pins.
//#define E_MUX0_PIN 40 // Always Required
//#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs
//#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs
#endif

/**
* Průša Multi-Material Unit v2
* Multi-Material Unit
* Set to one of these predefined models:
*
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* Requires EXTRUDERS = 5
* PRUSA_MMU1 : Průša MMU1 (The "multiplexer" version)
* PRUSA_MMU2 : Průša MMU2
* PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5)
* SMUFF_EMU_MMU2 : Technik Gegg SMUFF (Průša MMU2 emulation mode)
* SMUFF_EMU_MMU2S : Technik Gegg SMUFF (Průša MMU2S emulation mode)
*
* For additional configuration see Configuration_adv.h
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
* See additional options in Configuration_adv.h.
*/
//#define PRUSA_MMU2
//#define MMU_MODEL PRUSA_MMU2

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
Expand Down
60 changes: 37 additions & 23 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3532,11 +3532,24 @@
#endif

/**
* Průša Multi-Material Unit v2
* Průša Multi-Material Unit (MMU)
* Enable in Configuration.h
*
* These devices allow a single stepper driver on the board to drive
* multi-material feeders with any number of stepper motors.
*/
#if ENABLED(PRUSA_MMU2)

#if HAS_PRUSA_MMU1
/**
* This option only allows the multiplexer to switch on tool-change.
* Additional options to configure custom E moves are pending.
*
* Override the default DIO selector pins here, if needed.
* Some pins files may provide defaults for these pins.
*/
//#define E_MUX0_PIN 40 // Always Required
//#define E_MUX1_PIN 42 // Needed for 3 to 8 inputs
//#define E_MUX2_PIN 44 // Needed for 5 to 8 inputs
#elif HAS_PRUSA_MMU2
// Serial port used for communication with MMU2.
// For AVR enable the UART port used for the MMU. (e.g., mmuSerial)
// For 32-bit boards check your HAL for available serial ports. (e.g., Serial2)
Expand All @@ -3554,7 +3567,7 @@

// Add an LCD menu for MMU2
//#define MMU2_MENUS
#if ENABLED(MMU2_MENUS)
#if EITHER(MMU2_MENUS, HAS_PRUSA_MMU2S)
// Settings for filament load / unload from the LCD menu.
// This is for Průša MK3-style extruders. Customize for your hardware.
#define MMU2_FILAMENTCHANGE_EJECT_FEED 80.0
Expand All @@ -3579,29 +3592,12 @@
{ -50.0, 2000 }
#endif

/**
* MMU Extruder Sensor
*
* Support for a Průša (or other) IR Sensor to detect filament near the extruder
* and make loading more reliable. Suitable for an extruder equipped with a filament
* sensor less than 38mm from the gears.
*
* During loading the extruder will stop when the sensor is triggered, then do a last
* move up to the gears. If no filament is detected, the MMU2 can make some more attempts.
* If all attempts fail, a filament runout will be triggered.
*/
//#define MMU_EXTRUDER_SENSOR
#if ENABLED(MMU_EXTRUDER_SENSOR)
#define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail
#endif

/**
* Using a sensor like the MMU2S
* This mode requires a MK3S extruder with a sensor at the extruder idler, like the MMU2S.
* See https://help.prusa3d.com/en/guide/3b-mk3s-mk2-5s-extruder-upgrade_41560, step 11
*/
//#define PRUSA_MMU2_S_MODE
#if ENABLED(PRUSA_MMU2_S_MODE)
#if HAS_PRUSA_MMU2S
#define MMU2_C0_RETRY 5 // Number of retries (total time = timeout*retries)

#define MMU2_CAN_LOAD_FEEDRATE 800 // (mm/min)
Expand All @@ -3617,11 +3613,29 @@
#define MMU2_CAN_LOAD_INCREMENT_SEQUENCE \
{ -MMU2_CAN_LOAD_INCREMENT, MMU2_CAN_LOAD_FEEDRATE }

#else

/**
* MMU1 Extruder Sensor
*
* Support for a Průša (or other) IR Sensor to detect filament near the extruder
* and make loading more reliable. Suitable for an extruder equipped with a filament
* sensor less than 38mm from the gears.
*
* During loading the extruder will stop when the sensor is triggered, then do a last
* move up to the gears. If no filament is detected, the MMU2 can make some more attempts.
* If all attempts fail, a filament runout will be triggered.
*/
//#define MMU_EXTRUDER_SENSOR
#if ENABLED(MMU_EXTRUDER_SENSOR)
#define MMU_LOADING_ATTEMPTS_NR 5 // max. number of attempts to load filament if first load fail
#endif

#endif

//#define MMU2_DEBUG // Write debug info to serial output

#endif // PRUSA_MMU2
#endif // HAS_PRUSA_MMU2

/**
* Advanced Print Counter settings
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/HAL/LPC1768/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
#define IS_RX0(P) (P == P0_03)
#if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
#error "Serial port pins (0) conflict with Trinamic SPI pins!"
#elif ENABLED(MK2_MULTIPLEXER) && (IS_TX0(E_MUX1_PIN) || IS_RX0(E_MUX0_PIN))
#error "Serial port pins (0) conflict with MK2 multiplexer pins!"
#elif HAS_PRUSA_MMU1 && (IS_TX0(E_MUX1_PIN) || IS_RX0(E_MUX0_PIN))
#error "Serial port pins (0) conflict with Multi-Material-Unit multiplexer pins!"
#elif (AXIS_HAS_SPI(X) && IS_TX0(X_CS_PIN)) || (AXIS_HAS_SPI(Y) && IS_RX0(Y_CS_PIN))
#error "Serial port pins (0) conflict with X/Y axis SPI pins!"
#endif
Expand Down
21 changes: 9 additions & 12 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@
#include "feature/controllerfan.h"
#endif

#if ENABLED(PRUSA_MMU2)
#include "feature/mmu2/mmu2.h"
#if HAS_PRUSA_MMU2
#include "feature/mmu/mmu2.h"
#endif

#if HAS_L64XX
Expand Down Expand Up @@ -713,9 +713,7 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
TERN_(HAS_FILAMENT_SENSOR, runout.run());

// Run HAL idle tasks
#ifdef HAL_IDLETASK
HAL_idletask();
#endif
TERN_(HAL_IDLETASK, HAL_idletask());

// Check network connection
TERN_(HAS_ETHERNET, ethernet.check());
Expand Down Expand Up @@ -772,17 +770,16 @@ void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
#endif

// Update the Průša MMU2
TERN_(PRUSA_MMU2, mmu2.mmu_loop());
TERN_(HAS_PRUSA_MMU2, mmu2.mmu_loop());

// Handle Joystick jogging
TERN_(POLL_JOG, joystick.inject_jog_moves());

// Direct Stepping
TERN_(DIRECT_STEPPING, page_manager.write_responses());

#if HAS_TFT_LVGL_UI
LV_TASK_HANDLER();
#endif
// Update the LVGL interface
TERN_(HAS_TFT_LVGL_UI, LV_TASK_HANDLER());
}

/**
Expand Down Expand Up @@ -1187,8 +1184,8 @@ void setup() {
SETUP_RUN(caselight.update_brightness());
#endif

#if ENABLED(MK2_MULTIPLEXER)
SETUP_LOG("MK2_MULTIPLEXER");
#if HAS_PRUSA_MMU1
SETUP_LOG("Prusa MMU1");
SET_OUTPUT(E_MUX0_PIN);
SET_OUTPUT(E_MUX1_PIN);
SET_OUTPUT(E_MUX2_PIN);
Expand Down Expand Up @@ -1268,7 +1265,7 @@ void setup() {
SETUP_RUN(test_tmc_connection(true, true, true, true));
#endif

#if ENABLED(PRUSA_MMU2)
#if HAS_PRUSA_MMU2
SETUP_RUN(mmu2.init());
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "../inc/MarlinConfig.h"

#if ENABLED(MK2_MULTIPLEXER)
#if HAS_PRUSA_MMU1

#include "../module/stepper.h"

Expand All @@ -35,4 +35,4 @@ void select_multiplexed_stepper(const uint8_t e) {
safe_delay(100);
}

#endif // MK2_MULTIPLEXER
#endif // HAS_PRUSA_MMU1
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 346daa2

Please sign in to comment.