You are on page 1of 24

CAD/CAM Principles and Applications

by P.N.Rao

13. CNC Programming

13.1 Part Programming Fundamentals

x
x
x
x
x
x
x
x

* achieve final component shape


* details of instructions

* knowledge manuf processes


* geometry/trigonometry

Process planning
Axes selection
Tool selection
Cutting process parameters planning
Job and tool setup planning
Machining path planning
Part program writing
Part program proving

13.1.1 Process planning


x
x
x
x

13 CNC Programming 13-1/13-24

Machine tool used


Fixture(s) required
Sequence of operations
For each of operation
x
Cutting tools required
x
Process parameters

* choice of operation, accuracy required


* availability of tools

CAD/CAM Principles and Applications


by P.N.Rao

Fig. 13.1

13 CNC Programming 13-2/13-24

The steps involved in the development of a proven part


program in NC machining

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-3/13-24

Fig. 13.2 A typical component for NC machining


Table 13.1 Process plan for the component shown in Fig. 13.2
Op.
No.
10
20
30
40

Description

Tools

End mill the top face, 100 u 100 mm


End mill the steps, 20 u 100 u 5 mm
Mill pocket, 40 u 40 u 8 mm
Drill the six holes, I6 u 15 mm

13.1.2 Axes selection

Shell end mill, I60 mm


Shell end mill, I60 mm
HSS End mill, I10 mm
HSS twist drill, I6 mm

* axes motion
* datums and positioning home
* geometry symmetrical
* reference plane, z to surface

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-4/13-24

Fig. 13.3 Part for NC machining shown with axes system at the centre

Fig. 13.4

Same part as in Fig. 13.3 but with axes system at the bottom
left corner

CAD/CAM Principles and Applications


by P.N.Rao

13.1.3 Tool selection

13 CNC Programming 13-5/13-24

* economy, right tool, finishing/draft

13.1.4 Cutting process parameters planning

13.1.5 Job and tool setup planning

13.1.6 Machining path planning

* adjusting tool position / initial

* complex, cycles

13.1.7 Part program writing

* format / syntax

13.1.8 Part program proving

* trial run
* graphical simulation
* damanges of tool

Fig. 13.5

* handbook/feed/speed

Tool path of the part for proving the NC part program

CAD/CAM Principles and Applications


by P.N.Rao

Fig. 13.6

13 CNC Programming 13-6/13-24

Shaded 3D image of the tool cutting the part for providing


more realistic proving of the NC part program (Courtesy Virtual
Gibbs Inc.)

13.1.9 Documentation for NC

* process plan sheet


* tool card

13.2 Manual Part Programming Methods

* word address format


* block by block

N115 G81 X120.5 Y55.0 Z-12.0 R2.0 F150 M3


13.2.1 ISO standards for coding

Character
A
B

* typical sequence of blocks

Address For
Angular dimension around X axis
Angular dimension around Y axis

CAD/CAM Principles and Applications


by P.N.Rao

C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z

13 CNC Programming 13-7/13-24

Angular dimension around Z axis


Angular dimension around special axis or third feed function*
Angular dimension around special axis or second feed
function*
Feed function
Preparatory function
Unassigned
Distance to arc centre or thread lead parallel to X
Distance to arc centre or thread lead parallel to Y
Distance to arc centre or thread lead parallel to Z
Do not use
Miscellaneous function
Sequence number
Reference rewind stop
Third rapid traverse dimension or tertiary motion dimension
parallel to X*
Second rapid traverse dimension or tertiary motion dimension
parallel to Y*
First rapid traverse dimension or tertiary motion dimension
parallel to Z*
Spindle speed function
Tool function
Secondary motion dimension parallel to X*
Secondary motion dimension parallel to Y*
Secondary motion dimension parallel to Z*
Primary X motion dimension
Primary Y motion dimension
Primary Z motion dimension
* Where D, E, P, Q, R, U, V, and W are not used as indicated, they
may be used elsewhere.

