05 CNC Manual Part Programming
05 CNC Manual Part Programming
Ravi Kumar
Professor & Head, MED, NITW
Understand the fundamentals of part programming in terms of
the various steps needed to be taken for completing a successful
CNC part program.
Comprehend the elements of manual part programming methods
using word address format and the ISO G-coding systems.
Learn the part programming fundamentals related to the use of
various word addresses.
Appreciate different preparatory (‘G’ codes) and miscellaneous
functions (‘M’ codes) as used in CNC part programs.
Write and prove sample part programs for CNC machining centres
in planar milling operations using the word address format.
Understand the concept of canned or fixed cycles for the hole
making operations
Learn the use of cutter diameter and length compensation while
using with multiple cutting tools.
22 August 2025 2
Study part print
Machine
Identify machine tool
tool
database
Machina-
Prepare set-up sheet bility
with work setting and database
tooling assembly
Dry run
22 August 2025 4
choice of the machine tool used depends upon the operations required, accuracy requirements, machine-tool
capability and availability, cutting-tool availability and the shop practices. A careful choice of various options
at this stage helps in deciding the final cost of manufacture of the part. A typical process plan is shown in
Table 13.1 for the part to be machined as shown in Fig. 13.2.
15 15
20
10
Ø6
10
R5
40
10
40
20
100
5
8
15
Table 13.1 Process plan for the component shown in Fig. 13.2
Op. no. Description Tools
10 End mill the top face, 100 × 100 mm Shell end mill, f60 mm
20 End mill the steps, 20 × 100 × 5 mm Shell end mill, f60 mm
30 Mill pocket, 40 × 40 × 8 mm HSS end mill, f10 mm
22 August 2025
40 Drill the six holes, f6 × 15 mm HSS twist drill, f6 mm 5
354 CAD/CAM: Principles and Applications
Y Y
35 100
70
50
Ø6 20
Ø6
10
30
20
R5 R5
100
X
40
80
40
60
50
40
20
X
15
50 30
85
Z Z
X X
5
8
15
Fig. 13.4 Same part as in Fig. 13.3 but with
Fig. 13.3 Part for NC machining shown with
axes system at the bottom-left corner
axes system at the centre
N045 G04 X3.0 This calls for a stoppage of the control for a period of 3 seconds.
N045 G04 P3000 This calls for a stoppage of the control for a period of 3 seconds. No decimal point
programming with P word address in Fanuc controls.
These functions actually operate some controls on the machine tool and thus affect the running of the machine.
Generally, only one-M code is supposed to be given in a single block. However, some controllers allow for
two or 22more
AugustM codes to be given in a block, provided these are not mutually exclusive, e.g., coolant
2025 14 ON
(M07) and OFF (M09) cannot be given in one block.
CNC Progra
manufacturers allow this to be modified to whatever suits them. The above is only a possible in
e pre-set, change the datum position
ted default or turn-on code in operation. However, some control
whatever suits them. The above is only a possible indication but
ing plane
lt turn-on Y
out in the
machines
achines, in X Z
G1
e specified 7
a separate
working
he spindle
ontal-axis
22 August 2025 18
Fig. 13.10 XY plane selection for horizontal-axis
e point A, i.e.,
entered is
N015 G92 X200.0 Y170.0 Z50.0
dinate can be
he workpiece.
op surface by
rogrammable
ositions on the
e controller as
can be simply
This is also be
ch are located
by G53, G54,
22 August 2025 19
Fig. 13.13 Setting the workpiece on
the machine table
This is also be
ch are located
by G53, G54,
Fig. 13.13 Setting the workpiece on
the machine table
N105 G90 G00 X150.0 Y30.0
art Y
A
st.
he
ble
es
he 45° B
C
is
30
A
ny X
20
on 150
he 22 August 2025 20
A to B
0 Y45.0 ZAbsolute
40.0 Programming A to B 367
CNC Programming
70.0 N110 G90 G00 X50.0 Y45.0 Z40.0 Z
ng A to BN120 X90.0 Y90.0 Z70.0
Absolute programming A to B
N110 G90 G00 X50.0 Y45.0 Z 40.0
0 Y45.0 ZIncremental
40.0X90.0 Y90.0
N120 Programming
Z70.0 A to B Z
A
Y
5.0 Z30.0 N110 G90programming
Incremental G00 X50.0 Y45.0A to B Z40.0
ng B to AN120N110 G91G90 X40.0 Y45.0
G00 X50.0 Z30.0
Y45.0 Z 40.0
70
A
Y
N120 G91 X40.0 Y45.0 Z30.0 B
40
0 Y90.0 Z 70.0
70
Incremental programming B to A
B
45.0 Z-30.0
40
N110 G90 G00 X90.0 Y90.0 Z 70.0
nterpolation,N120G01 This code
G91 X-40.0 Y-45.0isZ-30.0
generally 50
45
is to beLinear
cut using a feed
or Straight line rate. When the
Interpolation, G01 This code is generally
90 50 90 45
used line
a straight whenatthea material
given feedis to be cut using
rate, this a feed rate. When the 90 90
odal. If motion
afunction
cut hasis desired along a straight line at a given feed rate, this
to be made from D to E
is used. It is modal. If a cut has to be made from D to E X
e of 250 mm per2025 X
(Fig.2213.16)
August atminute, then
a feed rate themm
of 250 block
per minute, then the block 21
command shown in
100
E
B
30
45.0 Z 40.0
X
Z70.0 F350 20
A to B 110
45.0 Z 40.0
Fig. 13.16 Linear interpolation,
(c) TMH, New Delhi, CAD/CAMpreparatory
Principles function G01
45.0 Z30.0 22F350
August 2025 and Applications by P N Rao, 3rd Ed 22
B to A
100
E
30
When the
X motion is from F to G
N125 G02 X65.0 Y60.0 I35.0 J-10.0 F250
20
110
13.16 When
Linear interpolation, preparatory theG01
function motion is from G to F
N130 G03 X15.0 Y30.0 I-15.0 J-40.0 F250
Y
o be
ed if G
wise F
axis
30
when
20
gram X
15
R3
5
50
22 August 2025 23
e 65
XZ plane. In such cases, it becomes necessary to specify the plane t
Z
Z
Y
A
Y
Y A
X 22 August 2025
X 25
100
mm diameter slot drill. If an end 0
R1
75
mill is to be used the program R E
50
should be modified with a hole to
25
be drilled at B first before the end A
mill is used. The setting is done X
25
with point A as reference (0, 0, 0) 65
Z
and the reference axes are along
X
X and Y directions. 10
Slot Drilling Vs. End Milling: Fig. 13.20 Example 13.1 Fig.
https://www.youtube.com/watch
?v=KVP-WZbDyA0
22 August 2025 27
5
C R1 D R3
0
100
0
R1
75
R E
50
25
A
X
25
65
Z
10 X
R
from the originalY contour by a value equal to
2 holes 8f 98
50 100 the radius of the 20cutter. Further, it became R
50 100
necessary to calculate the new intersection
DY
points which sometimes require the use of
a
Y1
R10 trigonometry. For example, see the path taken98
18.757
R10 80 98 Part contour
by a cutter80of radius R as shown in Fig. 13.24.
Y2
18.757
12
10 10 10
essary to evaluate the DX and DY using the X1
X
X X
12 following formulae. 18.757 20
20 X2
12 Z 18.757 2
80
&(
Z 2
a
80 __
( ) X #
12
12 DY = R tan
2 X " =
Fig. 13.24 Offset Tool path for machining
! "#$ $
contours
!
that
5
5 % !
are not parallel to the principal axes
"
90 – a
Fig. 13.22 Component for Example 13.2 DX =Tool
Fig. 13.23 R tan ______
path for machining the
5 ( ) & "# ) #
N010 G71 G92 X0 Y0 Z0 (Dimensions in ‘mm’, Set point) (" = ! $%& $
component
2 Example 13.22
for !
3.22 Component for Example 13.2 Fig. possibleTool
It is13.23 path for machining
formulaethe % ! "
N015 G90 (Absolute
to derive
component
situations as well.
similar
for of
Further, most
programming)
Example
for other contour
the new 13.22
controllers are pro-
N020 T01 S500 M06 (Tool:
vided with cutter radius 16mm options.
compensation slot drill change
In such cases, speed setting)
N025 G00 Z2.0 M03 (Rapid move to clearance plane)
it is not necessary to calculate such intersection values. The
details are given later.
N030 G01 Z-5.0 F100 (Feedoftothethe
The graphical simulation aboverequired depth)
is shown in Fig. 13.25,
N035 Y80.0 F120 (Cut along
simulating the material-removal straight
process line) tool. Fig. 13.25 Simulation of the above part
on the machine
N040 G02 X20.0 Y98.0 R20.0 F100(Circular move) program for the component
shown in Fig. 13.22
N045 G01 X98.0 (Cut along straight line)
N050 Y20 (Cut along straight line)
N055 G02 X80.0 Y2.0 R18.0 (Circular move)
N060 G01 X18.757 (Straight line to the intersection point)
N065 X2.0 Y18.757 (Straight line to the intersection point)
N070 Z2.0 M05 (Feed to clearance plane Stop spindle)
N075 G0 X0 Y0 Z0 (Rapid to set point)
N080 M02 (End of program)
h the single tool. However, in cases where there is more than one tool,
e, if the programmer has to take care of the individual tool lengths for the
374 CAD/CAM: Principles and Applications
h in each case.
easured in the Z 13.6 TOOL-LENGTH COMPENSATION Tool
1 2 3 4
er as explained In the programs discussed so far, only one tool was used to perform the machining function. Henc
workpiece setting is performed with the single tool. However, in cases where there is more than one
is always kept programming becomes cumbersome, if the programmer has to take care of the individual tool lengths f
being used, the purpose of programming the Z depth in each case.
L2
In NC practice, all tools are measured in the Z Tool
he pre-setting 1 2 3 4
L4
assembled state using a tool pre-setter as explained
entered and in Chapter 11, and this information is always kept
up to date (Fig. 13.26). For the tools being used, the
ber. Whenever L3
L2
difference in length, with respect to the pre-setting
L4
tool, is recorded and is manually entered and
y programmed stored with the associated tool number. Whenever L3
sation values these tools are called into action by programmed
X
instruction, the respective compensation values
n into account are activated and automatically taken into account
wing program in the tool motion. The following program
example explains how tool-length compensation
compensation is automatically taken care of.
Fig. 13.26 Tool-length compensation
______________
Fig.
N003 M06 T01 Tool-length compensation
13.26
______________
______________
N006 M06 T02
______________
22 August 2025 30
______________
In these program blocks, M06 refers to tool change and T01, T02, ... refer to the tools to be lo
Canned cycle or fixed cycles are the G-codes used to
combine a number of common motions that are used
with some types of operations such as drilling of
holes.
22 August 2025 31
derived in using the canned cycles can be gauged by looking at the pa
shown in Fig. 13.28.
N G81 X Y Z R
B
Rap
id
70
Clearance plane 50
35
Rapid
depth
Hole
Feed
A
25
Z
Breakthrough
distance
22 August 2025 32
Fig. 13.27 Typical motions embedded in Fig. 13.28
CNC Programming
22 August 2025 34
G88 Constant Yes N045
StopT02 S800 M06 Manual (Finish drill the f 20 hole)
Boring
N050 G81 X25 Y25 Z-13 R2 F125 M03
G89 Constant Yes — Feed Boring
le 13.3 The component to be machined is shown in Fig. 13.29. Write a program using canned
N055 G80 X-50 Y0 Z50 M05 CNC Pro
N060 T03 S800 M06 (Finish Drill the f 10 377
holes)
cycles to drill all the holes shown in Fig 13.29.
N065 G81 X25 Y75 Z-13 R2 F125 M03
CNC Programming
G81 is a canned cycle, which is modal. As 2a×result, for any point specified
2 × Ø 10 50
when G81 is in force the drilling
mm dia holes 10
% Ø 10 mm dia holes
action will be repeated. As a result, to cancel theN070 cannedX75 Y25
cycle, it is necessary to use the code G80. The 50 effect 10
N075 G80 X-50 Y-50 Z50 M05
1303
of G80 is to cancel the existing canned cycle inN080 force and make G00 operational. Any coordinates to which
T00 M05
the spindle should move can be programmed in N090 the G80M02 block.
010 G71 G92 X0 Y0 Z50
There are a number of canned cycles identified by
The graphical
100
ISO in this
simulation category.
of the Example 13.3Theistypical
shown inmotions embedded in
015 G90
various canned cycles as per ISO are shown Fig. 13.30, simulating the material-removal
in Table 13.2. Ø 20 process on the
machine tool.
020 T01 S800 M06 100 50
Example 13.3 The component to beExamplemachined 13.4is shown in Fig.to13.29.
The component be machinedWrite a program
is shown
Ø 20using canned
025 G82 X25 Y25 Z-5 R2 P2 F125 M03 (Centre drill all holes)
cycles to drill all the holes shown incanned in Fig. 13.31. Write a program using
Fig 13.29.
cycles
100 to drill all the holes shown
030 X25 Y75
% in Fig 13.31. All dimensions in mm 50
Fig. 13.30 Simulation of the program
% 13.29 Component for NC program in Example 13.3 for Example 13.3
035 X75 Y25
O1303 Fig.
O1303
N010 G71 G92 X0 Y0 Z50 N045 T02 S800 M06
040 G80 X-50 Y0 Z50 M05 N010 G71 G92 X0 Y0 Z50
(Finish drill the f 20 hole)
N050 G81 X25 Y25 Z-13 R2 F125 M03 100
N015 G90 N015
N055 G80 X-50 Y0 G90
Z50 M05
N020 T01 S800 M06
N060 T03 S800 M06 (Finish Drill the f 10 holes) All dimensions in mm
N020 T01 S800 M06
N025
N065 G81 X25 Y75 Z-13G82 X15 M03
R2 F125 Y15 Z-5 R2 P2 F125 M03 (Centre drill all holes)
N025 G82 X25 Y25 Z-5 R2 P2 F125 M03 (Centre
N070 X75 Y25 N030 X135 Y15 drill Fig.
all 13.29
holes) Component for NC program in Example 13.3
N075 G80 X-50 Y-50
N035Z50X75
M05Y50
N030 X25 Y75 N080 T00 M05 N045 T02 S800 M06 (Finish drill the f 20 hole)
N035 X75 Y25 N090 M02
The graphical simulation ofN050 G81 13.3
the Example X25is Y25
shownZ-13
in R2 F125 M03
N040 G80 X-50 Y0 Z50Fig.
M05 13.30, simulating the material-removal
N055 G80 X-50 processY0
on Z50
the M05
machine tool.
N060 T03 S800 M06 (Finish Drill the f 10 holes)
Example 13.4 The component to be machined is shown
N065Write
in Fig. 13.31. G81aX25 Y75using
program Z-13 R2 F125 M03
canned cycles to drill all the holes shown
N070 X75 Y25
in Fig 13.31. Fig. 13.30 Simulation of the program
% N075 G80 X-50 Y-50 Z50 M05 for Example 13.3
O1303
N080 T00 M05
N010 G71 G92 X0 Y0 Z50
22 August 2025 35
N015 G90 N090 M02
N020 T01 S800 M06
The graphical simulation of the Example 13.3 is shown in
M02
N065 G81 X25 Y75 Z-13 R2 F125 M03
al simulation of the Example 13.4 is shown in Fig. 13.32, simulating the material-removal
N070 X75 Y25
e machine tool. 4 × Ø 10 mm
13.4 N075
The G80
component to be machined is shown
X-50 Y-50 Z50 M05 75
dia holes
4 × Ø 10 mm 15 Ø 20
in Fig.
N080 T00 13.31. Write a program using
M05dia holes
75
canned
N090 M02Ø 20cycles to drill all the holes shown
The graphical
in Figsimulation
13.31. of the Example 13.3 is shown in Fig. 13.30 Simulation of the progra
Fig. 13.30, simulating the material-removal process on the
machine tool.
100 for Example 13.3
3Example 13.4 The component to be machined is shown
G71 G92 X0 Y0in Z50 Fig. 13.31. Write a program using
378 CAD/CAM: Principles and Applications
15
canned cycles to drill all the holes shown 150
G90 150
in inFig
All dimensions mm13.31.
All dimensions in mm
Fig. 13.30 Simulation of the program
% N030 X135 Y85 Fig. for Example 13.3 for NC program
T01
.31 S800
Component
in Example
M06
for
13.4
NC program Fig. 13.32 Simulation of the program
N035 X15
for Example 13.4Y85
13.31 Component
in Example 13.4
Fi
O1303
G82 X15
N010 Y15
G71 Z-5
G92 X0 R2
Y0 P2
Z50 F125 M03 (Centre
N040 G80 X-50 Y0drill
3.5 The component to be machined is shown in Fig. 13.33. All the hole-making operations
Z50 M05 all holes)
N045 T02 S800 M06Example 13.5 The component to be
(Finish drill themachined
20 hole)is shown in
X135 N015
are toY15 G90
be machined using the tools specified.
N050 G81 X75 Y50 Z-13 R2 F125 M03
are to be machined using the tools specifi
be noted in the above component is that the top surface is at three different levels as such,
N020 T01 S800 M06 The point to be noted in the above component is that the top
X75
plane willY50
be different for each of these planes. Hence, the part
N025
unt while using theG82 X15 Y15
appropriate Z-5 cycle.
canned R2 P2TheF125
N055
M03part program
following
G80will
program
(Centre
X-50
haveY0toZ50
the
drill all
machines the
takeM05
clearance plane will be different for each of these planes.
holes)
part
N060 T03 S800 M06 (Finish
this into account while using drill the 10canned
the appropriate holes)cycle. Th
N030 X135 Y15 N065 G81 X15 Y15completely.
Z-13 R2 F125 M03
N035 X75 Y50 N070 X135 Y15
N035 X135 Y85
N030 X15 Y85
N075 G80 X-50 Y-50 Z50 M05
22 August 2025
N080 T00 M05 36
N090 M02
20
84N180 X20 Y84 84
Y 115 40
N185 G80 95
X95 Y16 Ø6 60
N190
34 G84 X95 Y16 Z-23 R-6 F300
80 40
N195 Y84 16
Fig. 13.33 Component
N200 X115 X
20
N205 Y16 %
84 40 84
N210 G80 Z2 M05 O1245
Ø660 60
34
N215 T00 M06 40 N010 tool:
G71 G92 X0 Y0 Z50
8 Cutting
N220 G0 Z50 20 16
X 10 1. N015
CenterG90
drill
N225 40 X0 Y0 2. Twist drill Ø 6 mm
20 N020 T01 S800 M06
3. Twist drill Ø 8.5 mm
40
N230 60
M02 4. N025 G82 X20 Y34 Z-5 R2 F125 M03
Top M10
The graphical 20simulation 8 of the above is shown in Fig. 13.34 Simulation
Cutting tool:
1. Center drill
N030 X20of the
Y84above part program for
10
Fig. 13.34,
40 simulating Fig. the
13.33 Component for
material-removal NC
2.process
Twist drillprogram
Ø 6 mm in Example
for the13.5
component shown in Fig. 13.33
3. Twist drill Ø 8.5 mm N035 G80 X60 Y16
on the machine tool. 4. Top M10
N040 G82 X60 Y16 Z-25 R18 F125
% Fig. 13.33 Component for NC program in Example 13.5
N045 Y40
O1245 CUTTER-RADIUS COMPENSATION
13.8 N050 Y60
%
O1245N010 G71 G92 X0 Y0 Z50
In contouring operations, it becomes necessary to calculate the toolN055 path Y84
for preparing the program by
N015 G90
N010 G71 G92 X0 Y0 Z50
N06013.35
G80 Z6
offsetting
N015 G90 the contour by an amount equal to the radius of the cutter. Figure shows the part contour and
N020
theT01
N020 tool T01
S800path
S800 M06
M06 for a typical component. (Centre drillApart from(Centre
all holes) the problem drill all holes) N065one
of calculating, G82should
X95 Y16 Z-13that
realise R6 F125
whenever
N025 N025
theG82 X20 G82
cutter Y34 X20
Z-5
size R2 Y34M03
F125
changes, Z-5the
R2program
F125 M03 would need editing. However, if aN070 compensation
Y84 equal to the radius of
N030 X20 Y84
theN030
cutterX20
N035 G80 X60 Y16
Y84
is entered and stored in the control system, then the programN075 could be written for the component
X115
profile
N040 N035
G82 X60and
Y16 thus
G80 X60
Z-25 R18no
Y16 change in program would be required. It is as if the
F125 program is written with a cutter of
N080 Y84
zero
N045 Y40radius.
N04022 G82August 2025
X60 Y16 Z-25 R18 F125 37
N050 Y60 N085 G80 Z2 M05
N045 Y40
N055 Y84
N125 G81 X20 Y34 Z-15 R2 F125 M03
N090 T02 S800 M06 N130 X20drill
(Finish Y84the f 6 holes)
N095 G81 X60 Y16 Z-43 R18 F125 N135 G80 X95 Y16
N100 Y40 N140 G81 X95 Y16 Z-23 R-6 F125
N105 Y60 N145 Y84
N110 Y84 N150 X115
N115 G80 Z2 M05
N155 Y16
N120 T03 S800 M06 (Pre-drill the tapped holes)
N160 G80 Z2 M05
N125 G81 X20 Y34 Z-15 R2 F125 M03
N165 T04 S200 M06 (Tap all the h
N130 X20 Y84
N135 G80 X95 Y16
N175 G84 X20 Y34 Z-15 R2 F300 M03
N140 G81 X95 Y16 Z-23 R-6 F125 N180 X20 Y84
N145 Y84 N185 G80 X95 Y16
N150 X115 N190 G84 X95 Y16 Z-23 R-6 F300
N155 Y16 N195 Y84
N160 G80 Z2 M05 N200 X115
N165 T04 S200 M06 (Tap Y16
N205 all the holes)
N175 G84 X20 Y34 Z-15 R2 F300 M03 N210 G80 Z2 M05
N180 X20 Y84 N215 T00 M06
N185 G80 X95 Y16
N220 G0 Z50
N190 G84 X95 Y16 Z-23 R-6 F300
N225 X0 Y0
N19522Y84
August 2025 38
N230 M02
N200 X115
G40: Compensation ‘OFF’
G41: Cutter is on the left of the programmed path
381
G42: Cutter is right on the programmed path CNC Programming
10 30 12 70 90
0
10
20
Programmed R28
path
72
40
Offset path
of cutter
R3 31
60
40
80 74
22 August 2025 39
Fig. 13.35 Cutter radius compensation
382 CAD/CAM: Principles and Applications
Set point
Y A
1 G42
2
110 G40
6
90
140
X
60
3
4
N030
Fig. 13.36G42 G00showing
Example X110theY140 (Start-up
cutter-radius compensation usingcommand
the G codes G42A-1)
Example 13.6 The following program will illustrate the use of these preparatory functions. Figure
L 13.33
f 42
shows the top view and the top of the2 component surface is taken as Z = 0.
CNC Programmi
0
% 100
A
N010 G71 G92 X0 Y0 Z50.0 (Absolute pre-set at A, 50 mm above work surface) 200
N020 G90 (Absolute programming) 60 41
F
N030 T01 M06 G
B C
N040 G00 Z2 M03 S600 (Rapid plane positioning)
N050 G41 G01 X100 Y-60 F100 (cutter compensation ON; tool moves 1 20 the path left of the
along
K
f
programmed contour) f2 42 L
0
N055 Z-5.0 (Move to required depth) 200
N060 X300.0 E D
N070 Y-260.0 J f1
20
N080 X100.0 H
E D
N090 Y-60.0 200 J
N100 G40 G00 X0 Y0 (cutter radius compensation OFF) H
200
Fig.T013.37
N110 Z50.0 M05 Example showing
(compensation value the cutter
for tool radius
T1 cancelled) compensation using the G codes G41 and G4
Fig. 13.37 Example showing the cutter radius compensation using the G codes G41 and G4
N120 M06 T02 (Second tool for internal profile)
N130 X200.0 Y-120.0 Z2.0 S600 M03
N130 X200.0 Y-120.0 Z2.0 S600 M03 N140 G01 Z-5.0 F100
N150 G42 Y-100.0 (cutter compensation ON; tool path right of programmed contou
N140 G01 Z-5.0 F100 N160 G02 I0 J-60.0
N170 G00 Z50.0
N150 G42 Y-100.0 (cutter compensation ON; tool path right of programmed contou
N180 G40 X0 Y0 M05
N190 T0 M06
N160 G02 I0 J-60.0 N200 M02
In the block N050, the programmed position is B, but the cutter centre comes to the position
N170 G00 Z50.0 that BF is perpendicular to the next move BC (Block N060), programmed in the next block. AF is som
called ‘ramp-on-move’ in view of its shape. Similarly, in the block N150, the programmed position
N180 G40 X0 Y0 M05 the cutter centre attains the position M, such that LM is perpendicular to the direction of the nex
i.e., tangent to the circle (Block N160). In the block N100, the compensation is deactivated by t
G40, which is entered after the programmed position B. The cutter stops at K, such that KB is perp
N190 T0 M06 lar to the direction of the previous move, i.e., EB. KA is called `ramp-off move’.
In the blocks N110 and N180, T0 causes cancellation of the compensation values for the tool in
N200 M02 at that time. Radius compensation is also used when similar profiles are to be cut with different de
cut, e.g., rough cut and finish cut. When a rough cut is made, a compensation equal to the thicknes
in the register against the identifier 03. R10
70.432
mple 13.7 A complete part program using the 84.574
ISO codes for the following component for the
external contour for the component is shown in Fig. 13.38 using the cutter radius
compensation. 20
46.642 91.645
70.432 R10 120 77.503
R15
84.574 R10 R15
39.471 33
25.607
20 15 22.5 10
46.642
4.393 120
N020 T01 M06
91.645
77.503
R15 53.713 R15 N025 G42 G00 X0 Y0 Z2 D1
R10
39.471 124.85333
25.607
15 22.5
N030 G01 Z-10 F120 M03
134.799
10
4.393 N035 G01 Y15
10
53.713
N040 G02 X4.393 Y25.607 R15
124.853
134.799 N045 G01 X70.432 Y91.645
Fig. 13.38 Example for contour programming using the cutter-radius compensation
10N050 G02 X 84.574 Y77.503 R10
Example 13.8 A complete part program using the ISO codes for the following component for the
different holes present in the component is shown in Fig. 13.40. The cutting speed to
be used is 50 m/min and the feed rate is 0.08 mm/rev. Use the lower left-hand corner of the part as the
datum.
Drill Ø 7 mm thru
counterbore Ø 10 × 7 mm deep Drill Ø 5 mm thru
(2) places Bore Ø 5.5 mm thru
Ream Ø 6 + 0.00 thru
A + 0.005
37.5
386 CAD/CAM: Principles and Applications
Y
12.5
X
The part requires multiple
12.5
operations basedAon the information given in the part drawing. The operations
18.75
and tools required are the following:
62.5
N035 T02
N040 G80 X-50.0
S1590 Z50.0
M06 (End(End
of cycle)
mill 10 mm diameter)
N040 G82
N045 T02 S1590
X12.5M06
Y37.5 Z-7.0 P1.0 R2.0 F125 (End mill 10 mm diameter)
N045 X62.5
N050 G82 X12.5 Y37.5 Z-7.0 P1.0 R2.0 F125
Y12.5 386 37.5CAD/CAM: Principles and Applications
N050 X62.5 Y12.5
N055 G80 X-50.0 Z50.0 (End of cycle) Y
N055 G80 X-50.0 Z50.0 (End of cycle) 12.5
N060 T03 S3180 M06 (Drill 5 mmThe
diameter)
part requires
X multiple operations based on the informat
N060 T03 S3180 M06 (Drill 5 mm diameter) 12.5 A
N065 G81 X12.5 Y12.5 Z-22.0 R2.0 F250 and tools required are
62.5 the following:
18.75
N065 G81 X12.5 Y12.5 Z-22.0 R2.0 F250
N070
N070 X62.5 Y37.5
X62.5 Y37.5
Op. no Description Tool
Fig. 13.40 Part drawing for Example required
13.8
N075
N075 G80 X-50.0Z50.0
G80 X-50.0 Z50.0 (End(End of cycle)
of cycle) 10 Drill two holes Twist drill 7 mm dia
N080
N080 T04 S2890M06
T04 S2890 M06 (Bore(Bore 5.5diameter)
5.5 mm mm20 diameter)
Counterbore two holes End mill 10 mm dia
N085
N085 G86 X12.5Y12.5
G86 X12.5 Y12.5Z-22.0
Z-22.0 R2.0
R2.0 F230
F230 (Boring
(Boring cycle)cycle)
30 Drill two holes Twist drill 5 mm dia
N090 X62.5
N090 X62.5 Y37.5
Y37.5 40 Bore the two holes Boring bar 5.5 mm dia
N095 G80
G80 X-50.0 50 Ream two holes Reamer 6 mm dia
N095 X-50.0Z50.0
Z50.0 (End(End
of cycle)
of cycle)
N100 T05
N100 T05 S2650
S2650M06
M06 (Reamer 6 mm6diameter)
(Reamer mm diameter)
Given V = 50 m/min and f = 0.08 mm/rev
N105 G85
N105 G85 X12.5
X12.5Y12.5
Y12.5Z-22.0 R2.0
Z-22.0 F210
R2.0 F210 (Reaming cycle)
(Reaming cycle) CNC Programming
387
1000 V 1000 × 50
N110 X62.5 Y37.5
N110 X62.5 Y37.5 Spindle speed, N = ______ = _________ = 2273.64 rpm
pD p×7
N115 G80 X-50.0 Z50.0 M05 (End of cycle)
Feed to be used = 0.080 × 2200 = 176 mm/min
N120 G00 X-50.0 Y-50.0 Similar calculations can be done for all other tools and the
22 August 2025 for writing the part program as shown44below:
N130 M02 (End ofused
program)
The graphical simulation of the Example 13.8 is shown in %
f cycle) machine tool.
mill 8 mm 13.9
Example diameter)
A complete part program using the ISO Drill Ø 5 mm thru
Example 13.9
codes A following
for the completecomponent
part program
for theusing the ISO and tap M6
codes foris the
different holes present in the component following
shown component for the
in Fig. 13.42. A 12.5
(3) equally spaced holes
f The
cycle) 28.2843 28.2843 R40
partdifferent holes present
requires multipleR52.5 in the
operations component
based R52.5 is shown in Fig. 13.42.
on the information
5given
mmindiameter)
theThe
partpart requires
drawing. multiple operations
The operations and tools based on
required arethe information
45° 45° 12.5
given below.
R12.5 R12.5 12.5
given in the part drawing. The operations and toolsFig. required
13.41 are
Simulation of the program
given below. A 16 16
for Example 13.8 Simulation of the program
A Fig. 13.41 28.2843
R52.5
Op. no Description SECTION A-A ToolSECTION
required A-A for Example 13.8
Drill Ø 5 mm thru Drill Ø 5 mm thru
Op. no counter × counter
Ø 8Description
borehole bore Ø 8 × 10 mm deep
10 mm deep 45°
mm diaTool required 12.5
f cycle) 10 Drill one Twist drill 5 R12.5
20 Counter bore one hole End mill 8 mm dia
A 16
achine tap) Fig.10
13.42 Fig. 13.42
Part drawing Parthole
drawing
for Example
Drill one 388 for
13.9 Example 13.9 Twist drill 5 mm dia
CAD/CAM: Principles and Applications
30 Drill three holes Twist drill 5 mm dia SECTION A-A
20 Counter Drill Ø 5 mm thru
40 Tapping the three holes bore one hole Machine tap M6 End mill 8 mm dia
tumChoose
as the the datum
centre of as the centre of the bottom
30the bottom left-hand hole.
Drill
left-hand hole.
three holes
counter bore Ø 8 × 10 mm deep
Twist drill 5 mm dia
N025 M03
% Part drawing for Example
40 Tapping the three holes N030 G81 X0 Y0 Z-20.0
Drill Ø 5 mm thru
Fig.
R2.013.42
Machine tap M6
F80 (Start drilling) 13.9
O1309 (P N Rao)
and tap M6
(P N Rao)
N035 G80 X-50.0 Z50.0 (End of cycle)
f cycle) N010
71 G92 X0 Y0 Z50 G71 G92 X0 Y0 Z50 (3) equally (September
spacedChoose
holes
(September 22, 2008) N040 T02 S800 M0622,
the 2008)
datum as the c entre of the bottom left-hand hole.
A 12.5
Drill Ø 5 mm thru (End mill 8 mm diameter)
90 N015 G90 (Stock 65R40 x 65 x 16(Stock
mm) 65%x 65 x 16 mm)
and tapN045M6G82 X0 Y0 Z-10 P1 R2 F80
N020 T01 S800 M06 (Drill 7 O1309
mm (P N Rao)
f program)
1 S800 M06 (Drill
A
7 mm
12.5
diameter) (3) N050diameter)
equally spaced holesZ50.0
G80 X-50.0 (End of cycle)
N010 G71 G92 X0 Y0 Z50
R40 (September 22, 2008)
wn in N055 T03 S800 M06 (Drill 5 mm diameter)
N015 G90 (Stock 65 x 65 x 16 mm)
the 28.2843 N060 G81 X40 Y0 Z-20.0 R2.0 F80
R52.5 N020 T01 S800 M06 (Drill 7 mm diameter)
N065 X28.284 Y28.284
R12.5
45° 12.5 N070 X0 Y40.0
28.2843
N075 G80 X-50.0 Z50.0 (End of cycle)
R52.5 16
ISO A
N080 T04 S200 M06 (M6 Machine tap)
r the Drill Ø 5 mm thru 45°
SECTION A-A
N085 G84 X40 Y0 Z-16.0 R2.0 F200
R12.5counter bore Ø 8 × 10 mm deep 12.5
44. N090 X28.284 Y28.284
A 16
ation Fig. 13.42 Part drawing for Example N095
13.9X0 Y40.0
SECTION A-A
d are Drill Ø 5 mmN100
thru G80 X-50.0 Z50.0 M05 (End of cycle)
Choose the datum as the centre of the bottom left-hand hole.boreN110
counter Ø 8 ×G00
10 mm deep
X-50.0 Y-50.0
22 August 2025 45
% N120 M02 (End of program)
O1309 Fig. 13.42 Part drawing for Example 13.9
(P N Rao)
Example 13.10
machine tool.
A complete part program using the ISO 12.5
Drill Ø7 mm thru Section A-A
codes for the following component for the Counterbore Ø10 mmx 7 mm deep
17.6777
different Example 13.10
holes present in the component
A complete shown
partin program
Fig. 13.44.using the ISO 389
(4) equally spaced holes
CNC Programming
codes for
The part requires multiple operations the on
based following component for the
the information A DrillFig.
Ø513.44
for M6 Part drawing for Example 13.10
tap (4) places
given indifferent
the part drawing. The operations
holes present and tools required
in the component shown inareFig. 13.44. 80
17.6777
given below The part requires multiple operations based on the information N025 G81 X17.678 Y17.678 Z-16.0 R2.0 F80 (Start drilling)
Drill Ø5 for M6 Ø50
Op. no given in the part drawing. The
Description A
operations
Tool requiredand
tap (4) tools
places required are 17.6777 N030 X-17.678 Y17.678 1
Fig. 13.43 Simulation ofX-17.678
N035 the program
Y-17.678 Ø62.5
given below
10 Drill four holes Twist drill 7 mm dia for Example 13.9
N040 X17.678 Y-17.678
17.6777 Ø50
20 Op. no Description
Counter bore four holes End mill 10 mmTooldia
required N045 G80 X-50.0 Z50.0 Fig. 13.45 Simulation of the program for
(End of cycle) F
Ø62.5 Fig. 13.43 Simulation of the program Example 13.10
30 Drill four holes Twist drill 5 mm dia N050 T02 S800 M06 (End mill 10 mm diameter)
10 Drill four holes Twist drill 7 mm dia A
for Example 13.9 Ø37.5 Given V = 30 m/min and f = 0.08 mm/rev
40 Tapping the four holes Machine tap M6 N055 G82 X17.678 Y17.678 Z-7 P1 R2 F80 1000 V 1000 × 30
20 Counter bore four holes End mill 10 mm dia Spindle speed, N = ______ = _________ = 1591 rpm
pD p × 12
Ø37.5 N060 X-17.678 Y17.678
30datum as the
Choose the Drillcentre
four holes
A of the circle in view Twist
of thedrill 5 mm dia
symmetry of the geometry.
N065The coordinates
X-17.678 Y-17.678
Feed
12.5
to be used = 0.080 × 1590 = 127 mm/min
Similar calculations can be done for all other tools an
can then be40 Tapping
easily calculated the they
since four holes Machine
are all symmetrical tapthe
about M6datum. Drill Ø7 mm thru Section A-A
used for writing the part program as shown below:
N070 X17.678 Y-17.678
Counterbore Ø10 mmx 7 mm deep
12.5 Op. no Description Tool required
% Drill Ø7 mm thru Section A-A N075 G80 X-50.0 spaced
(4) equally Z50.0 holes (End of cycle)
10 Mill the pocket End mill 6 mm dia
Choose the datum as the centre
O1310 of the
Counterbore Ø10circle
mmx 7 inmm
(P Nview
deepof the symmetry of
Rao) theT03
N080 geometry.
S800 M06 The coordinates 20 (Drill Drill5fivemm
holes diameter) Twist drill 12 mm d
can then (4) equally spaced holes Fig. 13.44 Part drawing for Example 13.10
G71 be
G92easily
X0 Y0calculated since they are all(September
symmetrical22,about2008)the datum.
30 Drill twenty holes Twist drill 3 mm di
N010 Z50 N085 G81 X0 Y18.75 Z-16.0 R2.0 F80
N015 G90%M03 Fig. 13.44 Part drawing for (StockExample x 65 x 12.5 mm) N090 X0 Y18.75
6513.10
N020 T01O1310
S800 M06 N025
(DrillG81
7 mmX17.678 Y17.678N095
(P N Rao)
diameter)
X-18.75
Z-16.0 R2.0Y0 F80 (Start drilling)
N100 X0 Y-18.75
N025 G81N010
X17.678
G71Y17.678
G92 X0 Z-16.0
Y0 Z50R2.0 F80 (StartX-17.678
N030 drilling)(September
Y17.678 22,N105
2008)
X18.75 Y0
N030 X-17.678 Y17.678
N015 G90 M03 (Stock 65 x 65N110
x 12.5
N035 X-17.678 Y-17.678 G80 mm)
X-50.0 Z50.0 (End of cycle)
N035 X-17.678 Y-17.678
N020 T01 S800 M06 N040 X17.678(Drill 7 mm diameter)
Y-17.678 N115 T04 S300 M06 (M6 Machine tap)
N040 X17.678 Y-17.678
N045 G80 X-50.0 Z50.0 N120 G84 X0 Y18.75 Z-16.0 R2.0 (EndF80of cycle)
N045 G80 X-50.0 Z50.0 (End of cycle) N125 X0 Y18.75
N050 T02 S800 M06 (End mill 10 mm diameter)
N050 T02 S800 M06 (End mill 10 mm diameter) N130 X-18.75 Y0
N055 G82 X17.678 Y17.678 390 CAD/CAM:
Z-7X0P1Principles
R2 F80and Applications
N055 G82 X17.678 Y17.678 Z-7 P1 R2 F80 N135 Y-18.75
N060 X-17.678 Y17.678 N060 X-17.678 Y17.678 N140 X18.75 Y0
N065 X-17.678 Y-17.678 N065 X-17.678 Y-17.678 N145 G80 X-50.0 Z50.0 M05 (End of cycle)
N150 G00 X-50.0 Y-50.0
N070 X17.678 Y-17.678 N070 X17.678 Y-17.678
N160 M02 (End of program)
N075 G80 X-50.0 Z50.0 (End of
N075 cycle)
G80 X-50.0 Z50.0 (End of cycle)
The graphical simulation of Example 13.10 is shown in Fig. 13.45, simulating t
N080 T03 S800 M06 (Drill 5 mm diameter)
N080 T03 S800 M06process on the machine tool. (Drill 5 mm diameter)
N085 G81 X0 Y18.75 Z-16.0 R2.0 F80
N085 G81 X0 Y18.75 Z-16.0 R2.0 F80
N090 X022Y18.75
August 2025 Example 13.11 A complete part program using the ISO codes 46 for the following
N090 X0 Y18.75 external contour for the component is shown in Fig. 13.46. The
N095 X-18.75 Y0
N095 X-18.75 Y0 used is 30 m/min and the feed rate is 0.08 mm/rev. Use the lower left-hand corne
process on the machine tool.
Example 13.11 A complete part program using the ISO codes for the following component for the
external contour for the component is shown in Fig. 13.46. The cutting speed to be
used is 30 m/min and the feed rate is 0.08 mm/rev. Use the lower left-hand corner of the part as the
datum.
393
Taking datum at the left-hand bottom part of the part, all the dimensions where the cutter has to move
CNC Programming
in order to generate the part are shown in Fig. 13.47. Based on these dimensions, the part program is
CNC Progra
developed with three tools, the details of which are given in the program.
80
80
27.5 67.5
6 526
Y 3 46
40
40 3 34
28
6
48, 80
Ø3 Ø12 25
12
R3 1
30 9.5
ISO 80All dimensions in mm
AISI 1045 steel 68
65
to Fig. 13.45 Simulation of the program for Ø3
Fig. 13.46 Part drawing for Example 13.11 Ø12 62
Example 13.10 40
Given V = 30 m/min and f = 0.08 mm/rev 12 25
R3
Fig. 13.48
Spindle Simulation
1000 1000 × 30 of the program
V _________
speed, N = ______ = = 1591 rpm
X 1
9.5
pD p × 12 30
for Example 13.11
Feed to be used = 0.080 × 1590 = 127 mm/min
Fig.
Similar calculations can be done for all other tools and the values are 13.47
filled Parttable
in the tool drawing
which shown
are with cutter for Example 13.11
used for writing the part program as shown below:
Op. no Description Tool required N10 (P N Rao 22 September
Spindle, RPM 2008)
Feed, mm/min
10
8Mill the pocket N20 (USE 80 x1590
End mill 6 mm dia 80 x 10 mm AISI 1045
125 steel)
20 Drill five holes Twist drill 12 mm dia (INITIALIZE
N30 800STOCK TO X=0, Y=0,
65 Z=0)
30 Drill twenty holes Twist drill 3 mm dia 3180 250
N40 (T1 IS A 6 mm END MILL)
CAD/CAM: Principles and Applications
N420 G81 G99 Z-6.0 R1.0 F250.0
N10 (P N Rao 22 September 2008) N230 Y68.0 N430 X34.0 Y68.0
N20 (USE 80 x 80 x 10 mm AISI 1045 steel) N240 X28.0 N440 X40.0 Y68.0
N30 (INITIALIZE STOCK TO X=0, Y=0, Z=0) N250 Y62.0
N260 G0 Z2.0 M05 (Retract)
N450 X46.0 Y68.0
N40 (T1 IS A 6 mm END MILL)
N50 (T2 IS A 12 mm twist drill) N270 M06 T02 (Tool change 12 mm twist drill) N460 X52.0 Y68.0
N60 (T3 IS A 3 mm twist drill) N280 (Drill 5 holes) N470 X52.0 Y62.0
N70 G71 G90 N290 S800.00 M03 N480 X46.0 Y62.0
N300 G0 X12.5 Y15.0
N80 M06 T01 (Tool Change 6 mm End Mill) N490 X40.0 Y62.0
N310 G81 G99 Z-14.0 R1.0 F65.0
N90 (Pocket milling Operation, Contour 1)
N320 X67.5 Y15.0 N500 X34.0 Y62.0
N100 M3 S1590.0
N330 X40.0 Y 40.0 N510 X28.0 Y62.0
N110 G0 Z10.0 (Retract)
N340 X67.5 Y65.0 N520 X28.0 Y18.0
N120 G0 X28.0 Y12.0
N350 X12.5 Y 65.0
N130 G0 Z2.0 (Retract) N530 X34.0 Y18.0
N360 G80
N140 G1 Z-1.0 F125.0 (Plunge) N370 G0 Z10.0 (Retract) N540 X40.0 Y18.0
N150 G1 X52.0 F125.0 N380 M06 T03 (Tool change 3 mm twist drill) CNC N550 X46.0 391
Y18.0
Programming
N160 Y18.0 N390 (Drill 20 holes)80 N560 X52.0 Y18.0
N170 X28.0 N400 S3180.00 67.5
N180 Y12.0
52 N570 X52.0 Y12.0
N410 G0Y X28.040Y68.0
46
N190 G0 Z2.0 (Retract) N420 G81 G9934Z-6.0 R1.0 F250.0 N580 X46.0 Y12.0
28
N200 G0 Y62.0 (Position for the second contour)
N430 X34.0 Y68.0 6 N590 X40.0 Y12.0
N210 G1 Z-1.0 F100.0 (Plunge) N440 X40.0 Y68.0 N600 X34.0 Y12.0
N220 G1 X52.0 F200.0 N450 X46.0 Y68.0
N610 X28.0 Y12.0
N460 X52.0 Y68.0
80
N470 X52.0 Y62.0 68 N620 G80 M05
65 Ø12 62
Ø3
N48040X46.0 Y62.0 N630 G0 Z10.0 (Retract)
N490 X40.0
12
Y62.0 25 N640 M02 (END OF FILE)
R3
N500 X34.0 Y62.0 X 1
30 The
9.5graphical simulation of Example 13.1
(c) TMH, New Delhi, CAD/CAM Principles
22 August 2025 and Applications by P N Rao, 3rd Ed 49
(c) TMH, New Delhi, CAD/CAM Principles
22 August 2025 and Applications by P N Rao, 3rd Ed 50
(c) TMH, New Delhi, CAD/CAM Principles
22 August 2025 and Applications by P N Rao, 3rd Ed 51
(c) TMH, New Delhi, CAD/CAM Principles
22 August 2025 and Applications by P N Rao, 3rd Ed 52
(c) TMH, New Delhi, CAD/CAM Principles
22 August 2025 and Applications by P N Rao, 3rd Ed 53
(c) TMH, New Delhi, CAD/CAM Principles
22 August 2025 and Applications by P N Rao, 3rd Ed 54
Part programming is a systematic activity and following
the steps in proper sequence will help in developing
efficient part programs
Selection of the part coordinate axes system with respect
to the part geometry help in reducing the mathematical
calculations that are needed to write the part program
ISO standard for part programming utilises all the 26
characters of English alphabet as word addresses in a part
program.
Preparatory functions or G-codes control the geometrical
nature of the data input as well as operation of some of
the data in a program. A large number of these codes are
standardised by ISO.
22 August 2025 55
Motion commands are the most important part of the G-
codes used to control the motion in rapid (G00), linear
interpolation (G01) and Circular interpolation (G02 and G03).
Miscellaneous functions or M-codes are used to specify the
machine tool functions in the program. Less number of codes
are standardised in view of these being machine specific.
For programs involving multiple tools, tool length
compensation can be activated by the use of tool offset
registers.
Canned or fixed cycles offer the facility to reduce the bulk of
program by canning the often repeated command into a
single G-code. Examples are for the drilling of holes (G81).
In milling of contours large amount of complex calculations
are often required to take multiple cuts. This can be reduced
by the use of cutter diameter compensation (G41 and G42).
22 August 2025 56