G04 is a G-code command that instructs the CNC machine to pause or dwell for a specified amount of time. This can be useful for various purposes, such as allowing the spindle to reach the desired speed, waiting for a coolant to settle, or creating a precise hole or slot.
Usage Format
The general format of G04 is:
G04 X.. or G04 P..
where X or P is the dwell time in seconds or milliseconds, depending on the machine’s settings. For example:
G04 X2
means dwell for 2 seconds.
G04 P500
means dwell for 500 milliseconds.
Explanation
When the CNC machine encounters a G04 command, it will stop all motion and hold the current position until the dwell time elapses. Then, it will resume the next command in the program. The dwell time can be a fixed value or a variable, depending on the machine’s capabilities. For example:
G04 X#[1000+RND*100]
means dwell for a random time between 1000 and 1100 milliseconds.
The dwell command can be used in conjunction with other G-code commands, such as G00 (rapid move), G01 (linear move), G02 (clockwise arc), G03 (counterclockwise arc), etc. For example:
G00 X10 Y10
means rapid move to X10 Y10.
G04 X1
means dwell for 1 second.
G01 X20 Y20 F100
means linear move to X20 Y20 at feed rate 100.
Example
Here is an example of a CNC program that uses G04 to create a rectangular slot with rounded corners. The text diagram shows the path of the tool and the dwell points.
% (Program start)
O1000 (Program number)
T1 M06 (Select tool 1 and change tool)
G90 G54 (Absolute coordinates and work offset)
S1000 M03 (Spindle speed 1000 and clockwise rotation)
G00 X0 Y0 (Rapid move to X0 Y0)
G43 H1 Z5 M08 (Tool length compensation and coolant on)
G01 Z-5 F50 (Plunge to Z-5 at feed rate 50)
G01 X50 F100 (Linear move to X50)
G04 X0.5 (Dwell for 0.5 second)
G02 X60 Y10 I5 J0 (Clockwise arc to X60 Y10 with center at X55 Y10)
G04 X0.5 (Dwell for 0.5 second)
G01 Y40 (Linear move to Y40)
G04 X0.5 (Dwell for 0.5 second)
G03 X50 Y50 I0 J5 (Counterclockwise arc to X50 Y50 with center at X50 Y45)
G04 X0.5 (Dwell for 0.5 second)
G01 X0 (Linear move to X0)
G04 X0.5 (Dwell for 0.5 second)
G02 X-10 Y40 I-5 J0 (Clockwise arc to X-10 Y40 with center at X-5 Y40)
G04 X0.5 (Dwell for 0.5 second)
G01 Y10 (Linear move to Y10)
G04 X0.5 (Dwell for 0.5 second)
G03 X0 Y0 I0 J-5 (Counterclockwise arc to X0 Y0 with center at X0 Y5)
G04 X0.5 (Dwell for 0.5 second)
G00 Z5 (Rapid move to Z5)
M09 (Coolant off)
G91 G28 Z0 M19 (Return to reference position and orient spindle)
M30 (Program end)
%
Diagram:
Y
^
|
50 +-----+-----+
| | |
| | |
40 + *--+--* +
| / \ |
| / \ |
|/ \|
30 + +
| |
| |
20 + +
| |
| |
|\ /|
10 + \ / +
| \ / |
| *--+* |
0 +-----+-----+-----> X
| | |
0 25 50