You are on page 1of 56

CHAPTER SIX

CNC PART PROGRAMING

Compiled by Abubeker Omer


September 2021
12/03/23 1
PART PROGRAMMING FUNDAMENTALS
As discussed earlier, the numerical control machine tools
require a part program to generate the required geometric
shape of the components.
The part program is basically a detailed step-by-step
procedure that gives the necessary instructions to the various
parts of CNC machine tool to produce the part.
Thus, the actual utilization of the machine tool is as good as
the part program that runs the machine.
Hence it is a very important component in the use of CNC
machine tools, to be able to write good part programs.

12/03/23 2
 To develop a part program, it is necessary to follow
a series of steps in a proper sequence to come up
with a satisfactory program.
 It is possible to make the same part by any number
of procedures, but the one that uses the least amount
of time and resources, will be the best program.
 In order to achieve this, part the part programmer
need to have sufficient amount of knowledge in a
number of associated disciplines, such as machining
and mathematics.
 The following are some of the steps that are detailed
below :
12/03/23 3
The first step is to identify the various operations
and surfaces that need to be machined in order to get
the final shape of the part. This is termed as process
planning.
The process plan of a component in conventional
machining consists of machine tool used, work
holding fixtures required, and the sequence of
operations.
Additionally, for each of the operation, it is also
necessary to identify the cutting tools required along
with the process parameters such as cutting speed,
depth of cut, and feed rate.
12/03/23 4
The next step involved will be the identification of
the datum on the part that can be linked to the datum
of the chosen CNC machine tool.
The part programmer will have to identify the
datum and axes on the part in tune with that on the
CNC machine tool. It is not necessary that the part
datum and machine datum be the same, which is
more difficult for operation.
The CNC machine tools generally come with
‘floating datum’ whereby the part datum can be
located anywhere in the machine tool’s operation
space.
12/03/23 5
PREPARATORY FUNCTIONS
The preparatory functions are denoted by the word
address ‘G’. This function principally controls the
geometric functions of the controller.
Thus, it is mostly associated with the control of the
axes. These are also called as G codes.
It generally has two digits, e.g. G01, G42, and G90
as per ISO specifications.
Many of the current day controllers have extended
this to 3 or 4 digits. Most of these functions are
standardized by ISO as follows :
12/03/23 6
G00 Rapid traverse
G01 Linear interpolation
G02 Circular interpolation, CW
G03 Circular interpolation, CCW
G04 Dwell
G08 Acceleration
G09 Deceleration
G17 X-Y Plane
G18 Z-X Plane
G19 Y-Z Plane
G20 Inch Units (G70)
G21 Metric Units (G71)
G31 Skip Cutting
G33 or G92 Thread cutting
G40 Cutter compensation-cancel
G41 Cutter compensation-left
G42 Cutter compensation-right
G54 Offset fixture # 1
G55 Offset fixture # 2
G56 Offset fixture # 3
G57 Offset fixture # 4
G58 12/03/23
Offset fixture # 5 7
G54 Offset fixture # 6
Over all G-codes

12/03/23 8
 Most of the G codes are modal in nature, so that they need
not be repeated in every block.
 Another point to be noted with these codes is that the G
codes are divided into various groups depending upon their
functionality.
 It is expected that only one code from each of the group
should be given in any given block.
1. Motion group
*G00 Rapid Positioning
G01 Linear Interpolation
G02 Circular interpolation Clockwise
G03 Circular interpolation Counter clockwise
12/03/23 9
2. Active Plane Selection Group
*G17 XY Plane selection
G18 XZ Plane selection
G19 YZ Plane selection
3. Cutter Compensation Group
*G40 Cutter compensation, Cancel
G41 Cutter radius Compensation left
G42 Cutter radius Compensation right
4. Units Group
*G70 or G20 Inch units
G71or G21 Metric units

12/03/23 10
5. 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
6. Preset
G92 Absolute pre-set, Change the datum position & it can be
used as grooving code for GSK 928TC lathe machine.

12/03/23 11
 The * sign indicates the generally accepted default
or turn on code in operation.
 However, this is not generally true with all the
controllers and care have to be taken to check with
the programming manual of the controller.

