NC Programming Vik
NC Programming Vik
Programming
For the Fanuc 0T controller
Axes convention
X Axis
Z Axis
N2
50
20 N1
Z
0,0 30 50
Programming
For the Fanuc 0M controller
Axes convention
The tool can be moved to any position in a 3 dimensional cartesian co-ordinate system.
The Z axis is along the spindle axis. The X and Y axes are perpendicular to Z.
+
+Z
Z
- +Y
Y +
X -X +X
- -
+
-Y
-Z
-
X
-
+ - Z
+
Y
Z
Part
X
Machine table
List of G-codes
G-code Function
G00 Positioning rapid traverse
G01 Linear interpolation (feed)
G02 Circular interpolation CW
G03 Circular interpolation CCW
G04 Dwell
G20 Inch unit
G21 Metric unit
G28 Automatic zero return
G30 2nd reference point return
G40 Tool nose radius compensation cancel
G41 Tool nose radius compensation left
G42 Tool nose radius compensation right
G43 Tool length compensation
G52 Local co-ordinate system
G54 Work co-ordinate system 1 selection
G55 Work co-ordinate system 2 selection
G56 Work co-ordinate system 3 selection
G57 Work co-ordinate system 4 selection
G58 Work co-ordinate system 5 selection
G59 Work co-ordinate system 6 selection
G74 Left hand tapping cycle
G76 Fine boring cycle
G80 Canned cycle cancel
G81 Drilling cycle
G82 Drilling cycle with dwell
G83 Peck drilling cycle / deep drill
G84 Tapping cycle
G85 Boring / Reaming cycle
G86 Boring cycle
G87 Back boring cycle
G90 Absolute command
G91 Incremental command
G94 Feed per minute
G95 Feed per revolution
G98 Return to initial point in canned cycle
G99 Return to R point in canned cycle
List of M codes
M codes vary from machine to machine depending on the functions available on it. They are decided by the
manufacturer of the machine. The M codes listed below are the common ones.
M-codes Function
M00 Optional program stop automatic
M01 Optional program stop request
M02 Program end
M03 Spindle ON clock wise (CW)
M04 Spindle ON counter clock wise (CCW)
M05 Spindle stop
M06 Tool change
M07 Mist coolant ON (coolant 1 ON)
M08 Flood coolant ON (coolant 2 ON)
M09 Coolant OFF
M19 Spindle orientation
M30 End of program, Reset to start
M98 Sub program call
M99 Sub program end
There are other M-codes for functions like gear change, pallet change, pallet clamp / unclamp, door open /
close etc.
N2
50
20 N1
X
0,0 30 50
Format
N_ G00 X__ Y__Z__
Format
N__ G01 X__ Y__Z__ F__
Feed
Feed
Part
Part
Format
N__ G02/03 X__ Y__Z__ I__ J__K__ F__ using the arc center
OR
N__ G02/03 X__ Y__Z__ R__ F__ using the arc radius
Arc center
The arc center is specified by addresses I, J and K. I, J and K are the X, Y and Z co-ordinates of the arc
center with reference to the arc start point.
Arc start
Y
Arc end
-I
-J
Arc center
Arc start
Y Arc end Arc radius
Arc center
X
Block format
N__ G02 X__Y__ Z__ R__ F__
N__ G03 X__Y__ Z__ R__ F__
G41 G41
G42 G42
Block format
Program Zero
Gauge line
Length offset
Face milling cutter
T-slot milling cutter
Boring tool
Part
Work co-ordinate
system 1 selection
Work co-ordinate
system 2 selection Machine table
Canned cycles
Canned or fixed cycles are programming aids that simplify programming. Canned cycles combine many
programming operations and are designed to shorten the program length, minimize mathematical
calculations, and use minimal tool motions.
Examples : drilling, peck drilling, tapping, boring, back spot facing.
Format
P P
Format
Final depth
Final depth
Format
N__ G98/99 G83 R__ Z__ Q__ F__
Infeed feed rate mm/min
Peck depth
Final depth
Safe height / R point
Peck drilling cycle code
Return position code
Block number
Spindle CW Spindle CW
Format
Format
Spindle CW Spindle CW
Format
Spindle orientation
Initial point
Bore axis
Lateral shift
Final depth
Spindle CW Safe height / R point
Format
N__ G98 G87 R__ Z__ Q__ F__
Infeed feed rate mm/min
Lateral shift
Final depth
Safe height / R point
Back boring cycle code
Return position code
Block number
Spindle CW Spindle CW
Format
Spindle CW Spindle CW
Dwell at Dwell at
bottom bottom
Lateral shift Lateral shift
Format
N__ G98 G76 R__ Z__ Q__ F__
Infeed feed rate mm/min
Lateral shift
Final depth
Safe height / R point
Fine boring cycle code
Return position code
Block number
Verifying NC programs
Safety priorities
Safety priorities must be followed when verifying programs.
Typical errors
Syntax errors
Errors which prevent the machine controller from executing a command. E.g., writing G101 instead of G01
Motion errors
Machine does not generate an error, so these are difficult to diagnose.
E.g., Writing X instead of Z; wrong co-ordinates; reversing CW and CCW commands; improper
incremental/absolute mode selection.
Omission errors
Omitting decimal points, forgetting to program feed rates, forgetting to turn on the coolant
Setup errors
Wrongly measured work offset and tool offsets, or correct measurement and wrong entry
100
50
B
Dia 100
Dia 50
N2 X25. N2 X50.
N3 Z-50. N3 Z-50.
N4 X50. N4 X100.
N5 Z-100. N5 Z-100.
List of G-codes
G-code Function
G00 Positioning rapid traverse
G01 Linear interpolation (feed)
G02 Circular interpolation CW
G03 Circular interpolation CCW
G04 Dwell
G20 Inch unit
G21 Metric unit
G28 Automatic zero return
G30 2nd reference point return
G32 / G33 Thread cutting (single motion)
G40 Tool nose radius compensation cancel
G41 Tool nose radius compensation left
G42 Tool nose radius compensation right
G50 / G92 Local co-ordinate system setting, max. spindle speed setting
G70 Finishing cycle
G71 Stock removal in turning
G72 Stock removal in facing
G73 Pattern repeating
G74 Peck drilling on Z axis / Face grooving
G75 Peck drilling on X axis / Int-Ext grooving
G76 Multiple threading cycle
G94 / G98 Feed per minute
G95 / G99 Feed per revolution
G96 Constant surface speed control
G97 Constant surface speed control cancel
List of M codes
M codes vary from machine to machine depending on the functions available on it and the manufacturer of
the machine decides them. The M codes listed below are the common ones.
M-codes Function
M00 Optional program stop automatic
M01 Optional program stop request
M02 Program end
M03 Spindle ON clock wise (CW)
M04 Spindle ON counter clock wise (CCW)
M05 Spindle stop
M06 Tool change
M07 Mist coolant ON (coolant 1 ON)
M08 Flood coolant ON (coolant 2 ON)
M09 Coolant OFF
M30 End of program, Reset to start
M98 Sub program call
M99 Sub program end
There are other M-codes for functions like gear change, tail stock quill in/out, chuck clamp/unclamp, chip
conveyor forward/backward, door open / close etc.
Format
N_ G00 X_ Z_
Rapid traverse
Format
N__ G01 X__ Z__ F__
Feed motion
Format
N__ G02/03 X__ Z__ I__ K__ F__ using the arc center
OR
N__ G02/03 X__ Z__ R__ F__ using the arc radius
Arc center
The arc center is specified by addresses I and K. I and K are the X and Z co-ordinates of the arc center with
reference to the arc start point.
Arc start
X
Arc end
-K
-I
Arc center
Z
Arc radius
The radius is specified with address R.
Arc start
X Arc end Arc radius
Arc center
Z
N__ G02 X__ Z__ R__ F__
N__ G03 X__ Z__ R__ F__
If the radius is used, only arcs of less than 180 deg. can be programmed in a block. An arc with included
angle greater than 180 deg. must be specified in two blocks.
Z axis
To get an accurate contour during machining, the TTT point must move in such a manner that the nose
radius is tangential to the contour.
2. If tool nose radius compensation is not used for motion from P2 to P3, material is left out as shown in the
figure.
Z
Z
X
X
Z
Z
X
X
Z
X
Type No. 5 X
Type No. 6
The direction of the imaginary tool nose viewed from the tool nose center is determined by the direction of
the tool during cutting.
2 1
3 4
Neutral tools
7 5
G32
Thread cutting is done by moving the tool along the thread repeatedly at different depths tiil the final thread
profile is formed. Each cut must start at the same angular position on the part. The spindle has an encoder,
which generates a pulse at exactly the same angular position in every revolution. When a threading motion is
programmed, the linear motion of the tool starts when this pulse is detected. This ensures that every cut starts
at the same angular position.
Block format
N__ G32 X__ Z__ F__
X, Z are the end point of the thread and F is the pitch of the thread.
Each threading cut involves 4 motions: 1 threading motion and 3 rapid traverse motions. Since a thread
normally requires multiple cuts, G32 results in a long program and is not normally used. The G76 canned
cycle is normally used for threading.
Canned cycles
A canned cycle simplifies a program by using a few blocks containing G-codes functions to specify the
machining operations usually specified in several blocks.
d = Depth of cut
e = Retract amount
n = Number of the first block of the shape
n = Number of the last last block of the shape
u = Finishing allowance in X
w =Finishing allowance in Z
f = Feed rate
s = Spimdle speed
t = Tool number
d = Depth of cut
e = Retract amount
n = Number of the first block of the shape
n = Number of the last last block of the shape
u = Finishing allowance in X
w =Finishing allowance in Z
f = Feed rate
s = Spindle speed
t = Tool number
e = Retract amount
X = X component of point B
U = Incremental amount from A to B
Z = Z component of point C
W = Increment amount from A to C
i = Movement amount in X direction
k = Depth of cut in Z direction
d = Relief Amount of the tool at the cutting bottom
f = Feed rate
e = Retract amount
X = X component of point B
U = Incremental amount from A to B
Z = Z component of point C
W = Increment amount from A to C
i = Movement amount in X direction
k = Depth of cut in Z direction
d = Relief Amount of the tool at the cutting bottom
f = Feed rate
Format
m = No.of idle passes
r = Chamfering amount
a = Angle of tool tip
d min = Minimum thread depth
d = Finishing Allowance
i = Taper value
k = Height of thread
∆d = Depth of cut in first cut
L = Lead of thread
Verifying NC programs
Safety priorities
Safety priorities must be followed when verifying programs.
Typical errors
Syntax errors
This prevents the machine controller from executing a command. E.g., writing G101 instead of G01
Motion errors
Machine does not generate an error, so these are difficult to diagnose.
E.g., Writing X instead of Z; wrong co-ordinates; reversing CW and CCW commands; improper
incremental/absolute mode selection.
Omission errors
Omitting decimal points, forgetting to program feed rates, forgetting to turn on the coolant
Setup errors
Wrongly measured work offset and tool offsets, or correct measurement and wrong entry