You are on page 1of 55

Numerical Control Programming

NC PART PROGRAMMING

•Introduction
• Coordinate Systems
• NC Words
Coordinate System

Z AXIS Z // rotating spindle


• workpiece-rotating machine:
Z is parallel to the spindle Z
• tool-rotating machine:
Z is parallel to the tool axis

Z
Z
Coordinate System

X AXIS X // table
 workpiece-rotating machine:
X
X is the direction of tool movement Z

 horizontal milling machine :


X axis is parallel to the table
 vertical machine :
+X axis points to the right
when the programmer X
Z
Z
is facing the machine.
X
NC Words

• N, G, X, Y Z, A, B, C, I, J, K, F, S, T, R, M

 N: specify the sequence number


 G: preparatory word
to prepare for control functions (the motion of each axis,
coordinate system, coordinate plane, cutter radius
compensation, tool length offset……)
 M: miscellaneous word
to control miscellaneous functions (spindle on/off,
start/stop the machine, turn on/off the coolant, change the
tool, and rewind the program tape)
G-codes
• G00 Rapid transverse (Point to point positioning)
• G01 Linear interpolation (Feed Rate move)
• G02 Circular interpolation (Clockwise move)
• G03 Circular interpolation (Counter Clockwise move)
• G04 Dwell time
• G05 Hold/Delay
• G06 Parabolic interpolation
• G08 Acceleration of feed rate
• G09 Deceleration of feed rate
• G10 A linear interpolation for long dimension (10” to 100”)
• G11 A linear interpolation for long dimension
• G17 XY PLANE
• G18 XZ PLANE
• G19 YZ PLANE
• G28 Return to clearance plane
• G33 Threading (Lathe, constant lead)
• G33 Threading (Lathe, increasing lead)
• G35 Threading (Lathe, decreasing lead)
• G40 Tool/cutter compensation cancel to zero
• G41 Tool/cutter compensation to the left
• G42 Tool/cutter compensation to the right
• G43 Tool length compensation - negative direction
• G44 Tool length compensation - positive direction
• G64 Change in feed rate or speed
• G70 Dimensions in Inches
• G71 Dimensions in Millimetres
• G80 Canned cycle cancelled
• G81 Drill cycle G81 X# Y# Z# R#
• G82 Dwell cycle G82 X# Y# Z# R#
• G83 Peck cycle G83 X# Y# Z# R#
• G84 Tapping cycle G84 X# Y# Z# R# C#
• G85 Boring cycle 1 G85 X# Y# Z# R#
• G86 Boring cycle 2 G86 X# Y# Z# R#
• G88 Boring cycle 3 G88 X# Y# Z# R#
• G89 Boring cycle 4 G89 X# Y# Z# R#
• G90 Absolute mode
• G91 Incremental mode
• G92 Home coordinate reset G92 X# Y# Z#
• G94 IPM mode (Lathe) default
• G95 IPR mode (Lathe)
• G96 Spindle feed rate for constant Surface Feed (Lathe)
• G97 Spindle speed in revolution Constant Surface Feed (Lathe)
Groups

• Motion (G00, G01, G02 and G03)


• Dwell (G04)
• Active plane selection (G17, G18 and G19)
• Cutter compensation (G40, G41 and G42)
• Units (G70 and G71)
• Canned cycle (G80 and G81-G89)
• Coordinate system (G90 and G91)
• Pre-set (G92)
M codes
• M00 Program stop, spindle and coolant off
• M01 optional programmable stop
• M02 End of Program (interchangeable with M30)
• M03 Spindle On Clockwise
• M04 Spindle On Counter Clockwise
• M05 Spindle Stop
• M06 Tool Change
• M07 Coolant On 1
• M08 Coolant On 2
• M09 Coolant Off
• M10 Clamp
• M11 Unclamp
• M15 Rapid transverse in +
• M16 Rapid transverse in –
• M19 Spindle stop at specific angle
• M30 End of Program
• M13 Spindle On Clockwise + Coolant On
• M14 Spindle On Counter Clockwise + Coolant On
Common Format of a Block

