Unit No 5 CNC Part Programming
Unit No 5 CNC Part Programming
i. Absolute System
In this system the positions are indicated from fixed zero point or reference point. An example of this
type of dimensioning is shown in given figures. In this case the zero or reference point is the left hand
bottom corner of the workpiece and all dimension are given from that point.
A drawback of this system is that if an error creeps in a dimension it continuous to be.
Unit Group
This group of codes specifies the units in which the program is to be interpreted.
G20 In inch units
G21 In mm units
Motion Group
This is the most important group of codes used in part programming.
Dwell G04
This is to give a delay in the program. When the G04 code is encountered the controller stops at
that particular point for specified time mentioned in the block
N045 G04 X3.0 This calls for a stoppage of the control for a period of 3seconds.
CNC Part Programming Format
NC information is generally programmed in blocks of words. Each word conforms to the EIA
standards and they are written on a horizontal line. If five complete words are not included in
each block, the machine control unit (MCU) will not recognize the information; therefore the
control unit will not be activated. It consists of a character N followed by a three digit number
raising from 0 to 999.
M codes in CNC
M codes in CNC are almost the same for turning and milling. M codes are usually used for turning
ON/OFF various processes. The following are the M codes.
` 40 3 28 0 1
4 28 0 -40
5 32 0 -40
6 27 0 1
7 27 0 -40
Part Program
%;
N001 O1234; Program No
N002 G28 U0.0 W0.0; Automatic Return to reference position
N003 G21 G90 G94; Input in mm, Absolute Programming , Feed mm/min
T0101 M08 M03 S800; Tool change, Coolant On, Spindle on CW, Spindle rotate with speed
N004
M06 2016 rpm
%;
N001 O1234; Program No
N002 G28 U0.0 W0.0; Automatic Return to reference position
N003 G21 G90 G94; Input in mm, Absolute Programming , Feed mm/min
T0101 M08 M03 S800; Tool change, Coolant On, Spindle on CW, Spindle rotate with speed
N004
M06; 2016 rpm
%;
N001 O1234;
N002 G28 U0.0 W0.0; Automatic Return to reference position
N003 G21 G90 G98; Input in mm, Absolute Programming , Feed mm/min
Coolant On, , Spindle on CW, Spindle rotate with speed 2016 rpm, Tool
N004 M08 M03 S800 M06T0101;
change
N005 G00 X15 Z1 ;
N006 GOO X15 Z0 ;
N007 G00 X13 ;
N008 G01 X15 Z-30 F0.5 ;
N009 G00 X15 Z1 ;
N010 G00 X11 Z0 ;
N011 G01 X15 Z-30 F0.2 ;
N012 G00 X15 Z1;
N013 G00 X10 Z0 ;
N014 G01 X15 Z-30 F0.2 ;
N015 G28 U0.0 W0.0; Automatic Return to reference position
N016 M09 M05; Coolant Off, Spindle Stop
N017 M02 or M30; End of program
Q. Prepare a part program to machine the workpiece shown in Fig. No. 2 on CNC lathe
(Exam- Summer 2017)
R15
N01 012345;
N13 M30;
Write a part program for job as shown in Fig. No. 1. Take only finish cut. Use, Spindle
speed = 1500 rpm and feed rate = 0.1 mm/rev. Assume suitable data if necessary.
(Exam- Summer 2018)
Solution
X Z
Point
Coordinate Coordinate
P0 00 5
P1 00 0
P2 20 0
P3 40 -10
P4 40 -30
P5 60 -80
P6 60 -120
P7 70 -120
Solution
Point X Coordinate Z Coordinate
P0 00 05
P1 00 00
P2 10 00
P3 50 -20
P4 50 -30
P5 50 -40
P6 50 -80
Solution
Point X Coordinate Z Coordinate
P0 00 05
P1 00 00
P2 30 00
P3 50 -20
P4 50 -70
P5 80 -70
P6 80 -110
P7 82 -110
Solution
Given Data: V = 90 m/min.,
f = 0.2 mm/rev., D = 14 mm,
Depth of cut, dc = 1 mm, Length of Cut, l= 25 mm Cutting Parameters:
Spindle Speed: V = πDN/1000 N = 2043 rpm.
Feed: f = 0.2 mm/rev. Depth of Cut: dc = 1 mm
Point X Coordinate Z Coordinate
P0 00 02
P1 00 00
P2 12 00
P3 12 -25
P4 14 -25
P5 14 -41
P6 20 -41
N10 T0101
N20 G92 S1000 M42 Spindle speed limitation.
N40 G00 X0 Z5
N50 G01 Z0 F0.5 `
N60 G01 X80 F0.2
X : End point of arc in x-axis.
Z : End point of arc in z-axis.
N70 G02 X100 Z-30 I50 K0 I : Distance from arc start point to arc center point in x-axis.
K : Distance from arc start point to arc center point in z-axis.
N80 G01 Z-120
N90 G00 X200 Z200
M30
%;
N001 O1234; Program No
N002 G28 U0.0 W0.0; Automatic Return to reference position
N003 G21 G90 G94; Input in mm, Absolute Programming , Feed mm/min
T0101 M08 M03 S800; Tool change, Coolant On, Spindle on CW, Spindle rotate
N004
M06; with speed 2016 rpm
%
N10 012345 Name of main program.
Absolute co-ordinate system , metric input in 'mm' , feed rate
N20 G90 G21 G99 F0.2 ; per revolution F0.2 .
N110 G01 Z-20 ; Linear interpolation command where X14 and Z-20 .[P3]
Circular interpolation counter clockwise (external radius),
N120 G03 X20 Z-23 R3 ;
where X20 ,Z-23 and R3 .[P4]
N130 G01 Z-33 ; Linear interpolation command where X20 and Z-33 .[P5]
N140 G01 X22 ; Linear interpolation command where X22 and Z-33 .[P6]
N150 G01 Z-48 Linear interpolation command where X22 and Z-48 .[P7]
N160 G01 X25 ; Linear interpolation command where X25 and Z-48 .[P8]
%
N10 012345 Name of main program.
Absolute co-ordinate system , metric input in 'mm' , feed rate
N20 G90 G21 G99 F0.2 ;
per revolution F0.2
N30 M06 T04 04 ; Tool changing command , select tool no 4.
N40 M03 S1200 ; Spindle ON clockwise at speed 1200 rpm.
N50 M08 ; Coolant ON
N60 G28 U0 W0 ; Tool at reference point where U0 and W0
Turning cycle command where depth of cut for X axis is 0.5(total
N70 G71 U0.5 R1 ;
dia reduce each cut is 1) and tool relive distance 1 mm.
Turning cycle command , actual operation start from block no.
N80 G71 P100 Q300 U0.0 W0.0 ; 80 and actual operation end at block no. 150,finishing along X
axis 0 , and finishing along Z axis is 0
N100 G00 X0 Z0 ; Rapid command , where X0 and Z0
G01 X30 Z0 ; Linear interpolation command where X30 and Z0 .
G01 X30 Z-22 ; Linear interpolation command where X30 and Z-22 .
Circular interpolation clockwise command where X40 , Z-27 and
G02 X40 Z-27 R5 F 015 ;
radius 5 .
G01 X55 ; Linear interpolation command where X55 and Z-27 .
Circular interpolation counter clockwise command where X80 ,
G03 X80 Z-57 CR80 ;
Z-57 and radius 80
G01 Z-62 ; Linear interpolation command where X80 and Z-62 ;
N300 G01 X85 ; Linear interpolation command where X85 and Z-62 ;
Finish machining cycle , actual operation start from block no. 80
N90 G70 P100 Q300 F0.05 ; and actual operation end at block no. 150 , feed rate for finishing
cut 0.05
N100 G28 U0 W0 ; Tool at reference point where U0 and W0
N110 M05 M09 M30 ; Spindle stop , coolant off, main prog end .
Part Program for Drilling Operation
Part program for Threading Operation
: M40X2
Major diameter is 40
Pitch is 2
Thread depth calculation = Pitch x 0.61363
= 2 x 0.61363
= 1.227 mm in micron is 1227
Minor diameter = 40-1.23 = 38.7 mm
N60- Rapid action command where X45 and Z5 .
N70- Spindle off , coolant off , main program end .
CNC Part Programming for Milling Operation
1. Prepare a part program for machining
component as shown in Fig. No. 1. Use following
data: cutting speed: 1200 rpm, feed: 60
mm/min, thickness of component 3 mm, Tool
reference position is 4 mm above the surface of
the workpiece. Assume suitable data if any.
Neglect cutter radius compensation
Solution
POSITION X Y Z
Home 0 0 4
PO 0 0 0
P1 0 50 -4
P2 10 60 -4
P3 60 60 -4
P4 60 10 -4
P5 60 0 -4
Solution
POSITION X Y Z
Home 0 0 4
PO 0 0 0 Part Program
P0’ 0 0 -8
N01 G90 G21 G95 G40 G42;
P1 0 50 -8
P2 10 60 -8 N02 G00 X00 Z4;
P3 50 60 -8
P4 60 50 -8 N03 G01 X0 Z0 Y0 F 60;
P5 60 10 -8
P6 50 00 -8 NO4 G01 Z-8;
P7 10 00 -8
P8 00 10 -8 N05 G01 X0 Y50;
Solution
POSITION X Y Z Solution
Home 0 0 4
PO 0 0 0 N01 G90 G21 G94 G40 G41;
P0’ 0 0 -5
P1 16 20 -5 N02 G00 X00 Y00 Z4;
P2 50 80 -5
N03 G01 X16 Y20 Z4 F 80;
P3 84 20 -5
P4 16 20 -5
N04 G01 Z-5
012345
N10 G21 G90 G94
N20 G28 U0W0
N30 M03 S1400 M08
N40 G00 X0 Y0 Z10
N50 G00 X25 Y40
N60 G01 Z-15 F150
N70 Z5 F150
N80 G00 X60 Y55
N90 G01 Z-15 F150
N100 Z5
N110 G00 X80 Y75
N120 G01 Z-15
N130 Z5
N140 G28 U0 W0
N150 M09 M30