This article is part of the Prusa XL Technical Series on INVESTEGATE.de
All guides assume that the Prusa XL Fundamentals are correct.
If not, start here:
Prusa XL Basics – Technical Fundamentals

ScrubbyXL is a reliability-focused nozzle cleaning mod for the Prusa XL. It adds an automatic wipe before Mesh Bed Leveling (MBL) and optional nozzle wipes during printing (triggered via G-code), helping prevent filament buildup on the nozzle tip—especially on long prints where small residue can snowball into defects or failures.
Why ScrubbyXL Exists
Nozzle tip contamination is one of those problems that often starts small and ends in a ruined print. A tiny blob, some PETG residue, or slightly burnt material can stick to the nozzle and later get dragged across the first layer, interfere with probing, or eventually cause surface defects and collisions on long jobs.
ScrubbyXL addresses this with a simple idea: don’t wait for the problem to show up—wipe proactively. The first part happens before MBL: by adding a small tweak to your Start G-code, the nozzle is wiped clean so it can probe the bed in a cleaner state. The goal is not “more leveling”, but more consistent conditions while leveling, which helps the first layer start off right.
The second part is for long prints. ScrubbyXL can be triggered during printing at a user-defined interval (for example, every N layers) using G-code integrated in your slicer settings. This helps reduce the gradual buildup that otherwise accumulates over many hours and can eventually cause a print to fail late in the job.
Versions & configuration
To fit different setups, ScrubbyXL comes in multiple variants:
- Mounting hole sizes: M3 / M4 / M5.
- Silicone brush sizes: A1 or A1 mini.
- Mounting options: magnetic (magnets inserted during the print or glued in later) or a fixed, fully screwed version without magnets.
My recommended setup is the magnetic version with inserted magnets and the A1 mini brush. Magnetic mounting is especially practical because you may want to remove the brush quickly—particularly on the right side where Tool 5 loads/unloads above that area. For the best wiping result, I recommend installing wipers on both sides, but you can also run only one side and adjust the G-code accordingly.
Download the ScrubbyXL Mod for the Prusa XL on Printables
What to expect
G-Codes
Start G-code changes
- Integrated the nozzle-clean / wipe routine so the nozzle is mechanically cleaned as part of startup.
- Adjusted the tool wait for temp position to the front to to make it easier to clean the nozzle manually.
- Added an audible beep indicator (beeps before the nozzle wipe and before the purge line) for better feedback during startup.
- Commented out
G29 P9, because it drives the temperature too high right before MBL. - Shifted the purge line for the first and last tool by 3 mm to avoid any contact with the brush mod.
- Reworked Surfalex2000’s brass brush-mod G-code to improve the cleaning result (more reliable wipe behavior).
Optimized and fixed Prusa XL full start gcode for the ScrubbyXL
Start G-Code for the Prusa XL (5TH)
M17 ; enable steppers
M862.3 P "XL" ; printer model check
M862.5 P2 ; g-code level check
M862.6 P"Input shaper" ; FW feature check
M115 U6.4.0+11974
G90 ; use absolute coordinates
M83 ; extruder relative mode
; set print area
M555 X{first_layer_print_min[0]} Y{first_layer_print_min[1]} W{(first_layer_print_max[0]) - (first_layer_print_min[0])} H{(first_layer_print_max[1]) - (first_layer_print_min[1])}
; inform about nozzle diameter
{if (is_extruder_used[0])}M862.1 T0 P{nozzle_diameter[0]} A{(filament_abrasive[0] ? 1 : 0)} F{(nozzle_high_flow[0] ? 1 : 0)}{endif}
{if (is_extruder_used[1])}M862.1 T1 P{nozzle_diameter[1]} A{(filament_abrasive[1] ? 1 : 0)} F{(nozzle_high_flow[1] ? 1 : 0)}{endif}
{if (is_extruder_used[2])}M862.1 T2 P{nozzle_diameter[2]} A{(filament_abrasive[2] ? 1 : 0)} F{(nozzle_high_flow[2] ? 1 : 0)}{endif}
{if (is_extruder_used[3])}M862.1 T3 P{nozzle_diameter[3]} A{(filament_abrasive[3] ? 1 : 0)} F{(nozzle_high_flow[3] ? 1 : 0)}{endif}
{if (is_extruder_used[4])}M862.1 T4 P{nozzle_diameter[4]} A{(filament_abrasive[4] ? 1 : 0)} F{(nozzle_high_flow[4] ? 1 : 0)}{endif}
; turn off unused heaters
{if ! is_extruder_used[0]}M104 T0 S0{endif}
{if ! is_extruder_used[1]}M104 T1 S0{endif}
{if num_extruders > 2 and ! is_extruder_used[2]}M104 T2 S0{endif}
{if num_extruders > 3 and ! is_extruder_used[3]}M104 T3 S0{endif}
{if num_extruders > 4 and ! is_extruder_used[4]}M104 T4 S0{endif}
M217 Z{max(zhop, 2.0)} ; set toolchange z hop to 2mm, or zhop variable from slicer if higher
; set bed and extruder temp for MBL
M140 S[first_layer_bed_temperature] ; set bed temp
M104 T{initial_tool} S{((filament_notes[initial_tool]=~/.*MBL160.*/) ? 160 : (filament_notes[initial_tool]=~/.*HT_MBL10.*/) ? (first_layer_temperature[initial_tool] - 10) : (filament_type[initial_tool] == "PC" or filament_type[initial_tool] == "PA") ? (first_layer_temperature[initial_tool] - 25) : (filament_type[initial_tool] == "FLEX") ? 210 : (filament_type[initial_tool]=~/.*PET.*/) ? 175 : 170)} ; set temp
; Home XY
G28 XY
; try picking tools used in print
G1 F{travel_speed * 60}
{if (is_extruder_used[0]) and (initial_tool != 0)}T0 S1 L0 D0{endif}
{if (is_extruder_used[1]) and (initial_tool != 1)}T1 S1 L0 D0{endif}
{if (is_extruder_used[2]) and (initial_tool != 2)}T2 S1 L0 D0{endif}
{if (is_extruder_used[3]) and (initial_tool != 3)}T3 S1 L0 D0{endif}
{if (is_extruder_used[4]) and (initial_tool != 4)}T4 S1 L0 D0{endif}
; select tool that will be used to home & MBL
T{initial_tool} S1 L0 D0
; HERE THE TOOL HAS TO WAIT PURELY BECAUSE OF SILICONE BRUSH
G1 Z30
G1 X145 Y-8 F{travel_speed * 60}
M109 T{initial_tool} S{((filament_notes[initial_tool]=~/.*MBL160.*/) ? 160 : (filament_notes[initial_tool]=~/.*HT_MBL10.*/) ? (first_layer_temperature[initial_tool] - 10) : (filament_type[initial_tool] == "PC" or filament_type[initial_tool] == "PA") ? (first_layer_temperature[initial_tool] - 25) : (filament_type[initial_tool] == "FLEX") ? 210 : (filament_type[initial_tool]=~/.*PET.*/) ? 175 : 170)} ; wait for temp
; home Z with MBL tool
M84 E ; turn off E motor
G28 Z
G0 Z5 ; add Z clearance
; HERE THE TOOL HAS TO WAIT PURELY BECAUSE OF SILICONE BRUSH
G1 Z30
G1 X145 Y-8 F{travel_speed * 60}
M104 T{initial_tool} S{if is_nil(idle_temperature[initial_tool])}70{else}{idle_temperature[initial_tool]}{endif} ; set idle temp
M190 S[first_layer_bed_temperature] ; wait for bed temp
G29 G ; absorb heat
M109 T{initial_tool} S{((filament_notes[initial_tool]=~/.*MBL160.*/) ? 160 : (filament_notes[initial_tool]=~/.*HT_MBL10.*/) ? (first_layer_temperature[initial_tool] - 10) : (filament_type[initial_tool] == "PC" or filament_type[initial_tool] == "PA") ? (first_layer_temperature[initial_tool] - 25) : (filament_type[initial_tool] == "FLEX") ? 210 : (filament_type[initial_tool]=~/.*PET.*/) ? 175 : 170)} ; wait for temp
M300 S800 P200. ; PIEP indicator
; move to the nozzle cleanup area
; nozzle cleanup FOR LEFT AND RIGHT SILICONE WIPER
M302 S155 ; lower cold extrusion limit to 155C
G1 E{-(filament_type[0] == "FLEX" ? 4 : 2)} F2400 ; retraction for nozzle cleanup
M84 E ; turn off E motor
; --- Start Nozzle Wipe
G1 Z5 ; Move bed out of the way
{if initial_tool == 0 or initial_tool == 1 }
; --- Start Nozzle Wipe LEFT ---
G1 X-2 Y-8 F24000 ; Move to start of wipe area
G1 X28 Y-8 F24000 ; Wipe pass 1
G1 X-2 Y-7.5 F24000 ; Reposition
G1 X28 Y-7.5 F24000 ; Wipe pass 2
G1 X-2 Y-7 F24000 ; Reposition
G1 X28 Y-7 F24000 ; Wipe pass 3
G1 X-2 Y-6.5 F24000 ; Reposition
G1 X28 Y-6.5 F24000 ; Wipe pass 4
G1 X-2 Y-6 F24000 ; Reposition
G1 X28 Y-6 F24000 ; Wipe pass 5
G1 X-2 Y-6.5 F24000 ; Reposition
G1 X28 Y-6.5 F24000 ; Wipe pass 6
G1 X-2 Y-7 F24000 ; Reposition
G1 X28 Y-7 F24000 ; Wipe pass 7
G1 X-2 Y-7.5 F24000 ; Reposition
G1 X28 Y-7.5 F24000 ; Wipe pass 8
G1 X-2 Y-8 F24000 ; Reposition
G1 X28 Y-8 F24000 ; Wipe pass 9
; --- End Nozzle Wipe LEFT ---
{else}
; --- Start Nozzle Wipe RIGHT ---
G1 X332 Y-8 F24000 ; Move to start of wipe area
G1 X361 Y-8 F24000 ; Wipe pass 1
G1 X332 Y-7.5 F24000 ; Reposition
G1 X361 Y-7.5 F24000 ; Wipe pass 2
G1 X332 Y-7 F24000 ; Reposition
G1 X361 Y-7 F24000 ; Wipe pass 3
G1 X332 Y-6.5 F24000 ; Reposition
G1 X361 Y-6.5 F24000 ; Wipe pass 4
G1 X332 Y-6 F24000 ; Reposition
G1 X361 Y-6 F24000 ; Wipe pass 5
G1 X332 Y-6.5 F24000 ; Reposition
G1 X361 Y-6.5 F24000 ; Wipe pass 6
G1 X332 Y-7 F24000 ; Reposition
G1 X361 Y-7 F24000 ; Wipe pass 7
G1 X332 Y-7.5 F24000 ; Reposition
G1 X361 Y-7.5 F24000 ; Wipe pass 8
G1 X332 Y-8 F24000 ; Reposition
G1 X361 Y-8 F24000 ; Wipe pass 9
; --- End Nozzle Wipe RIGHT ---
{endif}
G1 X{(min(((((first_layer_print_min[0] + first_layer_print_max[0]) / 2) < ((print_bed_min[0] + print_bed_max[0]) / 2)) ? (((first_layer_print_min[1] - 7) < -2) ? 70 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)) : (((first_layer_print_min[1] - 7) < -2) ? 260 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32))), first_layer_print_min[0])) + 32} Y{(min((first_layer_print_min[1] - 7), first_layer_print_min[1]))} Z{5} F{(travel_speed * 60)}
; nozzle cleanup
;Commented out below because it sets the temperature too high in front of the MBL.
;G29 P9 X{((((first_layer_print_min[0] + first_layer_print_max[0]) / 2) < ((print_bed_min[0] + print_bed_max[0]) / 2)) ? (((first_layer_print_min[1] - 7) < -2) ? 70 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)) : (((first_layer_print_min[1] - 7) < -2) ? 260 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)))} Y{(first_layer_print_min[1] - 7)} W{32} H{7}
M107 ; turn off the fan
; MBL
M84 E ; turn off E motor
G29 P1 ; invalidate mbl & probe print area
G29 P1 X30 Y0 W{(((is_extruder_used[4]) or ((is_extruder_used[3]) or (is_extruder_used[2]))) ? "300" : ((is_extruder_used[1]) ? "130" : "50"))} H20 C ; probe near purge place
G29 P3.2 ; interpolate mbl probes
G29 P3.13 ; extrapolate mbl outside probe area
G29 A ; activate mbl
G1 Z10 F720 ; move away in Z
G1 F{travel_speed * 60}
P0 S1 L1 D0; park the tool
; set extruder temp
{if first_layer_temperature[0] > 0 and (is_extruder_used[0])}M104 T0 S{first_layer_temperature[0]}{endif}
{if first_layer_temperature[1] > 0 and (is_extruder_used[1])}M104 T1 S{first_layer_temperature[1]}{endif}
{if first_layer_temperature[2] > 0 and (is_extruder_used[2])}M104 T2 S{first_layer_temperature[2]}{endif}
{if first_layer_temperature[3] > 0 and (is_extruder_used[3])}M104 T3 S{first_layer_temperature[3]}{endif}
{if first_layer_temperature[4] > 0 and (is_extruder_used[4])}M104 T4 S{first_layer_temperature[4]}{endif}
{if (is_extruder_used[0]) and initial_tool != 0}
M591 S0 ; disable stuck detection
; Ready to print melody, before purging
M300 S1200 P150
G4 P200
M300 S1500 P150
G4 P200
M300 S1800 P300
G4 P500
;
; purge first tool
; Edited. X position changed from 30 to 33 due to silicone brush.
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T0 S{first_layer_temperature[0]}
T0 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X33 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[0])}10{else}30{endif} X40 Z0.2 F{if is_nil(filament_multitool_ramming[0])}500{else}170{endif} ; purge while moving towards the sheet
G0 X70 E9 F800 ; continue purging and wipe the nozzle
G0 X73 Z0.05 F8000 ; wipe, move close to the bed
G0 X76 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[0]} F2400 ; retract
{e_retracted[0] = retract_length_toolchange[0]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[0]) ? (first_layer_temperature[0] + standby_temperature_delta) : (idle_temperature[0]))} T0
{endif}
{if (is_extruder_used[1]) and initial_tool != 1}
;
; purge second tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T1 S{first_layer_temperature[1]}
T1 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X150 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[1])}10{else}30{endif} X140 Z0.2 F{if is_nil(filament_multitool_ramming[1])}500{else}170{endif} ; purge while moving towards the sheet
G0 X110 E9 F800 ; continue purging and wipe the nozzle
G0 X107 Z0.05 F8000 ; wipe, move close to the bed
G0 X104 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[1]} F2400 ; retract
{e_retracted[1] = retract_length_toolchange[1]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[1]) ? (first_layer_temperature[1] + standby_temperature_delta) : (idle_temperature[1]))} T1
{endif}
{if (is_extruder_used[2]) and initial_tool != 2}
;
; purge third tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T2 S{first_layer_temperature[2]}
T2 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X210 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[2])}10{else}30{endif} X220 Z0.2 F{if is_nil(filament_multitool_ramming[2])}500{else}170{endif} ; purge while moving towards the sheet
G0 X250 E9 F800 ; continue purging and wipe the nozzle
G0 X253 Z0.05 F8000 ; wipe, move close to the bed
G0 X256 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[2]} F2400 ; retract
{e_retracted[2] = retract_length_toolchange[2]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[2]) ? (first_layer_temperature[2] + standby_temperature_delta) : (idle_temperature[2]))} T2
{endif}
{if (is_extruder_used[3]) and initial_tool != 3}
;
; purge fourth tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T3 S{first_layer_temperature[3]}
T3 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X327 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[3])}10{else}30{endif} X320 Z0.2 F{if is_nil(filament_multitool_ramming[3])}500{else}170{endif} ; purge while moving towards the sheet
G0 X290 E9 F800 ; continue purging and wipe the nozzle
G0 X287 Z0.05 F8000 ; wipe, move close to the bed
G0 X284 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[3]} F2400 ; retract
{e_retracted[3] = retract_length_toolchange[3]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[3]) ? (first_layer_temperature[3] + standby_temperature_delta) : (idle_temperature[3]))} T3
{endif}
{if (is_extruder_used[4]) and initial_tool != 4}
;
; purge fifth tool
; Edited. X position for TOOL 4 changed from 330 to 327 due to silicone brush.
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T4 S{first_layer_temperature[4]}
T4 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X327 Y-4.5 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[4])}10{else}30{endif} X320 Z0.2 F{if is_nil(filament_multitool_ramming[4])}500{else}170{endif} ; purge while moving towards the sheet
G0 X290 E9 F800 ; continue purging and wipe the nozzle
G0 X287 Z0.05 F8000 ; wipe, move close to the bed
G0 X284 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[4]} F2400 ; retract
{e_retracted[4] = retract_length_toolchange[4]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[4]) ? (first_layer_temperature[4] + standby_temperature_delta) : (idle_temperature[4]))} T4
{endif}
;
; purge initial tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T{initial_tool} S{first_layer_temperature[initial_tool]}
T{initial_tool} S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
; Edited. X position for TOOL 0 changed from 30 to 33 due to silicone brush.
; Edited. X position for TOOL 4 changed from 330 to 327 due to silicone brush.
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327)))} Y{(initial_tool < 4 ? -7 : -4.5)} Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[initial_tool])}10{else}30{endif} X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 10)} Z0.2 F{if is_nil(filament_multitool_ramming[initial_tool])}500{else}170{endif} ; purge while moving towards the sheet
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 40)} E9 F800 ; continue purging and wipe the nozzle
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 40) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 3)} Z{0.05} F{8000} ; wipe, move close to the bed
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 40) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 3 * 2)} Z0.2 F{8000} ; wipe, move quickly away from the bed
G1 E-{retract_length[initial_tool]} F2400 ; retract
{e_retracted[initial_tool] = retract_length[initial_tool]}
M591 R ; restore stuck detection
G92 E0 ; reset extruder position
Before Layer Change G-code
During printing, the nozzle is automatically cleaned every X layer)
Before Layer Change G-code
;BEFORE_LAYER_CHANGE
G92 E0.0
;[layer_z]
; During printing, the nozzle is automatically cleaned every X layer. (X = 400 layers)
; --- Every 400 layers: automatic wipe ---
{if layer_num > 0 && layer_num % 400 == 0}
; Save current position (Buddy FW)
G1 F{travel_speed * 100}
G60 S0 ; store current XYZ position
M300 S300 P200. ; PIEP indicator
; Lift Z a bit for safety
G1 Z{layer_z + 5} F1000
; --- Start Nozzle Wipe ---
{if initial_tool == 0 or initial_tool == 1 }
; --- Start Nozzle Wipe LEFT ---
G1 X-2 Y-8 F24000
G1 X28 Y-8 F24000
G1 X-2 Y-7.5 F24000
G1 X28 Y-7.5 F24000
G1 X-2 Y-7 F24000
G1 X28 Y-7 F24000
G1 X-2 Y-6.5 F24000
G1 X28 Y-6.5 F24000
G1 X-2 Y-6 F24000
G1 X28 Y-6 F24000
G1 X-2 Y-6.5 F24000
G1 X28 Y-6.5 F24000
G1 X-2 Y-7 F24000
G1 X28 Y-7 F24000
G1 X-2 Y-7.5 F24000
G1 X28 Y-7.5 F24000
G1 X-2 Y-8 F24000
G1 X28 Y-8 F24000
; --- End Nozzle Wipe LEFT ---
{else}
; --- Start Nozzle Wipe RIGHT ---
G1 X332 Y-8 F24000
G1 X361 Y-8 F24000
G1 X332 Y-7.5 F24000
G1 X361 Y-7.5 F24000
G1 X332 Y-7 F24000
G1 X361 Y-7 F24000
G1 X332 Y-6.5 F24000
G1 X361 Y-6.5 F24000
G1 X332 Y-6 F24000
G1 X361 Y-6 F24000
G1 X332 Y-6.5 F24000
G1 X361 Y-6.5 F24000
G1 X332 Y-7 F24000
G1 X361 Y-7 F24000
G1 X332 Y-7.5 F24000
G1 X361 Y-7.5 F24000
G1 X332 Y-8 F24000
G1 X361 Y-8 F24000
; --- End Nozzle Wipe RIGHT ---
{endif}
; --- End Nozzle Wipe ---
; Restore position
G61 S0 ; restore stored XYZ position
{endif}
Bonus: Print Finish Sound
Plays a short finishing melody.
End G-Code
G4 ; wait
{if layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+5, max_print_height)}{endif} ; Move bed down
P0 S1 ; park tool
{if layer_z < max_print_height}G1 Z{z_offset+min(max_layer_z+97, max_print_height)} F300{endif} ; Move bed further down
; turn off extruder heaters
{if is_extruder_used[0]}M104 T0 S0{endif}
{if is_extruder_used[1]}M104 T1 S0{endif}
{if is_extruder_used[2]}M104 T2 S0{endif}
{if is_extruder_used[3]}M104 T3 S0{endif}
{if is_extruder_used[4]}M104 T4 S0{endif}
M140 S0 ; turn off heatbed
M107 ; turn off fan
M221 S100 ; reset flow percentage
M84 ; disable motors
;Finishing melody
M300 S1200 P150
G4 P200
M300 S1500 P150
G4 P200
M300 S1800 P300
G4 P500
M77 ; stop print timer
; max_layer_z = [max_layer_z]
Optional: Additional MBL brass brush mod from Surfalex2000
If you also want to use the MBL brass brush mod from @Surfalex2000:
Start G-Code for the Prusa XL (5TH)
M17 ; enable steppers
M862.3 P "XL" ; printer model check
M862.5 P2 ; g-code level check
M862.6 P"Input shaper" ; FW feature check
M115 U6.4.0+11974
G90 ; use absolute coordinates
M83 ; extruder relative mode
; set print area
M555 X{first_layer_print_min[0]} Y{first_layer_print_min[1]} W{(first_layer_print_max[0]) - (first_layer_print_min[0])} H{(first_layer_print_max[1]) - (first_layer_print_min[1])}
; inform about nozzle diameter
{if (is_extruder_used[0])}M862.1 T0 P{nozzle_diameter[0]} A{(filament_abrasive[0] ? 1 : 0)} F{(nozzle_high_flow[0] ? 1 : 0)}{endif}
{if (is_extruder_used[1])}M862.1 T1 P{nozzle_diameter[1]} A{(filament_abrasive[1] ? 1 : 0)} F{(nozzle_high_flow[1] ? 1 : 0)}{endif}
{if (is_extruder_used[2])}M862.1 T2 P{nozzle_diameter[2]} A{(filament_abrasive[2] ? 1 : 0)} F{(nozzle_high_flow[2] ? 1 : 0)}{endif}
{if (is_extruder_used[3])}M862.1 T3 P{nozzle_diameter[3]} A{(filament_abrasive[3] ? 1 : 0)} F{(nozzle_high_flow[3] ? 1 : 0)}{endif}
{if (is_extruder_used[4])}M862.1 T4 P{nozzle_diameter[4]} A{(filament_abrasive[4] ? 1 : 0)} F{(nozzle_high_flow[4] ? 1 : 0)}{endif}
; turn off unused heaters
{if ! is_extruder_used[0]}M104 T0 S0{endif}
{if ! is_extruder_used[1]}M104 T1 S0{endif}
{if num_extruders > 2 and ! is_extruder_used[2]}M104 T2 S0{endif}
{if num_extruders > 3 and ! is_extruder_used[3]}M104 T3 S0{endif}
{if num_extruders > 4 and ! is_extruder_used[4]}M104 T4 S0{endif}
M217 Z{max(zhop, 2.0)} ; set toolchange z hop to 2mm, or zhop variable from slicer if higher
; set bed and extruder temp for MBL
M140 S[first_layer_bed_temperature] ; set bed temp
M104 T{initial_tool} S{((filament_notes[initial_tool]=~/.*MBL160.*/) ? 160 : (filament_notes[initial_tool]=~/.*HT_MBL10.*/) ? (first_layer_temperature[initial_tool] - 10) : (filament_type[initial_tool] == "PC" or filament_type[initial_tool] == "PA") ? (first_layer_temperature[initial_tool] - 25) : (filament_type[initial_tool] == "FLEX") ? 210 : (filament_type[initial_tool]=~/.*PET.*/) ? 175 : 170)} ; set temp
; Home XY
G28 XY
; try picking tools used in print
G1 F{travel_speed * 60}
{if (is_extruder_used[0]) and (initial_tool != 0)}T0 S1 L0 D0{endif}
{if (is_extruder_used[1]) and (initial_tool != 1)}T1 S1 L0 D0{endif}
{if (is_extruder_used[2]) and (initial_tool != 2)}T2 S1 L0 D0{endif}
{if (is_extruder_used[3]) and (initial_tool != 3)}T3 S1 L0 D0{endif}
{if (is_extruder_used[4]) and (initial_tool != 4)}T4 S1 L0 D0{endif}
; select tool that will be used to home & MBL
T{initial_tool} S1 L0 D0
; HERE THE TOOL HAS TO WAIT PURELY BECAUSE OF SILICONE BRUSH
G1 Z30
G1 X145 Y-8 F{travel_speed * 60}
M109 T{initial_tool} S{((filament_notes[initial_tool]=~/.*MBL160.*/) ? 160 : (filament_notes[initial_tool]=~/.*HT_MBL10.*/) ? (first_layer_temperature[initial_tool] - 10) : (filament_type[initial_tool] == "PC" or filament_type[initial_tool] == "PA") ? (first_layer_temperature[initial_tool] - 25) : (filament_type[initial_tool] == "FLEX") ? 210 : (filament_type[initial_tool]=~/.*PET.*/) ? 175 : 170)} ; wait for temp
; home Z with MBL tool
M84 E ; turn off E motor
G28 Z
G0 Z5 ; add Z clearance
; HERE THE TOOL HAS TO WAIT PURELY BECAUSE OF SILICONE BRUSH
G1 Z30
G1 X145 Y-8 F{travel_speed * 60}
M104 T{initial_tool} S{if is_nil(idle_temperature[initial_tool])}70{else}{idle_temperature[initial_tool]}{endif} ; set idle temp
M190 S[first_layer_bed_temperature] ; wait for bed temp
G29 G ; absorb heat
M109 T{initial_tool} S{((filament_notes[initial_tool]=~/.*MBL160.*/) ? 160 : (filament_notes[initial_tool]=~/.*HT_MBL10.*/) ? (first_layer_temperature[initial_tool] - 10) : (filament_type[initial_tool] == "PC" or filament_type[initial_tool] == "PA") ? (first_layer_temperature[initial_tool] - 25) : (filament_type[initial_tool] == "FLEX") ? 210 : (filament_type[initial_tool]=~/.*PET.*/) ? 175 : 170)} ; wait for temp
M300 S800 P200. ; PIEP indicator
; move to the nozzle cleanup area
; Surfalex2000 Nozzle Brush Mount on Printables
; https://www.printables.com/model/644817-prusa-xl-series-front-nozzle-srcubber-for-use-with
G1 E-10 F2400 ; more retraction to compensate oozing before nozzle cleanup
; Start surfalex2000 nozzle brush cycle
; --- Start nozzle brush cycle (speed ramp) ---
G1 X160 Y-5 Z5 F8000
G1 X160 Y-5 Z1 F8000
; --- Zyklus 1 (langsam) ---
G1 X200 Y-5 F8000
G1 X200 Y-4
G1 X160 Y-4
G1 X160 Y-6
G1 X200 Y-6
G1 X200 Y-5
G1 X160 Y-5
; --- Zyklus 2 (mittel) ---
G1 X200 Y-5 F14000
G1 X200 Y-4
G1 X160 Y-4
G1 X160 Y-6
G1 X200 Y-6
G1 X200 Y-5
G1 X160 Y-5
; --- Zyklus 3 (schnell) ---
G1 X200 Y-5 F16000
G1 X200 Y-4
G1 X160 Y-4
G1 X160 Y-6
G1 X200 Y-6
G1 X200 Y-5
G1 X160 Y-5
; --- Zyklus 4 (schnell) ---
G1 X200 Y-5 F20000
G1 X200 Y-4
G1 X160 Y-4
G1 X160 Y-6
G1 X200 Y-6
G1 X200 Y-5
G1 X160 Y-5
G1 X160 Y-5 Z5 F20000 ; nozzle brush cycle
; End surfalex2000 nozzle brush cycle
; nozzle cleanup FOR LEFT AND RIGHT SILICONE WIPER
M302 S155 ; lower cold extrusion limit to 155C
G1 E{-(filament_type[0] == "FLEX" ? 4 : 2)} F2400 ; retraction for nozzle cleanup
M84 E ; turn off E motor
; --- Start Nozzle Wipe
G1 Z5 ; Move bed out of the way
{if initial_tool == 0 or initial_tool == 1 }
; --- Start Nozzle Wipe LEFT ---
G1 X-2 Y-8 F24000 ; Move to start of wipe area
G1 X28 Y-8 F24000 ; Wipe pass 1
G1 X-2 Y-7.5 F24000 ; Reposition
G1 X28 Y-7.5 F24000 ; Wipe pass 2
G1 X-2 Y-7 F24000 ; Reposition
G1 X28 Y-7 F24000 ; Wipe pass 3
G1 X-2 Y-6.5 F24000 ; Reposition
G1 X28 Y-6.5 F24000 ; Wipe pass 4
G1 X-2 Y-6 F24000 ; Reposition
G1 X28 Y-6 F24000 ; Wipe pass 5
G1 X-2 Y-6.5 F24000 ; Reposition
G1 X28 Y-6.5 F24000 ; Wipe pass 6
G1 X-2 Y-7 F24000 ; Reposition
G1 X28 Y-7 F24000 ; Wipe pass 7
G1 X-2 Y-7.5 F24000 ; Reposition
G1 X28 Y-7.5 F24000 ; Wipe pass 8
G1 X-2 Y-8 F24000 ; Reposition
G1 X28 Y-8 F24000 ; Wipe pass 9
; --- End Nozzle Wipe LEFT ---
{else}
; --- Start Nozzle Wipe RIGHT ---
G1 X332 Y-8 F24000 ; Move to start of wipe area
G1 X361 Y-8 F24000 ; Wipe pass 1
G1 X332 Y-7.5 F24000 ; Reposition
G1 X361 Y-7.5 F24000 ; Wipe pass 2
G1 X332 Y-7 F24000 ; Reposition
G1 X361 Y-7 F24000 ; Wipe pass 3
G1 X332 Y-6.5 F24000 ; Reposition
G1 X361 Y-6.5 F24000 ; Wipe pass 4
G1 X332 Y-6 F24000 ; Reposition
G1 X361 Y-6 F24000 ; Wipe pass 5
G1 X332 Y-6.5 F24000 ; Reposition
G1 X361 Y-6.5 F24000 ; Wipe pass 6
G1 X332 Y-7 F24000 ; Reposition
G1 X361 Y-7 F24000 ; Wipe pass 7
G1 X332 Y-7.5 F24000 ; Reposition
G1 X361 Y-7.5 F24000 ; Wipe pass 8
G1 X332 Y-8 F24000 ; Reposition
G1 X361 Y-8 F24000 ; Wipe pass 9
; --- End Nozzle Wipe RIGHT ---
{endif}
G1 X{(min(((((first_layer_print_min[0] + first_layer_print_max[0]) / 2) < ((print_bed_min[0] + print_bed_max[0]) / 2)) ? (((first_layer_print_min[1] - 7) < -2) ? 70 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)) : (((first_layer_print_min[1] - 7) < -2) ? 260 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32))), first_layer_print_min[0])) + 32} Y{(min((first_layer_print_min[1] - 7), first_layer_print_min[1]))} Z{5} F{(travel_speed * 60)}
; nozzle cleanup
;Commented out below because it sets the temperature too high in front of the MBL.
;G29 P9 X{((((first_layer_print_min[0] + first_layer_print_max[0]) / 2) < ((print_bed_min[0] + print_bed_max[0]) / 2)) ? (((first_layer_print_min[1] - 7) < -2) ? 70 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)) : (((first_layer_print_min[1] - 7) < -2) ? 260 : (min(print_bed_max[0], first_layer_print_min[0] + 32) - 32)))} Y{(first_layer_print_min[1] - 7)} W{32} H{7}
M107 ; turn off the fan
; MBL
M84 E ; turn off E motor
G29 P1 ; invalidate mbl & probe print area
G29 P1 X30 Y0 W{(((is_extruder_used[4]) or ((is_extruder_used[3]) or (is_extruder_used[2]))) ? "300" : ((is_extruder_used[1]) ? "130" : "50"))} H20 C ; probe near purge place
G29 P3.2 ; interpolate mbl probes
G29 P3.13 ; extrapolate mbl outside probe area
G29 A ; activate mbl
G1 Z10 F720 ; move away in Z
G1 F{travel_speed * 60}
P0 S1 L1 D0; park the tool
; set extruder temp
{if first_layer_temperature[0] > 0 and (is_extruder_used[0])}M104 T0 S{first_layer_temperature[0]}{endif}
{if first_layer_temperature[1] > 0 and (is_extruder_used[1])}M104 T1 S{first_layer_temperature[1]}{endif}
{if first_layer_temperature[2] > 0 and (is_extruder_used[2])}M104 T2 S{first_layer_temperature[2]}{endif}
{if first_layer_temperature[3] > 0 and (is_extruder_used[3])}M104 T3 S{first_layer_temperature[3]}{endif}
{if first_layer_temperature[4] > 0 and (is_extruder_used[4])}M104 T4 S{first_layer_temperature[4]}{endif}
{if (is_extruder_used[0]) and initial_tool != 0}
M591 S0 ; disable stuck detection
; Ready to print melody, before purging
M300 S1200 P150
G4 P200
M300 S1500 P150
G4 P200
M300 S1800 P300
G4 P500
;
; purge first tool
; Edited. X position changed from 30 to 33 due to silicone brush.
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T0 S{first_layer_temperature[0]}
T0 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X33 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[0])}10{else}30{endif} X40 Z0.2 F{if is_nil(filament_multitool_ramming[0])}500{else}170{endif} ; purge while moving towards the sheet
G0 X70 E9 F800 ; continue purging and wipe the nozzle
G0 X73 Z0.05 F8000 ; wipe, move close to the bed
G0 X76 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[0]} F2400 ; retract
{e_retracted[0] = retract_length_toolchange[0]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[0]) ? (first_layer_temperature[0] + standby_temperature_delta) : (idle_temperature[0]))} T0
{endif}
{if (is_extruder_used[1]) and initial_tool != 1}
;
; purge second tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T1 S{first_layer_temperature[1]}
T1 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X150 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[1])}10{else}30{endif} X140 Z0.2 F{if is_nil(filament_multitool_ramming[1])}500{else}170{endif} ; purge while moving towards the sheet
G0 X110 E9 F800 ; continue purging and wipe the nozzle
G0 X107 Z0.05 F8000 ; wipe, move close to the bed
G0 X104 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[1]} F2400 ; retract
{e_retracted[1] = retract_length_toolchange[1]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[1]) ? (first_layer_temperature[1] + standby_temperature_delta) : (idle_temperature[1]))} T1
{endif}
{if (is_extruder_used[2]) and initial_tool != 2}
;
; purge third tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T2 S{first_layer_temperature[2]}
T2 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X210 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[2])}10{else}30{endif} X220 Z0.2 F{if is_nil(filament_multitool_ramming[2])}500{else}170{endif} ; purge while moving towards the sheet
G0 X250 E9 F800 ; continue purging and wipe the nozzle
G0 X253 Z0.05 F8000 ; wipe, move close to the bed
G0 X256 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[2]} F2400 ; retract
{e_retracted[2] = retract_length_toolchange[2]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[2]) ? (first_layer_temperature[2] + standby_temperature_delta) : (idle_temperature[2]))} T2
{endif}
{if (is_extruder_used[3]) and initial_tool != 3}
;
; purge fourth tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T3 S{first_layer_temperature[3]}
T3 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X327 Y-7 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[3])}10{else}30{endif} X320 Z0.2 F{if is_nil(filament_multitool_ramming[3])}500{else}170{endif} ; purge while moving towards the sheet
G0 X290 E9 F800 ; continue purging and wipe the nozzle
G0 X287 Z0.05 F8000 ; wipe, move close to the bed
G0 X284 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[3]} F2400 ; retract
{e_retracted[3] = retract_length_toolchange[3]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[3]) ? (first_layer_temperature[3] + standby_temperature_delta) : (idle_temperature[3]))} T3
{endif}
{if (is_extruder_used[4]) and initial_tool != 4}
;
; purge fifth tool
; Edited. X position for TOOL 4 changed from 330 to 327 due to silicone brush.
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T4 S{first_layer_temperature[4]}
T4 S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
G0 X327 Y-4.5 Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[4])}10{else}30{endif} X320 Z0.2 F{if is_nil(filament_multitool_ramming[4])}500{else}170{endif} ; purge while moving towards the sheet
G0 X290 E9 F800 ; continue purging and wipe the nozzle
G0 X287 Z0.05 F8000 ; wipe, move close to the bed
G0 X284 Z0.2 F8000 ; wipe, move quickly away from the bed
G1 E{-retract_length_toolchange[4]} F2400 ; retract
{e_retracted[4] = retract_length_toolchange[4]}
G92 E0 ; reset extruder position
M104 S{(is_nil(idle_temperature[4]) ? (first_layer_temperature[4] + standby_temperature_delta) : (idle_temperature[4]))} T4
{endif}
;
; purge initial tool
;
G1 F{travel_speed * 60}
P0 S1 L2 D0; park the tool
M109 T{initial_tool} S{first_layer_temperature[initial_tool]}
T{initial_tool} S1 L0 D0; pick the tool
G92 E0 ; reset extruder position
; Edited. X position for TOOL 0 changed from 30 to 33 due to silicone brush.
; Edited. X position for TOOL 4 changed from 330 to 327 due to silicone brush.
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327)))} Y{(initial_tool < 4 ? -7 : -4.5)} Z10 F{(travel_speed * 60)} ; move close to the sheet's edge
G0 E{if is_nil(filament_multitool_ramming[initial_tool])}10{else}30{endif} X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 10)} Z0.2 F{if is_nil(filament_multitool_ramming[initial_tool])}500{else}170{endif} ; purge while moving towards the sheet
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 40)} E9 F800 ; continue purging and wipe the nozzle
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 40) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 3)} Z{0.05} F{8000} ; wipe, move close to the bed
G0 X{(initial_tool == 0 ? 33 : (initial_tool == 1 ? 150 : (initial_tool == 2 ? 210 : 327))) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 40) + ((initial_tool == 0 or initial_tool == 2 ? 1 : -1) * 3 * 2)} Z0.2 F{8000} ; wipe, move quickly away from the bed
G1 E-{retract_length[initial_tool]} F2400 ; retract
{e_retracted[initial_tool] = retract_length[initial_tool]}
M591 R ; restore stuck detection
G92 E0 ; reset extruder position