Sequence Preparatory Dimension Feed Spindle Tool Misc.


# Function Words Rate Function Function Function

N50 G90 G01 X1.40Y2.25 F10 S1500 T01 M03

Individual Words
N – Sequence or line number
A tag that identifies the beginning of a block of code. It is used by
operators to locate specific lines of a program when entering data or
verifying the program operation.

G – Preparatory function
G words specify the mode in which the milling machine is to move along
its programmed axes.
Dimension Words
X – Distance or position in X direction
Y – Distance or position in Y direction
Z – Distance or position in Z direction
M – Miscellaneous functions
M words specify CNC machine functions not related to dimensions or
axial movements.
F – Feed rate (inches per minute or millimeters per minute)
Rate at which cutting tool moves along an axis.

S – Spindle speed (rpm – revolutions per minute)


Controls spindle rotation speed.

T – Tool number
Specifies tool to be selected.
I – Circular cutting reference for x axis

J – Circular cutting reference for y axis

K – Circular cutting reference for z axis


NC Words

• Modal codes and non modal codes/

• modal functions
Modal functions stay active until some other command changes it.
Modal commands are arranged in sets called “modal groups”, and
only one member of a modal group may be in forces at any given
time.
• non-modal functions
Non-modal functions have effect only on the lines on which they
occur.
NC Words

modal groups
NC Words

M CODES modal groups

M00 Program stop M06 Tool change

M01 Optional stop M07 Flood coolant on

M02 End of program M08 Mist coolant on

M03 Spindle CW M09 Coolant off

M04 Spindle CCW M30 End of tape


NC Words

N, G, X, Y , Z, A, B, C, I, J, K, F, S, T, R, M

 F: feed rate of the tool motion


 S: cutting-speed

 T: tool number
NC Words

N, G, X, Y , Z, A, B, C, I, J, K, F, S, T, R, M

• X, Y, Z, A, B, C: provide the coordinate positions of the tool.


X, Y, and Z define the three translational (Cartesian) axes of
a machine. A, B and C are used for the three rotational axes
about the X, Y, and Z axes.

• I, J, K: specify the center for circular motion


NC Words
G codes

• Unit selection:
• G70 (inch), G71(metric)
• Coordinates selection:
• G90(absolute), G91(incremental)
• Working plane selection:
• G17(X-Y), G18(Z-X), G19(Y-Z)
Set up working coordinate
Z
• Machine zero
• is unchangeable and usually is set up with the machine 23
• Working coordinate
(is decided by the offset from the machine zero) X
• G92 25.2
• Be defined in program G92 X25.2 Z23.0

G55 G56 G57 G58

G54 G59

Machine zero
Rapid traverse: G00

• G00:
• to make the machine move at maximum speed.
• It is used for positioning motion.
G90 G00 X20.0 Y10.0

End
G90:
(20,10)
absolute
coordinate (10,10)
s

Start (0,0)
Linear interpolation: G01

• G01:
• linear interpolation at feed speed.
G91 G0l X200.0 Y100.0 F200.0

Y
G91: End
incremental 100.0
coordinates

Start 200.0 X
Circular interpolation: G02, G03
• G02, G03:
• For circular interpolation, the tool destination and the circle center
are programmed in one block
• G02 is clockwise interpolation, G03 is counterclockwise
interpolation

End point Circle center, radius


Circular interpolation: G02, G03

Mill Circular Interpolation G02 G03 with R G92:


To define working
N0010 G92 X200.0 Y40.0 Z0;
coordinate
N0020 G90 G03 X140.0 Y100.0 R60.0 F300;
N0030 G02 X120.0 Y60.0 R50.0; G90:
absolute
Y coordinates
B
100
R50
R60
60
40 c A

X
O 90 120 140 200
Circular interpolation: G02, G03

CNC Incremental Programming G91 Example Code G92:


