3 CNC Programming R2
3 CNC Programming R2
Preparatory codes
G codes
M codes
Miscellaneous codes
CODES
G codes
M codes
Control the machine
functions other than
tool movements
CODES
G codes
G Codes - Axial Movements
+X
+Z
-Z
-X
Coordinate positioning : Diametral
We will use Diametral
system for this course
+X
+Z
-Z
-X
G Codes - Axial Movements
G00 X30 Z5
Tool
Home Position
+X X30 Z5
40 -Z
+Z
-X
G Codes - Axial Movements
G00 X30 Z5
G01 X30 Z-20 F40 Feed rate
Tool
X30 Z-20
+X X30 Z5
40 -Z
+Z
-X
G Codes - Axial Movements
G00 X30 Z5 (Home 1)
G01 X30 Z00 F40(1 2)
X40 Z-35 (2 3)
3 Home
Position
2 1
+X
Ø40 Ø30 -Z
+Z
-X
35
G Codes - Axial Movements
Clockwise Circular
G02 Machining in a clockwise circular arc
interpolation
G00 X20 Z5
-X
15
25
G Codes - Axial Movements
Counter-clockwise
Machining in a counter-clockwise
G03 Circular
circular arc
interpolation
G00 X20 Z5
Ø40
Ø40 Ø20
Ø20 -Z +Z Counter-
clockwise
-X
15
25
G Codes – Machine Setup
For Milling ONLY
All coordinates are relative to the
G90 Absolute positioning reference position
(i.e. Workpiece Origin)
All coordinates are relative to the
G91 Incremental positioning current position
× Absolute positioning
Machine will run on Absolute Mode by
default
U Incremental mode in X axis
× Incremental positioning W Incremental mode in Z axis
G Codes - Axial Movements
Return to machine (Rapid traverse) Moves the tool at a
G28
home position very fast rate to the home position
Incremental Incremental
mode in mode in
Tool
X axis Z axis
Important point
Home Tool will
+X Position • move 00 in the X direction
and 00 in the Z direction
40 (incremental mode)
+Z
-Z
• and then will return to the
-X Home position
G Codes – Machine Setup
C
A
B
A B
C
0
+Y
D
0
-X +X
-Y
CODES
M codes
Control the machine
functions other than
tool movements
M codes : Group 1
M08 Coolant ON
10
30
45
50
-X
+X
-Z
+Z
-X
+X
Roughing depth of
Cut
-Z
+Z
-X
+X
-Z
+Z
-X
+X
-Z
+Z
-X
+X
-Z
+Z
-X
+X
-Z
+Z
-X
+X
-Z
+Z
-X
+X
-Z
+Z
Material to be left
for finish pass
-X
+X
Material being
removed by
finishing pass
-Z
+Z
-X
+X
Roughing depth of
Cut
-Z
+Z
Material to be left
for finish pass
-X
Canned Cycles
• Many turning operations require tedious and
redundant motions, such as the multiple passes
performed during a rough turning operation or
multiple pecks required for deep hole-drilling
operations.
• Machine control manufacturers have equipped the
controls with features that make these tedious
operations easier and faster to program.
• These machining routines can be packaged or
“canned” into one or two blocks of code and are
called canned cycles.
Stock Removal Turning Cycle : G71
• Function G71 is the stock removal cycle for turning
that removes metal along the direction of the Z axis.
In a case where there is a lot of material to be
removed, this cycle provides an easy method for
programming.
Block 1 G71 U R
Block 2 G71 P Q U W F
Stock Removal Turning Cycle : G71
depth of
roughing cut amount of retract, along
(no sign) the X axis, for each cut
Block 1 G71 U R
Block 2 G71 P Q U W F
block number where the amount of material for roughing feed rate
code for the contour finishing to be left on
begins all diameters
(X axis)
Depth of Cut U
R12.5
Retract amount R
-Z +Z
10
25
62.5
75
-X
Stock Removal Turning Cycle : G71
G70 P Q F S
20
Facing Cycle : G94
G21 G98 (Metric unit and feed in mm/min)
G28 U0 W0 (Go to home position)
M06 T0101 (Tool 1 & Offset 1) P
Ø10
M03 S2500 (Clockwise spindle at 2500rpm) X12 Z2
+X
G00 X12 Z2 ( Home
(Go → position)
to home P)
20
Facing Cycle : G94
G21 G98 (Metric unit and feed in mm/min)
G28 U0 W0 (Go to home position)
M06 T0101 (Tool 1 & Offset 1) P
Ø10
M03 S2500 (Clockwise spindle at 2500rpm) X12 Z2
+X
G00 X12 Z2 ( Home
(Go → position)
to home P)
20
Facing Cycle : G94
G21 G98 (Metric unit and feed in mm/min)
G28 U0 W0 (Go to home position)
M06 T0101 (Tool 1 & Offset 1) P
M03 S2500 (Clockwise spindle at 2500rpm) X12 Z2
+X
G00 X12 Z2 ( Home
(Go → position)
to home P)
20
Peck Drilling Canned Cycle G74
amount of retract
G74 R
G74 X Z Q F
G74 R
Z
G74 X Z Q F
Micrometre (µm)
R
Q Micrometre (µm)
Clearance
Clearance
G74 R1
20
G74 X0 Z-20 Q5000 F50
Micrometre (µm)
1
Clearance
Threading Cycle : G76 angle of Micrometre (µm) in
software
Relief angle (to the thread mm in machine
number of
retract it may be minimum cut
finishing cuts
require some depth for rough
angle) cut
Block 2 G76 X Z P Q F