<p>An alternative solution to using a hard delay with the <a href="http://reprap.org/wiki/G-code#G4:_Dwell">G4 dwell command</a>, is to increase the time that the temperature set with <a href="http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait">M109</a> has to be held before it continues with the next command.</p>

<p>In Marlin, this setting is named <code>TEMP_RESIDENCY_TIME</code>, and can be found around line 150 in <code>Configuration.h</code>. By default, this is set to 5 seconds, which looks like:</p>

<pre><code>// Actual temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 5  // (seconds)
</code></pre>

<p>If increasing this setting solves your exact problem, I cannot say, but it could be worth looking into.</p>

CC BY-SA 3.0
2016-02-08T08:05:43.270Z
2016-02-08T08:05:43.270Z
Tormod Haugene
<p>Thank you Fernando Baltazar for the G-code you used to solve the hot end cooling issue after bed levelling probing. I did change <code>M190</code> to <code>S60</code> but kept everything else. This worked.</p>
<pre><code>G29 ; Autonivel
M190 S35 ; set bed temperature
G1 Z4 F240 ; lift nozzle
M109 S195 ; wait for temperature to be reached
G21 ; set units to millimeters
G90 ; use absolute coordinates
M82 ; use absolute distances for extrusion
M104 S210 ; set temperature
G92 E0
G1 E-1.5000 F1800
G1 Z0.225 F240
</code></pre>

CC BY-SA 4.0
2022-11-06T03:43:13.500Z
2022-11-06T11:16:50.637Z
2022-11-06T11:16:50.637Z
Shawn Clarady
<p>I´m using this code for my prints.</p>

<pre><code>    G29 ; Autonivel
    M190 S35 ; set bed temperature
    G1 Z4 F240 ; lift nozzle
    M109 S195 ; wait for temperature to be reached
    G21 ; set units to millimeters
    G90 ; use absolute coordinates
    M82 ; use absolute distances for extrusion
    M104 S210 ; set temperature
    G92 E0
G1 E-1.5000 F1800
G1 Z0.225 F240
</code></pre>

<p>On M190 S35, the nozzle is still on the low position (1.2mm), then goes to 4mm then waits for the extruder temperature Ex. 195°C; when the extruder reach the 195°C for 10 seconds then the printers starts to print going the nozzle to 0.22mm while the nozzle reach the second temperature of 210°C. On This time its allow me to clean the nozzle and normalize the temperatures for a good prints.</p>

<p><strong>Note:</strong>
To avoid the nozzle stays many time on low position (1.2mm) normally I preheat the bed at 35°C. some times to heat the bed takes a longer time than heating the nozzle. This is the main reason that I prefer to preheat the printer.</p>

CC BY-SA 3.0
2018-03-01T00:36:26.497Z
2018-03-01T00:36:26.497Z
Fernando Baltazar
<p>The G-code to delay is <code>G4</code>.</p>

<p><code>G4 P60000</code> will wait for one minute. The <code>P</code> is in milliseconds. Some firmware also accept a <code>S</code> Parameter that has the seconds. So, if supported, <code>G4 S60</code> would do the same thing.</p>

<p>The details for this and all other G-codes are documented
<a href="http://reprap.org/wiki/G-code" rel="noreferrer">here</a>.</p>

CC BY-SA 3.0
2018-03-01T19:57:39.130Z
In my end-G-code, I shut off the hot end, and wait several minutes before shutting off the fan. I was getting communications timeout errors and the fan would never actually shut off from the code (using Monoprice Select Mini with Octoprint). If this occurs for you before the print, it will not print at all. I resolved it by simply breaking it up unto a series of shorter delays.
mbmcavoy
CC BY-SA 4.0
2019-05-28T06:55:09.390Z
For cncjs, the command is G4 P0.5 for half a second, for example. i.e. it's a float, not an int.
Gavin Simpson
CC BY-SA 4.0
2019-05-28T20:49:51.850Z
so the P actually behaving like the S parameter (seconds instead of milliseconds).  Can you also put that information into here: https://reprap.org/wiki/G-code#G4:_Dwell
Lars Pötter
CC BY-SA 4.0
2023-07-18T18:27:46.417Z
3D printer firmware tends to use P<milliseconds> whereas CNC firmware (eg. LinuxCNC, GRBL, etc) uses P<seconds> floating point. You have to test it on your specific firmware to make sure.
CR.
CC BY-SA 4.0
2016-02-08T17:15:01.823Z
2018-08-02T19:32:02.170Z
2018-08-02T19:32:02.170Z
Lars Pötter
<p>My printer has an auto-leveling feature that works by touching the build plate with the tip of the nozzle.</p>

