From af7c1dd8fa6ed2e8f4665c3417bf491ad5b713d6 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 26 May 2022 19:18:14 -0500 Subject: [PATCH] Chameleon multi-extruder --- Marlin/Configuration.h | 1 + Marlin/Configuration_adv.h | 20 ++++++- Marlin/src/core/macros.h | 40 +++++++++++++ Marlin/src/feature/mmu/chameleon.cpp | 76 +++++++++++++++++++++++++ Marlin/src/feature/mmu/chameleon.h | 38 +++++++++++++ Marlin/src/inc/Conditionals_LCD.h | 8 ++- Marlin/src/inc/SanityCheck.h | 29 +++++++++- Marlin/src/module/stepper/indirection.h | 6 ++ Marlin/src/module/tool_change.cpp | 8 +++ buildroot/tests/mega2560 | 11 ++-- ini/features.ini | 1 + platformio.ini | 3 +- 12 files changed, 229 insertions(+), 12 deletions(-) create mode 100644 Marlin/src/feature/mmu/chameleon.cpp create mode 100644 Marlin/src/feature/mmu/chameleon.h diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0b8691f8551f..3d900e9327ae 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -253,6 +253,7 @@ * PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5) * EXTENDABLE_EMU_MMU2 : MMU with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) * EXTENDABLE_EMU_MMU2S : MMUS with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware) + * CHAMELEON : Chameleon with up to 4 switchable filaments * * Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails. * See additional options in Configuration_adv.h. diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 55512e64fbf0..a97f6eb81a96 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -4265,7 +4265,25 @@ //#define MMU2_DEBUG // Write debug info to serial output -#endif // HAS_PRUSA_MMU2 +#elif HAS_CHAMELEON + // Initial location of the button, minus 3mm for the axis (e.g., if the button is at X225 use X222 here + #define CHAMELEON_BUTTON_X X_MAX_POS + #define CHAMELEON_HOLDING_X (CHAMELEON_BUTTON_X - 3) + #define CHAMELEON_TOOLCHANGE_Y Y_CENTER + #define CHAMELEON_RAMMING_SEQUENCE \ + { -50, 2000 }, \ + { -80, 600 }, \ + { 1, 2000 }, \ + { -50, 2000 }, \ + { -80, 600 }, \ + { 1, 2000 }, \ + { -10, 2000 }, \ + { 1, 2000 }, \ + { -10, 2000 }, \ + { 1, 2000 }, \ + { -50, 2000 }, \ + { -80, 100 } +#endif /** * Advanced Print Counter settings diff --git a/Marlin/src/core/macros.h b/Marlin/src/core/macros.h index 8dfcb875ac4e..71447408034d 100644 --- a/Marlin/src/core/macros.h +++ b/Marlin/src/core/macros.h @@ -338,6 +338,18 @@ #define GANG_N_1(N,K) _GANG_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K) // Macros for initializing arrays +#define LIST_32(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,DD,EE,FF,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,DD,EE,FF +#define LIST_31(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,DD,EE,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,DD,EE +#define LIST_30(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,DD,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,DD +#define LIST_29(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC,...) A,B,C,D,E,F,G,H,I,J,K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Q,R,S,T #define LIST_19(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S #define LIST_18(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R @@ -563,6 +575,17 @@ #define INC_18 19 #define INC_19 20 #define INC_20 21 +#define INC_21 22 +#define INC_22 23 +#define INC_23 24 +#define INC_24 25 +#define INC_25 26 +#define INC_26 27 +#define INC_27 28 +#define INC_28 29 +#define INC_29 30 +#define INC_30 31 +#define INC_31 32 #define INCREMENT_(n) INC_##n #define INCREMENT(n) INCREMENT_(n) @@ -598,6 +621,23 @@ #define DEC_13 12 #define DEC_14 13 #define DEC_15 14 +#define DEC_16 15 +#define DEC_17 16 +#define DEC_18 17 +#define DEC_19 18 +#define DEC_20 19 +#define DEC_21 20 +#define DEC_22 21 +#define DEC_23 22 +#define DEC_24 23 +#define DEC_25 24 +#define DEC_26 25 +#define DEC_27 26 +#define DEC_28 27 +#define DEC_29 28 +#define DEC_30 29 +#define DEC_31 30 +#define DEC_32 31 #define DECREMENT_(n) DEC_##n #define DECREMENT(n) DECREMENT_(n) diff --git a/Marlin/src/feature/mmu/chameleon.cpp b/Marlin/src/feature/mmu/chameleon.cpp new file mode 100644 index 000000000000..622822be6438 --- /dev/null +++ b/Marlin/src/feature/mmu/chameleon.cpp @@ -0,0 +1,76 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ + +#include "../../inc/MarlinConfig.h" + +#if HAS_CHAMELEON + +#include "chameleon.h" +//#include "../../MarlinCore.h" +#include "../../module/planner.h" +#include "../../module/stepper.h" +#include "../../lcd/marlinui.h" + +//#define DEBUG_OUT ENABLED(DEBUG_CHAMELEON) +#include "../../core/debug_out.h" + +Chameleon chameleon; + +struct E_Step { + float extrude; + feedRate_t feedRate; +}; + +void Chameleon::tool_change(const uint8_t index) { + if (index == active_extruder) return; + + ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(index + 1)); + + static constexpr E_Step ramming_sequence[] PROGMEM = { CHAMELEON_RAMMING_SEQUENCE }; + execute_extruder_sequence(ramming_sequence, COUNT(ramming_sequence)); + + ui.reset_status(); +} + +void Chameleon::execute_extruder_sequence(const E_Step * const sequence, const uint8_t steps) { + planner.synchronize(); + stepper.enable_extruder(); + + const E_Step *step = sequence; + + LOOP_L_N(i, steps) { + const float es = pgm_read_float(&(step->extrude)); + const feedRate_t fr_mm_m = pgm_read_float(&(step->feedRate)); + + DEBUG_ECHO_MSG("E step ", es, "/", fr_mm_m); + + current_position.e += es; + line_to_current_position(MMM_TO_MMS(fr_mm_m)); + planner.synchronize(); + + step++; + } + + stepper.disable_extruder(); +} + +#endif // HAS_CHAMELEON diff --git a/Marlin/src/feature/mmu/chameleon.h b/Marlin/src/feature/mmu/chameleon.h new file mode 100644 index 000000000000..f8c3633cbc02 --- /dev/null +++ b/Marlin/src/feature/mmu/chameleon.h @@ -0,0 +1,38 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (c) 2022 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + */ +#pragma once + +#include + +struct E_Step; + +class Chameleon { + public: + Chameleon() {} + static void tool_change(const uint8_t new_tool); + + private: + static void execute_extruder_sequence(const E_Step * const sequence, const uint8_t steps); + static void push_button(); +}; + +extern Chameleon chameleon; diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 5e23cedc4d38..3d6f0287ad39 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -548,6 +548,7 @@ #define PRUSA_MMU1 1 #define PRUSA_MMU2 2 #define PRUSA_MMU2S 3 +#define CHAMELEON 4 #define EXTENDABLE_EMU_MMU2 12 #define EXTENDABLE_EMU_MMU2S 13 @@ -560,6 +561,8 @@ #elif MMU_MODEL % 10 == PRUSA_MMU2S #define HAS_PRUSA_MMU2 1 #define HAS_PRUSA_MMU2S 1 + #elif MMU_MODEL == CHAMELEON + #define HAS_CHAMELEON 1 #endif #if MMU_MODEL >= EXTENDABLE_EMU_MMU2 #define HAS_EXTENDABLE_MMU 1 @@ -569,6 +572,7 @@ #undef PRUSA_MMU1 #undef PRUSA_MMU2 #undef PRUSA_MMU2S +#undef CHAMELEON #undef EXTENDABLE_EMU_MMU2 #undef EXTENDABLE_EMU_MMU2S @@ -635,7 +639,7 @@ #define E_STEPPERS EXTRUDERS #define E_MANUAL EXTRUDERS -#elif HAS_PRUSA_MMU2 // Průša Multi-Material Unit v2 +#elif HAS_PRUSA_MMU2 || HAS_CHAMELEON // Multi-Material Unit #define E_STEPPERS 1 #define E_MANUAL 1 @@ -647,7 +651,7 @@ #undef DISABLE_INACTIVE_EXTRUDER #endif -// Průša MMU1, MMU(S) 2.0 and EXTENDABLE_EMU_MMU2(S) force SINGLENOZZLE +// Chameleon, Průša MMU1, MMU(S) 2.0, and EXTENDABLE_EMU_MMU2(S) force SINGLENOZZLE #if HAS_MMU #define SINGLENOZZLE #endif diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index ea39aa1b7020..00f3e8c14aa0 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1159,12 +1159,21 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif +#if HAS_CHAMELEON + #if EXTRUDERS > 32 + #undef SINGLENOZZLE + #error "CHAMELEON only supports up to 32 EXTRUDERS. Please update your Configuration." + #endif +#endif + /** * Options only for EXTRUDERS > 1 */ #if HAS_MULTI_EXTRUDER - #if HAS_EXTENDABLE_MMU + #if HAS_CHAMELEON + #define MAX_EXTRUDERS 32 + #elif HAS_EXTENDABLE_MMU #define MAX_EXTRUDERS 15 #else #define MAX_EXTRUDERS 8 @@ -2427,6 +2436,24 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif // HOTENDS > 2 #endif // HAS_MULTI_HOTEND +#if HOTENDS < 8 && TEMP_SENSOR_7 != 0 + #error "TEMP_SENSOR_7 shouldn't be set with less than 8 hotends." +#elif HOTENDS < 7 && TEMP_SENSOR_6 != 0 + #error "TEMP_SENSOR_6 shouldn't be set with less than 7 hotends." +#elif HOTENDS < 6 && TEMP_SENSOR_5 != 0 + #error "TEMP_SENSOR_5 shouldn't be set with less than 6 hotends." +#elif HOTENDS < 5 && TEMP_SENSOR_4 != 0 + #error "TEMP_SENSOR_4 shouldn't be set with less than 5 hotends." +#elif HOTENDS < 4 && TEMP_SENSOR_3 != 0 + #error "TEMP_SENSOR_3 shouldn't be set with less than 4 hotends." +#elif HOTENDS < 3 && TEMP_SENSOR_2 != 0 + #error "TEMP_SENSOR_2 shouldn't be set with less than 3 hotends." +#elif HOTENDS < 2 && TEMP_SENSOR_1 != 0 + #error "TEMP_SENSOR_1 shouldn't be set with less than 2 hotends." +#elif HOTENDS < 1 && TEMP_SENSOR_0 != 0 + #error "TEMP_SENSOR_0 shouldn't be set with no hotends." +#endif + /** * Pins must be set for temp sensors, with some other feature requirements. */ diff --git a/Marlin/src/module/stepper/indirection.h b/Marlin/src/module/stepper/indirection.h index e9a9aa7de90c..77112c5d8a61 100644 --- a/Marlin/src/module/stepper/indirection.h +++ b/Marlin/src/module/stepper/indirection.h @@ -544,6 +544,12 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? DISABLED(INVERT_E0_DIR): ENABLED(INVERT_E0_DIR)); }while(0) #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? ENABLED(INVERT_E0_DIR): DISABLED(INVERT_E0_DIR)); }while(0) +#elif ENABLED(CHAMELEON) // One multiplexed stepper driver, reversed on T2/T3, T6/T7, T10/T11, etc. + + #define E_STEP_WRITE(E,V) E0_STEP_WRITE(V) + #define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 1) ? !INVERT_E0_DIR: INVERT_E0_DIR); }while(0) + #define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 1) ? INVERT_E0_DIR: !INVERT_E0_DIR); }while(0) + #elif E_STEPPERS > 1 #if E_STEPPERS > 7 diff --git a/Marlin/src/module/tool_change.cpp b/Marlin/src/module/tool_change.cpp index dbd95121dce0..b43ec91b3733 100644 --- a/Marlin/src/module/tool_change.cpp +++ b/Marlin/src/module/tool_change.cpp @@ -87,6 +87,8 @@ #include "../feature/mmu/mmu.h" #elif HAS_PRUSA_MMU2 #include "../feature/mmu/mmu2.h" +#elif HAS_CHAMELEON + #include "../feature/mmu/chameleon.h" #endif #if HAS_MARLINUI_MENU @@ -1111,6 +1113,12 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) { mixer.T(new_tool); #endif + #elif HAS_CHAMELEON + + UNUSED(no_move); + + chameleon.tool_change(new_tool); + #elif HAS_PRUSA_MMU2 UNUSED(no_move); diff --git a/buildroot/tests/mega2560 b/buildroot/tests/mega2560 index 9cb50688cdea..acdc98f373a8 100755 --- a/buildroot/tests/mega2560 +++ b/buildroot/tests/mega2560 @@ -39,20 +39,19 @@ exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE ..." # Add a Sled Z Probe, use UBL Cartesian moves, use Japanese language # use_example_configs AnimationExample -opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE jp_kana DEFAULT_EJERK 10 \ - EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1 +opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO \ + EXTRUDERS 8 TEMP_SENSOR_BED 1 MMU_MODEL CHAMELEON DEFAULT_EJERK 10 LCD_LANGUAGE jp_kana opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \ LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \ SDSUPPORT LONG_FILENAME_WRITE_SUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \ Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \ EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \ - MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \ + NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE CLASSIC_JERK LIN_ADVANCE QUICK_HOME \ NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL \ SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \ - BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_HOTEND_Z_OFFSET BABYSTEP_DISPLAY_TOTAL + BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL opt_disable SEGMENT_LEVELED_MOVES -exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE | Sled Probe | Skew | JP-Kana | Babystep offsets ..." "$3" - +exec_test $1 $2 "Azteeg X3 Pro | Chameleon (x8) | RRDFGSC | UBL | LIN_ADVANCE | Sled Probe | Skew | JP-Kana | Babystep offsets ..." "$3" # # 5 runout sensors with distinct states diff --git a/ini/features.ini b/ini/features.ini index 2f26aa25236e..7e2a4c829869 100644 --- a/ini/features.ini +++ b/ini/features.ini @@ -137,6 +137,7 @@ TEMP_STAT_LEDS = src_filter=+ + HAS_MEATPACK = src_filter=+ MIXING_EXTRUDER = src_filter=+ + +HAS_CHAMELEON = src_filter=+ HAS_PRUSA_MMU1 = src_filter=+ HAS_PRUSA_MMU2 = src_filter=+ + PASSWORD_FEATURE = src_filter=+ + diff --git a/platformio.ini b/platformio.ini index 751543c8a32b..8bf7fc63ba18 100644 --- a/platformio.ini +++ b/platformio.ini @@ -137,8 +137,7 @@ default_src_filter = + - - + - - - - - - - - + - - - - - - - -