Skip to content

Commit f2999f2

Browse files
committed
Chameleon multi-extruder
1 parent 3f34397 commit f2999f2

11 files changed

Lines changed: 265 additions & 8 deletions

File tree

Marlin/Configuration.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@
377377
* PRUSA_MMU2S : Průša MMU2S (Requires MK3S extruder with motion sensor, EXTRUDERS = 5)
378378
* EXTENDABLE_EMU_MMU2 : MMU with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware)
379379
* EXTENDABLE_EMU_MMU2S : MMUS with configurable number of filaments (ERCF, SMuFF or similar with Průša MMU2 compatible firmware)
380+
* CHAMELEON : Chameleon with up to 4 switchable filaments
380381
*
381382
* Requires NOZZLE_PARK_FEATURE to park print head in case MMU unit fails.
382383
* See additional options in Configuration_adv.h.

Marlin/Configuration_adv.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4449,7 +4449,35 @@
44494449

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

4452-
#endif // HAS_PRUSA_MMU2
4452+
#elif HAS_CHAMELEON
4453+
#define CHAMELEON_BUTTON1_X X_MAX_POS // Button 1 depressed position
4454+
#define CHAMELEON_BUTTON2_X X_MIN_POS // Button 2 depressed position (Used for EXTRUDERS > 2)
4455+
//#define CHAMELEON_TOOLCHANGE_Y Y_CENTER // A standard Y position for all tool-changes
4456+
//#define CHAMELEON_TOOLCHANGE_Z Z_MAX_POS // Enable and adjust if the switch is top-mounted
4457+
4458+
// Design the ramming sequence to first retract out of the hotend,
4459+
// then do blob elimination at the tip, then retract all the way
4460+
// back out of the feeder splitter.
4461+
#define CHAMELEON_RAMMING_SEQUENCE \
4462+
{ -10, 10000 }, /* < fast (shape) */ \
4463+
{ -40, 600 }, /* < slow (cool) */ \
4464+
{ +50, 10000 }, /* > fast (shape) */ \
4465+
{ -10, 10000 }, /* < fast (shape) */ \
4466+
{ -40, 600 }, /* < slow (cool) */ \
4467+
{ +51, 10000 }, /* > fast (unblob) */ \
4468+
{ -11, 10000 }, /* < fast (shape) */ \
4469+
{ +11, 10000 }, /* > fast (unblob) */ \
4470+
{ -11, 10000 }, /* < fast (shape) */ \
4471+
{ +11, 10000 }, /* > fast (unblob) */ \
4472+
{ -11, 10000 }, /* < fast (shape) */ \
4473+
{ -40, 100 }, /* < slow (cool) */ \
4474+
{ -110, 10000 }, /* < fast (shape) */ \
4475+
{ +40, 1000 }, /* > fast (shape) */ \
4476+
{ -40, 1000 }, /* < fast (shape) */ \
4477+
{ +40, 1000 }, /* > fast (shape) */ \
4478+
{ -130, 5000 } /* < fast (unload) */
4479+
4480+
#endif
44534481

