G81 is a canned cycle for drilling in CNC machines. A canned cycle is a predefined sequence of operations that can be repeated with different parameters, such as depth, feed rate, and spindle speed. Canned cycles simplify the programming of common machining tasks and reduce the number of lines of code.
Usage format
The general format of G81 is:
G81 X Y Z R F
where:
X
andY
are the coordinates of the hole centerZ
is the depth of the hole (negative value)R
is the retract height above the hole (positive value)F
is the feed rate for drilling
Explanation
When G81 is executed, the following steps are performed:
- The tool moves to the hole center at the current feed rate
- The tool moves down to the retract height at the current feed rate
- The tool moves down to the depth at the specified feed rate
- The tool retracts to the retract height at the current feed rate
- The tool moves to the next hole center or returns to the initial position
A text diagram of G81 is shown below:
R
|<----->|
| |
| | F
| v
| |
| |
| Z
| |<----->|
| | |
| | |
| | |
+-------+-------+ X,Y
Example
Here is an example of G81 code for drilling four holes in a square pattern:
G90 G17 G54 G00 X0 Y0 S1200 M03
G43 H01 Z0.1 M08
G81 X1 Y1 Z-0.5 R0.2 F5
X3
Y3
X1
G80 G00 Z0.1 M09
G91 G28 Z0 M05
M30
The code does the following:
- Sets the absolute mode, XY plane, and work offset
- Moves to the origin and starts the spindle at 1200 rpm
- Activates the tool length compensation and moves to 0.1 inch above the workpiece
- Starts the G81 cycle with the following parameters:
- Hole center at X1 Y1
- Hole depth at -0.5 inch
- Retract height at 0.2 inch
- Feed rate at 5 inch/min
- Repeats the cycle for the other three holes
- Cancels the cycle and moves to 0.1 inch above the workpiece
- Returns to the machine home position and stops the spindle
- Ends the program