12/03/23 12
MISCELLANEOUS FUNCTIONS, M
The miscellaneous functions or M-codes are the ones used
for operating the machine tool functions.
Generally, only one -M code is supposed to be given in a
single block.
Similar to G-codes, ISO has standardized a number of M-
codes as follows :
Code & its Function
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
M0512/03/23
Spindle stop 13
M06 Tool change
M07 Coolant supply No. 1 on
M08 Coolant supply No. 2 on
M09 Coolant off
M10 Clamp
M11 Unclamp (Clamp off)
M13 Spindle on, CW (+) coolant on
M14 Spindle on, CCW (–) coolant on
M15 Rapid traverse in + direction
M16 Rapid traverse in - direction
M19 Spindle stop at specified angular position
M30 Program stop at end tape reset to start
M31 Interlock by-pass
M32-M35 Constant cutting velocity
12/03/23 14
M40-M45 Gear changes; otherwise unassigned
M50 Coolant supply No. 3 on
M51 Coolant supply No. 4 on
M55 Linear cutter offset No. 1 shift
M56 Linear cutter offset No. 2 shift
M60 Piece part change
M61 Linear piece part shift, location 1
M62 Linear piece part shift, location 2
M68 Clamp piece part
M69 Unclamp piece part
M71 Angular piece part shift, location 1
M72 Angular piece part shift, location 2
M78 Clamp non-activated machine bed-ways
M79 Unclamp non-activated machine bed-ways
M98 Subprogram call
M9912/03/23
Subprogram end 15
Program Number
•N CODE: Sequence number, used to identify each block
with in an NC program and provides a means by which NC
commands may be rapidly located.
•It is program line number; is generally good practice to
increment each block number by 5 or 10 to allow additional
blocks to be inserted if future changes are required.

12/03/23 16
Basics of NC Part Programming:-
•During secondary motion, either the tool moves
relative to the workpiece or the workpiece moves
relative to the tool.
•In NC programming, it is always assumed that the
tool moves relative to the workpiece.
•The position of the tool is described by using a
Cartesian coordinate system.
•If (0,0,0) position can be described by the operator,
then it is called floating zero.
•In defining the motion of the tool from one point to
another,
12/03/23
either absolute positioning mode 17 or
incremental positioning mode can be used.
1. Absolute positioning. In this mode, the desired
target position of the tool for a particular move is
given relative to the origin point of the program.

2. Incremental positioning. In this mode, the next


target position for the tool is given relative to the
current tool position.
12/03/23 18
Absolute Advantages to Absolute Positioning
•No accumulation of positioning errors or tolerances between
dimensions
•Positioning errors are isolated to a single instance instead of
cascading into multiple part errors
•Faster programming
12/03/23 19
•Easier to correct and trace cutter movement from raw code.
G01 Linear Interpolation
Linear Interpolation results in a straight line feed
move.
Unless tool compensation is used, the coordinates are
associated with the centreline of the tool.
As an example, for the motion that occurs in x-y
plane with the same maximum speed for the x- and y-
axis, initial motion is at an angle of 45deg.
to the axes until motion in one of the axes is
completed and then the balance of the motion occurs
in the other axis. This is called point-to-point motion.
12/03/23 20
 G01 is another preparatory function to specify that the tool
should be moved to a specified location along a straight line
path. It is referred to as linear interpolation.
 This function is typically used to specify machining of
straight features such as turning a cylindrical surface in
turning, cutting a slot in milling, etc.

12/03/23 21
G02 Circular Interpolation Clockwise (CW) &
G03 Circular Interpolation Counter Clockwise (CCW)
•G02 is also a preparatory function to specify that the tool
should be moved to a specified location along a circular path
in a clockwise direction.
•In order to specify the path to the MCU, the end point of the
arc and the location of the Center of the arc should be
specified.
•Within the block in which the G02 code is programmed, the
Center of the arc is given by specifying its location relative to
the start of the arc.

