• Easily understood .
• Minimum air cutting.
• Avoid repetition of tools.
• Should be simple and short.
• Considered future tooling changes
feasibility.
• Should not hamper m/c tool life.
Contents
• What is mean by CNC program ?
• Coordinate measuring systems.
• Dimensioning system.
• CNC programming formats.
• G-CODES (Preparatory functions.)
• M-CODES (Miscellaneous Functions)
• Canned Cycles.
• Subprogram/Subroutine.
• Preparation required before doing program.
• Example of one program.
• Precautionary measures while doing and executing
CNC Program.
CNC program
100.0
1
3
• Generally our drawings
50.0
50.0
are dimensioned in
100.0
150.0
absolute method so it
becomes very to find out
the co-ordinates .
System of dimensioning
3
tremendous calculations
50.0
N20 G90 ;
N30 G00 X100. Y100. ;
150.0
100.0
N40 X150. Y100. ;
X
100.0
150.0
N50 X150. Y150. ;
N60 X100. Y150. ;
N70 X100. Y100. ;
N80 M30
Program format
• Format is method of writing set of instructions.
• N10 G01 X10. Y10. F200 S200 T01 M3 ;
SEQUENCE
NO.
PREPARATOTY
FUNCTION
X-COORDINATE
Y COORDINATE
FEED FUNCTION
SPEED FUNCTION
TOOL FUNCTION
MISCLLANEOUS FUNCTION
END OF BLOCK
G codes
• G-Codes are also called as “Preparatory
functions” as they take active part in part
program execution.
• They are always programmed at the start of
block.
• They decides type of machine movement
,type of interpolation,type of dimension etc.
Type of G codes
G codes
15 60
(0,0)
-X +X
20
1
2
-Y
G01 (Linear interpolation)
• Position data command programmed after G01
is executed at programmed feedrate along a
straight line.
• Movement being made along straight line
joining start point and end point.
• G01 is modal and canceled with G00 , G02 or
G03.
• On graphic screen G01 appears as continuos
line.
G01(Linear interpolation).
• Example :
To move from point 1 to point 2 command data is given as
G01 X75 Y-20 F20 ;
End of block
Position data
+Y
15 60
(0,0)
-X +X
20
1
2
-Y
G02/G03 (Circular interpolation)
G02
N10 G01 X40. Y40. ;
(80,80) (80,80) N20 G02 X80. Y80. R40 ;
(40,40) (40,40) G03
N10 G01 X80. Y80. ;
GO2
G03
(80,80) G02
N10 G01 X40. Y40. ;
(40,40)
N20 G02 X80. Y80. I40 J0 ;
GO2
G04 (Dwell)
• It is used to program dwell time in sec.
• Dwell time value is programmed by means
of letter X.
• For e.g. N10 G04 X2 ;
– Means spindle will take dwell of 2 sec. While
executing this line.
• It is blockwise active.
• No other function can be programmed in a
block in which G04 is programmed.
Cutter radius compensation
• Advantages :
1.Different dia. of cutters can be used without
changing part program.
Cutter Cutter
center center
line line
G41
G42
Cutter radius compensation
Example
80.0
35.0
35.0
R15.0
95.0
G70 (Inch unit system)
Operation 1
Initial level 1 : Positioning of axes X&Y.
Operation 2
Operation 6 3 : Hole machining.
4 : Operation at the bottom of hole.
Point R level
5 : Retraction to point R level
6 : Rapid traverse upto initial point.
Operation 3 Operation 5
Operation 4
Drilling cycle (G81) :
G81(G98) G81(G99)
INITIAL LEVEL
INITIAL LEVEL
P P
POINT 'Z' POINT 'Z'
Format for Counter boring cycle (G82) :
Format : G82 X_ Y_ Z_ R_ P_ F_ K_
• IMPORTANT POINTS :
1.Before specifying G81 use a miscellaneous function
(M CODE) to rotate the spindle.
2.Specify „R‟ in block that perform drilling .If it is
specified in block that does not performed drilling it
can be stored as MODAL data.
3. In canned cycle mode tool offsets are ignored.
4.Do not specify G codes from G00 To G03 together
with G81 otherwise G81 is canceled.
Peck drilling cycle (G83) :
G83(G98) G83(G99)
w/p
R R
Z=0 Z=0
q q
d d
d d
Format for Peck drilling cycle (G83) :
Format : G83 X_ Y_ Z_ Q_ R_ F_ K_
• IMPORTANT POINTS :
1.Before specifying G81 use a miscellaneous function
(M CODE) to rotate the spindle.
2.Specify „R‟ in block that perform drilling .If it is
specified in block that does not performed drilling it
can be stored as MODAL data.
3. In canned cycle mode tool offsets are ignored.
4.Do not specify G codes from G00 To G03 together
with G81 otherwise G81 is canceled.
Tapping cycle (G84) :
G84(G98) G84(G99)
INITIAL LEVEL
spindle
cw
spindle
POINT R cw POINT R POINT 'R' LEVEL
w/p
w/p
spindle spindle
ccw p ccw P
POINT 'Z' POINT 'Z'
Format for tapping cycle (G84) :
Format : G84 X_ Y_ Z_ Q_ R_ F_ K_
G85(G98) G85(G99)
INITIAL LEVEL
• IMPORTANT POINTS :
1.Before specifying G81 use a miscellaneous function
(M CODE) to rotate the spindle.
2.Specify „R‟ in block that perform drilling .If it is
specified in block that does not performed drilling it
can be stored as MODAL data.
3. In canned cycle mode tool offsets are ignored.
4.Do not specify G codes from G00 To G03 together
with G81 otherwise G81 is canceled.
Boring cycle (G86) :
G86(G98) G86(G99)
spindle
cw
INITIAL LEVEL
spindle
cw
POINT R POINT R POINT 'R' LEVEL
w/p
w/p
spindle spindle
stop POINT 'Z' stop POINT 'Z'
Format for boring cycle (G86) :
Format : G86 X_ Y_ Z_ Q_ R_ F_ K_
• IMPORTANT POINTS :
1.Before specifying G81 use a miscellaneous function
(M CODE) to rotate the spindle.
2.Specify „R‟ in block that perform drilling .If it is
specified in block that does not performed drilling it
can be stored as MODAL data.
3. In canned cycle mode tool offsets are ignored.
4.Do not specify G codes from G00 To G03 together
with G81 otherwise G81 is canceled.
Back boring cycle (G87) :
G87(G98) G87(G99)
NOT USED
POINT R
spindle cw
spindle cw
Format for back boring cycle (G87) :
Format : G87 X_ Y_ Z_ Q_ R_ F_ K_
• IMPORTANT POINTS :
1.Before specifying G81 use a miscellaneous function
(M CODE) to rotate the spindle.
2.Specify „R‟ in block that perform drilling .If it is
specified in block that does not performed drilling it
can be stored as MODAL data.
3. In canned cycle mode tool offsets are ignored.
4.Do not specify G codes from G00 To G03 together
with G81 otherwise G81 is canceled.
Boring cycle (G88) :
G88(G98) G88(G99)
spindle
cw
INITIAL LEVEL
spindle
cw
POINT R POINT R POINT 'R' LEVEL
w/p
spindle w/p
spindle stop
stop p
p
POINT 'Z' POINT 'Z'
Format for boring cycle (G88) :
Format : G88 X_ Y_ Z_ Q_ R_ F_ K_
• IMPORTANT POINTS :
1.Before specifying G81 use a miscellaneous function
(M CODE) to rotate the spindle.
2.Specify „R‟ in block that perform drilling .If it is
specified in block that does not performed drilling it
can be stored as MODAL data.
3. In canned cycle mode tool offsets are ignored.
4.Do not specify G codes from G00 To G03 together
with G81 otherwise G81 is canceled.
Boring cycle (G89) :
G89(G98) G89(G99)
INITIAL LEVEL
• IMPORTANT POINTS :
1.Before specifying G81 use a miscellaneous function
(M CODE) to rotate the spindle.
2.Specify „R‟ in block that perform drilling .If it is
specified in block that does not performed drilling it
can be stored as MODAL data.
3. In canned cycle mode tool offsets are ignored.
4.Do not specify G codes from G00 To G03 together
with G81 otherwise G81 is canceled.
CANNED CYCLE SUMMARY
CANNED CYCLE SUMMARY
G CODE Drilling Operatio Retractio Application
(- Z n at the n
direction) bottom of (+ Z
hole direction)
G73 Intermittent --- Rapid High speed
feed traverse peck drilling
cycle.
G74 feed Spindle cw feed Left hand
tapping cycle.
G76 feed Oriented Rapid Fine boring
spindle traverse cycle
stop
G81 feed --- Rapid Drilling cycle
traverse
G82 feed dwell Rapid Counter boring
traverse cycle
G83 Intermittent --- Rapid Peck drilling
feed traverse cycle.
G84 feed Spindle feed Tapping cycle
ccw
G85 feed --- feed Boring cycle
G86 feed Spindle Rapid Boring cycle
stop traverse
G87 feed Spindle Manual/ Back boring
stop Rapid cycle
traverse
G88 feed Dwell- Manual/ Boring cycle
Spindle Rapid
stop traverse
G89 feed Dwell- feed Boring cycle
Spindle
stop
SUBROUTINES
• Also called as SUBPROGRAM.
• These are powerful time saving technique.
• Subroutines provides the capability of
programming certain fixed sequence or
frequently repeated patterns.
• Subroutines are in fact independent
programs with all feature of usual part
program.
• Subroutines are stored in memory under
separate program no.
SUBROUTINES
• Whenever particular feature is required
within the program, associated subroutine is
called for execution.
• Subroutine may called any time and any
no.of times.
• After execution of subroutine the control
returns to main program .
• To describe and use a subroutine following
information is required in form of code and
symbol.
SUBROUTINES
• For e.g.
– Start of subroutine.
– End of subroutine.
– A means of calling subroutine.
50.0
90.0 N70 G00 Z8. ;
N80 G90 ;
N90 M17 ;
Introducing subroutine in main
program
N10 G90 G71 G94 S500 M03 ;
N20 G00 X50. Y50. ;
N30 G00 Z5 M08 ;
(200,200) N40 L101 ;
Y (120,120) N50 G00 X120. Y120. ;
90.0
50.0 N60 L101;
X
50.0
90.0
N70 G00 X200. Y200. ;
N80 L101 ;
N90 G00 X0. Y0. Z20. M09
N100 M30 ;
What programmer has to do ?
• Study the drawing thoroughly.
• Identify type of material to be machined.
• Know the specification and functions of
machine to be used.
• Decide the dimension mode (mm or inches)
• Decide the coordinate system .
• Identify the plane of cutting.
• Know the cutting parameters for job/tool
combinations.
What programmer has to do ?
• Know the federate programming.
• Check required toolings.
• Establish sequence of machining operations.
• Identify whether use of any special feature
like subroutines is required or not.
Part Program Example.
OPERATIONS TOOLS
• Bore dia 60H7 Core Drill dia 55
B. Bar dia 59.5
B. Bar dia 60