<p>I started using a BuildTak surface and BuildTak is damaged when you push a hot nozzle into it.</p>

<p>So I edited the start G-code to run the auto-leveling before heating up the hotend</p>

<p>But ABS doesn't stick to the build surface unless I pre-heat the hotend and wait about a minute.</p>

<p>So now I'm looking for a G-code command to put at the end of the start G-code that will make the printer wait a minute before printing</p>

<p>The sequence I'm looking for is:</p>

<ul>
<li>Heat up the bed</li>
<li>Auto level</li>
<li>Raise the hotend a little bit so it doesn't touch the build plate</li>
<li>Heat up the hotend</li>
<li><em>Wait a minute (that's the only part that is missing, everything else works)</em></li>
<li>Start printing</li>
</ul>

<p>Any way to insert a delay into the G-code?</p>

<p>I'm using Cura to slice/print, my printer is Robo3D R1+</p>

CC BY-SA 3.0
2016-02-07T21:39:03.737Z
G4 P60000   as explained here:http://reprap.org/wiki/Gcode#G4:_Dwell
Lars Pötter
CC BY-SA 3.0
2016-02-07T21:44:57.287Z
Hi, @Nir! So, you want to set hotend temperature, and wait until it is warm before printing (at the end of start.gcode)? I generally doubt you really need to explicitly set a delay - it is basically a hack to overcome (not fix) the problem!
Tormod Haugene
CC BY-SA 3.0
2016-02-07T21:52:47.733Z
@LarsPötter That should be an answer, not a comment!
Tom van der Zanden
CC BY-SA 3.0
2016-02-07T22:04:28.917Z
@TormodHaugene - I wrote the entire back story as to why I'm looking for this, if you have a better solution I'm open to trying it
Nir
CC BY-SA 3.0
2016-02-07T22:05:36.203Z
@Nir, I believe I answered that previous question. It's getting late now, but I can have a look at it tomorrow, if you like! :-)
Tormod Haugene
CC BY-SA 3.0
2016-02-08T07:26:35.527Z
@Nir, could you post the code in start.gcode  that you are currently using? I believe ´M109 S{print_temperature}´ is the command you are looking for, as was posted in the previous question. Did that work?

http://3dprinting.stackexchange.com/questions/454/how-to-configure-cura-to-run-the-z-probe-before-heating/469#469
Tormod Haugene
CC BY-SA 3.0
2016-02-08T07:36:25.650Z
@TormodHaugene - yes, M 109 works, everything works perfectly for PLA but ABS doesn't stick to the bed, if I pre-heat the hotend (and remove the M 109) the ABS does stick to the bed - so my working assumption (that I have to test) is that it takes a little bit of extra time for the heat to make it from the thermistor to the tip of the nozzle
Nir
CC BY-SA 3.0
2016-02-08T07:39:21.423Z
@Nir, Oh, I see. In that case, you are probably right that adding a delay or "Dwell" (with G4) is the way to go. :-)
Tormod Haugene
<g-code>
Is there a G-code for waiting?
Nir
# Is there a G-code for waiting?

(Asked by: username_0 on 2016-02-07)

My printer has an auto-leveling feature that works by touching the build plate with the tip of the nozzle.

I started using a BuildTak surface and BuildTak is damaged when you push a hot nozzle into it.

So I edited the start G-code to run the auto-leveling before heating up the hotend

But ABS doesn't stick to the build surface unless I pre-heat the hotend and wait about a minute.

So now I'm looking for a G-code command to put at the end of the start G-code that will make the printer wait a minute before printing

The sequence I'm looking for is:

* Heat up the bed
* Auto level
* Raise the hotend a little bit so it doesn't touch the build plate
* Heat up the hotend
* *Wait a minute (that's the only part that is missing, everything else works)*
* Start printing

Any way to insert a delay into the G-code?

I'm using Cura to slice/print, my printer is Robo3D R1+

**Tags:** g-code

> **Comments:**
> **username_1**: G4 P60000   as explained here:http://reprap.org/wiki/Gcode#G4:_Dwell  
> **username_2**: Hi, @username_0! So, you want to set hotend temperature, and wait until it is warm before printing (at the end of start.gcode)? I generally doubt you really need to explicitly set a delay - it is basically a hack to overcome (not fix) the problem!  
> **username_3**: @username_1 That should be an answer, not a comment!  
> **username_0**: @username_2 - I wrote the entire back story as to why I'm looking for this, if you have a better solution I'm open to trying it  
> **username_2**: @username_0, I believe I answered that previous question. It's getting late now, but I can have a look at it tomorrow, if you like! :-)  
> **username_2**: @username_0, could you post the code in start.gcode  that you are currently using? I believe ´M109 S{print_temperature}´ is the command you are looking for, as was posted in the previous question. Did that work?  http://3dprinting.stackexchange.com/questions/454/how-to-configure-cura-to-run-the-z-probe-before-heating/469#469  
> **username_0**: @username_2 - yes, M 109 works, everything works perfectly for PLA but ABS doesn't stick to the bed, if I pre-heat the hotend (and remove the M 109) the ABS does stick to the bed - so my working assumption (that I have to test) is that it takes a little bit of extra time for the heat to make it from the thermistor to the tip of the nozzle  
> **username_2**: @username_0, Oh, I see. In that case, you are probably right that adding a delay or "Dwell" (with G4) is the way to go. :-)  

