I have upgraded my ER-20 with a Bondtech dual gear feeder. It is not or hardly possible to load/unload filament manually with this feeder, so some .gcode is needed to do it. I wanted to implement something similar to the atomic cleaning method for unloading: https://ultimakernasupport.zendesk.com/hc/en-us/articles/115004187066-Atomic-Cleaning-Method

Here is my current .gcode:

G21 ; Metric values
G90 ; Absolute positioning
M82 ; Extruder absolute mode
G28 ; Auto home
M420 S1
G1 X100 Y100 Z100 F1000
; M92 E415 ; 415 steps/mm
M302 S105 ; Allow extrusion above 105C
M109 S218 ; Heat hotend to 218C
G92 E0 ; Reset extruder positioning
M104 S160 ; Start the cool down
M117 Extrude prime blob
G1 E10 F100 ; Extrude a short before unload to avoid blob forming
M109 S160 ; Wait for 160C
M104 S110
G92 E0
G1 E0.2 F100 ; Pressurize the hotend
M117 Pressurize hotend
M109 S110 ; Heat hotend to 110C
G92 E0 ; Reset extruder positioning
M117 Pull out slow
G1 E-3 F200 ; Pull back a bit, slow
M117 Pull out fast
G1 E-430 F2000 ; Pull back 43cm with 2000mm/min
G92 E0 ; Reset extruder positioning
M400 ; Wait for command finish
M117 Remove the filament now
; M400 ; Wait for command finish
M302 S170 ; Allow extrusion above 170C
M104 S0

It doesn't work:

  • the auto bed leveling is always done, I don't know how to turn it off
  • when I see that the "Extrude a short before unload to avoid blob forming" event is happening, I also see the "Pull out fast" message on the display and the "print" process ends

Could anyone take a look at this code please? Or is there any .gcode validator for Marlin somewhere?

What I intend to do with this code:

  • heat up the hotend to 218 °C
  • extrude some material while a cool down to 160 °C is already started
  • when temp 160 °C is reached, start a cool-down process to 110 °C and push a little material to the feeder (pressurize)
  • when 110 °C is reached pull out some material from the hotend slow (maybe the feeder won't be enough strong to do it, but I have never reached this point to check)
  • then pull out the filament from the Bowden and feeder fast

1 Answer 1


There are three things to fix and one suggestion:

  • Change follwing lines of M109, using parameter R instead of S, because the latter is not waiting to cool down:

    M109 R160 ; Wait for 160C
    M109 R110 ; Heat hotend to 110C
  • The behavior of M420 will depend on type of bed leveling, saved mesh, etc. It is off topic to troubleshoot this. The printer operates 10 cm above the surface for this operation. G28 disables bed leveling. Why do you need to re-enable it? Just remove this line:

    ; M420 S1 - remove (or comment out)
  • Redefine maximum extrusion length in Configuration.h to allow for scripted long pull (G1 E-430), for example:

    #define EXTRUDE_MAXLENGTH 450
  • Suggestion: Use relative mode for extrusion (M83) instead of absolute positioning (M82). It will simplify your code a lot. You just want to express the distance in E parameter. Then you will not have to reset position with G92 E0 every now and then (do it just once on the start). (I use this Extrusion mode also for slicing becuase it makes easier to re-start a print in case of failure).

  • $\begingroup$ Note: 160 might be below the temperature that allows to move the extruder.. Luckily OP included M302 S105 before the cooldown. $\endgroup$
    – Trish
    Feb 8, 2021 at 8:23
  • $\begingroup$ Yes, the script looks quite mature and consistent. Btw. I have added #define USER_DESC_7 "Allow cold extrusion" #define USER_GCODE_7 "M302 P1" to my custom commands in Configuration_adv.h and used it quite often since then. $\endgroup$
    – octopus8
    Feb 8, 2021 at 8:36
  • $\begingroup$ Thanks @octopus8. I use the factory firmware for my EryOne ER-20. As I see the Marlin FW development is Windows centrist. The flashing tool was even not working for me on Linux, I had to borrow a Windows machine to flash the printer with the new factory FW release. $\endgroup$
    – Endre
    Feb 8, 2021 at 17:25
  • $\begingroup$ Maybe I'll try to set up some kind of serial debug logging (if it is possible), and I hope I'll get some meaningful error messages (like M302 is not supported by this config). $\endgroup$
    – Endre
    Feb 8, 2021 at 17:27
  • 1
    $\begingroup$ Hi, I guess I got it. I have checked the source of the Factory FW and I have seen that the maximum extrusion length is set to 200. So I divided my long one piece extrusion into 3 smaller and now the pull back is working. $\endgroup$
    – Endre
    Feb 8, 2021 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .