While not a process that we regularly require, reversing the direction of the extruder motor can become necessary at times, usually due to problems that arise after modifications to the extruder itself.
Even though there are a few different ways to reverse the extruder direction, such as swapping the wires or flipping the connector, these ways are often not desirable due to the necessity of disassembling the extruder and making physical changes.
Today, our topic will be reversing the extruder direction purely with G-code commands, removing the need to modify the firmware or the wiring of your 3D printer to achieve the same effect, which we believe will be helpful for many 3D printing enthusiasts.
So, how to reverse the extruder direction with G-code?
To reverse the extruder direction with G-code commands, you can execute the M92 (Set Axis Steps-Per-Unit) G-Code with the corresponding axis parameter and the negative of the steps-per-unit value your printer currently uses for that axis.
Moving forward, we will take a better look at how reversing the extruder direction with only G-code works, find out how it’s possible to apply this method through the Cura slicer, and analyze the way of inverting the extruder direction through firmware modification for Marlin firmware.
How to Reverse the Extruder Direction with G-Code (Marlin)?
While there isn’t a G-code specifically made for reversing the extruder direction, we are able to perform this task by applying a small trick to another command.
By running the M92 (Set Axis Steps-Per-Unit) G-code and passing the negative of the current steps-per-unit as the value for the axis parameter you would like to modify, you can reverse the extruder direction by only using G-code.
The trick here is using a negative value for the steps per unit parameter, which causes the printer to run the extruder motor in the opposite direction of the usual, effectively reversing it.
For instance, let’s assume that the current E steps value of the extruder is 450, and you would like to reverse the direction of the E axis of the extruder.
To reverse the E axis of the extruder with G-Code, you can pass the E-450 parameter to the M92 command, effectively inverting the extruder motor while keeping the E steps value the same.
Below is the example G-code for reversing the extruder motor and setting the Esteps value of your 3D printer to 450:
While we can consider this a trick solution compared to more concrete solutions such as directly modifying the firmware or making physical changes to the wiring of the extruder motor, it gets the job done quickly and effortlessly.
Unless you have used the M92 G-code to change the Esteps value before, you can find the default Esteps value by looking at the Configuration.h file of the Marlin Firmware code you are currently using.
On the other hand, if you have changed the Esteps value before with the M92 G-code, there is no way to know the current number unless you noted it earlier when you changed it.
How to Reverse the Extruder Direction in Cura?
Another way to reverse the extruder direction with G-code is to apply the G-code through Cura instead of sending the command to the printer through more complicated means.
To reverse the extruder direction in Cura, you can add the M92 G-code, the axis parameter you would like to modify (X, Y, Z, or E), and its negative value to the start G-code section.
For instance, if your current value for the X steps per unit parameter is 300, and you would like to reverse the X-axis direction, add the M92 X-300 G-code to the start G-code section.
This process will cause Cura to issue the command for reversing the extruder direction to the 3D printer before starting each print, which will stay that way until you remove the G-code from the section.
If you aren’t familiar with the start G-code section of Cura, here is a step-by-step guide you can follow:
- Click the settings button on the top menu of Cura.
- Hover over the Printer option in the dropdown menu that appears.
- Click the Manage Printers option in the dropdown menu that appears.
- Choose the printer you would like to modify on the left pane.
- Click the Machine Settings button on the right side.
- Add the M92 G-code to the Start G-code box that you can see to the bottom left of the window.
To normalize the direction of the extruder and remove the reversing effect, all you have to do is remove the M92 G-code you have added from the start G-code section.
How to Reverse the Extruder Direction by Modifying the Marlin Firmware?
While slightly more technically demanding than performing it with G-code, reversing the extruder direction by modifying the Marlin firmware offers a more effective solution for those looking to invert the extruder direction permanently.
Here are the steps we recommend following to reverse the extruder direction by modifying the Marlin firmware:
- Download a fresh and updated copy of the Marlin firmware.
- Open the Configuration.h file in your favorite text editor.
- Find the “#define INVERT_E0_DIR false”, “#define INVERT_X_DIR”, “#define INVERT_Y_DIR”, and “#INVERT_Z_DIR” lines in the configuration file.
- Replace the false with true (or vice versa)for all the axes you would like to reverse.
- (Optional) If you would like to reverse the E axes for multiple extruders, replace the false with true for other “#define INVERT_E<x>_DIR false” lines, where the <x> refers to the extruder number (with 0 being the first extruder).
- Save the Configuration.h file.
- Re-flash your 3D printer with the version of Marlin firmware you have modified.
Compared to the alternative ways of doing so, reversing the extruder direction with G-code is a pretty straightforward task that won’t take too much of your time and effort.
To quickly recap, you can reverse the direction of the extruder motor by using the M92 (Set Axis Steps-Per-Unit) and passing the negative of the current steps-per-unit value your printer uses for that axis alongside the axis parameter.
While this is more of a “dirty” solution, it will get the job done quickly and easily if you prefer not to delve into making physical modifications to the wiring or re-flashing the firmware of the 3D printer.