44544482
/**
44554483
* Advanced Print Counter settings

Marlin/src/core/macros.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,12 @@
302302
#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)
303303

304304
// Expansion of some list items
305+
#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
306+
#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
307+
#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
308+
#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,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,AA,BB,CC
309+
#define LIST_28(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,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,TU,V,W,X,Y,Z,AA,BB
310+
#define LIST_27(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,...) 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
305311
#define LIST_26(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,...) 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
306312
#define LIST_25(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,...) 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
307313
#define LIST_24(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X
@@ -564,6 +570,17 @@
564570
#define INC_18 19
565571
#define INC_19 20
566572
#define INC_20 21
573+
#define INC_21 22
574+
#define INC_22 23
575+
#define INC_23 24
576+
#define INC_24 25
577+
#define INC_25 26
578+
#define INC_26 27
579+
#define INC_27 28
580+
#define INC_28 29
581+
#define INC_29 30
582+
#define INC_30 31
583+
#define INC_31 32
567584
#define INCREMENT_(n) INC_##n
568585
#define INCREMENT(n) INCREMENT_(n)
569586

@@ -599,6 +616,23 @@
599616
#define DEC_13 12
600617
#define DEC_14 13
601618
#define DEC_15 14
619+
#define DEC_16 15
620+
#define DEC_17 16
621+
#define DEC_18 17
622+
#define DEC_19 18
623+
#define DEC_20 19
624+
#define DEC_21 20
625+
#define DEC_22 21
626+
#define DEC_23 22
627+
#define DEC_24 23
628+
#define DEC_25 24
629+
#define DEC_26 25
630+
#define DEC_27 26
631+
#define DEC_28 27
632+
#define DEC_29 28
633+
#define DEC_30 29
634+
#define DEC_31 30
635+
#define DEC_32 31
602636
#define DECREMENT_(n) DEC_##n
603637
#define DECREMENT(n) DECREMENT_(n)
604638

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
23+
#include "../../inc/MarlinConfig.h"
24+
25+
#if HAS_CHAMELEON
26+
27+
#include "chameleon.h"
28+
//#include "../../MarlinCore.h"
29+
#include "../../module/planner.h"
30+
#include "../../module/stepper.h"
31+
#include "../../lcd/marlinui.h"
32+
33+
//#define DEBUG_OUT ENABLED(DEBUG_CHAMELEON)
34+
#include "../../core/debug_out.h"
35+
36+
Chameleon chameleon;
37+
38+
struct E_Step {
39+
float extrude;
40+
feedRate_t feedRate;
41+
};
42+
43+
// Change tools the Chameleon 3D way
44+
void Chameleon::tool_change(const uint8_t index) {
45+
const uint8_t switches = active_extruder ^ index;
46+
if (!switches) return;
47+
48+
ui.status_printf(0, GET_TEXT_F(MSG_MMU2_LOADING_FILAMENT), int(index + 1));
49+
50+
#ifdef CHAMELEON_TOOLCHANGE_Y
51+
current_position.y = CHAMELEON_TOOLCHANGE_Y;
52+
#endif
53+
#ifdef CHAMELEON_TOOLCHANGE_Z
54+
NOLESS(current_position.z, CHAMELEON_TOOLCHANGE_Z);
55+
line_to_current_position(5000);
56+
#endif
57+
if (switches & 0x1) {
58+
current_position.x = CHAMELEON_BUTTON1_X + (X_CENTER > (CHAMELEON_BUTTON1_X)) ? 10 : -10;
59+
}
60+
else {
61+
#if EXTRUDERS > 2
62+
if (switches & 0x2)
63+
current_position.x = CHAMELEON_BUTTON2_X + (X_CENTER > (CHAMELEON_BUTTON2_X)) ? 10 : -10;
64+
#endif
65+
}
66+
line_to_current_position(5000);
67+
68+
static constexpr E_Step ramming_sequence[] PROGMEM = { CHAMELEON_RAMMING_SEQUENCE };
69+
execute_extruder_sequence(ramming_sequence, COUNT(ramming_sequence));
70+
71+
toggle(switches);
72+
73+
active_extruder = index;
74+
75+
ui.reset_status();
76+
}
77+
78+
// Execute a list of E moves
79+
void Chameleon::execute_extruder_sequence(const E_Step * const sequence, const uint8_t steps) {
80+
planner.synchronize();
81+
stepper.enable_extruder();
82+
83+
const E_Step *step = sequence;
84+
85+
for (uint8_t i = 0; i < steps; ++i) {
86+
const float es = pgm_read_float(&(step->extrude));
87+
const uint16_t fr_or_ms = pgm_read_float(&(step->feedRate));
88+
89+
DEBUG_ECHO_MSG("Move E", es, " @ ", fr_or_ms);
90+
91+
if (es) {
92+
current_position.e += es;
93+
line_to_current_position(MMM_TO_MMS(fr_or_ms));
94+
planner.synchronize();
95+
}
96+
else
97+
safe_delay(fr_or_ms);
98+
99+
step++;
100+
}
101+
102+
// Reset E to 0 for the new extruder tool
103+
current_position.e = 0;
104+
sync_plan_position_e();
105+
106+
stepper.disable_extruder();
107+
}
108+
109+
// Bump the switches needed to change feeders
110+
void Chameleon::toggle(const uint8_t switches) {
111+
if (switches & 0x1) {
112+
current_position.x = CHAMELEON_BUTTON1_X;
113+
line_to_current_position(2000);
114+
current_position.x += (X_CENTER > (CHAMELEON_BUTTON1_X)) ? 10 : -10;
115+
line_to_current_position(2000);
116+
}
117+
#if EXTRUDERS > 2
118+
if (switches & 0x2) {
119+
current_position.x = CHAMELEON_BUTTON2_X;
120+
line_to_current_position(2000);
121+
current_position.x += (X_CENTER > (CHAMELEON_BUTTON2_X)) ? 10 : -10;
122+
line_to_current_position(2000);
123+
}
124+
#endif
125+
planner.synchronize();
126+
}
127+
128+
#endif // HAS_CHAMELEON

Marlin/src/feature/mmu/chameleon.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**
2+
* Marlin 3D Printer Firmware
3+
* Copyright (c) 2023 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4+
*
5+
* Based on Sprinter and grbl.
6+
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7+
*
8+
* This program is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* (at your option) any later version.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
20+
*
21+
*/
22+
#pragma once
23+
24+
#include <stdint.h>
25+
26+
struct E_Step;
27+
28+
class Chameleon {
29+
public:
30+
Chameleon() {}
31+
static void tool_change(const uint8_t new_tool);
32+
33+
private:
34+
static void execute_extruder_sequence(const E_Step * const sequence, const uint8_t steps);
35+
static void toggle(const uint8_t switches);
36+
};
37+
38+
extern Chameleon chameleon;