12/03/23 22
Canned Cycles
The sequence of some machining operations is may
be the same for any part and for any machine.
For example, drilling a hole involves the following
steps:
•Position the tool above the point where the hole will
be drilled Set the correct spindle speed.
•Feed the tool into the workpiece at a controlled feed
rate to a predetermined depth.
•Retract the tool at a rapid rate to just above the point
where the hole started.
12/03/23 23
MANUAL PART PROGRAMMING METHODS
It is necessary to have a specified format or
language that should be used to write the part
programs.
It would be preferable to use a language that is close
to English, but that would make the language
interpretation more difficult.
Hence, the part programming language used
universally by the CNC controllers is the ‘Word
Address Format’ that relies on providing a character
address for each of the number that is specified in the
part program block.
12/03/23 24
 Prior to this a number of formats such as fixed sequential
and tab sequential format have been tried that are no more
in use.
 A typical block in the word address format is given below :
N050 G01 X10.45 Y75.0 Z-8.0 F150 M03;
The meaning of these parameters is explained below :
N050 refers to the block number 50
G01 refers to a preparatory function for linear interpolation
X10.45 refers to X coordinate with the value of 10.45 units
Y75.0 refers to Y coordinate with the value of 75.0 units
Z-8.0 refers to Z coordinate with the value of -ve 8.0 units
F150 refers to a feed rate of 150 units/min or 150 units/revolution
M03 refers to a miscellaneous function value of 03 that starts the
Spindle in the clockwise direction.
12/03/23 25
• The complete part program is broken down into a
number of blocks each of which consists of a
number of words as given above.
• Each of the block refers to a set of instructions that
can be simultaneously executed.
• Each block generally starts with a block number that
can be used as a label and is programmed with a N
word address. This may be followed by a number of
words as required.
• From the beginning of the CNC era, standardisation
played an important role in simplifying the
programming where a large number of
12/03/23 26
manufacturers are involved.
Manual part programming methods for CNC lathe
Example 1
Typical Programming -Turning Operation

12/03/23 27
PART PROGRAM
N5 M10
N10 T0101
N15 G00 X80 Z50
N20 M03 S600
N25 M08
N30 G01 X50 Z0 F100
N35 Z-30
N40 X80 Z-50
N45 G00 X100 Z50
N50 M05
N55 M09
N60 M11
N65 M30
12/03/23 28
Example 2
CNC part programming for multi step Turning operation

12/03/23 29
Part program Code Explanation
N5 T0101 Tool no 1 with offset no 1 FANUC Control
N10 G21 S500 M03 Metric, rotation CW with 500 RPM
N15 G00 X25 Z0 G95 F0.3 Feed rate of 0.3 mm per revolution
N20 G01 Z-7.5 At point P1
N25 G01 X40 Z-15 At point P2
N30 G01 Z-25 At point P3
N35 G01 X60 Z-35 At point P4
N40 G00 X200 Z100 Rapidly Retracting to X200 & Z100 units
N45 M05 Spindle stop
N50 M30 End of program, reset to start (Rewind)

12/03/23 30
Example 3 Part Program for GSK Lathe Machine
N0010 M03 S1000
N0020 M06 T0202
N0030 G00 X70 Z0
N0040 G71 U0.5 R1
N0050 G71 P60 Q120 U0.5 W0.5 F100 M08
N0060 G00 X0 Z0
N0070 G03 X20 Z-20
N0080 G01 Z-45
N0090 G01 X40 Z-80
N0100 Z-105
N0110 G02 X70 Z-120
N0120 G01 Z-160
N0130 G00 X100 Z100
N0140 G70 P70 Q120 F20
N0150 G00 X100 Z100
N0160 M09
N0170 M05
N0180 M30
12/03/23 31
Example 4 Part Program for GSK Lathe Machine
N0010 M03 S1000
N0020 T0202 M06
N0030 G00 X50 Z0
N0040 G71 U0.5 R1
N0050 G71 P60 Q130 U0.5 W0.5 F100
N0060 G00 X16 Z0
N0070 G01 Z-20
N0080 G03 X30 Z-28 R8
N0090 G01 Z-45
N0100 G01 X40 Z-60
N0110 G01 Z-68
N0120 G02 X40 Z-78 R8
N0130 G01 z-88
N0140 G00 X100 Z100
N0150 G70 P70 Q130 F20
N0160 G00 X100 Z100
N0170 M05
N0180 M30

