Skip to content

Commit

Permalink
Merge pull request #6938 from thinkyhead/bf_prusa_multiplexer
Browse files Browse the repository at this point in the history
Initial support for the Průša MK2 Multiplexer
  • Loading branch information
thinkyhead committed Jun 27, 2017
2 parents c2c8aaf + 5b11b33 commit 66faedb
Show file tree
Hide file tree
Showing 64 changed files with 743 additions and 69 deletions.
6 changes: 6 additions & 0 deletions Marlin/Conditionals_LCD.h
Expand Up @@ -307,13 +307,19 @@

#define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)

// MK2 Multiplexer forces SINGLENOZZLE to be enabled
#if ENABLED(MK2_MULTIPLEXER)
#define SINGLENOZZLE
#endif

/**
* Extruders have some combination of stepper motors and hotends
* so we separate these concepts into the defines:
*
* EXTRUDERS - Number of Selectable Tools
* HOTENDS - Number of hotends, whether connected or separate
* E_STEPPERS - Number of actual E stepper motors
* E_MANUAL - Number of E steppers for LCD move options
* TOOL_E_INDEX - Index to use when getting/setting the tool state
*
*/
Expand Down
19 changes: 19 additions & 0 deletions Marlin/Configuration.h
Expand Up @@ -138,6 +138,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Expand Up @@ -648,7 +648,7 @@
*
* Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
*
* Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
* Slic3r (including Průša Slic3r) produces Gcode compatible with the automatic mode.
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
*/
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
Expand Down
64 changes: 59 additions & 5 deletions Marlin/Marlin_main.cpp
Expand Up @@ -9436,6 +9436,39 @@ inline void gcode_M503() {

#endif // ADVANCED_PAUSE_FEATURE

#if ENABLED(MK2_MULTIPLEXER)

inline void select_multiplexed_stepper(const uint8_t e) {
stepper.synchronize();
disable_e_steppers();
WRITE(E_MUX0_PIN, TEST(e, 0) ? HIGH : LOW);
WRITE(E_MUX1_PIN, TEST(e, 1) ? HIGH : LOW);
WRITE(E_MUX2_PIN, TEST(e, 2) ? HIGH : LOW);
safe_delay(100);
}

/**
* M702: Unload all extruders
*/
inline void gcode_M702() {
for (uint8_t s = 0; s < E_STEPPERS; s++) {
select_multiplexed_stepper(e);
// TODO: standard unload filament function
// MK2 firmware behavior:
// - Make sure temperature is high enough
// - Raise Z to at least 15 to make room
// - Extrude 1cm of filament in 1 second
// - Under 230C quickly purge ~12mm, over 230C purge ~10mm
// - Change E max feedrate to 80, eject the filament from the tube. Sync.
// - Restore E max feedrate to 50
}
// Go back to the last active extruder
select_multiplexed_stepper(active_extruder);
disable_e_steppers();
}

#endif // MK2_MULTIPLEXER

#if ENABLED(DUAL_X_CARRIAGE)

/**
Expand Down Expand Up @@ -10257,14 +10290,23 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
UNUSED(fr_mm_s);
UNUSED(no_move);

// Set the new active extruder
active_extruder = tmp_extruder;
#if ENABLED(SWITCHING_EXTRUDER) && !DONT_SWITCH

stepper.synchronize();
move_extruder_servo(tmp_extruder);

#elif ENABLED(MK2_MULTIPLEXER)

if (tmp_extruder >= E_STEPPERS)
return invalid_extruder_error(tmp_extruder);

select_multiplexed_stepper(tmp_extruder);

#endif

#endif // HOTENDS <= 1

#if ENABLED(SWITCHING_EXTRUDER) && !DONT_SWITCH
move_extruder_servo(active_extruder);
#endif
active_extruder = tmp_extruder;

SERIAL_ECHO_START();
SERIAL_ECHOLNPAIR(MSG_ACTIVE_EXTRUDER, (int)active_extruder);
Expand Down Expand Up @@ -11001,6 +11043,12 @@ void process_next_command() {
break;
#endif // DUAL_X_CARRIAGE

#if ENABLED(MK2_MULTIPLEXER)
case 702: // M702: Unload all extruders
gcode_M702();
break;
#endif

#if ENABLED(LIN_ADVANCE)
case 900: // M900: Set advance K factor.
gcode_M900();
Expand Down Expand Up @@ -12968,6 +13016,12 @@ void setup() {
#endif
#endif

#if ENABLED(MK2_MULTIPLEXER)
SET_OUTPUT(E_MUX0_PIN);
SET_OUTPUT(E_MUX1_PIN);
SET_OUTPUT(E_MUX2_PIN);
#endif

lcd_init();
#if ENABLED(SHOW_BOOTSCREEN)
#if ENABLED(DOGLCD)
Expand Down
11 changes: 11 additions & 0 deletions Marlin/SanityCheck.h
Expand Up @@ -352,10 +352,21 @@
#error "EXTRUDERS must be 1 with HEATERS_PARALLEL."
#endif

#elif ENABLED(MK2_MULTIPLEXER)
#error "MK2_MULTIPLEXER requires 2 or more EXTRUDERS."
#elif ENABLED(SINGLENOZZLE)
#error "SINGLENOZZLE requires 2 or more EXTRUDERS."
#endif

/**
* Sanity checking for the Průša MK2 Multiplexer
*/
#ifdef SNMM
#error "SNMM is now MK2_MULTIPLEXER. Please update your configuration."
#elif ENABLED(MK2_MULTIPLEXER) && DISABLED(ADVANCED_PAUSE_FEATURE)
#error "ADVANCED_PAUSE_FEATURE is required with MK2_MULTIPLEXER."
#endif

/**
* A Dual Nozzle carriage with switching servo
*/
Expand Down
19 changes: 19 additions & 0 deletions Marlin/example_configurations/Anet/Configuration.h
Expand Up @@ -138,6 +138,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
19 changes: 19 additions & 0 deletions Marlin/example_configurations/CL-260/Configuration.h
Expand Up @@ -138,6 +138,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
19 changes: 19 additions & 0 deletions Marlin/example_configurations/Cartesio/Configuration.h
Expand Up @@ -139,6 +139,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/example_configurations/Cartesio/Configuration_adv.h
Expand Up @@ -645,7 +645,7 @@
*
* Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
*
* Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
* Slic3r (including Průša Slic3r) produces Gcode compatible with the automatic mode.
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
*/
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
Expand Down
19 changes: 19 additions & 0 deletions Marlin/example_configurations/Felix/Configuration.h
Expand Up @@ -138,6 +138,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
2 changes: 1 addition & 1 deletion Marlin/example_configurations/Felix/Configuration_adv.h
Expand Up @@ -645,7 +645,7 @@
*
* Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
*
* Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
* Slic3r (including Průša Slic3r) produces Gcode compatible with the automatic mode.
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
*/
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
Expand Down
19 changes: 19 additions & 0 deletions Marlin/example_configurations/Felix/DUAL/Configuration.h
Expand Up @@ -138,6 +138,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
19 changes: 19 additions & 0 deletions Marlin/example_configurations/FolgerTech-i3-2020/Configuration.h
Expand Up @@ -138,6 +138,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
Expand Up @@ -648,7 +648,7 @@
*
* Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
*
* Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
* Slic3r (including Průša Slic3r) produces Gcode compatible with the automatic mode.
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
*/
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
Expand Down
19 changes: 19 additions & 0 deletions Marlin/example_configurations/Hephestos/Configuration.h
Expand Up @@ -141,6 +141,25 @@
// For Cyclops or any "multi-extruder" that shares a single nozzle.
//#define SINGLENOZZLE

/**
* 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 steppers
//#define E_MUX2_PIN 44 // Needed for 5 to 8 steppers
#endif

// A dual extruder that uses a single stepper motor
//#define SWITCHING_EXTRUDER
#if ENABLED(SWITCHING_EXTRUDER)
Expand Down
Expand Up @@ -645,7 +645,7 @@
*
* Set to 0 to auto-detect the ratio based on given Gcode G1 print moves.
*
* Slic3r (including Prusa Slic3r) produces Gcode compatible with the automatic mode.
* Slic3r (including Průša Slic3r) produces Gcode compatible with the automatic mode.
* Cura (as of this writing) may produce Gcode incompatible with the automatic mode.
*/
#define LIN_ADVANCE_E_D_RATIO 0 // The calculated ratio (or 0) according to the formula W * H / ((D / 2) ^ 2 * PI)
Expand Down

0 comments on commit 66faedb

Please sign in to comment.