N5 G2 Xr53 Yr53 Zr53 U..V..W..I..J..K..F5 S4 T4 M2 *


13.2.2 Co-ordinate function

* x, y

13.2.3 Feed function

* F word address
* modal / 150 mm/min

13.2.4 Speed function

* S / rpm

CAD/CAM Principles and Applications


by P.N.Rao

13.2.5 Tool function

13.3 Preparatory functions

CODE
G00 *
G01 *
G02 *
G03 *
G04
G05
G06
G07
G08
G09
G10
inches)
G11
G12
G13-G16
G17
G18
G19
G20
G21
G22-G29
G30
G31
G32
G33
G34
G35
G36-G39
G40 *
G41 *
G42 *
G43
G44

13 CNC Programming 13-8/13-24

* tool magazines, T

* denotes G
* G codes, pre-set functions
* modal mostly

FUNCTION
Point-to-point positioning, rapid traverse
Line interpolation
Circular interpolation, clockwise (WC)
Circular interpolation, anti-clockwise (CCW)
Dwell
Hold/Delay
Parabolic interpolation
Unassigned
Acceleration of feed rate
Deceleration of feed rate
Linear interpolation for long dimensions (10 inches-100
Linear interpolation for short dimensions (up to 10 inches)
Unassigned
Axis designation
XY plane designation
ZX plane designation
YZ plane designation
Circular interpolation, CW for long dimensions
Circular interpolation, CW for short dimensions
Unassigned
Circular interpolation, CCW for long dimensions
Circular interpolation, CCW for short dimensions
Unassigned
Thread cutting, constant lead
Thread cutting, linearly increasing lead
Thread cutting, linearly decreasing lead
Unassigned
Cutter compensation-cancels to zero
Cutter radius compensation-offset left
Cutter radius compensation-offset right
Cutter compensation-positive
Cutter compensation-negative

CAD/CAM Principles and Applications


by P.N.Rao

G45-G52
G53
G54-G59
G60
G61
G62
G63
G64
G65-G69
G70
G71
G72-G79
G80
G81-G89
G90
G91
G92
G93
G94
G95
G96
G97
G98-G99

13 CNC Programming 13-9/13-24

Unassigned
Deletion of zero offset
Datum point/zero shift
Target value, positioning tolerance 1
Target value, positioning tolerance 2, or loop cycle
Rapid traverse positioning
Tapping cycle
Change in feed rate or speed
Unassigned
Dimensioning in inch units
Dimensioning in metric units
Unassigned
Canned cycle cancelled
Canned drilling and boring cycles
Specifies absolute input dimensions
Specifies incremental input dimensions
Programmed reference point shift
Unassigned
Feed rate/min (inch units when combined with G70)
Feed rate/rev (metric units when combined with G71)
Spindle feed rate for constant surface feed
Spindle speed in revolutions per minute
Unassigned

Motion group
*G00
G01
G02
G03

Rapid Positioning
Linear Interpolation
Circular interpolation Clockwise
Circular interpolation Counter clockwise

Dwell
G04

Dwell

Active plane selection group


*G17
XY Plane selection
G18
XZ Plane selection
G19
YZ Plane selection
Cutter compensation group
*G40
Cutter compensation, Cancel
G41
Cutter radius Compensation left
G42
Cutter radius Compensation right

CAD/CAM Principles and Applications


by P.N.Rao

Units group
*G70
G71

13 CNC Programming 13-10/13-24

Inch units
Metric units

Hole making canned cycle group


*G80
Canned Cycle Cancel
G81-G89 Canned Cycles definition and ON
Co-ordinate system group
*G90
Absolute co-ordinate system
G91
Incremental co-ordinate system
Preset
G92

Absolute pre-set, Change the datum position

13.3.1 Co-ordinate system group, G90 and G91

* input of dim, info


* respect to chosen datum
* G91 cancel

Fig. 13.7 Absolute (G90) and incremental (G91) systems

13.3.2 Units group, G70, G71

* G20 & G21 Fanuc controller


* G70 default

13.3.3 Active plane selection group, G17, G18, G19

* default G17

CAD/CAM Principles and Applications


by P.N.Rao

Fig. 13.8

13 CNC Programming 13-11/13-24

XY plane selection for vertical axis milling machines

G17 XY Plane selection

Fig. 13.9

XY plane selection for horizontal axis milling machines

G18 XZ Plane selection

Fig. 13.10 XZ plane selection for horizontal axis milling machines

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-12/13-24

G19 YZ Plane selection

Fig. 13-11 YZ plane selection for horizontal axis milling machines


13.3.4 Preset, G92

* coordinate datum position of point

Fig. 13-12 Setting the workpiece on the machine table


N015 G92 X200.0 Y170.0 Z50.0

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-13/13-24

13.3.5 Motion group, G00, G01, G02, G03

Rapid Positioning, G00

* modal
* rapid rate, movement in air
* save time

Fig. 13-13 Positioning, preparatory function G00

N105 G90 G00 X150.0 Y30.0

Absolute programming A to B
N110 G90 G00 X50.0 Y45.0 Z 40.0
N120 X90.0 Y90.0 Z70.0

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-14/13-24

Fig. 13-14 Positioning, preparatory function G00 in 3 dimensions


Incremental programming A to B
N110 G90 G00 X50.0 Y45.0 Z 40.0
N120 G91 X40.0 Y45.0 Z30.0
Incremental programming B to A
N110 G90 G00 X90.0 Y90.0 Z 70.0
N120 G91 X-40.0 Y-45.0 Z-30.0
Linear or Straight line Interpolation, G01

N115 G01 X110.0 Y30.0 F250

* material to be cut
* modal

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-15/13-24

Fig. 13-15 Linear interpolation, preparatory function G01


Incremental programming A to B
N110 G90 G00 X50.0 Y45.0 Z 40.0
N120 G91 G01 X40.0 Y45.0 Z30.0 F350
Incremental programming B to A
N110 G90 G00 X90.0 Y90.0 Z 70.0
N120 G91 G01 X-40.0 Y-45.0 Z-30.0 F350

Circular Interpolation, G02 / G03

* arc to be tranversed in plane


* I & J center of arc / R

Fig. 13.16 Circular interpolation, preparatory function G02/G03

N125 G02 X65.0 Y60.0 I35.0 J-10.0 F250


* R35

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-16/13-24

Fig. 13.17 Circular interpolation in XY plane using G17 plane selection

Fig. 13.18 Circular interpolation in XZ plane using G18 plane selection

Dwell, G04

* give delay in program


* N10 G04 X3.0

13.4 Miscellaneous Functions, M

CODE

FUNCTION

* control on M/C

CAD/CAM Principles and Applications


by P.N.Rao

M00
M01
M02
M03 *
M04
M05 *
M06 *
M07
M08
M09
M10
M11
M12
M13
M14
M15
M16
M17-M18
M19
M20-M29
M30 *
M31
M32-M35
M36-M39
M40-M45
M46-M49
M50
M51
M52-M54
M55
M56
M57-M59
M60
M61
M62
M63-M67
M68
M69
M70
M71
M72
M73-M77

13 CNC Programming 13-17/13-24

Program stop, spindle and coolant off


Optional programmable stop
End of program-often interchangeable with M30
Spindle on, CW
Spindle on, CCW
Spindle stop
Tool change
Coolant supply No. 1 on
Coolant supply No. 2 on
Coolant off
Clamp
Unclamp
Unassigned
Spindle on, CW + coolant on
Spindle on, CCW + coolant on
Rapid traverse in + direction
Rapid traverse in - direction
Unassigned
Spindle stop at specified angular position
Unassigned
Program stop at end tape + tape rewind
Interlock by-pass
Constant cutting velocity
Unassigned
Gear changes; otherwise unassigned
Unassigned
Coolant supply No. 3 on
Coolant supply No. 4 on
Unassigned
Linear cutter offset No. 1 shift
Linear cutter offset No. 2 shift
Unassigned
Piece part change
Linear piece part shift, location 1
Linear piece part shift, location 2
Unassigned
Clamp piece part
Unclamp piece part
Unassigned
Angular piece part shift, location 1
Angular piece part shift, location 2
Unassigned

CAD/CAM Principles and Applications


by P.N.Rao

M78
M79
M80-M99

13 CNC Programming 13-18/13-24

Clamp non-activated machine bed-ways


Unclamp non-activated machine bed-ways
Unassigned

13.5 Program Number

* labelling of prog, for storage


* Fanuc Oxxxx
* sub-program

Fig. 13-19 Example


N001 G92 X0 Y0 Z0
absolute presetting at A.
N002 G90
absolute programming.
N003 G00 X25.0 Y25.0 Z2.0 T01 S3000 M03 tool brought rapidly
at B,
2 mm above XY plane.
N004 G01 Z-12.0 F120
tool goes down to full depth.
N005 Y75.0
proceeds to C.
N006 X65.0
proceeds towards right to D.
N007 G02 Y25.0 I0 J-35.0
cuts curved profile till E.
N008 X25.0 *G01
proceeds to B.
N009 Z2.0
tool moves 2 mm above the XY plane
N010 G00 Z50.0 M05
spindle stops and rapidly moves up
N011 X0 Y0
rapid move to start position 0,0
N012 M30
end of program and tape rewind

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-19/13-24


* G41

Fig. 13-20 Component for example 13.2

Fig. 13-21 Tool path for machining the component for example 13.2

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-20/13-24

Fig. 13-22 Offset Tool path for machining contours that are not parallel to
the principal axes * G41

13.6 Tool Length Compensation

* measured using tool, presetter


* stored

Fig. 13-23 Tool length compensation

13.7 Canned Cycles

* repeated no of times
* drilling & tapping

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-21/13-24

Fig. 13.24 Typical motions embedded in G81 canned cycle

Fig. 13.25 Example for canned cycles.

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-22/13-24

Table 13-2 Standard canned cycle motions

*
*

Cann
ed
cycle
numb
er

Feed from
surface

G80
G81
G82
G83
G84
G85
G86
G87
G88
G89

Off
Constant
Constant
Intermittent
Constant
Constant
Constant
Constant
Constant
Constant

At programmed depth
(end of feed point)
Dw
ell

Spindle
return
motion
-Stop
-Rapid
--Rapid
Yes -Rapid
--Reverse Feed
-Feed
--Rapid
Stop
-Manual
Stop
-Manual
Yes Stop
Feed
Yes --

Used for

Spindle
speed

Cancel canned cycle


Drilling, centre drilling
Counter sinking,
Counter boring
Deep hole drilling
Tapping
Reaming
Boring
Multiple Boring
Boring
Boring

Fig. 13.26 Component for NC program in example 13.3

CAD/CAM Principles and Applications


by P.N.Rao

13.8 Cutter Radius Compensation

13 CNC Programming 13-23/13-24

* calculate tool path to offset contour


* cutter size R

Fig. 13-27 Cutter radius compensation


G40 Compensation `off'.
*
G41 used when the cutter is on the left of the programmed path
when looking in the direction of the tool movement, i.e. the
radius compensation is considered to the left of the programmed profile.

Fig. 13.28 Example showing the cutter radius compensation using the G
codes G42

CAD/CAM Principles and Applications


by P.N.Rao

13 CNC Programming 13-24/13-24

* G41 starting point

Fig. 13.29 Example showing the cutter radius compensation using the G
codes G41 and G42

Fig. 13.30 Example for contour programming using the cutter radius
compensation

You might also like