To define working
Mill Circular Interpolation G02 G03 with R
coordinate
G91 G03 X-60 Y60 R60 F300
G02 X-20 Y-40 R50 G90:
absolute
Y coordinates
B
100
R50
R60
60
40 c A

X
O 90 120 140 200
M code

• miscellaneous word
• miscellaneous functions:
• turn the spindle on/off
• start/stop the machine
• turn on/off the coolant
• change the tool
• rewind the program (tape)
M code

M00 Program stop M06 Tool change

M01 Optional stop M07 Flood coolant on

M02 End of program M08 Mist coolant on

M03 Spindle CW M09 Coolant off

M04 Spindle CCW M30 End of tape

modal groups
M code: M00, M01

• M00 and M01 both stop the machine in the


middle of a program.
• M01 is effective only when the optional stop
button on the control panel is depressed. The
program can be resumed through the control
panel.
M code: M03, M04, M05

• M03 turns on the spindle clockwise.


• M04 turns the spindle on counterclockwise.
(The spindle rpm must be specified in the same line
or in a previous line. )
• M05 turns off the spindle.
M code: M07, M08, M09

• M07 and M08 turn on different modes of coolant.


• M07: flood coolant on
• M08: mist coolant on
• M09 turns off the coolant.
M code: M06

• M06 signals the tool-change operation.


• On a machine equipped with an automatic tool
changer, it stops the spindle, retracts the spindle to
the tool-change position, and then changes the tool
to the one specified in the T-code.
M code: M02, M30

• M02 marks the end of the program.


• M30 marks the end of the tape. It stops the spindle
and rewinds the program (tape)
CNC Programming Exercise

G90 Absolute Coordinate


N1 G00 X0.000 Y0.000 Position to work origin
N2 G90 Set program to absolute value
N3 G1 X12.000 Y12.000 F300.00 P0 to P1
N4 X26.000 Y16.000 P1 to P2
N5 X38.000 Y32.000 P2 to P3
N6 M30

G91 Incremental Coordinate


N1 G00 X0.000 Y0.000 Position to work origin
N2 G91 Set program to increment value
N3 G1 X12.000 Y12.000 F300.00 P0 to P1
N4 X14.000 Y4.000 P1 to P2
N5 X12.000 Y16.000 P2 to P3
N6 M30
CNC Mill Programming Exercise
G90 Absolute Programming
E G90 G00 X0 Y0 (Point A)
G01 X50.0 (From A to B)
X70.0 Y35.0 (From B to C)
X45.0 (From C to D)
X0 Y80.0 (From D to E)
D C Y0 (From E to A)
M30

G91 Incremental Programming


G91 G00 X0 Y0 (Point A)
A B G01X50.0 (From A to B)
X20.0 Y35.0 (From B to C)
X-25.0 Y0 (From C to D)
X-45.0 Y45.0 (From D to E)
X0 Y-80.0 (From E to A)
M30
CNC Mill Programming Exercise

N1 G90 G00 X0 Y0
N2 G01 X30
N3 G03 X54 R12
N4 G01 X82
N5 G02 X108 R13
N6 G01 X123
N7 X80 Y45
N8 X40
N9 Y75
N10 G03 X35 Y80 R5
N11 G01 X20
N12 G03 X0 Y80 R10
N13 G01 Y0
N14 M30
CNC Mill Programming Exercise
Explanation of CNC G-Code
7 6 G00 : Rapid traverse.
G54 : Zero Offset no. 1.
G64 : Continuous-path mode.
G90 : Absolute dimensioning system.
8 G91 : Incremental dimensioning
system.
G17 : X-Y plan selection.
9 G42 : Cutter radius compensation
activation (right hand side movement)
G40 : Cutter radius compensation de-
5 active
3 S : Spindle speed
F : Axis motion feed
10 4 M : Cutter motion (3=clockwise,
2 4=anti-clockwise)
D : Tool no
1

N1 G00 G90 G17 X-20 Y-20 Z50 ;Point 1