12/03/23 32
Example 5 Part Program for GSK Lathe Machine
N0010 M03 S1 N001 G0 X40 Z5; (Rapid position)
N002 M03 S200; (Start spindle)
N0020 T0202 N003 G01 X0 Z0 F900; (Approach workpiece)
N0030 G00 X40 Z0 N005 G03 U24 W-24 R15; (Cut R15 arc)
N0040 G71 U0.5 R1 N006 G02 X26 Z-31 R5; (Cut R5 arc)
N007 G01 Z-40; (Cutф26)
N0050 G71 P60 Q90 U0.5 W0.5 F100 N008 X40 Z5; (Return to starting point)
N0060 G01 X0 Z0 N009 M30; (End of program)
N0070 G03 X22 Z-27 R15
N0080 G02 X26 Z-31 R5
N0090 G01 Z-40
N0100 G00 X100 Z100
N0110 G70 P70 Q90 F20
N0120 G00 X100 Z100
N0130 M05
12/03/23 33
N0140 M30
Example 6 Part Program for GSK Lathe Machine
N0010 M03 S1200
N0020 T0202
N0030 G00 X115 Z0
N0040 G71 U0.5 R1
50 G71 P60 Q110 U0.5 W0.5 F100
N0060 G01X15 Z0
N0070 G01 Z-30
N0080 G03 X30 Z-50 R5
N0090 G01 X30 Z-75
N0100 G01 X80 Z-95
N0110 G01 Z-145
0120 G00 X100 Z100
0130 G70 P70 Q110 F20
N0140 G00 X100 Z100
N0150 M05
12/03/23 34
N0160 M30
Example 7 Part Program for GSK Lathe Machine
N0010 M03 S900
N0020 M06 T0404
N0030 G00 X30 Z0
N0040 G71 U0.5 R1
N0050 G71 P60 Q110 U0.5 W0.5 F100 M08
N0060 G00 X20 Z0
N0070 G01 Z-15
N0080 G02 X25 Z-25 R15
N0090 G01 Z-40
N0100 G03 X30 Z-50 R15
N0110 G01 Z-70
N0120 G00 X50 Z100
N0130 G70 P70 Q110 F25
N0130 G00 X50 Z100
N0140 M09
N0150 M05
12/03/23 35
N0160 M30
Example 8 Part Program for GSK 928TC Lathe Machine
N0010 M03 S1200
N0020 M06 T0101
N0030 G00 X60 Z0
N0040 G71 U0.5 R1
N0050 G71 P60 Q100 U0.5 W0.5 F100 M08
N0060 G00 X20 Z1
N0070 G01 Z-10
N0080 G02 X40 Z-20 R10
N0090 G01 Z-30
N0100 G01 X60 Z-50
N0110 G00 X50 Z100
N0130 G70 P70 Q100 F25
N0130 G00 X10 Z100
N0140 M09
N0150 M05
N0160 M30
12/03/23 36
Example 9 Part Program for GSK 928TC Lathe Machine
N0010 M03 S1000
N0020 M06 T0202
N0030 G00 X140 Z0
N0040 G71 U0.5 R1
N0050 G71 P60 Q130 U0.5 W0.5 F100 M08
N0060 G00 X0 40 Z0
N0070 G01 Z-170
N0080 G01 X60 Z-310
N0090 G01 Z-420
N0100 G01 X100 Z-510
N0110 G01 Z-590
N0120 G01 X140 Z-570
N0130 G01 Z-610
N0140 G00 X150 Z100
N0150 G70 P70 Q130 F20
N0160 G00 X200 Z100
N0170 M09
N0180 M05
12/03/23 37
N190 M30
Exercises
1. Write a part program for the following operations given
below using FANUC Lathe Machine.

12/03/23 38
2. Write a part program for the following operation given
below using FANUC Lathe Machine.

12/03/23 39
12/03/23 40
12/03/23 41
Manual part programming methods for CNC milling
Example 1

12/03/23 42
Part Program
N5 G90 G71 G54
N10 T0101 M06
N15 G92 X-100 Y86 Z95
N20 G00 X0 Y0 S2500 M03
N25 Z12.5
N30 G01 Z-12.5 F150
N35 X-20 Y30
N40 G02 X10 Y70 R80
N45 G01 X140 Y60
N50 G02 X150 Y0 R50
N55 G01 X0 Y0
N60 G00 Z12.5
N65 M05
N70 M30