---

## 4 answers

### Answer by username_1 on 2016-02-08. Score: 31 | Accepted answer

The G-code to delay is `G4`.

`G4 P60000` will wait for one minute. The `P` is in milliseconds. Some firmware also accept a `S` Parameter that has the seconds. So, if supported, `G4 S60` would do the same thing.

The details for this and all other G-codes are documented
[here](http://reprap.org/wiki/G-code).

> **Comments:**
> **username_6**: In my end-G-code, I shut off the hot end, and wait several minutes before shutting off the fan. I was getting communications timeout errors and the fan would never actually shut off from the code (using Monoprice Select Mini with Octoprint). If this occurs for you before the print, it will not print at all. I resolved it by simply breaking it up unto a series of shorter delays.  
> **username_7**: For cncjs, the command is G4 P0.5 for half a second, for example. i.e. it's a float, not an int.  
> **username_1**: so the P actually behaving like the S parameter (seconds instead of milliseconds).  Can you also put that information into here: https://reprap.org/wiki/G-code#G4:_Dwell  
> **username_8**: 3D printer firmware tends to use P<milliseconds> whereas CNC firmware (eg. LinuxCNC, GRBL, etc) uses P<seconds> floating point. You have to test it on your specific firmware to make sure.  

---

### Answer by username_2 on 2016-02-08. Score: 15

An alternative solution to using a hard delay with the [G4 dwell command](http://reprap.org/wiki/G-code#G4:_Dwell), is to increase the time that the temperature set with [M109](http://reprap.org/wiki/G-code#M109:_Set_Extruder_Temperature_and_Wait) has to be held before it continues with the next command.

In Marlin, this setting is named `TEMP_RESIDENCY_TIME`, and can be found around line 150 in `Configuration.h`. By default, this is set to 5 seconds, which looks like:

```
// Actual temperature must be close to target for this long before M109 returns success
#define TEMP_RESIDENCY_TIME 5  // (seconds)

```

If increasing this setting solves your exact problem, I cannot say, but it could be worth looking into.


---

### Answer by username_4 on 2022-11-06. Score: 2

Thank you username_5 username_5 for the G-code you used to solve the hot end cooling issue after bed levelling probing. I did change `M190` to `S60` but kept everything else. This worked.

```
G29 ; Autonivel
M190 S35 ; set bed temperature
G1 Z4 F240 ; lift nozzle
M109 S195 ; wait for temperature to be reached
G21 ; set units to millimeters
G90 ; use absolute coordinates
M82 ; use absolute distances for extrusion
M104 S210 ; set temperature
G92 E0
G1 E-1.5000 F1800
G1 Z0.225 F240

```


---

### Answer by username_5 on 2018-03-01. Score: 1

I´m using this code for my prints.

```
    G29 ; Autonivel
    M190 S35 ; set bed temperature
    G1 Z4 F240 ; lift nozzle
    M109 S195 ; wait for temperature to be reached
    G21 ; set units to millimeters
    G90 ; use absolute coordinates
    M82 ; use absolute distances for extrusion
    M104 S210 ; set temperature
    G92 E0
G1 E-1.5000 F1800
G1 Z0.225 F240

```

On M190 S35, the nozzle is still on the low position (1.2mm), then goes to 4mm then waits for the extruder temperature Ex. 195°C; when the extruder reach the 195°C for 10 seconds then the printers starts to print going the nozzle to 0.22mm while the nozzle reach the second temperature of 210°C. On This time its allow me to clean the nozzle and normalize the temperatures for a good prints.

**Note:**
To avoid the nozzle stays many time on low position (1.2mm) normally I preheat the bed at 35°C. some times to heat the bed takes a longer time than heating the nozzle. This is the main reason that I prefer to preheat the printer.


---

