M18 & M84 G-Code: In-Depth Guide with Simple Examples

Martin

Disclosure: Links marked with * are Affiliate Links. I earn from qualifying purchases if you decide to make a purchase through these links – at no additional cost for you!


With the M18 and M84 G-codes, you can deactivate the individual stepper motors. With the correct parameters according to these G-codes, you can deactivate them either individually or several at the same time. It is also possible to deactivate them after a certain time.

In this article, I’ll show you how to use the G-codes correctly and how they are commonly used on 3D printers.

What Do the M18 and M84 G-Codes Do?

M84 G-code at the end of the End G-code.

The M18 and M84 G-codes both do the same thing. Their application is also identical. They cause the stepper motors to be deactivated.

When a stepper motor is disabled, the axis can be moved manually. For 3D printers, this is especially useful at the end of a print. This allows you, for example, to pull the print bed forward to remove the print object.

To allow you to move the axes freely at the end of a print, it is sufficient to write the M84 command at the end of the End G code.

How to Use the M18 and M84 G-Codes?

The syntax of the two G-codes is identical:

  • M18 [E<flag>] [S<seconds>] [X<flag>] [Y<flag>] [Z<flag>]
  • M84 [E<flag>] [S<seconds>] [X<flag>] [Y<flag>] [Z<flag>]

The various parameters can be used to specify the deactivation of the stepper motors.

  • [E/X/Y/Z<flag>] = if you enter one of the four stepper motors here, only this stepper motor will be disabled.
  • [S<seconds>]: Allows you to set a timer that will disable the motors after the specified number of seconds.

If you do not specify any parameters, all stepper motors will be disabled immediately.

Examples for the M18 and M84 G-codes

Here are some examples for the M18 and M84 G-codes:

  • M84 Z E S30: Disables the z-axis and extruder stepper motors after 30 seconds.
  • M18 X Y Z: Immediately disables the x, y and z axis stepper motors.
  • M84: Deactivates all stepper motors immediately.

Disclosure: This website is the property of Martin Lütkemeyer and is operated by Martin Lütkemeyer. Martin Lütkemeyer is a member of the Amazon Services LLC and other Affiliate Programs. These are affiliate advertising programs designed to enable websites to earn advertising revenue through advertising and linking to Amazon.com and others. Links marked with * are affiliate links.