Hey All,

Calling all gCode experts I am having some strange gCode issues and would really appreciate some help. Please note I am still a gCode noob!

I found some gCode online to "automate" filament changes on the Ender 3. So basically you have a filament unload "script" and a filament load "script".

First attempt:

***Filament Unload GCode***
M109 S215.000 ;Heat hotend to 215C for PLA
G28 ; home all axes (X, Y, and Z)
G1 Z100 F200 ; lift nozzle 100mm
G21 ;Let the printer know you are following this point with metric values
G91 ;Let the printer know you are using relative positioning
M300 S880 P300 ; Play tone
M300 S660 P250 ; Play tone
M300 S440 P200 ; Play tone
G92 E0 ;Reset the position of the extruder
G1 E10 F100 ; Extrude a short distance before unloading to avoid blob forming
M400; Wait for command to finish
G92 E0 ;Reset the position of the extruder
G1 E-400 F1000 ;Retract 400 mm of filament at 500--2000 mm/minute speed, change 700 to the lenght of your bowdentube + 100 mm.
G1 E-100 F500 ;Retract 100 mm of filament at 500--2000 mm/minute speed, change 700 to the lenght of your bowdentube + 100 mm.
M400; Wait for command to finish
G92 E0 ;Reset the position of the extruder
G90 ; Set absolute positioning
M400; Wait for command to finish
M117 REMOVE FILAMENT ;Display message on LCD-display to remove the filament
M104 S0; Set Hot-end to 0C (off)
M140 S0; Set bed to 0C (off)

***Filament Load GCode***
M109 S215.000 ;Heat hotend to 215C
G28 ; home all axes (X, Y, and Z)
G1 Z100 F200 ; lift nozzle 100mm
G21 ;Let the printer know you are following this point with metric values
G91 ;Let the printer know you are using relative positioning
M92 E415 ; Set esteps for Bondtech BMG *****
M300 S440 P200 ; Play tone
M300 S660 P250 ; Play tone
M300 S880 P300 ; Play tone
G4 S5 ; wait 5 seconds
M117 LOADING FILAMENT...
G92 E0 ;Reset the position of the extruder
G1 E150 F500 ;Feed 150 mm of filament at 500 mm/minute speed. Fast move.
M400; Wait for command to finish
G92 E0 ;Reset the position of the extruder
G1 E30 F100 ;Feed 30 mm of filament at 100 mm/minute speed. Slow move.
M400; Wait for command to finish
G92 E0 ;Reset the position of the extruder
G90 ; Set absolute positioning
M400; finish move
M117 NEW FILAMENT LOADED ;Display message on LCD-display
M104 S0; Set Hot-end to 0C (off)
M140 S0; Set bed to 0C (off)
M999 ; Reboot printer

So let me explain what the problem is with the first attempt. Everything works very well, it unloads the filament successfully, then I insert new filament and run the LOAD GCode. It loads perfectly as expected. Then, when I start a new print, it over extrudes a lot and the print will fail. I then have to reboot the Ender 3 - and then my extrusion is perfect again. So I am trying to figure out why these scripts are causing this over extrusion issue once it's done and starting a new print.

I then decided to create one Script that will both Unload and Load filament with a "pause" in the middle.

Second attempt:
;UNLOAD FILAMENT
M109 S215 ;Heat hotend to 215C
G28 ; home all axes (X, Y, and Z)
G1 Z50 F300 ; lift nozzle 50mm
G91 ;Let the printer know you are using relative positioning
M300 S880 P300 ; Play tone
M300 S660 P250 ; Play tone
M300 S440 P200 ; Play tone
G1 E10 F100 ; Extrude a short distance before unloading to avoid blob forming
M400; Wait for command to finish
G1 E-400 F1000 ;Retract 400 mm of filament fast
G1 E-100 F500 ;Retract 100 mm of filament slow
M400; Wait for command to finish
M0 ; pause and wait for user input

;LOAD FILAMENT
M300 S440 P200 ; Play tone
M300 S660 P250 ; Play tone
M300 S880 P300 ; Play tone
G4 S1 ; wait 1 seconds
M117 LOADING FILAMENT
G1 E400 F1000 ;Feed 400 mm of filament at 1000 mm/minute speed. Fast move.
M400; Wait for command to finish
G1 E150 F100 ;Feed 150 mm of filament at 100 mm/minute speed. Slow move.
M400; Wait for command to finish
M117 NEW FILAMENT LOADED ;Display message on LCD-display
G90 ; Set absolute positioning
M104 S0; Set Hot-end to 0C (off)
M140 S0; Set bed to 0C (off)

So here is what I found with my second attempt:

The first part works perfectly, it heats up, lifts the nozzle, then it removes the filament. Then it pauses - so all good.
I then load the new filament and press enter on the printer to resume. It then continues but the "G1 E400 F1000" line that follows the pause starts, but it extrudes EXTREMELY SLOWLY - like it takes 5 minutes just for the filament to reach the hot end. I have NO idea why this is extruding soooo slowly..

Any help will be greatly appreciated.

Thanks!!
Ruan