N2 S450 M03 F250 D01 (12.5 MM DIA) N9 X-40 Y60 ;Point 6
N3 G00 Z0 N10 X-20 Y0 ;Point 7
N4 G42 Z-5 N11 X-10 Y-25 ;Point 8
N5 G91 G01 X20 Y20 ;Point 2 N12 X-30 Y-15 ;Point 9
N6 X10 Y10 ;Point 3 N13 X0 Y-40 ;Point 10
N7 X70 Y-10 ;Point 4 N14 G40 G90
N8 X20 Y20 ;Point 5 N15 G00 X-20 Y-20 Z50 ;Point 1
N16 M30
G97 Revolutions per minute (spindle speed)
G42 Cutter compensation, Right
G40 Cutter compensation cancel, offset Cancel
G95 Feed per Revoluton

N1 T0101 ; Tool no 1 with offset no 1 FANUC Control


N2 G97 S500 M03 ; Spindle rotation clockwise with 500 RPM
N3 G42 G00 X0 Z0 ; P0 tool nose radius compensation active
N4 G01 X25 G95 F0.3 ;
N5 G01 Z-7.5 ; P1
N6 G01 X40 Z-15 ; P2
N7 G01 Z-25 ; P3
N8 G01 X60 Z-35 ; P4
N9 G40 G00 X200 Z100; Tool nose radius compensation cancel
G 90 G71 G94
M03 S1000
T1D1
G00 X26 Z0
G01 X0 Z0 F10
G00 X25 Z0
G01 X25 Z-70 F10
G00 X26 Z-70
G00 X20 Z0
G01 X20 Z-30 F10
G01 X25 Z-50
G00 X26 Z-50
G00 X15 Z0
G01 X15 Z-22.6 F10
G02 X20 Z-30 CR12 F8
G00 X21 Z-30
G00 X5 Z0
G03 X15 Z-5 CR5 F8
G00 X16 Z-5
G00 X26 Z0
M30
Example

• A 2.0-in 2.0-in. square is to be milled using a 1/2-in. end milling


cutter (end mill). Write an NC part program to make the square.
Example

Part program Explanation


N0010 G41 S1000 F5 M03 Begin compensation(left), set feed and
speed, spindle on (CW)
N0020 G00 X6.000 Y6.000 Move to lower left corner
N0030 G01 Z-1.000 Plunge down the tool
N0040 G01 Y8.000 Cut to upper left corner
N0050 G01 X8.000 M96 Cut to upper right corner with external curve
N0060 G01 Y6.000 M96 Cut to lower right corner with external curve
N0070 G01 X6.000 M96 Cut to lower left corner with external curve
N0080 G01 Z1.000 Lift the tool
N0090 G40 M30 End the composition, stop the machine
Direct Numerical Control (DNC):

• A system in which a central computer downloads


the NC programs block by block to many NC
machine tools simultaneously is called Direct
Numerical Control (DNC) system.

2004 51
DNC

 Direct numerical control (DNC) – control of multiple


machine tools by a single (mainframe) computer
through direct connection and in real time
 1960s technology
 Two way communication
 Distributed numerical control (DNC) – network
consisting of central computer connected to machine
tool MCUs, which are CNC
 Present technology
 Two way communication
Direct Numerical Control (DNC):

• This system used to work with the early NC machine


tools which can not read more than a block of
information at a time. The central computer feed the
program information one block at a time. When the
machine execute the information, the next block of
information would be fed.

2004 53
Distributed Numerical Control (DNC):

• Distributed NC is known by the same acronym as


Direct Numerical Control (DNC). After the
introduction of CNC, the machine tools have had the
capability of storing large amount of information.
Therefore, there have been no need to have drip
feed information system, like, Direct Numerical
Control. Instead, Distributed Numerical Control is
introduced. In such a system, a host computer
communicate with many CNC machine tools via
networks and download or upload programs.

2004 54
Distributed Numerical Control (DNC):

• With Distributed Numerical Control systems, it is


possible to monitor the activities in individual CNC
machine tools on host computer.
• Therefore, better shop floor control can be achieved.

2004 55

You might also like