Marlin/src/inc/Conditionals_LCD.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#define PRUSA_MMU1 1
8686
#define PRUSA_MMU2 2
8787
#define PRUSA_MMU2S 3
88+
#define CHAMELEON 4
8889
#define EXTENDABLE_EMU_MMU2 12
8990
#define EXTENDABLE_EMU_MMU2S 13
9091

@@ -98,6 +99,8 @@
9899
#elif MMU_MODEL % 10 == PRUSA_MMU2S
99100
#define HAS_PRUSA_MMU2 1
100101
#define HAS_PRUSA_MMU2S 1
102+
#elif MMU_MODEL == CHAMELEON
103+
#define HAS_CHAMELEON 1
101104
#endif
102105
#if MMU_MODEL >= EXTENDABLE_EMU_MMU2
103106
#define HAS_EXTENDABLE_MMU 1
@@ -107,6 +110,7 @@
107110
#undef PRUSA_MMU1
108111
#undef PRUSA_MMU2
109112
#undef PRUSA_MMU2S
113+
#undef CHAMELEON
110114
#undef EXTENDABLE_EMU_MMU2
111115
#undef EXTENDABLE_EMU_MMU2S
112116

@@ -138,7 +142,7 @@
138142
#define E_STEPPERS EXTRUDERS
139143
#define E_MANUAL EXTRUDERS
140144

141-
#elif HAS_PRUSA_MMU2 // Průša Multi-Material Unit v2
145+
#elif HAS_PRUSA_MMU2 || HAS_CHAMELEON // Multi-Material Unit
142146

143147
#define E_STEPPERS 1
144148
#define E_MANUAL 1

Marlin/src/inc/SanityCheck.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,13 +652,22 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
652652
#endif
653653
#endif
654654

655+
#if HAS_CHAMELEON
656+
#if EXTRUDERS > 32
657+
#undef SINGLENOZZLE
658+
#error "CHAMELEON only supports up to 32 EXTRUDERS. Please update your Configuration."
659+
#endif
660+
#endif
661+
655662
/**
656663
* Options only for EXTRUDERS > 1
657664
*/
658665
#if HAS_MULTI_EXTRUDER
659666

660667
#ifndef MAX_EXTRUDERS
661-
#if HAS_EXTENDABLE_MMU
668+
#if HAS_CHAMELEON
669+
#define MAX_EXTRUDERS 32
670+
#elif HAS_EXTENDABLE_MMU
662671
#define MAX_EXTRUDERS 15
663672
#else
664673
#define MAX_EXTRUDERS 8

