Even though it’s a simple one compared to most other programming languages, the fact that G-code is indeed a programming language often deters 3D printing enthusiasts from using them due to the complexity associated with it.
On the other hand, as knowing G-code is perhaps the most effective way of controlling and configuring your 3D printer in many areas, it’s definitely a necessary skill to take your 3D printed models to the highest level possible.
Considering there are too many G-codes to cover at once, today, we will look at two vital G-codes for configuring the acceleration properties of your 3D printer, which we believe will be helpful to optimize your prints in many ways.
So, what are the M204 and M201 G-Codes in 3D printer firmware such as Marlin and RepRapFirmware?
M204 (Set Starting Acceleration) is the G-code for setting the starting acceleration for printing, retraction, and travel moves without extrusion.
On the other hand, M201 (Set Print Max Acceleration) is the G-code for setting a maximum acceleration value for the X, Y, Z, and E (extruder) axes.
Moving forward, we will take a more detailed look at both the M204 and the M201 G-codes separately, discuss the difference between these two G-codes, and find out how you can save the changes you have made with M204 and M201 G-codes permanently for all the upcoming prints.
What Is the M204 (Set Starting Acceleration) G-Code?
The M204 G-code is the command that is responsible for setting the starting acceleration values for every part of the 3D printer that accelerates.
In a nutshell, the M204 G-Code allows you to set the values for starting print acceleration, starting retraction acceleration, and starting travel acceleration.
As setting each of the starting acceleration values is done through the parameters of the M204 command, taking a look at each of these parameters will help us understand how this G-code functions.
- P (Printing Acceleration) – The starting acceleration value for the printing moves where the printer actively extrudes plastic.
- R (Retract Acceleration) – The starting acceleration value for the retraction moves the printer performs, where the printer pulls the filament back from the nozzle.
- T (Travel Acceleration) – The starting acceleration value for the travel moves the printer performs, where the printer is not extruding plastic.
- S (Move Acceleration) The parameter for setting both the printing acceleration (P) and the travel acceleration (T) at the same time.
Each parameter accepts a numeric value in units of mm/s^2 (millimeters per second squared), such as a value of 2000 corresponding to a starting acceleration value of 2000 mm/s^2.
Now that we have an idea of using the M204 G-code, it’s time to look at a few examples.
In this example, we have used the P flag with a value of 2000, which will instruct the printer to set the starting printing acceleration to a value of 2000 millimeters per second squared.
M204 P2200 T2500 R500
In this example, we can see that it’s possible to use multiple flags at once, as we have passed the P flag with a value of 2200, the T flag with a value of 2500, and the R flag with a value of 500.
Invoking this command will instruct the printer to set the starting printing acceleration to 2200 mm/s^2, the starting travel acceleration to 2500 mm/s^2, and the starting retraction acceleration to 500 mm/s^2.
What Is the M201 (Set Print Max Acceleration) G-Code?
M201 is the G-code command responsible for setting the maximum acceleration value of all the axes of your 3D printer.
The M201 G-code allows you to set the maximum values for X-axis acceleration, Y-axis acceleration, Z-axis acceleration, and E-axis acceleration.
As you will need to pass the parameter that corresponds to the axis you would like to set the print max acceleration value for, let’s take a quick look at the parameters you can use with the M210 G-code.
- E (E-axis Max Acceleration)
- X (X-axis Max Acceleration)
- Y (Y-axis Max Acceleration)
- Z (Z-axis Max Acceleration)
- T (Target Extruder)
Here are a few examples of the M201 G-code in use, which will be helpful to cement our understanding of how the command operates.
M201 X200 Y300
In this example, we have used the X flag with a value of 200 and the Y flag with a value of 300, which will instruct the printer to set the maximum acceleration of the X-axis to 200 mm/s^2, and the maximum acceleration of the Y-axis to 300mm/s^2.
In this example, we have used the E flag with a value of 150, which tells the printer to set the maximum acceleration of the E-axis to 150 mm/s^2.
A vital thing to note is that the E-axis isn’t a real axis like the X, Y, and Z axes. Even though it’s labeled an axis, the E-axis actually refers to the filament’s position in the extruder.
What Is the Difference Between M204 and M201 G-Codes?
Even though the M201 and M204 G-codes can sound like they have similar duties at first look due to their relation to acceleration, they actually serve two distinct purposes.
While the M201 G-code sets the maximum acceleration values each axis (X, Y, Z, and E) can have, the M204 G-code allows you to set the starting acceleration values for various printer movements – such as travel, print, and retraction.
As both G-code commands require entirely different parameters to operate, you don’t have to worry about using the wrong G-code and misconfiguring your printer as the printer will ignore the instruction in such a case.
How to Save M204 and M201 G-Code Changes Permanently?
Similar to many other G-codes, the changes you make to the configuration of your printer with M204 and M201 are only temporary (will be lost when you power the printer off) unless you save them.
To permanently save the values you have set with M204 and M201, you need to use the M500 (Save to EEPROM) command.
This process will instruct the printer to save the changes to the persistent memory (EEPROM) that it loads whenever it’s powered on, allowing your settings to persist through power cycles.
Both the M204 and M201 G-codes serve a vital purpose that affects every printing process you conduct with your 3D printer, which makes it significant to have a good understanding of them.
To quickly recap, the M204 G-Code allows you to set the starting acceleration values for printing moves, travel moves, and extruder retraction moves.
On the other hand, the M210 G-code allows you to set the maximum acceleration values for the X, Y, Z, and E (extruder) axes, essentially capping the acceleration values the printer can use for each axis.