While it may look like G-code has a steep learning curve due to it being a programming language, it’s pretty easy to get into once you start, especially with the amount of detailed documentation and explanations you can find on the Internet.
Alongside the fact that G-code knowledge is pretty valuable for 3D printing the 3D printing process, we believe that there is no reason for any 3D printing enthusiast not to get themselves familiar with it, especially those who would like to improve themselves in the topic of 3D printing.
Today, our topics are specifically the M221 and M220 commands in Marlin, two G-codes that are vital for the health of the 3D printing process even though you won’t use them regularly.
So, what are the M221 and M220 G-Codes in Marlin Firmware?
The M220 G-code in Marlin firmware allows you to set the feed rate percentage of your 3D printer, allowing you to increase or decrease the speed of your printer.
On the other hand, the M221 G-code in Marlin firmware sets the flow percentage, controlling how much plastic the printer extrudes.
In the upcoming sections, we will analyze both the M221 and the M220 G-codes individually and in more detail and discuss the differences between these two G-codes.
Table of Contents
What Is the M221 (Set Flow Percentage) G-Code in Marlin Firmware?
While not a G-code that you would use too regularly, the M221 command in Marlin firmware controls a vital attribute of the 3D printer that you need to configure correctly for the printing process to go smoothly and without issues.
The M221 G-code is the command that allows you to set the flow rate of your 3D printer, which is a percentage value that the printer uses as a multiplier to calculate the amount of plastic it will extrude.
You can pass two parameters to the M221 G-code, which are:
- Flow rate percentage (S) – The value you will be setting the flow rate to.
- Target extruder (T) – The index of the extruder that the command will set the flow rate for. (Optional)
So, an example for the usage of the M221 G-code would be:
As you can see, we have only passed the S parameter with a value of 120 to the M221 G-code in this example, and as a result, the firmware will set the flow rate of your printer to 120% after running this command.
Since 100% is the default flow rate, a flow rate of 120% means that your printer will be extruding 20% more plastic throughout the printing process.
Another example with the optional T parameter; that you would only need to use for multi-extruder setups would be:
M221 S150 T1
Here, we have passed the S parameter with a value of 150 and the T parameter with a value of 1.
In this case, you would be setting the flow rate of the second extruder to 150%, as indexing starts from the number 0.
As the printer will only store the updated flow rate setting in the volatile memory, you will also need to run the M500 G-code to save the change to the EEPROM if you want to make it persistent.
What Is the M220 (Set Feedrate Percentage) G-Code in Marlin Firmware?
Another G-code that you will most likely only have to configure once; using the M200 command in Marlin is an easy way to control the speed of your 3D printer.
The M220 G-code is the command that allows you to set the feed rate of your 3D printer, which is a percentage value that the printer uses as a multiplier to calculate the final speeds for all types of movement in all axes.
There are three parameters that you can use with the M220 G-Code, which are:
- Feed rate percentage (S) – The value you will be setting the feed rate value to.
- Back up (B) – Backs the current feed rate up.
- Restore (R) – Restores the feed rate value in the backup.
First, let’s look at the standard usage of the M220 G-code with an example:
In this example, we have passed the S parameter with a value of 110, meaning that the firmware will set the printer’s feed rate value to 110%, accelerating all of your printer’s movements by 10 percent (as 100% is the default).
Now, let’s take a look at the backup and restore features of M220:
The command above would back the current feed rate up, which would be 110%, following our example from earlier.
Now, let’s imagine we ran these two commands one after another:
In this case, we would first be setting the feed rate to 80% and then restoring it with the R command, which would put the feed rate value back to 110%, the value we have backed up earlier.
How Are the M220 and M221 G-Codes Different in Marlin Firmware?
As flow rate and feed rate are two terms that often get mixed up with each other, knowing the difference between M220 and M221 is vital to ensure that you don’t misconfigure your 3D printer.
To understand the difference between M220 and M221, let’s first take a quick look at the difference between feed rate and flow rate.
In a nutshell, the flow rate parameter is a multiplier that the printer uses to calculate the amount of plastic that it extrudes at any given time.
On the other hand, the feed rate parameter is a multiplier that the printer applies to all G-code-based movements in all axes to calculate the effective move speed.
With a better understanding of the difference between flow and feed rate, the difference between M220 and M221 also becomes quite clear, with M220 being responsible for feed rate and M221 for flow rate.
Despite not being G-codes that you will regularly use, having the M220 and M221 commands in your toolbox will definitely have considerable benefits once the situation for their usage arises.
To quickly recap, the M221 G-code is responsible for setting the flow percentage, also known as the extrusion multiplier, of your 3D printer, which affects the amount of plastic that the printer extrudes.
On the other hand, the M220 G-code offers a way to set the feed rate percentage, which is a variable that controls the overall speed of the 3D printer.
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.