12/03/23 43
CODE EXPLANATION
N5 absolute positioning, metric unit
N10 tool change to T1
N15 define work zero point at A
N20 rapid traverse to A, spindle on (2500 RPM, CW)
N25 rapid plunge to 12.5 mm above Z0
N30 feed to Z-12.5, feed rate 150 MMPM
N35 cut line AB to B
N40 cut arc BC to C
N45 cut line CD to D
N50 cut arc DE to E
N55 cut line EA to A
N60 rapid retract to Z12.5
N65 Program stop
N70 end of program and reset to start

12/03/23 44
Example 2 Milling Part Programming

12/03/23 45
N010 G71 G92 X0 Y0 Z50
N020 G90
N030 T01 S500 M06
N040 G00 Z2.0 M03
N050 G01 Z-5.0 F100
N060 Y80.0 F120
N070 G02 X20.0 Y98.0 R20.0 F100
N080 G01 X98.0
N090 Y20.0
N100 G02 X80.0 Y2.0 R18.0
N110 G01 X18.757
N120 X2.0 Y18.757
N130 Z2.0 M05
N140 X0 Y0 Z50
N150 M30

12/03/23 46
CNC Part Program for Drilling
Example 1 Drilling using canned cycle
Ø10mm X 4 holes

12/03/23 47
Example 2 Drilling Using canned cycle
Ø10mm X 3 holes N5 T0202 M06
N10 M03 S1500
N15 G00 X25.0 Y35.0 Z2.0
N20 G01 Z-15.0 F125
N25 G00 Z2.0
N30 X55.0 Y50.0
N35 G01 Z-15.0 F125
N40 G00 Z2.0
N45 X75.0 Y70.0
N50 G01 Z-15.0 F125
N55 G00 Z2.0
N60 X0.0 Y0.0 Z50.0
N65 G81 X25.0 Y35.0 Z-15.0 R5.0
F125
N70 X55.0 Y50.0
N75 X75.0 Y70.0
N80 G80 X0.0 Y0.0 Z50.0
12/03/23 N85 M05 48
N90 M30
Exercises on Milling & Drilling
1.Write a part program for the figure given below

12/03/23 49
2.Write a part program for the figure given below

12/03/23 50
N5 G54 G21 G90 G17 G98;
N10 S450 M03 F250 T01; (12.5 mm Dia)
N15 G00 X-20 Y-20 Z50;
N20 Z5;
N25 G01 Z0;
N30 Z-5;
N35 G42 X0 Y0 M08; (Liner motion)
N40 X60 Y0; (Liner motion)
N45 X85 Y30; (Liner motion)
N50 Y50; (Liner motion)
N55 G03 X70 Y65 R15; (Circular motion G03 for Counter Clockwise motion)
N60 G01 X45 Y65; (Liner motion)
N65 G02 X30 Y50 R15; (Circular motion G02 for Clockwise motion)
N70 G01 X10 Y50; (Liner motion)
N75 X0 Y0; (Liner motion)
N80 G40 X-20 Y-20;
N85 G00 Z50 M09;
N90 Y100;
N95 M30;

12/03/23 51
3.Write a part program for the figure given below

12/03/23 52
12/03/23 53
Advanced part programming
Computer Aided Part Programming:
NC program preparation may be tedious and
difficult if the part to be machined has a complex
geometry.
The main difficulty is to find out the cutter locations
during the machining. Computers may be used to
assist the programmers in preparing the NC codes.

12/03/23 54
Advantages of applying computer-aided part
programming include the following:
It reduces the manual calculations involves in
determining the geometric characteristics of the part.
It provides the cutter path simulation.
It provides tool collision checking.
It shortens the program preparation time.
It makes the program preparation easier.

12/03/23 55
CAD/CAM Based Part Programming
The output of any CAD package include the
geometric data of the part to be machined.
Therefore, many CAD/CAM package can produce
cutter location (CL) data to be used for NC code
generation.
There is still to be a process planning module for a
workable NC code generation.
Some of the CAD/CAM packages that have the NC
code generation capabilities are Computer vision,
CATIA, Solid work, CAD, Master CAM, Pro
Engineer,
12/03/23
Mechanical Desktop (Auto Desk). 56

You might also like