This one will be quick and easy. Recently I found out about wonderful feature of Marlin 3D printer firmware called firmware retraction. So what is the difference between firmware retraction and normal retraction made by Slic3r? It is easy, you can set different speeds for retract and recover. 

Basically you can pull out the plastic really fast and save time but you can’t try to force the filament back in as fast as it would cause many problems.

When the recover speed is too big, you risk filament drive stripping piece of the filament and cause jam. Also there is a slight lag between the filament actually flowing out of the extruder nozzle, especially with bowden extruder setup. Newest Slic3r (tested with 1.2.6) has support for firmware retraction so you can easily try it out.

And it has one more GIANT advantage. You can tweak your retract during the print with simple G-code commands. That means no need to reslice the model just to tweak it! I love this!

First and foremost you have to have it enabled during compilation of your firmware. This might be a problem if you bought fully built printer with no support from china, but don’t worry I am writing a guide how to setup and compile a firmware for your printer too 😉 BTW I finally started selling my printers online, took me 3 years to get it right and FW retraction is enabled 😉 Check it out here.

Marlin FW

When you are setting up the Marlin FW for compilation there is you can find the settings in Configuration_adv.h. 



so you will end up with


You don’t have to worry about the other settings too much as we will be setting them via G-code later. Now just reflash your board and move on to Slic3r settings.


First you need to go to Printer Settings -> General and enable “Use firmware retraction” checkbox.


Now move to Custom G-code tab and modify the Start G-code.


Here is what I added to the beginning.

M208 S-0.05 F180
M207 S1 F1800

M208 is setting for extrusion recover length and speed. In my case I tend to recover -0.05mm less as it prevents creating a small blob on the place where filament starts flowing and speed is 3mm/s.

M207 is retraction settings. I retract 1mm at speed of 30mm/s.

You can modify these setting even during your print and find the best settings for your nozzle and plastic you are using, how awesome is that!! It is really easy in Pronterface! Let me know your settings in our Forums please 😉




7 thoughts on “Slic3r and Marlin configuration for RepRap FW retraction

  1. Hi Josef,
    I have tried FW Retraction and cannot get it to work – any suggestion would be most welcome!
    I am using a pellet extruder on a Velleman K8200 (re-badged 3Drag), with Repetier Host V1.0.6 and Slic3r 1.1.7. I have followed your instructions carefully and still no success.
    With a pellet extruder, retraction is necessary as when extrusion stops, there is some nozzle ooze, but the material also pushes back up the extruder, so that more material is needed at the start of extrusion than would be necessary with filament.
    Thanks for your help,

    • Eventually I got it to work, but now the Z-axis lifts at every retraction, even mid layer. I cannot find the cause or a solution; your assistance will be appreciated.


      • Hi,

        Check the firmware settings (Marlin):

        #ifdef FWRETRACT
        #define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt
        #define RETRACT_LENGTH 4.7 //default retract length (positive mm)
        #define RETRACT_LENGTH_SWAP 13 //default swap retract length (positive mm), for extruder change
        #define RETRACT_FEEDRATE 35 //default feedrate for retracting (mm/s)

        #define RETRACT_ZLIFT 1.2

        #define RETRACT_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering)
        #define RETRACT_RECOVER_LENGTH_SWAP 0.8 //default additional swap recover length (mm, added to retract length when recovering from extruder change)
        #define RETRACT_RECOVER_FEEDRATE 8 //default feedrate for recovering from retraction (mm/s)
        (sorry for the formatting)

        Youcan also check it in your slicer, it’s under “Advanced Settings” in Cura.

        Btw, is it the pellet extruder from Richrep or some other design?

        Thanks, good luck!

      • Hi, if you haven’t solved this yet, manually input the Gcode
        M207 S0 Z0
        M208 S0 Z0

        I had the same problem you did and this cleared it up. Somewhere in my firmware it is still being set, so in Slic3r I added those commands to the start Gcode custom area.

        Hope it helps

  2. Nice write up! I’m going to try it out.

    Wally: that is called Z hop/lift. If you look right under the line in configuration_adv.h that you modified, you will see the parameters.

    #ifdef FWRETRACT
    #define MIN_RETRACT 0.1 //minimum extruded mm to accept a automatic gcode retraction attempt
    #define RETRACT_LENGTH 3 //default retract length (positive mm)
    #define RETRACT_FEEDRATE 45 //default feedrate for retracting (mm/s)
    #define RETRACT_ZLIFT 0 //default retract Z-lift
    #define RETRACT_RECOVER_LENGTH 0 //default additional recover length (mm, added to retract length when recovering)
    #define RETRACT_RECOVER_FEEDRATE 8 //default feedrate for recovering from retraction (mm/s)

  3. How do you guys make the extruder to stop extruding material when it doesn’t need to?

    I am starting to build my own pellet extruder for 3d Printing but one of the problem I encountered was that the rate of extrusion is controlled manually by Anyone has a solution to this?

    • easiest way is to let it go to a filament state to cool either 3mm or 1.75 then treat it as normal filament but major advantage fresh no moisture or contaminants, in a flat chamber to flake out slightly in an S bend shape.

Leave a Reply

Your email address will not be published. Required fields are marked *