What Is the M108 G-Code in Marlin Firmware? (Explained)

As every single action, whether it’s moving to a position or heating the hotend up, corresponds to a single G-code command, a 3D printer executes hundreds of individual G-code commands lined up one after another to conduct the printing process, with G-codes such as G0 and G1 (Linear Move) being present in every G-code file.

On the other hand, not all G-codes are actively required for the printing process to move forward at all times, and in fact, the majority of the G-code commands are situational ones that you will only need to execute in particular scenarios as opposed to regularly finding them in the G-code files that your slicer produces.

In today’s article, we will be talking about one such G-code that we can consider to fall under the umbrella of situational commands, which you can find in Marlin firmware with the code M108 (Break and Continue), and learn more about its purpose and role in the 3D printing process.

So, what is the purpose of the M108 G-code in Marlin Firmware?

Executing the M108 G-Code command in Marlin firmware tells the 3D printer to continue from a pause, such as one triggered by the M0 (Unconditional Stop) G-code, or break out of a waiting state, such as one that the M109 (Wait for Hotend Temperature) G-code starts.

Next up, we will dive deeper into the functionality of the M108 G-code, find out how to use it, discuss the scenarios where it’s suitable to use it, and finally, go through the difference between the M108 and the M24 G-codes, which can sound similar at first even though they are different.

What Is the M108 (Break and Continue) G-Code in Marlin Firmware? 

Even though the M108 G-code isn’t one that you will frequently use during the natural flow of 3D printing, there are times when it becomes necessary for the printing process to continue, making it a good idea to keep it in mind.

In the process of 3D printing, there are various reasons to tell the 3D printer to pause, whether it’s waiting for the hotend to reach the intended temperature before starting the print or waiting for the user to perform a particular action, such as a bed level testing G-code stopping the nozzle in a corner and waiting for you to be ready before moving on to the next one.

As a result, there also needs to be a way to manually tell the 3D printer to end the pause and continue executing the following commands in the queue, as it would be the only way to get the printing process back on track in cases where user input is needed, or in cases where the 3D printer is stuck in a loop and is unable to meet the condition.

For such cases, the way to tell the 3D printer to end the pause is by executing the M108 G-code, as its exact purpose is to break the 3D printer out from being stuck in a pause and allow it to move on to the following G-code command in the queue.

In cases where the printer is waiting for a user action to continue the printing process, interacting with the LCD controller of your 3D printer should also have the same effect as using the M108 G-code, which provides a more straightforward way to break out of the pause.

How to Use the M108 (Break and Continue) G-Code in Marlin Firmware?

Using the M108 G-code is a pretty straightforward process as it does not have any extra parameters you need to be aware of, unlike many other G-code commands that can get a lot more complicated with the parameters and the values they require.

As the M108 G-code has neither mandatory nor optional parameters, all you need to do is to send the M108 command to your 3D printer through an interface that allows you to issue G-code commands directly, such as OctoPrint.

An example (and the only one) of the M108 G-code in use would be as follows:

M108

While the above example is sufficient for the M108 G-code to function, in some cases, it’s possible for the parser queue to be full, which will end up with the firmware being unable to execute the command that you have run.

To allow the M108 G-code to go through even when the parser queue is full, you will need to enable the EMERGENCY_PARSER flag that you can find in the Configuration_adv.h file of Marlin firmware and flash the edited version of the firmware to your 3D printer.

As enabling the emergency parser will allow Marlin to reliably execute the M108, M112, M140, and M876 commands regardless of the state of the parser queue, it’s the only way to ensure that you can use the M108 G-code in any situation.

When to Use the Marlin Firmware M108 (Break and Continue) G-Code?

As the M108 G-code is a situational command, being able to recognize the situations where it can be necessary to use it is the primary skill you will need to utilize this G-code.

There are two situations where you can utilize the M108 G-code to get your 3D printer to get out of the pause state and keep executing the commands in the queue, which are as follows:

  • The 3D printer is paused until user input. You can break out of a pause initiated by the M0 G-code, which essentially tells the 3D printer to stop until the user manually continues the process. The standard way of breaking out of such a scenario would be to use the LCD controller.
  • The 3D printer is paused until a condition is fulfilled. You can break out of a pause initiated by commands such as M109 and M104, which tell the printer to stop until the hotend or the bed reaches the desired temperature. In a standard scenario, the 3D printer should automatically break out of the pause by reaching the required temperature.

Please note that breaking out in the second scenario is most likely not a good idea, as the existence of a more significant problem that will cause the printing process to fail is highly likely if the printer is unable to fulfill a condition such as reaching the correct hotend temperature.

What Is the Difference Between M108 and M24 G-Codes?

Sometimes it’s possible for two G-codes to have similar descriptions, which can lead to confusion if you aren’t familiar with the commands, even though, in reality, they fulfill entirely different purposes.

While the purpose of the M24 (Start or Resume SD Print) G-code is to continue a paused SD card print initiated by the M25 (Pause SD Print) G-Code, the purpose of the M108 (Break and Continue) G-code is to continue from a generic pause or wait, such as the ones triggered by G-codes like M0 and M190.

As a result, when making the correct choice between the M108 and the M24 G-codes to continue the printing process, the primary factor to look at is the nature of the pause, which is signified by the G-code command that was executed to initiate it.

Wrapping Up

While you will rarely need the M108 G-code for a successful printing process, it’s a handy one to keep in mind for when the occasion arises, especially considering that it’s pretty straightforward to use with no specific parameters and values required.

To quickly recap, the M108 G-code in Marlin has two purposes, which are to end the pause state, which allows the 3D printer to continue the parsing of the upcoming G-code commands, and to break out of a wait state, such as the 3D printer waiting for a temperature to be reached.

It’s once again worth noting that you will need to activate the EMERGENCY_PARSER flag in Marlin’s configuration for the M108 G-code to work reliably, as, without the emergency parser available, the M108 G-code can be blocked in cases where the parser queue is full.

Happy printing!