CNC Programming PDF
CNC Programming PDF
Rao, CAD/CAM
Know about
Machine tools
Cutting Tools
Fixtures
Manufacturing processes
Knowledge of geometry, algebra and
trigonometry.
Machine shop experience as well
10 November 2017 2
1. Process planning
2. Axes selection
3. Tool selection
4. Cutting process parameters planning
5. Job and tool setup planning
6. Machining path planning
7. Part program writing
8. Part program proving
10 November 2017 3
Study part print
Identify operations
Capability
of cutting
and tooling
Cutting
tools tool
database
Determine feeds,
speeds, depths,
power
Machinability
database
Prepare setup
sheet with work
setting and tooling
assembly
Develop part
program
Simulate tool
path
Dry run
10 November 2017 4
Detailed plan of the steps involved in
manufacturing/machining a given part
Machine tool used
Fixtures required
Sequence of operations
For each operations
Cutting tools required
Process parameters
Study part drawing
Based on accuracy, availability etc
Total cost
10 November 2017 5
15 15
20
10
Process Plan:
Ø
6 1. Endmill the top face 100x100mm
2. Endmill the steps, 20x100x5mm
R5
3. Mill pocket, 40x40x8mm
40
10
40
4. Drill the six holes, Φ6x15mm
10
20
100
15
5
10 November 2017 6
• ISO designation of axis- choose accordingly.
• Reference poistion/ fixed datum/home position
• Floating datum- free to choose any datum
• Choose to minimize calculations
• Keep all in first quadrant
• Z-axis datum is top of the work piece, generally
• Symmetric cases- center of work piece
10 November 2017 7
Y
35
50
6 20
Ø
10
30
20
R5 X
40
50
10 November 2017 8
Y
100
70
6
Ø
R5
100
40
80
60
50
40
20
X
15
30
85
Z 15
X
5
8
10 November 2017 9
• Right tool for the job and economy
• Regular tools- no special tooling required
• For a contour- end mill or slot drill?
• Size of the tool
• Choose largest size for surface finish and MRR
10 November 2017 10
• Parameters:
• refer to hand book
• Feeds, speeds- as high as possible
• Set-up
• Setting the job and adjusting the cutting tool
• Path
• Path connected to cost
• Canned cycles
10 November 2017 11
Writing:
Write program according to format and syntax
Proving:
• Check that program is correct
• Simulate
• Trial run without Tool/work piece
• Trial with cheaper material as well
10 November 2017 12
10 November 2017 13
10 November 2017 14
1. Computer drawing
2. Process-planning sheet
3. Tool cards
4. Set-up sheet
5. Programming sheets
6. Punched paper tape (if that is the case)
10 November 2017 15
10 November 2017 16
• Word address format
• An alphabet followed by numeric data (E.g.: N105)
• Quickly processed by controller
• Blocks start with Nxxx (N100)
10 November 2017 17
A Angular dimension around X axis
B Angular dimension around Y axis
C Angular dimension around Z axis
F Feed function
G Preparatory function
H Unassigned
I Distance to arc centre or thread lead parallel to X
J Distance to arc centre or thread lead parallel to Y
K Distance to arc centre or thread lead parallel to Z
M Miscellaneous function
N Sequence number
O Reference rewind stop
S Spindle speed function
T Tool function
U Secondary motion dimension parallel to X*
V Secondary motion dimension parallel to Y*
W Secondary motion dimension parallel to Z*
X Primary X motion dimension
Y Primary Y motion dimension
Z Primary Z motion dimension
D,E,P,Q,R,U,V and W are not used
10 November 2017 18
ISO standards for coding
Co-ordinate function
Feed function (F mm per minute)
Speed function (S rpm)
Tool function (T15)
Comment using ‘()’
N010 G00 Z50.0 M05 (spindle stops and rapidly moves)
G Codes
M Codes
10 November 2017 19
G- preset function associated with the movement of
machine axes and the associated geometry
Two digits: G01, G42, G90….
Some controllers- 3 digits
ISO standards
Most manufacturers follow
Some remain until overridden by another G
Some are common in all controllers
Fanuc, MAHO,
10 November 2017 20
G00 Point-to-point positioning, rapid traverse
G01 Line interpolation
G02 Circular interpolation, clockwise (WC)
G03 Circular interpolation, anti-clockwise (CCW)
G04 Dwell
G13-G16 Axis designation
G17 XY plane designation
G18 ZX plane designation
G19 YZ plane designation
G33 Thread cutting, constant lead
G34 Thread cutting, linearly increasing lead
G35 Thread cutting, linearly decreasing lead
G40 Cutter compensation-cancels to zero
G41 Cutter radius compensation-offset left
G42 Cutter radius compensation-offset right
G43 Cutter compensation-positive
G44 Cutter compensation-negative
10 November 2017 21
G53 Deletion of zero offset
G54-G59 Datum point/zero shift
G63 Tapping cycle
G64 Change in feed rate or speed
G70 Dimensioning in inch units
G71 Dimensioning in metric units - default
G80 Canned cycle cancelled
G81-G89 Canned drilling and boring cycles
G90 Specifies absolute input dimensions
G91 Specifies incremental input dimensions
G92 Programmed reference point shift
G94 Feed rate/min (inch units when combined with G70)
G95 Feed rate/rev (metric units when combined with G71)
G96 Spindle feed rate for constant surface feed
G97 Spindle speed in revolutions per minute
10 November 2017 22
Y N007 G90 G01 X5.0 Y10.0
N008 X25.0 Y15.0
N009 X35.0 Y5.0
10 November 2017 24
Z
G17
10 November 2017 25
Y
X Z
G17
10 November 2017 26
Z
G18
10 November 2017 27
Z
Y
G19
10 November 2017 28
10 November 2017 29
Y
A Go to B from A:
N105 G90 G00 X150.0 Y30.0
45° C B
A 30
X
20
150
10 November 2017 30
Y
N115 G01 X110.0 Y30.0 F250
D
100
E
30
X
20
110
10 November 2017 31
N125 G02 X65.0 Y60.0 I35.0 J-10.0 F250
Y N130 G03 X15.0 Y30.0 I-15.0 J-40.0 F250
G
F
20
30
X
R3
15
5
50
65
10 November 2017 32
• Functions operate some controls on the machine tools and
affect running of m/c
• One code in a block- usually
• ISO codes
10 November 2017 33
M00 Program stop, spindle and coolant off
M01 Optional programmable stop
M02 End of program-often interchangeable with M30
M03 Spindle on, CW
M04 Spindle on, CCW
M05 Spindle stop
M06 Tool change
M07 Coolant supply No. 1 on
M08 Coolant supply No. 2 on
M09 Coolant off
M13 Spindle on, CW + coolant on
M14 Spindle on, CCW + coolant on
M19 Spindle stop at specified angular position
M30 Program stop at end tape + tape rewind
10 November 2017 34
Y
125
The component to be machined is
shown in Fig. 13.20. It is assumed
that the pocket is through and hence R R3
5
C 10 D
only outside is to be machined as a
finish cut of the pocket. The tool to 100
be used is a 20 mm diameter slot 75 1 0
drill. If an end mill is to be used the 50 B R E
program should be modified with a 25
hole to be drilled at B first before the A X
25
end mill is used. The setting is done 65
Z
with point A as reference (0, 0, 0)
and the reference axes are along X X
10
and Y directions.
10 November 2017 35
Y
125
5
R
C 10 D R3
100
75 1 0
50 B R E
25
A X
25
65
Z
X
10
10 November 2017 36
10 November 2017 37
10 November 2017 38
Y 98
20
98
80
18.757 20
X
Z 18.757
80
2 X
5
10 November 2017 39
Y
Cutter centre path
R
R
Y R tan
2
Y1
Part contour
Y2
X
X1
X2
10 November 2017 40
%
O1002 (Program number)
N010 G71 G92 X0 Y0 Z50 (Set point)
N015 G90 (Absolute programming)
N020 T01 S500 M06 (Tool change speed setting)
N025 G00 Z2.0 M03 (Rapid move to clearance plane)
N030 G01 Z-5.0 F100 (Feed to the required depth)
N035 Y80.0 F120 (Cut along straight line)
N040 G02 X20.0 Y98.0 R20.0 F100 (Circular move)
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 Z50 (Rapid to set point)
N080 M02 (End of program)
10 November 2017 41
10 November 2017 42
Z TOOL
1 2 3 4
L2
L4
L3
10 November 2017 43
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.
10 November 2017 44
N G81 X Y Z R
RAP
ID
Clearance plane
FEED
RAPID
Depth
Hole
Breakthrough
distance
10 November 2017 45
Y
N010 G81 X25.0 Y35.0 Z-18.0 R2.0 F125 *
100 N015 X55.0 Y50.0 *
N020 X75.0 Y70.0 *
D N025 G80 X0 Y0 Z50 *
C
B 100
Ø1
0
70
50
35
A X
25
55
Z 75
15
10 November 2017 46
Canned Feed from At programmed depth Used for
cycle surface (end of feed point)
number Dwell Spindle Spindle
speed return
motion
G80 Off -- Stop -- Cancel canned cycle
G81 Constant -- -- Rapid Drilling, centre drilling
G82 Constant Yes -- Rapid Counter sinking, Counter boring
G83 Intermittent -- -- Rapid Deep hole drilling
G84 Constant -- Reverse Feed Tapping
G85 Constant -- -- Feed Reaming
G86 Constant -- Stop Rapid Boring
G87 Constant -- Stop Manual Multiple Boring
G88 Constant Yes Stop Manual Boring
G89 Constant Yes -- Feed Boring
10 November 2017 47
2 xØ10 mm dia holes 50 10
The component to be
machined is shown in
Fig. 13.29. Write a
100
program using canned Ø20
10 November 2017 48
%
O1303
N010 G71 G92 X0 Y0 Z50
N015 G90
N020 T01 S800 M06
N025 G82 X25 Y25 Z-5 R2 P2 F125 M03 (Centre drill all holes)
N030 X25 Y75
N035 X75 Y25
N040 G80 X-50 Y0 Z50 M05
N045 T02
N050 G81
S800 M06
X25 Y25 Z-13 R2 F125 M03
(Finish Drill the 20 hole)
N055 G80 X-50 Y0 Z50 M05
N060 T03
N065 G81
S800 M06
X25 Y75 Z-13 R2 F125 M03
(Finish Drill the 10 holes)
N070 X75 Y25
N075 G80 X-50 Y-50 Z50 M05
N080 T00 M05
N090 M02
10 November 2017 49
10 November 2017 50
130
Y 115
95
80
100
84 84
60
34 40
16
X
20
40
Cutting tools:
60
1 End mill Ø40 mm
8 2 Centre drill
20 10 3 Twist drill Ø6 mm
4 Twist drill Ø8.5 mm
5 Tap M10
10 November 2017 51
10 November 2017 52
G40, G41, G42
10 30 12 70 90
0
10
20
Programmed Path
40
Offset Path of Cutter
60
80
10 November 2017 53
Y Set point
1 G42 A
2
110 G40
6
90
140
60 X
3
4
10 November 2017 54
100
A
41
60
F
G
B C
K
L
Ø2 42
0
200
0
12
Ø
E D
J
H
200
10 November 2017 55
70.432 R10
84.574
20
46.642
120 91.645
77.503
R15
R10 R15
39.571
25.607 33
15 22.5
10
4.393 53.713
124.853
134.799
10
10 November 2017 56
10 November 2017 57
A complete part program using Drill Ø7 mm thru
Counterbore Ø10 x 7 mm deep Drill Ø5 mm thru
Bore Ø5.5 mm thru
the ISO codes for the following (2) places
+0.00
Ream Ø6 +0.005 thru
A
component for the different
holes present in the component
shown in Fig. 13.40. The cutting
speed to be used is 50 m/min 37.5
10 November 2017 58
Given V = 50 m/min and f = 0.08 mm/rev
1000 V 1000 50
Spindle speed, N = 2273.64 rpm
D 7
Feed to be used = 0.080 × 2200 = 176 mm/min
10 November 2017 59
%
O1308 (P N Rao)
N010 G71 G92 X0 Y0 Z50 (September 22, 2008)
N015 G90 (Stock 75 x 50 x 20mm)
N020 T01 S2200 M06 (Drill 7 mm diameter)
N025 G81 X12.5 Y37.5 Z-22.0 R2.0 F175 M03 (Start drilling)
N030 X62.5 Y12.5
N035 G80 X-50.0 Z50.0 (End of cycle)
N040 T02 S1590 M06 (End mill 10 mm diameter)
N045 G82 X12.5 Y37.5 Z-7.0 P1.0 R2.0 F125
N050 X62.5 Y12.5
N055 G80 X-50.0 Z50.0 (End of cycle)
N060 T03 S3180 M06 (Drill 5 mm diameter)
N065 G81 X12.5 Y12.5 Z-22.0 R2.0 F250
N070 X62.5 Y37.5
N075 G80 X-50.0 Z50.0 (End of cycle)
N080 T04 S2890 M06 (Bore 5.5 mm diameter)
N085 G86 X12.5 Y12.5 Z-22.0 R2.0 F230 (Boring cycle)
N090 X62.5 Y37.5
N095 G80 X-50.0 Z50.0 (End of cycle)
N100 T05 S2650 M06 (Reamer 6 mm diameter)
N105 G85 X12.5 Y12.5 Z-22.0 R2.0 F210 (Reaming cycle)
N110 X62.5 Y37.5
N115 G80 X-50.0 Z50.0 M05 (End of cycle)
N120 G00 X-50.0 Y-50.0
N130 M02 (End of program)
10 November 2017 60
10 November 2017 61
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.
10 November 2017 62
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).
10 November 2017 63