Using G-codes to fine-tune your prints is one of the quickest ways to achieve better overall print quality, but the learning curve looks steep to many 3D printing enthusiasts who don’t have prior experience with them.
In reality, it’s pretty simple to learn the main functionality of most G-codes as long as you know the syntax for them and the changes they make to your printer, which we will try to explain to you as clearly as possible.
Today’s topic will be two G-codes in particular, responsible for controlling the temperature of the heated bed in various ways. Considering that bed temperature is one of the primary variables for a successful print, we believe that the capability of directly controlling it is a significant asset.
So, what are the M140 and M190 G-codes?
- M140 (Set Bed Temperature) – Sets the temperature of the heated bed to the specified target while the printing process is continuing.
- M190 (Wait for Bed Temperature) – Sets the temperature of the heated bed to the specified target and stops the printing process until the bed reaches the target.
Depending on the firmware you’re on, both of these commands can come with extra parameters that allow them to have an even greater level of functionality, which is why we will be taking an in-depth look at both of them moving forward.
M140 G-Code (Set Bed Temperature)
The M140 G-code is the most straightforward method for setting the heated bed temperature.
Sending the M140 G-Code to the 3D printer with the target bed temperature causes the heated bed’s temperature to start shifting towards the target as the printing process continues in the meanwhile.
As the syntax for using the main functionality of the M140 command only requires target temperature as a parameter, it’s a pretty straightforward command to execute.
Let’s look at a quick example:
In this example, the S parameter refers to the target temperature, and 100 refers to its value.
Running this command will prompt the printer to start shifting the heated bed’s temperature to 100 degrees and hold this temperature while the printing process continues in the background.
Aside from target temperature (S), the M140 command only has one more parameter that you can access in every 3D printing firmware, material preset index (I).
The I parameter allows you to pick between presets corresponding to pre-configured temperatures, essentially replacing the S parameter for setting the target temperature. In a scenario where you pass both parameters, the I parameter overrides S.
A quick example would be:
In this example, the printer sets the temperature of the heated bed to the target temperature stored in material preset 1.
Additionally, RepRapFirmware offers a few extra parameters specific to it.
Standby Temperature (R)
The R flag allows you to set the standby temperature of the heated bed.
When you pass the R flag and the target standby temperature, the heated bed will hold this temperature during standby periods, which acts as a way to keep the heated bed warm.
Let’s look at a quick example:
M140 S80 R50
In this example, the target temperature, denoted by S,is 80 degrees, and the standby temperature, denoted by R, is 50 degrees.
When you run this command, the heated bed will stay at 80 degrees during the printing process and go down to 50 degrees during standby periods.
Bed Heater Index (P)
The P flag allows you to set the bed heater index for printers that have multiple bed heaters.
When you pass the P flag and the index of the bed heater of your choice, the M140 command will only affect the bed heater you have chosen, allowing you to set different temperatures separate heaters.
Here is an example:
M140 P1 S70
When you run this command, you will notice that the temperature of bed heater “1” is set to 70 degrees, with other bed heaters staying unaffected.
M190 G-Code (Wait for Bed Temperature)
The M190 G-code is another way of setting the bed temperature, but it doesn’t exactly work the same way as the M140 G-code does.
When you run the M190 G-code, the printer will stop printing until the heated bed reaches the target temperature you have chosen. The printing process will automatically continue when the heated bed is at the target temperature.
Let’s look at a quick example once again:
In this example, S is the target temperature flag, and 90 is the target temperature value of 90 degrees. Due to how the S flag works, the printing process only stops if the current heated bed temperature is lower than the target.
Under the assumption that the heated bed is at 60 degrees before running this command, the printing process would stop until the heated bed reaches 90 degrees.
On the other hand, if the heated bed is at 100 degrees when you run this command, the printing process will continue, similar to running M140, as the target (90 degrees) is lower than the current temperature (100 degrees).
Popular firmware such as Marlin and Prusa introduce the R flag as an extra option, which causes the printer to stop the printing process, whether it’s a heating or cooling operation.
Here is an example:
In this example, R50 refers to a target temperature of 50 degrees. Due to how the R flag works, the printer will stop printing regardless of whether the current temperature is higher or lower than the target temperature.
Whether the printer bed is at 40 degrees or 60 degrees when you run this command, the printing process will stop until it reaches 50 degrees.
Both M140 and M190 allow you to control the temperature of the heated bed in an in-depth manner, allowing you to fine-tune your prints to achieve maximum print quality and minimal errors.
As there is not much of a technical complexity involved with using these commands, we highly recommend adding them to your toolkit, considering that these G-codes will come in handy sooner or later.
We will be continuing our series on G-codes in further articles with more commands that we think are vital for every 3D printing enthusiast to know and use, so stay tuned!
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.