<p>The code <code>G4</code> refers to <em>dwell</em>. (From what I'm seeing, it can be written as either <code>G4</code> or <code>G04</code>). <code>P</code>is the length of dwell time, usually in milliseconds. The parameter <code>S</code> seems to be invalid, because the only inputs are <code>X</code> (seconds), <code>P</code> (milliseconds), or <code>U</code> (undefined). If you have <code>S20</code> in your code, it is invalid, whereas <code>P2000</code> will cause all axes to remain unmoving for 2 seconds before moving on. </p>

<p>(Note: Not all machines will accept <code>X</code> or <code>U</code>.)</p>

<p><strong>EDIT:</strong> This answer is specific to <em>non-specific</em> g-code, taken from this <a href="https://all3dp.com/g-code-tutorial-3d-printer-gcode-commands/" rel="nofollow noreferrer"><em>Source</em></a>, since the OP did not state any specifics about their firmware type or equipment used.</p>

CC BY-SA 4.0
2018-11-16T13:12:04.833Z
See Oscar's answer -- yours is applicable only to certain firmwares.
Carl Witthoft
CC BY-SA 4.0
2018-11-16T16:02:30.933Z
I'm curious to know for which firmware(s) this is, could you please add that to your answer.
0scar
CC BY-SA 4.0
2018-11-16T10:54:07.443Z
2018-11-16T16:19:32.830Z
2018-11-16T16:19:32.830Z
Pᴀᴜʟsᴛᴇʀ2
<p>The answer is that <strong><em>it depends on the type of firmware</em></strong> you are using.</p>

<p>Let us look at the documentation of <a href="https://reprap.org/wiki/G-code#G4:_Dwell" rel="nofollow noreferrer"><code>G4</code></a> to find that <code>G4</code> is valid for all the listed firmware types:
<a href="https://i.sstatic.net/Tt7wT.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Tt7wT.png" alt="enter image description here"></a></p>

<blockquote>
  <p>Pause the machine for a period of time.</p>
</blockquote>

<p>Furthermore it states that:</p>

<blockquote>
  <p><strong>Parameters</strong></p>
  
  <ul>
  <li>Pnnn Time to wait, in milliseconds (In Teacup, P0, wait until all previous moves are finished)</li>
  <li>Snnn Time to wait, in seconds (Only on Repetier, Marlin, Smoothieware, and RepRapFirmware 1.16 and later)</li>
  </ul>
</blockquote>

<p>It clearly shows that the <code>S</code> parameter (which defines the pause in seconds) is only supported by a few firmware types. Do note that this documentation may not be up-to-date, so it is best to look into the source code or the users manual of the particular firmware you are using.</p>

<hr>

<p>E.g. if you are using Marlin Firmware, <code>G4 S20</code> will pause the machine for 20 seconds while <code>G4 P2000</code> will pause the machine for 2000 milliseconds which is 2 seconds. This means that a different time is requested, to have 20 seconds waiting time you could use <code>G4 P20000</code></p>

<p>To answer your question what the <strong><em>actual difference</em></strong> between the 2 commands is:</p>

<ul>
<li>it is <strong>either</strong> 18 seconds of extra waiting time if your firmware supports the <code>S</code> parameter, <strong>or</strong> </li>
<li>a firmware that skips or chokes on the command because it is not supported (that also probably depends on your firmware).</li>
</ul>

CC BY-SA 4.0
2018-11-16T13:09:51.973Z
2018-11-16T14:35:54.573Z
2018-11-16T14:35:54.573Z
0scar
<p>Given the Marlin Firmware what is the difference between the following lines of code:</p>

<blockquote>
  <p>G4 S20</p>
</blockquote>

<p>and</p>

<blockquote>
  <p>G4 P2000</p>
</blockquote>

CC BY-SA 4.0
2018-11-16T13:11:07.663Z
You really ought to be able to look up gcode reference tables online!
Carl Witthoft
CC BY-SA 4.0
2018-11-16T13:11:19.000Z
Please [edit] your question to include the firmware you are using so that people can answer the question for your specific case.
0scar
CC BY-SA 4.0
2018-11-17T18:01:55.920Z
@CarlWitthoft of course I did prior to asking.
Arthur Mamou-Mani
<g-code>
G4 S20 vs. G4 P2000
Arthur Mamou-Mani
# G4 S20 vs. G4 P2000

(Asked by: username_0 on 2018-11-16)

Given the Marlin Firmware what is the difference between the following lines of code:

> G4 S20

and

> G4 P2000

**Tags:** g-code
> **Comments:**
> **username_1**: You really ought to be able to look up gcode reference tables online!  
> **username_2**: Please [edit] your question to include the firmware you are using so that people can answer the question for your specific case.  
> **username_0**: @CarlWitthoft of course I did prior to asking.  

---

## 2 answers

### Answer by username_2 on 2018-11-16. Score: 6 | Accepted answer

The answer is that ***it depends on the type of firmware*** you are using.

Let us look at the documentation of [`G4`](https://reprap.org/wiki/G-code#G4:_Dwell) to find that `G4` is valid for all the listed firmware types:
[![enter image description here](https://i.sstatic.net/Tt7wT.png)](https://i.sstatic.net/Tt7wT.png)

> Pause the machine for a period of time.

Furthermore it states that:

> **Parameters**
>
> * Pnnn Time to wait, in milliseconds (In Teacup, P0, wait until all previous moves are finished)
> * Snnn Time to wait, in seconds (Only on Repetier, Marlin, Smoothieware, and RepRapFirmware 1.16 and later)

It clearly shows that the `S` parameter (which defines the pause in seconds) is only supported by a few firmware types. Do note that this documentation may not be up-to-date, so it is best to look into the source code or the users manual of the particular firmware you are using.

---

E.g. if you are using Marlin Firmware, `G4 S20` will pause the machine for 20 seconds while `G4 P2000` will pause the machine for 2000 milliseconds which is 2 seconds. This means that a different time is requested, to have 20 seconds waiting time you could use `G4 P20000`

To answer your question what the ***actual difference*** between the 2 commands is:

* it is **either** 18 seconds of extra waiting time if your firmware supports the `S` parameter, **or**
* a firmware that skips or chokes on the command because it is not supported (that also probably depends on your firmware).


---

### Answer by username_3 on 2018-11-16. Score: 1

The code `G4` refers to *dwell*. (From what I'm seeing, it can be written as either `G4` or `G04`). `P`is the length of dwell time, usually in milliseconds. The parameter `S` seems to be invalid, because the only inputs are `X` (seconds), `P` (milliseconds), or `U` (undefined). If you have `S20` in your code, it is invalid, whereas `P2000` will cause all axes to remain unmoving for 2 seconds before moving on.

(Note: Not all machines will accept `X` or `U`.)

**EDIT:** This answer is specific to *non-specific* g-code, taken from this [*Source*](https://all3dp.com/g-code-tutorial-3d-printer-gcode-commands/), since the OP did not state any specifics about their firmware type or equipment used.

> **Comments:**
> **username_1**: See Oscar's answer -- yours is applicable only to certain firmwares.  
> **username_2**: I'm curious to know for which firmware(s) this is, could you please add that to your answer.  

---