Marlin/src/module/stepper/indirection.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,12 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
587587
#define FWD_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? HIGH : LOW ); }while(0)
588588
#define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 0) ? LOW : HIGH); }while(0)
589589

590+
#elif ENABLED(CHAMELEON) // One multiplexed stepper driver, reversed on T2/T3, T6/T7, T10/T11, etc.
591+
592+
#define E_STEP_WRITE(E,V) E0_STEP_WRITE(V)
593+
#define NORM_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 1) ? HIGH : LOW ); }while(0)
594+
#define REV_E_DIR(E) do{ E0_DIR_WRITE(TEST(E, 1) ? LOW : HIGH); }while(0)
595+
590596
#elif E_STEPPERS > 1
591597

592598
#if E_STEPPERS > 7

Marlin/src/module/tool_change.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@
7878
#include "../feature/mmu/mmu.h"
7979
#elif HAS_PRUSA_MMU2
8080
#include "../feature/mmu/mmu2.h"
81+
#elif HAS_CHAMELEON
82+
#include "../feature/mmu/chameleon.h"
8183
#endif
8284

8385
#if HAS_MARLINUI_MENU
@@ -1120,6 +1122,12 @@ void tool_change(const uint8_t new_tool, bool no_move/*=false*/) {
11201122
mixer.T(new_tool);
11211123
#endif
11221124

1125+
#elif HAS_CHAMELEON
1126+
1127+
UNUSED(no_move);
1128+
1129+
chameleon.tool_change(new_tool);
1130+
11231131
#elif HAS_PRUSA_MMU2
11241132

11251133
UNUSED(no_move);

buildroot/tests/mega2560

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,20 @@ exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE ..."
4040
# Add a Sled Z Probe, use UBL Cartesian moves, use Japanese language
4141
#
4242
use_example_configs AnimationExample
43-
opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE jp_kana DEFAULT_EJERK 10 \
44-
EXTRUDERS 5 TEMP_SENSOR_1 1 TEMP_SENSOR_2 5 TEMP_SENSOR_3 20 TEMP_SENSOR_4 1000 TEMP_SENSOR_BED 1
43+
opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO \
44+
EXTRUDERS 8 TEMP_SENSOR_BED 1 MMU_MODEL CHAMELEON DEFAULT_EJERK 10 LCD_LANGUAGE jp_kana
4545
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \
4646
SET_PROGRESS_MANUALLY SET_PROGRESS_PERCENT PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME STATUS_MESSAGE_SCROLLING SCROLL_LONG_FILENAMES \
4747
SDSUPPORT LONG_FILENAME_WRITE_SUPPORT SDCARD_SORT_ALPHA NO_SD_AUTOSTART USB_FLASH_DRIVE_SUPPORT CANCEL_OBJECTS \
4848
Z_PROBE_SLED AUTO_BED_LEVELING_UBL UBL_HILBERT_CURVE UBL_TILT_ON_MESH_POINTS UBL_TILT_ON_MESH_POINTS_3POINT \
4949
RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT \
5050
EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \
51-
MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE QUICK_HOME \
51+
NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE CLASSIC_JERK LIN_ADVANCE QUICK_HOME \
5252
NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL \
5353
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \
54-
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_HOTEND_Z_OFFSET BABYSTEP_DISPLAY_TOTAL
54+
BABYSTEPPING BABYSTEP_XY BABYSTEP_ZPROBE_OFFSET DOUBLECLICK_FOR_Z_BABYSTEPPING BABYSTEP_DISPLAY_TOTAL
5555
opt_disable SEGMENT_LEVELED_MOVES
56-
exec_test $1 $2 "Azteeg X3 Pro | EXTRUDERS 5 | RRDFGSC | UBL | LIN_ADVANCE | Sled Probe | Skew | JP-Kana | Babystep offsets ..." "$3"
56+
exec_test $1 $2 "Azteeg X3 Pro | Chameleon (x8) | RRDFGSC | UBL | LIN_ADVANCE | Sled Probe | Skew | JP-Kana | Babystep offsets ..." "$3"
5757

5858
#
5959
# 5 runout sensors with distinct states

0 commit comments

Comments
 (0)