3 G Codes Part 1 CNC PDF
3 G Codes Part 1 CNC PDF
UMY
Universitas
Muhammadiyah
Yogyakarta
www.umy.ac.id
CNC/CAM
#3 G Codes Part 1
Tutik Sriani, S.T., M.Eng, PhD
1
1995
Word Characters
2
Address Definition
N Address if block number
G Preparatory function
X, Y, Z Positional data
I, J, K Interpolation parameters
F Feed
S Spindle speed
T Tool number
D Tool offset number
M Miscellaneous function
H Auxiliary function
SPOS/A Spindle position
L Subprogram call
P Number of program passes
Address Definition
R Arithmetic parameter
: Main block
AX Axis value (variable axis program)
ACC Axial acceleration
FA Axial feed
FL Axial feed limit
IP Interpolation parameter
OVRA Axial override
PO Polynomial coefficient
POS Positioning axis
POSA Positioning axis across block
boundary
1995
Operators
3
Operator Definition
+ Addition
- Subtraction
* Multiplication
/ Division (ex: = 0.75)
: Chain operator
Sin() Sine
COS() Cosine
TAN() Tangent
ASIN() Arcsine
SQRT() Square root
ABS() Absolute number
POT() 2
nd
power (square)
TRUNC() Truncate to integer
Address Definition
ROUND() Round to integer
LN() Natural logarithm
EXP() Exponential function
== Equal to
<> Not equal to
> Greater than
< Less than
>= Greater than or equal to
<= Less than or equal to
AND AND
OR OR
NOT Negation
XOR Exclusive OR
1995
Some of G Codes for Milling
4
1995
Some of G Codes for Milling
5
1995
Some of G Codes for Turning
6
1995
Some of G Codes for Turning
7
1995
Plane Designation
8
It is advisable to define the working plane at the beginning of the program. The working
plane must be specified when the tool path compensation G41/G42 is called so that the
control can correct the tool length and radius. In the initial setting, G17 (X/Y plane) is defined
for milling and G18 (Z/X plane) is defined for turning.
1995
0. Positional Data
9
Seq. Code Explanation
N01 G90 G00 X45 Y60 T1 S2000 M3 Absolute dimensioning, rapid traverse to YZ, tool, spindle
on clockwise
N02 G21 G01 Z-5 F500 Enter positions in metric (mm), tool infeed
N03 G02 X20 Y35 I=AC(45) J=AC(35) Circle center point in absolute dimensions
(0,0) : G90 (absolute) or
G91 (incremental)
Dimension: G20/G70 (imperial) or
G21/G71 (metric)
1995
1. G00, Rapid Traverse Movement
Program: G0 X Y Z
X,Y,Z: endpoint in Cartesian coordinates
G00 is used for approaching starting positions or tool
change locations, retracting the tool, etc.
Use the rapid traverse movements to position the tool
rapidly, to travel round the workpiece or to approach tool
change locations.
This function is not suitable for workpiece machining!
10
1995
1. G00, Milling Sample
11
Seq Code Explanation
N01 G90 G 21 S400
M3
Absolute dimensioning,
metric, spindle on CW
N02 G00 X30 Y20 Z2 Approach start position
N03 G01 Z-5 F1000 Tool infeed
N04 X80 Y 65 Travel on straight line
N05 G00 Z2 Retract tool
N06 G00 X-20 Y100
Z100 M30
Retract tool, end of
program
1995
1. G00, Turning Sample
12
Seq Code Explanation
N01 G90 G21 S400 M3 Absolute dimensioning,
metric, spindle on CW
N02 G00 X25 Z5 Approach start position
N03 G01 G94 Z0
F1000
Tool infeed
N04 G95 Z-7.5 F0.2
N05 X60 Z-35 Travel on straight line
N06 Z-50
N07 G00 X62
N08 G00 X80 Z20 Retract tool
N09 M30 End of program
1995
2. G01, Linear Interpolation (Milling)
Program: G01 X Y Z F
X,Y,Z: endpoint (Cartesian), F = feed-rate (mm/min)
13 13
Seq Code Explanation
N01 G90 G21 Absolute dimensioning,
metric
N02 G17 S400 M3 Select working plane
(X/Y), spindle CW
N03 G00 X20 Y20 Z2 Approach start position
N04 G01 Z-2 F40 Tool infeed
N05 X80 Y80 Z-15 Travel along inclined
straight line
N06 G00 Z100 M30 Retract to tool change
location, end of program
1995
2. G01, Linear Interpolation (Straight-Turning)
14
Seq Code Explanation
N01 G90 G20 Absolute dimensioning,
imperial
N02 G18 S400 M03 Select working plane
(X/Z), spindle CW
N03 G00 X4.325 Z0.1 Approach start position
N04 G01 X3.8175 Z-
2.555 F0.01
Pass 1
N05 X3.51 Pass 2
N06 X3.2025 Pass 3
N07 X2.895 Pass 4
N08 X2.5875 Pass 5
N09 X2.22 Pass6
N10 G00 X10.0 Z2.0 Outside workpiece
Back two slides for tapering sample!
1995
Class Exercise #1.1-1.2
15
1995
3. G02/G03, Circular Interpolation
Program: G02/G03 X Y Z I J K
G2 Travel on a circular path in clockwise direction
G3 Travel on a circular path in counterclockwise direction
X Y Z End point in Cartesian coordinates
I J K Circle center point in Cartesian coordinates (in X,Y,Z)
Enables machining full circle/arc.
The control needs the working plane parameter (G17 to G19) in
order to calculate the direction of rotation for the circle G2 is
clockwise/G3 is counterclockwise. It is generally advisable to specify
the working plane.
16
1995
3.1 G02/G03 with Center & End Point
17
Seq Code Explanation
N01 G00 X67.5 Y80.211 Positioning @start point
N02 G03 X17.203
Y38.029 I17.5
J30.211 F500
Infeed CCW, XY @end
point, IJ center point
Incremental mode:
Absolute mode:
Seq Code Explanation
N01 G00 X67.5 Y80.211 Positioning @start point
N02 G03 X17.203
Y38.029 I=AC(50)
J=AC(50)
Infeed CCW, XY @end
point, IJ center point
Able to mill full circle
MILLING
1995
3.1 G02/G03 with Center & End Point
TURNING
Seq Code Explanation
N01 G00 X12 Z0 Positioning @start point
N02 G01 X40 Z-25 F0.2 Tool infeed
N03 G03 X70 Z-75 I-
3.335 K-29.25
Tool infeed CCW, XZ
@end point, IK@center
N04 G1 Z-95 Straight turning
Incremental mode:
Absolute mode:
Seq Code Explanation
N01 G00 X12 Z0 Positioning @start
point
N02 G01 X40 Z-25 F0.2 Tool infeed
N03 G03 X70 Z-75
I=AC(33.33) K=AC(54.25)
Tool infeed CCW, XZ
@end, IK@center
N04 G01 Z-95 Straight turning
1995
3.2 G02/G03 with Radius & End Point
19 19
Seq Code Explanation
N01 G00 X67.5 Y80.211 Positioning @start point
N02 G03 X17.203
Y38.029 CR=34.913
F500
Infeed CCW, XY @end
point, circle radius value
Can not mill full circle
MILLING
1995
3.2 G02/G03 with Radius & End Point
20
TURNING
Seq Code Explanation
N01 G00 X12 Z0 Positioning @start point
N02 G01 X40 Z-25 F0.2 Tool infeed
N03 G03 X70 Z-75
CR=30
Tool infeed CCW, XZ
@end point, radius value
N04 G01 Z-95 Straight turning
1995
3.3 G02/G03 with Arc Angle & End Point/Center Point
21
Seq Code Explanation
N01 G00 X67.5 Y80.211 Positioning @start point
N02 G03 X17.203
Y38.029
AR=140.134 F500
Infeed CCW, XY @end
point, arc angle value
Seq Code Explanation
N01 G00 X67.5 Y80.211 Positioning @start point
N02 G03 I17.5 J30.211
AR=140.134 F500
Infeed CCW, IJ @center
point, arc angle value
MILLING
1995
3.3 G02/G03 with Arc Angle & End Point/Center Point
22
TURNING
Seq Code Explanation
N01 G00 X12 Z0 Positioning @start point
N02 G01 X40 Z-25 F0.2 Tool infeed
N03 G03 X70 Z-75
AR=135.944
Tool infeed CCW, XZ
@end point, arc angle
Seq Code Explanation
N01 G00 X12 Z0 Positioning @start point
N02 G01 X40 Z-25 F0.2 Tool infeed
N03 G03 I-3.335 K-29.25
AR=135.944
Tool infeed CCW, IK
@center point, arc angle
Seq Code Explanation
N01 G00 X12 Z0 Positioning @start
N02 G01 X40 Z-25 F0.2 Tool infeed
N03 G03 I=AC(33.33)
K=AC(-54.25)
AR=135.944
Tool infeed CCW, IK
@center point
1995
Class Exercise #1.3-1.4
23