Can You Reverse Extruder Direction with G-Code in Marlin?

If you came across a scenario where your 3D printer is extruding filament when it should retract and vice versa after assembling it for the very first time, which would practically indicate that the extruder stepper motor is running in reverse due to wiring-related problems, you’re most likely looking for a quick solution on the software level that will help you resolve this problem without having to go through the hassle of re-wiring things.

In this guide, we will explain whether it would be possible to reverse the extruder motor direction with G-code commands in Marlin Firmware and go through the standard method of inverting the extruder motor direction by modifying the Marlin Firmware configuration files, which will allow you to solve things on the software level.

Can You Reverse Extruder Motor Direction with G-Code in Marlin Firmware?

Unfortunately, reversing the extruder motor direction with G-code commands isn’t something that Marlin Firmware supports out of the box, meaning that you won’t be able to perform such an adjustment unless the developer of the Marlin fork installed on your 3D printer has explicitly implemented this feature.

For instance, if you’re using the MRiscoC Professional Firmware, which is available for Ender 3 V2 and Ender 3 S1 series of printers in particular, you will find a custom G-code command (and an LCD controller option) that allows you to revert the extruder motor direction (C562 E1), a feature that you won’t find to be available by default in the original version of Marlin Firmware.

professional firmware lcd panel invert extruder

professional firmware c562 gcode


So, if you’re also using a Marlin fork that comes with additional features that aren’t included in the original firmware, we highly recommend going through the firmware documentation to find out whether the developer added a custom G-code command or menu option to make it possible to reverse the extruder motor direction, as this is definitely a possibility to take into consideration.

While some sources mention that you can use the M92 G-code command, which allows you to set the steps-per-unit values for the X, Y, Z, and E axes to reverse the extruder motor direction by giving it a negative E value, such as M92 E-93 if your printer’s current E-step value is 93, this method, unfortunately, does not work in the latest version of Marlin Firmware.

In the scenario where you attempt to perform such a change to the E-steps by passing it a negative value, you will be greeted with the “too long extrusion prevented” error message the next time you attempt to extrude some filament regardless of the actual length of the extrusion, no extrusion will take place at all, and you will need to restart your 3D printer for things to go back to normal.

too long extrusion prevented marlin


Bonus Information: While you won’t be able to invert the extruder motor direction with the M92 G-code command, it is actually possible to reverse the direction of the X, Y, and Z stepper motors by giving them the inverse of the steps-per-unit value that’s currently active, which is something to keep in mind for a scenario where a quick fix to the direction of the X, Y, or Z axes becomes necessary.

Reversing Extruder Motor Direction by Modifying Marlin Firmware Configuration

While modifying the extruder motor direction with G-code, which would be pretty convenient, isn’t supported in Marlin Firmware, fixing the problem you’re facing on a software level and not having to deal with correcting the wiring is still possible by making an adjustment to the configuration file.

For this process, the first step you will first need to take is to grab a copy of the Marlin Firmware source code (or the source code of the Marlin fork you’re already using for your 3D printer, if available) and extract the files into a folder of your choice.

Next, you will need to navigate to the Marlin Configurations repository on GitHub, find the premade configuration file for the printer & mainboard combination you’re using, and copy the Configuration.h & Configuration_adv.h files over to the folder where you have extracted the Marlin source code files, effectively replacing the original configuration files with the new ones.

This step won’t be necessary if you have the source code for firmware explicitly configured for your 3D printer and not the standard Marlin Firmware source code, as the configuration files will already be compatible with your 3D printer in this case.

marlin configurations repository


For instance, if you’re the owner of an Ender 3 V2 Neo, you would need to navigate to the Creality folder first, followed by Ender 3 V2 Neo, grab both of the configuration files in there, and put them inside the Marlin folder on your computer, which resides in the folder you have extracted the source code files to.

marlin ender 3 v2 neo config in marlin repository


Once that’s done, the next step you will need to take is to open the Configuration.h file that you have just copied over to the Marlin directory with your favorite text editor (we recommend Visual Studio Code, as it makes it very convenient to compile the firmware with the Auto Build Marlin extension), as you will need to edit this file to make the necessary changes to the firmware.

marlin firmware source code vscode


Next, you will need to locate the INVERT_E0_DIR parameter in the file, and change its value to true from false, which will tell effectively tell the firmware to invert the direction of the extruder motor and make it possible to run the extruder motor in reverse without having to correct the wiring.

marlin invert e0 dir to reverse extruder direction


While making this change concludes the process of reversing the extruder direction, we highly recommend going through the configuration files to ensure that everything is in order, as even though the configuration files you find in the Configurations repository are prepared specifically for each 3D printer, meaning that parameters such as bed size and mainboard model will be correct, the more situational parameters, such as the one that activates BLTouch, will require custom configuration on your part.

bltouch marlin config example


Finally, once you have ensured that you have adjusted both configuration files correctly, you will need to compile the firmware and flash it to your 3D printer, which will finalize the process of inverting the direction of your 3D printer’s extruder motor.

If you haven’t compiled Marlin firmware from source before, we highly recommend referring to the official Marlin documentation on the Auto Build Marlin plugin, which will take you through creating the firmware file that you will need to flash the firmware to your 3D printer in the most convenient way possible.

Conclusion

Even though there’s no such G-code command that allows you to reverse the extruder motor direction in Marlin Firmware right now, it’s possible to find forks of Marlin where the developers have implemented this feature themselves, which makes it a good idea to check the documentation of the firmware installed on your 3D printer to find out.

On the other hand, while it’s inarguably a less convenient solution than using G-code commands, making this adjustment through Marlin’s configuration file is still very much possible, which, if you’re already used to modifying, compiling, and flashing firmware, should be a breeze.