G04 CNC Code
G04 is a CNC G code and used to dwell (pause) in CNC programs.
In this time period – specified in the program (with G04 CNC code) – any axis motion is stopped, while all other program commands and functions remain unchanged (function normally). When the specified time expires, control system resumes processing of program block immediately following the dwell command.
G04 Code Format
|G04 X.. (or P or U) ;|
|G04: CNC G code for dwell|
|X: Time for dwell in seconds (All machines, excluding fixed cycles)|
If you use P or U instead of X;
P: Time for dwell in milliseconds (All machines, including fixed cycles)
U: Time for dwell in seconds (Lathes only)
|1s = 1000ms|
|1ms = 0.001s|
|s = second|
|ms = millisecond|
|P1 = P0001 … 1 millisecond =0.001 second|
|P10 = P0010 … 10milliseconds =0.01 second|
|P100 = P0100 … 100 milliseconds =0.1 second|
|P1000 = P1000 … 1000 milliseconds =1.0 second|
G04 CNC Code Examples
Example – 1
Examples of practical application of the dwell format are:
|G04 X2.0 ; ( preferred for long dwells – in seconds )|
G04 P2000 ; ( preferred for short or medium dwells – in ms )
G04 U2.0 ; ( lathe only – in seconds )
In these examples, the dwell is 2 seconds or 2000 milliseconds. All three formats are shown with identical results.
Example – 2
|G04 X0.5 ;|
G04 P500 ;
G04 U0.5 ;
This example illustrates a dwell of 500 milliseconds, or one half of a second. Again, all three formats are shown.
Example – 3
At the bottom of grooves a dwell of one second is to be programmed.
|N20 G00 X45.Z-15. ;|
N25 G01 X30.F0.2 ;
N30 G04 X1. ; (Dwell of 1 second)
N35 G00 X45. ;
N40 Z-25. ;
N45 G01 X30. ;
N50 G04 X1. ; (Dwell of 1 second)
N55 G00 X45. ;
Block numbers N25 and N45 correspond to grooving operation. At the bottom of each groove a dwell of one second is programmed. Block numbers N30 and N50 represent the same.
Note: X axis is the only axis common to all CNC machines. No axis motion will take place when the X, P or U address is used with the dwell command G04.
Programming a dwell with G04 CNC code is very easy and can be quite useful in two main applications:
- During actual cutting, when the tool is in contact with material
- For operation of machine accessories, when no cutting takes place
Each application is equally important to programmers, although the two are not used simultaneously.
Applications for Cutting
When cutting tool is removing material stock, it is in contact with the machined part. A dwell can be applied during machining for a number of reasons. If the spindle is running, the spindle speed (r/min) is very important.
In practice, the application of dwell during a cut may be used for breaking chips while drilling, grooving, countersinking, counter boring, or parting-off. Dwell may also be used while turning or boring, in order to eliminate any physical marks left on the part by end thrust of the cutting tool. This thrust is the result attributed to various tool pressures during cutting. In many other applications, the dwell function is useful to control cutting feed deceleration on a corner during very fast feedrates, for example. This use of dwell could be particularly useful for older control systems with a possible backlash problem. In both cases, specified dwell command ‘forces’ the machining operation to be fully completed in one block, before the next block can be executed. CNC programmer still has to supply the exact length of time required for the pause duration. This time has to be sufficient – neither too short nor too long.
Note: Dwell command is always completed before the next operation begins!
Applications for Accessories
The second common application of dwell is after certain miscellaneous functions – M functions. Several such functions are used to control a variety of CNC machine accessories, such as barfeeder, tailstock, quill, part catcher, custom features, and many others.
Programmed dwell time must allow for the full completion of a certain procedure, such as the operation of a tailstock. During such a procedure, the machine spindle may be either stationary or rotating. Since there will be no contact of the cutting tool with part material in this situation, it is not important whether the machine spindle actually rotates or not.
On some CNC machines, the dwell command may also be needed when changing spindle speed, usually after gear range change. This applies mainly to CNC lathes. In these cases, the best advice as to how and when to program dwell time is to follow the CNC machine manufacturer’s recommendation.