G-codeMotionMill · Lathe · 3D printer

G04: Dwell

G04 holds the program at the end of the block before it for a set time, then carries on with the next block. G04 P1000 is a one second pause on a Fanuc, a Haas and Marlin, where P is in milliseconds, and a 16 minute 40 second pause on Grbl, where P is in seconds. The axes stand still while the spindle keeps the speed it had and the feed rate already programmed stays in force afterwards. G04 is a one-shot code in group 00: it acts in its own block and is gone by the next.

Syntax

G04 P__         Dwell, P in milliseconds (Fanuc, Haas without a decimal point, Marlin)
G04 X__         Dwell, X with a decimal point in seconds (ISO form)
G4 F__          Dwell in seconds (Siemens native)
G4 S__          Dwell in spindle revolutions (Siemens native)
G04 F__         Dwell in seconds (Okuma OSP)

Parameters

AddressMeaningNotes
PDwell timeWhole milliseconds on a Fanuc, no decimal point: P500 is half a second. Seconds on Grbl. On a Haas, P with a decimal point is seconds and without one milliseconds
XDwell time, ISO formA decimal point is allowed. Without one the value is read in input units, so X1000 on a 0.001 increment is 1, not 1000
UDwell time, lathe ISO formRead as X, decimal point rule included
FDwell in secondsSiemens native and Okuma OSP. On a Siemens it does not replace the cutting feed
SDwell in spindle revolutions, or secondsRevolutions on a Siemens in native mode; seconds on Marlin, where S wins over P if both are given

The dwell starts once the block before it is complete, so a G04 after a feed to depth waits at the bottom, not partway down. To dwell for a number of turns rather than a time, divide 60 by the spindle speed: at 1200 rev/min one revolution takes 0.05 seconds, so three turns is G04 P150.

Example

O0010 (COUNTERBORE 2 HOLES FOR M6 CAP SCREWS, ALUMINIUM)
G21 G17 G40 G49 G80 G90          (safe start block)
T05 M06                          (11MM COUNTERBORE, 6.6MM PILOT)
G54
S1200 M03
G00 X30. Y20.                    (first hole)
G43 H05 Z25. M08                 (tool length comp on, coolant)
Z2.
G01 Z-6.5 F80                    (feed to depth, 6MM HEAD PLUS 0.5)
G04 P150                         (3 TURNS AT 1200 REV/MIN CLEAN THE FLOOR)
G00 Z2.                          (retract)
X70.                             (second hole)
G01 Z-6.5 F80
G04 P150
G00 Z25. M09
G49
G91 G28 Z0.                      (home Z)
M05
M30

Controller differences

ControlBehaviour
FanucP is whole milliseconds and takes no decimal point: G04 P1000 is one second, and G04 P0.5 stops the program with PS0007, illegal use of decimal point. The manual's own advice for tapping closely spaced holes is a G04 between them, so the spindle is back to speed before the next hole.
HaasThe decimal point decides the unit: G04 P10. is ten seconds and G04 P10 ten milliseconds. On the lathe the code card gives P as seconds and milliseconds, and the workbook reads P2.5 as two and a half seconds.
Siemens 840DNative G4 goes in a block of its own, with the time in seconds at F (G4 F3) or in spindle revolutions at S (G4 S30, or S2= for spindle 2). The F and S on the G4 block are used only for the dwell: the feed and speed programmed before it carry on. G4 interrupts continuous-path mode. In ISO dialect mode G04 X or G04 P is read as a time, unless bit 2 of MD20734 $MC_EXTERN_FUNCTION_MASK is set, which makes it seconds under G94 and spindle revolutions under G95.
MazakIn EIA/ISO the feed mode picks the unit: G04 is a dwell in time under G94 and a dwell in spindle revolutions under G95 (G98 and G99 on an Integrex).
OkumaOn an OSP lathe the time goes in F, G04 F__, and the longest dwell allowed is 9999.99 seconds.
GrblP is in seconds and takes a decimal: G4 P0.5 is half a second and G4 P1000 is 1000 seconds. A G4 with no P stops the stream with error:28, and a negative P with error:4. Before it waits, Grbl lets every buffered move finish, so the machine comes to a full stop.
MarlinP is milliseconds and S seconds, and S wins if both are on the block. G4 with no word at all waits for the moves already queued to finish, the same as M400.

What goes wrong

A dwell copied from one control to another runs a thousand times too long or too short. G04 P1000 is one second on a Fanuc, a Haas and Marlin, and 16 minutes 40 seconds on Grbl, where P is seconds. On a Haas the decimal point flips the unit: P1.5 is a second and a half, P15 is 15 milliseconds. A Fanuc refuses the decimal outright and stops on PS0007. Read every P against the control it is going to run on.

Next is the dwell that counts turns instead of seconds. Under G95 a Mazak reads G04 as spindle revolutions, and so does a Siemens in ISO mode with bit 2 of MD20734 set, where G04 X1000 written without a decimal point is one revolution. Native Siemens says it openly with G4 S30, but 30 turns is six seconds at 300 rev/min and 1.8 seconds at 1000, so the same block changes length every time the speed does.

Then the dwell in the wrong place. Siemens G4 breaks continuous-path mode, and Grbl and Marlin empty the motion buffer before they wait, so a pause written partway along a contour brings the axes to a dead stop with the cutter against the wall. On a finish pass that leaves a witness mark you can feel with a fingernail. Dwell at the bottom of a plunge or before a retract, nowhere else.

Last, the dwell that is simply too long. At 1200 rev/min one turn takes 50 milliseconds, so three turns, P150, clean the floor of a counterbore. A habitual P2000 is 40 turns of rubbing, enough to glaze the floor and work-harden stainless before the next tool arrives.

Updated 23 Oct 2026