Realistically speaking, it’s entirely possible to successfully conduct the process of 3D printing without any G-code knowledge, as the slicer software, the interface of the 3D printer itself, and optionally, a 3D printing interface software, such as OctoPrint, presents everything you need in a much more user-friendly manner.
On the other hand, the more you familiarize yourself with the set of G-code commands that are available, the better level of control you will have over the actions of your 3D printer, which will give you an easier time enabling new features or troubleshooting problems that your 3D printer has whenever the occasion arises.
In today’s article, our topic will be the M900 (Linear Advance Factor) G-code command in particular, which plays a vital role in the configuration of the Linear Advance feature that you can find in some 3D printers, designed to solve the issue of the 3D printer overshooting the corners due to the pressure dynamics in the nozzle.
So, what is the purpose of the M900 G-code in Marlin firmware?
The M900 G-code command in Marlin firmware allows you to set the K-factor value that the Linear Advance feature requires to operate and produce optimal results, which also works as a way to activate Linear Advance and keep it active until the K-factor value is set to 0 again.
Moving forward, we will take a more detailed look at the functionality of the M900 G-code, find out how to execute the command, and finally, discuss the scenarios where it would be suitable to utilize it.
Table of Contents
What Is the M900 G-Code in Marlin Firmware?
While the M900 G-code is not one that you will need to use frequently, it’s a vital part of the configuration that allows the Linear Advance feature to operate correctly, making it crucial to familiarize yourself with this command if you’re using the Linear Advance feature.
The Linear Advance feature requires a value called the K-factor to operate, which is essentially a variable the Linear Advance algorithm uses to perform the correct calculation for your 3D printer to extrude the filament consistently across pressurization and depressurization cycles.
The process of finding the correct Linear Advance K-factor value for your 3D printer involves printing a calibration pattern, which makes the 3D printer print lines with different K-factor values that you can observe and pick from, based on whichever line looks more consistent.
The M900 G-code command in Marlin comes into play after finding the optimal K-factor value, as its purposes are to allow you to set the K-factor value that the Linear Advance algorithm will use for your prints, modify it whenever necessary, and also disable the Linear Advance feature if you wish.
Now that we have a better understanding of the purpose of the M900 G-code command, it’s time to take a look at the process of using it.
How to Use the M900 G-Code in Marlin Firmware?
Using the M900 G-code command is relatively straightforward, as only one parameter and value is necessary for it to operate correctly.
To set the primary Linear Advance K-factor with the M900 (Linear Advance Factor) G-code command in Marlin firmware, you will need to use the K parameter alongside the value you would like to use for the K-factor value, which creates the syntax “M900 K<value>”.
Here is an example of the M900 G-code command in usage to make things more straightforward, where we set the K-factor value to 0.35:
On the other hand, if you have the EXTRA_LIN_ADVANCE_K parameter (Marlin 2 and above only) enabled in the Marlin firmware configuration, there will be three more optional parameters that you can use with the M900 G-code command.
Below, you can find the optional parameters that the M900 G-code command accepts, alongside descriptions that clarify their purposes:
- L (secondary K-factor) – The L parameter allows you to save a secondary K-factor value that you can switch to whenever necessary.
- S (slot) – The S parameter allows you to switch between the primary and secondary K-factor values in cases where both are configured, with S0 corresponding to primary (K) and S1 corresponding to secondary (L).
- T (extruder index) – The T parameter allows you to choose the index of the extruder that the changes you have performed with the M900 G-code will apply.
To better understand how these optional parameters come into play, let’s look at a few examples.
M900 T1 K0.35 L0.40 -> Set the primary K-factor value to 0.35 and the secondary K-factor value to 0.40 for the extruder with index 1.
M900 T1 S1 -> Activate the secondary K-factor value (0.40 from the example above) for the extruder with index 1.
M900 T1 L0.45 -> Set the secondary (currently active) K-factor value to 0.45 for the extruder with index 1.
M900 T1 S0 – Activate the primary K-factor value (0.35 from the example above) for the extruder with index 1.
Finally, to turn the Linear Advance feature off, pass the value of 0 to the K parameter (M900 K0).
When to Use the M900 G-Code in Marlin Firmware?
As the M900 G-code plays a vital role in ensuring that the Linear Advance feature functions correctly, having a good understanding of when to execute the command and re-configure the Linear Advance to operate optimally are vital to get the most out of the feature.
You can use the M900 G-code in Marlin Firmware whenever you would like to change the K-factor value that the Linear Advance feature uses, when you would like to activate Linear Advance for the first time, and when you would like to deactivate the Linear Advance feature whenever necessary.
To ensure that the Linear Advance feature works as intended at all times, you will also need to repeat the process of K-factor calibration whenever you make modifications to factors such as the filament you use, the nozzle printer you print with, the extruder of your 3D printer and the size of the nozzle, and update the K-factor value accordingly with the M900 G-code.
Even though the M900 G-code isn’t one that you will find yourself regularly using, as its purpose is to modify a parameter that your 3D printer will use across different prints, it does play an essential role in ensuring that the Linear Advance feature works correctly.
To quickly recap, using the M900 (Linear Advance Factor) G-code command in Marlin allows you to modify the Linear Advance K-factor value, which you can use to configure the accuracy of the Linear Advance feature, enable it, and disable it.
It’s also worth noting that the Linear Advance feature will only work if your 3D printer’s hardware has support for it, and attempting to use this G-code command with 3D printers that don’t have Linear Advance support won’t have any effect.
Mike started his 3D printing journey with the Anet A8 when it first came out back in 2017, and has been obsessed with 3D printers ever since. Nowadays, he primarily uses his Ender 3 to print functional parts that make his life more convenient whenever possible.