Notifications
Clear all

GCode for filament switch?  

  RSS
jamesan
(@jamesan)
Active Member
GCode for filament switch?

Hello, does someone have the example gcode snippet to trigger the MMU3 (on Mk4s) to unload the current filament and load another?   I wrote a program that is supposed to randomly change the MMU3 filament every layer.  The trick is I do not want to wipe at all.  I intend for the colors to slowly blend from one to another.  (For a one perimeter thick light diffuser) The gcode injects correctly but I am doing something wrong because the printer fails to extrude at all even though the code up through the first layer is unchanged.  I use T# to effectuate the filament switch. I’ve also seen M600 suggested but haven’t tried it yet.  I’m stuck somewhere for a couple hours with only my phone but I’ll try to upload original and modified gcode later.  Thank you.

Posted : 24/05/2025 6:20 pm
jamesan
(@jamesan)
Active Member
Topic starter answered:
RE: GCode for filament switch?

 

 toolchange_gcode = f""";

This is the Python template that is filled out and inserted when the RNG decides it is time to change filaments.

toolchange_gcode = f"""
; RANDOMIZED TOOLCHANGE START 
; Switching from T{from_extruder} to T{to_extruder} 

M220 B
M220 S100

; TOOLCHANGE UNLOAD
G1 E-15.0000 F6000  ; Retract filament safely
G1 E-28.0000
G1 E-8.0000 F3000
G1 E-4.0000 F1800
G1 E-55.0000 F6000
G4 S0
M104 S220

M900 K0  ; Disable Linear Advance temporarily
; Filament-specific end gcode
T{to_extruder}
M572 S0.036 ; Filament gcode

M104 S220  ; Set new filament temp

G4 S0
M591 R  ; Resume filament sensor
G4 S0
; Load new filament
G1 E6.4000 F3000

; Resume printing directly after tool change
M220 R
G1 F18000
G4 S0
G92 E0

; RANDOMIZED TOOLCHANGE END
"""
Posted : 24/05/2025 9:30 pm
Share: