Skip to content

Commit 8102d52

Browse files
committed
Chameleon multi-extruder
1 parent 9a6392e commit 8102d52

11 files changed

Lines changed: 301 additions & 17 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
@@ -4391,7 +4391,35 @@
43914391

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

4394-
#endif // HAS_PRUSA_MMU2
4394+
#elif HAS_CHAMELEON
4395+
#define CHAMELEON_BUTTON1_X X_MAX_POS // Button 1 depressed position
4396+
#define CHAMELEON_BUTTON2_X X_MIN_POS // Button 2 depressed position (Used for EXTRUDERS > 2)
4397+
//#define CHAMELEON_TOOLCHANGE_Y Y_CENTER // A standard Y position for all tool-changes
4398+
//#define CHAMELEON_TOOLCHANGE_Z Z_MAX_POS // Enable and adjust if the switch is top-mounted
4399+
4400+
// Design the ramming sequence to first retract out of the hotend,
4401+
// then do blob elimination at the tip, then retract all the way
4402+
// back out of the feeder splitter.
4403+
#define CHAMELEON_RAMMING_SEQUENCE \
4404+
{ -10, 10000 }, /* < fast (shape) */ \
4405+
{ -40, 600 }, /* < slow (cool) */ \
4406+
{ +50, 10000 }, /* > fast (shape) */ \
4407+
{ -10, 10000 }, /* < fast (shape) */ \
4408+
{ -40, 600 }, /* < slow (cool) */ \
4409+
{ +51, 10000 }, /* > fast (unblob) */ \
4410+
{ -11, 10000 }, /* < fast (shape) */ \
4411+
{ +11, 10000 }, /* > fast (unblob) */ \
4412+
{ -11, 10000 }, /* < fast (shape) */ \
4413+
{ +11, 10000 }, /* > fast (unblob) */ \
4414+
{ -11, 10000 }, /* < fast (shape) */ \
4415+
{ -40, 100 }, /* < slow (cool) */ \
4416+
{ -110, 10000 }, /* < fast (shape) */ \
4417+
{ +40, 1000 }, /* > fast (shape) */ \
4418+
{ -40, 1000 }, /* < fast (shape) */ \
4419+
{ +40, 1000 }, /* > fast (shape) */ \
4420+
{ -130, 5000 } /* < fast (unload) */
4421+
4422+
#endif
43954423

