Basic Machine Codes PDF
Basic Machine Codes PDF
1]
25
G00
(8.0,7.0,10.0)
N60
G90
G00
X
Y
Z
Sequence number
Absolute dimensions
Linear interpolation in rapid traverse
X-coordinate of end position
Y-coordinate of end position
Z-coordinate of end position
(3.0,1.0,2.0)
X
G01 Linear Interpolation ( Feed )
G01 X__ Y__ Z__ F__ ;
The tool is moved in a straight line at a given or predefined feedrate.The speed of each
axis is automatically controlled so that the tool moves in a straight line. This is used for
linear cutting motion. The move can be programmed in either absolute (G90) or incremental
(G91) mode.
Block format (example)
N70 G91 G01 X5.0 Y6.0 Z8.0 F100 ;
G01
(8.0,7.0,10.0)
N70
G91
G01
X
Y
Z
F
Sequence number
Incremental dimensions
Linear interpolation
Distance from start to end position
along X-axis
Distance from start to end position
along Y-axis
Distance from start to end position
along Z-axis
Feedrate
(3.0,1.0,2.0)
26
[Ch. 2
G02
Block format (radius and end position example)
(7.6,8.2)
Sequence number
Absolute dimensions
Circular interpolation, clockwise
X-coordinate of end position
Y-coordinate of end position
Radius of arc, arc less than 180 degrees
(see below)
Feedrate
R=3.5
Centre
(4.0,2.5)
G02
Y
(7.6,8.2)
Sequence number
Absolute dimensions
Circular interpolation, clockwise
X-coordinate of end position
Y-coordinate of end position
Distance along X-axis from start to
arc centre
Distance along Y-axis from start to
arc centre
Feedrate
Centre
(6.4,4.8)
J
(4.0,2.5)
I
G02
Y
R
1
End position
Sec. 2.1]
27
G03
R=3.5
Centre
(7.0,2.0)
X
Block format (radius and end position example)
G03
N130 G91 G03 X-5.7 Y1.5 R-3.5 F100. ;
N130
G91
G03
X
Y
RF
Sequence number
Incremental dimensions
Circular interpolation, counter-clockwise
Distance along X-axis from start to end
position
Distance along Y-axis from start to end
position
Radius of arc, arc greater than
180 degrees
Feedrate
R=3.5
Centre
(2.3,4.2)
Y
8.0 2.7
X
G03
N140 G90 G03 X1.7 Y4.1 I-2.4 J2.3 F100. ;
N140
G90
G03
X
Y
I
J
F
Sequence number
Absolute dimensions
Circular interpolation, counter-clockwise
X-coordinate of end position
Y-coordinate of end position
Distance along X-axis from start to
arc centre
Distance along Y-axis from start to
arc centre
Feedrate
Y
Centre
(5.0,4.9)
(1.7,4.1)
J
(7.4,2.6)
I
28
[Ch. 2
G04
N150 G04 X1.5 ;
Z
0
SECOND
X
The following example is equivalent to the one
above.
Block format (millisecond example)
G04
N160 G04 P1500 ;
Z
0
MILLISECOND
x1000
Sec. 2.1]
29
G19
Y
G18
G17
G02
G18
G17
G03
G18
G17
30
[Ch. 2
POSITION
X 0.0000 in.
Y 0.0000 in.
Z 0.0000 in.
(4.0,5.0,4.0)
4.0 in.
5.0 in.
4.0 in.
POSITION
X 0.000 mm
Y 0.000 mm
Z 0.000 mm
(100,150,100)
100 mm
150 mm
100 mm
Sec. 2.1]
31
G22
Z
Sequence number
Stored stroke limit ON
X-coordinate point of boundary
Y-coordinate point of boundary
Z-coordinate point of boundary
X-coordinate point of boundary
Y-coordinate point of boundary
Z-coordinate point of boundary
Y
(250,210,100)
(100,70,0)
G22
N480 G22 X100. Y210. Z100. I250. J70. K0. ;
N480
G22
X
Y
Z
I
J
K
Sequence number
Stored stroke limit ON
X-coordinate point of boundary
Y-coordinate point of boundary
Z-coordinate point of boundary
X-coordinate point of boundary
Y-coordinate point of boundary
Z-coordinate point of boundary
Y
(100,210,100)
(250,70,0)
Sequence number
Stored stroke limit OFF
Positioning
X-coordinate of end position
32
[Ch. 2
G28
N10 G91 G28 Z0.0 ;
N20 G91 G28 X0.0 Y0.0 ;
N10
G91
G28
Z
Home
position
Sequence number
Incremental dimensions
Return to reference point (Z home position)
Incremental Z-distance to
intermediate point
Y
Start
position
When performing a tool change, it is only necessary to return the Z axis to the home
position.
Block format (tool change example)
G28
N400 G90 G28 Z100. ;
N400 Sequence number
G90 Absolute dimensions
G28 Return to reference point (Z home position)
Z
Z-coordinate point of intermediate point
Z Home
position
Intermediate
point (Z=100)
Start
position
Sec. 2.1]
33
G29
N410 G90 G28 X60. Y100. ;
Y
Intermediate
point
(60,100)
G28
G29
X and Y
Home
position
G29
G28
(120,40)
Start
position
Y
Intermediate
point
(80,110)
G28
G29
X and Y
Home
position
G29
60
G28
70
Start
position
34
G40, G41, G42 Tool
G40 ;
G41 D__ ;
G42 D__ ;
[Ch. 2
Radius Compensation
Tool radius compensation cancel
Tool radius compensation left
Tool radius compensation right
The tool is moved to the left (G41) or to the right (G42) of the program path by the
amount of the cutter radius. The offset amount is registered with a D address.
Block format (tool radius compensation left
example)
G41
(30,55)
(30,30)
X
G42
(60,30)
X
G40
(10,10)
Sec. 2.1]
35
G42
(60,40)
(100,40)
G42
N700 G42 D17 ;
.
.
(50,70)
60
R=
(95,20)
G41
N800 G41 D18 ;
.
.
(80,75)
(40,50)
36
[Ch. 2
Z
Standard
tool
H10=9 mm
H11=8 mm
G43
24
16
Tool path without compensation
G44
Sec. 2.1]
37
(Scaling OFF)
(Scaling ON)
The tool is moved by a scaling factor P about a scaling point defined by address I, J
and K.
Block format (scaling example)
G51
N520 G51 I70. J70. K0. P500 ;
(30,110)
(90,110)
(110,110)
Scaling centre
(70,70)
(50,50)
(30,30)
(90,50)
(110,30)
Programmed path
Tool path with scaling
38
[Ch. 2
25
20
G55
X
20
X
30
5 20
20
Sec. 2.1]
39
G90
Z
Sequence number
Absolute dimensions
X-coordinate of end point
Y-coordinate of end point
Z-coordinate of end point
(25,35,30)
Y
30
35
(0,15,5)
25
G91
Z
Sequence number
Incremental dimensions
Linear interpolation
X-distance from current point to end point
Y-distance from current point to end point
Z-distance form current point to end point
(25,35,30)
25
20
(0,15,5)
25
40
G92
[Ch. 2
This command sets the origin of the coordinate system a specified distance from the
home position or current tool position. Address X, Y and Z defines the location of the origin
in relation to the current tool position. It is used at the start of the program to establish the
coordinate system in relation to the CNC machine home position or can be used to establish
the coordinate system in relation to some arbitrary position.
Block format (home position example)
N40 G91 G28 X0. Y0. Z0. ;
.
.
G92
Z
Home
position
Sequence number
Programming of absolute zero point
X-distance from tool position to zero point
Y-distance from tool position to zero point
Z-distance from tool position to zero point
(350,350,250)
Absolute
zero point
Y
250
350
X
350
G92
Z
Arbitrary
position
(200,200,100)
Absolute
Zero Point
100
200
200
Sec. 2.1]
2.1.2
41
G00
(30,10)
60
G01
100
80
42
[Ch. 2
Sequence number
Absolute dimensions
Circular interpolation CW
X-diameter of end position
Z-coordinate of end position
Feedrate
G02
End
Point
R=50
Z
140
100
G02
Sequence number
Absolute dimensions
Circular interpolation CW
X-diameter of end position
Z-coordinate of end position
X-distance from start to arc center
(this is not a diameter value)
Z-distance from start to arc center
Feedrat
e
End
Point
Arc
Centre
I
Z
140
K
100
Sec. 2.1]
43
G03
Sequence number
Incremental dimensions
Circular interpolation CCW
Incremental X-diameter from start to end
position
Z-distance from start to end position
Radius of arc
Feedrate
End Point
50
R=60
Z
50
G03
End Point
40
50
I
44
[Ch. 2
Tool
G41
(30,-30)
(20,-50)
Tool direction
Tool path without
compensation
G42
(30,-50)
(15,-30)
Z
Tool direction
Tool path without
compensation
Sec. 2.1]
45
G74
50
Cutting feed
Rapid traverse
G74
X
Z
Z
K
Cutting feed
Rapid traverse
46
G75
[Ch. 2
Grooving in X Axis
G75 X__ Z__ I__ K__ F__ D__ ;
G75
Z
Cutting feed
Rapid traverse
G78
X
The tool performs straight thread cutting or
taper cutting depending whether address I is
specified. Address X is a diameter value and F is a
feedrate value to specify the lead. At the end point
the thread is chamfered at a 45 degree angle.
Cutting feed
Rapid traverse
G78
Z
Cutting feed
Rapid traverse
Sec. 2.1]
47
G96
Spindle
speed
(rpm)
Z (mm)
G97
1000
Spindle
speed
(rpm)
Z (mm)
48
[Ch. 2
M04
M03
X
Block format (example)
N60 S0200 M04 ;
N60 Sequence number
S
Spindle speed (m/min.)
M03 Spindle start CCW
Sec. 2.1]
49
M05
N80 G01 Z-20. M05 ;
N80
G01
Z
M05
Sequence number
Linear interpolation
Z-coordinate of end point
Spindle stops at Z=-20
Z
M06 Tool Change
M06 T____ ;
20
The current tool in use is replaced by the tool with the tool identification number given
in the T address. To perform a tool change on the milling machine, the Z-axis must be
returned home first. The tool is then inserted in the spindle arm. A tool change on the lathe
machine is performed by a rotation of the turret. The turret should be far enough away from
the workpiece to avoid a collision.
Block format (example)
M06
N90 M06 T0505 ;
N90 Sequence number
M06 Tool change
T0505
Tool number 05 with offset amount
stored with 05
05
Z
M07 Oil Mist On
M07 ;
The tool and workpiece are lubricated and cooled by an oil to improve the finish and
reduce tool wear and breakage.
Block format (example)
M07
N100 M07 ;
N100 Sequence number
M07 Oil mist on
M09 Coolant, Oil Unit Off
M09 ;
The coolant is turned off when cutting is
not being performed.
50
[Ch. 2
The spindle rotates in the high gear. Its use depends on the material of the workpiece
and tool being used, and the requirement for a high quality finish.
M98 Subprogram Call
M98 P____ L__ ;
The program flow is transferred from the main program to the subprogram. Address
P specifies the subprogram being called and address L indicates the number of times the
subprogram is executed. See the subprogram section for more details.
M99 End of Subprogram
M99 ;
The program flow is transferred from the subprogram back to the main program. This
is used at the end of a subprogram. See the subprogram section for more details.
Sec. 2.1]
2.1.4
F
51
The tool is moved at a speed specified by address F. The feedrate units are inch/min
when programmed with G20 and mm/min when programmed with G21.
Block format (example)
N70 G21 G01 X10. F100. ;
N70
G21
G01
X
F
Sequence number
Metric units
Linear interpolation
X coordinate of end point
Feedrate (mm/min)
Tool Function
T___ ;
The tool is called by its tool number and its tool offset number. Both numbers are
given in the T address and are registered in the tool table in the CNC controller memory.
Block format (example)
N30 T0104 ;
N30 Sequence number
T
Tool number (01), tool offset number (04)
52
[Ch. 2
Initialization
Facing
Deep side cutting
Track pocketing
Side cutting
Hole pattern
Program end
6 - 5 dia. * 20 deep
20
30
30
40
30
140
100
20
50
45
20
5
25
90
5
20
180
20
220
Z
5
20
10
Tools used:
100 mm dia. Face Mill
5 mm dia. End Mill
22 mm dia. End Mill
5 mm dia. Drill
Unit: mm
Sec. 2.1]
Listing of G code
1)
Initialization
O23;
N10
N20
N30
N40
N50
N60
N70
2)
Facing
N80
N90
N100
N110
N120
N130
N140
N150
N160
N170
N180
N190
N200
3)
N210
N220
N230
N240
N250
N260
N270
N280
T15;
M06;
G49;
S1400 M03;
G90 G43 G00 Z100.0 H15;
G00 X-130.0 Y-70.0;
G01 Z-10.0 F500.0;
G42 G01 X-110.0 Y-70.0 D25
F1000.0;
G01 X110.0 F1000.0;
Y70.0;
X-110.0;
Y-70.0;
G01 G40 Y-100.0;
Z10.0;
N290
N300
N310
N320
N330
N340
53
Initialization
Z
Facing
Z
54
4)
Track pocketing
N350
N360
N370
N380
N390
N400
N410
N420
N430
N440
5)
Side cutting
N450
N460
N470
N480
N490
N500
N510
N520
N530
N540
N550
N560
N570
N580
[Ch. 2
Track pocketing
Z
Y
X
Side cutting
Z
Y
X
Sec. 2.1]
6)
Hole pattern
N590 T16;
N600 M06;
N610 S1400 M03;
N620 G49;
N630 G90 G43 G00 Z100.0 H16;
N640 G01 X20.0 Y0.0 F1000.0;
N650 G01 Z-20.0 F500.0;
N660 G04 X1.0;
N670 G01 Z0.0;
N680 G00 Y17.32 X10.0;
N690 G01 Z-20.0 F500.0;
N700 G04 X1.0;
N710 G01 Z0.0;
N720 G01 X-10.0;
N730 G01 Z-20.0 F500.0;
N740 G04 X1.0;
N750 G01 Z0.0;
N760 G01 X-20.0 Y0.0;
N770 G01 Z-20.0 F500.0;
N780 G04 X1.0;
N790 G01 Z0.0;
N800 X-10.0 Y-17.32;
N810 G01 Z-20.0 F500.0;
N820 G04 X1.0;
N830 G01 Z0.0;
N840 G01 X10.0;
N850 G01 Z-20.0 F500.0;
N860 G04 X1.0;
N870 G01 Z0.0;
7)
55
Drilling
Z
Program end
Program end
N880 G91 G28 Z0.0;
N890 G91 G28 X0.0 Y0.0;
N900 M05;
N910 G40;
N920 G49;
N930 M30;
%