G04: Dwell
G04 pauses the program for a set time while the spindle keeps turning. It's used to let the spindle reach speed and to clean up the bottom of a hole.
G04 stops the axes for a set time, then carries on with the next line. The spindle and coolant keep running. It isn't modal: it only applies to the line it's on.
G4 P2
Common uses
- Spindle warm-up. After
M3, some spindles take a second or two to reach full speed. A short dwell stops the first cut starting too early. - The bottom of a hole or counterbore. A brief pause at full depth lets the tool clean up the floor before it retracts. For many holes, the G82 drilling cycle does this for you.
- Chip and coolant breaks. A pause can give coolant or air time to clear chips.
P and X: seconds or milliseconds?
The biggest trap with G04 is the unit of the dwell time, which differs between controls:
| Control | Dwell word | Unit |
|---|---|---|
| GRBL | P |
Seconds (decimals allowed) |
| LinuxCNC | P |
Seconds |
| Mach3 | P |
Seconds by default, milliseconds if set in the configuration |
| Fanuc-style | X |
Seconds (decimals allowed) |
| Fanuc-style | P |
Milliseconds, whole numbers |
So G4 P500 is half a second on a Fanuc-style control, but over eight minutes on GRBL or LinuxCNC. If a program was written for a different machine, check every G04 before you run it.
Example: spindle warm-up and a dwell at the bottom of a hole
The program waits 2 seconds after starting the spindle, spot drills one hole 2 mm deep, and pauses half a second at the bottom before retracting. The P values are in seconds, as GRBL and LinuxCNC read them.
(G04 example: dwell for spindle warm-up and at the bottom of a hole)
(P is in seconds here, as on GRBL and LinuxCNC)
G21 G17 G90 G54
T1 M6 (6 mm spot drill)
S8000 M3
(Wait 2 seconds for the spindle to reach speed)
G4 P2
G0 Z10
G0 X20 Y20
G0 Z2
G1 Z-2 F100
(Pause 0.5 seconds at the bottom for a clean floor)
G4 P0.5
G0 Z10
M5
M30
In CutViewer, choose Dwell (G04) in the menu next to the play controls to jump between the two G04 lines.
Line by line:
S8000 M3starts the spindle, thenG4 P2waits 2 seconds before any move.G1 Z-2 F100drills down to full depth.G4 P0.5holds the tool at the bottom for half a second, thenG0 Z10retracts.
How CutViewer shows G04
A dwell doesn't move the tool, so there's nothing to draw. CutViewer lists every G04 line so you can jump between them with the Dwell (G04) option in the menu next to the play controls. Axis words on a G04 line, such as Fanuc's X dwell time, are not treated as a move.
Frequently Asked Questions
Is G04 P in seconds or milliseconds?
It depends on the control. GRBL and LinuxCNC read P as seconds. On Fanuc-style controls, P is in milliseconds and takes whole numbers, while X gives the time in seconds. Mach3 uses seconds by default but has a setting to switch to milliseconds. Check before copying a program between machines.
Is G04 modal?
No. G04 only applies to the line it's on. Put it on a line of its own with the dwell time.
Does the spindle stop during a G04 dwell?
No. The axes stop, but the spindle and coolant keep running unless the program turns them off.
What is the difference between G04 and G82?
G04 is a single pause wherever you put it. G82 is a drilling cycle with a dwell at the bottom of every hole, set by its own P word, so you don't need a separate G04 for each hole.
More G-Code Guides
Rapid positioning and straight cutting moves.
Clockwise and counter-clockwise arcs with I/J/K or R.
Choose the XY, XZ or YZ plane for arcs.
Inch or millimetre units for the program.
Return to home or a second reference position.
Cutter radius compensation, left, right and off.
Tool length offset on and off.
Work coordinate systems and machine coordinates.
Drilling canned cycles, from plain drilling to peck drilling.
Tapping cycle, and how to work out the feed rate.
Absolute positions or incremental distances.
Set the current position by shifting coordinates.
Feed per minute, per revolution, or inverse time.
Constant surface speed or a fixed spindle RPM.
Where a drilling cycle retracts between holes.
Spindle, coolant, tool change, stop and subprogram codes.
Check your own program before you cut: open it in CutViewer to see the toolpath in 3D, the run time and any problems.
Open CutViewer