43964424
/**
43974425
* Advanced Print Counter settings

Marlin/src/core/macros.h

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

299299
// Expansion of some list items
300+
#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
301+
#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
302+
#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
303+
#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
304+
#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
305+
#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
300306
#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
301307
#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
302308
#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
@@ -559,6 +565,17 @@
559565
#define INC_18 19
560566
#define INC_19 20
561567
#define INC_20 21
568+
#define INC_21 22
569+
#define INC_22 23
570+
#define INC_23 24
571+
#define INC_24 25
572+
#define INC_25 26
573+
#define INC_26 27
574+
#define INC_27 28
575+
#define INC_28 29
576+
#define INC_29 30
577+
#define INC_30 31
578+
#define INC_31 32
562579
#define INCREMENT_(n) INC_##n
563580
#define INCREMENT(n) INCREMENT_(n)
564581

@@ -594,6 +611,23 @@
594611
#define DEC_13 12
595612
#define DEC_14 13
596613
#define DEC_15 14
614+
#define DEC_16 15
615+
#define DEC_17 16
616+
#define DEC_18 17
617+
#define DEC_19 18
618+
#define DEC_20 19
619+
#define DEC_21 20
620+
#define DEC_22 21
621+
#define DEC_23 22
622+
#define DEC_24 23
623+
#define DEC_25 24
624+
#define DEC_26 25
625+
#define DEC_27 26
626+
#define DEC_28 27
627+
#define DEC_29 28
628+
#define DEC_30 29
629+
#define DEC_31 30
630+
#define DEC_32 31
597631
#define DECREMENT_(n) DEC_##n
598632
#define DECREMENT(n) DECREMENT_(n)
599633

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: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@
585585
#define PRUSA_MMU1 1
586586
#define PRUSA_MMU2 2
587587
#define PRUSA_MMU2S 3
588+
#define CHAMELEON 4
588589
#define EXTENDABLE_EMU_MMU2 12
589590
#define EXTENDABLE_EMU_MMU2S 13
590591

@@ -597,6 +598,8 @@
597598
#elif MMU_MODEL % 10 == PRUSA_MMU2S
598599
#define HAS_PRUSA_MMU2 1
599600
#define HAS_PRUSA_MMU2S 1
601+
#elif MMU_MODEL == CHAMELEON
602+
#define HAS_CHAMELEON 1
600603
#endif
601604
#if MMU_MODEL >= EXTENDABLE_EMU_MMU2
602605
#define HAS_EXTENDABLE_MMU 1
@@ -606,6 +609,7 @@
606609
#undef PRUSA_MMU1
607610
#undef PRUSA_MMU2
608611
#undef PRUSA_MMU2S
612+
#undef CHAMELEON
609613
#undef EXTENDABLE_EMU_MMU2
610614
#undef EXTENDABLE_EMU_MMU2S
611615

@@ -629,14 +633,6 @@
629633
#else
630634
#undef EXTRUDERS
631635
#define EXTRUDERS 0
632-
#undef TEMP_SENSOR_0
633-
#undef TEMP_SENSOR_1
634-
#undef TEMP_SENSOR_2
635-
#undef TEMP_SENSOR_3
636-
#undef TEMP_SENSOR_4
637-
#undef TEMP_SENSOR_5
638-
#undef TEMP_SENSOR_6
639-
#undef TEMP_SENSOR_7
640636
#undef SINGLENOZZLE
641637
#undef SWITCHING_EXTRUDER
642638
#undef MECHANICAL_SWITCHING_EXTRUDER
@@ -690,7 +686,7 @@
690686
#define E_STEPPERS EXTRUDERS
691687
#define E_MANUAL EXTRUDERS
692688

693-
#elif HAS_PRUSA_MMU2 // Průša Multi-Material Unit v2
689+
#elif HAS_PRUSA_MMU2 || HAS_CHAMELEON // Multi-Material Unit
694690

695691
#define E_STEPPERS 1
696692
#define E_MANUAL 1
@@ -702,7 +698,7 @@
702698
#undef DISABLE_OTHER_EXTRUDERS
703699
#endif
704700

705-
// Průša MMU1, MMU(S) 2.0 and EXTENDABLE_EMU_MMU2(S) force SINGLENOZZLE
701+
// Chameleon, Průša MMU1, MMU(S) 2.0, and EXTENDABLE_EMU_MMU2(S) force SINGLENOZZLE
706702
#if HAS_MMU
707703
#define SINGLENOZZLE
708704
#endif
@@ -787,6 +783,41 @@
787783
#endif
788784
#endif
789785

786+
#if HOTENDS <= 7
787+
#undef TEMP_SENSOR_7
788+
#define TEMP_SENSOR_7 0
789+
#if HOTENDS <= 6
790+
#undef TEMP_SENSOR_6
791+
#define TEMP_SENSOR_6 0
792+
#if HOTENDS <= 5
793+
#undef TEMP_SENSOR_5
794+
#define TEMP_SENSOR_5 0
795+
#if HOTENDS <= 4
796+
#undef TEMP_SENSOR_4
797+
#define TEMP_SENSOR_4 0
798+
#if HOTENDS <= 3
799+
#undef TEMP_SENSOR_3
800+
#define TEMP_SENSOR_3 0
801+
#if HOTENDS <= 2
802+
#undef TEMP_SENSOR_2
803+
#define TEMP_SENSOR_2 0
804+
#if HOTENDS <= 1
805+
#undef TEMP_SENSOR_1
806+
#define TEMP_SENSOR_1 0
807+
#if HOTENDS == 0
808+
#undef TEMP_SENSOR_0
809+
#define TEMP_SENSOR_0 0
810+
#undef TEMP_SENSOR_REDUNDANT
811+
#define TEMP_SENSOR_REDUNDANT 0
812+
#endif
813+
#endif
814+
#endif
815+
#endif
816+
#endif
817+
#endif
818+
#endif
819+
#endif
820+
790821
/**
791822
* Number of Linear Axes (e.g., XYZIJKUVW)
792823
* All the logical axes except for the tool (E) axis

Marlin/src/inc/SanityCheck.h

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

646+
#if HAS_CHAMELEON
647+
#if EXTRUDERS > 32
648+
#undef SINGLENOZZLE
649+
#error "CHAMELEON only supports up to 32 EXTRUDERS. Please update your Configuration."
650+
#endif
651+
#endif
652+
646653
/**
647654
* Options only for EXTRUDERS > 1
648655
*/
649656
#if HAS_MULTI_EXTRUDER
650657

651658
#ifndef MAX_EXTRUDERS
652-
#if HAS_EXTENDABLE_MMU
659+
#if HAS_CHAMELEON
660+
#define MAX_EXTRUDERS 32
661+
#elif HAS_EXTENDABLE_MMU
653662
#define MAX_EXTRUDERS 15
654663
#else
655664
#define MAX_EXTRUDERS 8

0 commit comments

Comments
 (0)