4. CNC Part Programming
4. CNC Part Programming
Programming
1
Introduction
A part program is a sequential list of machining
instructions for the CNC machine to execute.
These instructions are CNC code that contains all the
information required to machine a part, as specified by the
programmer.
CNC code consists of blocks (also called lines), each of
which contains an individual command for a movement or
specific action.
CNC codes are listed sequentially in numbered blocks.
Each movement is made before the next one.
2
Part Programming Steps
3
Introduction
There are many methods to compose a program by using ISO
codes. The most common one is the ISO standardized word and
address format. It divides the whole program into a number of
blocks, and alphabets are used to represent different words within
the blocks. The lengths of the block and word depend on the
needs of the design.
4
Part Programming
The common letters used in part programming are as follows:
6
List of G & M codes commonly
found on FANUC
https://en.wikipedia.org/wiki/G-code
w
7
8
Part Programming
Table 2 and 3 shows some common G and M codes that are used
in CNC machines.
10
11
12
(I, J)
13
Three Major Phases of A CNC Program
The following shows the three major phases of a CNC program.
%
: 1001
N5 G90 G20
N10 M06 T2 Program set up
N15 M03 S1200
N20 G00 X1.00 Y1.00
N25 Z0.1
N30 G01 Z-0.125 F5.0
N35 G01 X2.0 Y2.0 Material processing
N40 G00 Z1.0
N45 X0 Y0
N50 M05
N55 M30 System shutdown
https://ncviewer.com
14
Three Major Phases of A CNC Program
1. Program Setup
The program setup contains all the instructions that prepare the machine for
operation.
% (Program start flag)
: 1001 (Four-digit program number)
N5 G90 G20 (Absolute Positioning defined wrt part zero
and inch programming)
N10 M06 T2 (Stop for tool change, use tool #2)
N15 M03 S1200 (Turn the spindle on with 1200 rpm)
15
Three Major Phases of A CNC Program
2. Material Removal
The material removal phase deals exclusively with the actual cutting feed moves.
N20 G00 X1.0 Y1.0 (Rapid move to (X1, Y1) from origin)
N25 Z0.1 (Rapid down to Z0.1 just above the part)
N30 G01 Z-0.125 F5.0 (Feed down to Z-0.125 at 5 ipm)
N35 X2.0 Y2.0 (Feed diagonally to X2 and Y2)
N40 G00 Z1.0 (Rapid up to Z1 (clear the part)
N45 X0 Y0 (Rapid back home X0 Y0)
3. System shutdown
The system shutdown phase contains the G- and M-codes that turn off all the
options that were turned on in the setup phase.
N50 M05 (Turn the spindle off)
N55 M30 (End of program)
16
NC Program Explanation
https://ncviewer.com/
18
PART PROGRAMMING - VIDEO CLIP
19
Example - 01
20
%
O0001;
N5 G90 G80 G40 G17 G21 G54 G94;
N10 M06 T01;
N15 M03 S2500 F2;
N20 G00 X60 Y0;
N25 Z2;
N30 G01 Z-2;
N35 Y90;
N40 G00 Z100;
N45 G28 X0 Y0 Z0;
N50 M05;
N55 M30; (End of Program)
21
Example - 02
22
%
O0002
N5 G90 G80 G40 G17 G21 G55 G95;
N10 M06 T02;
N15 M03 S2000 F3;
N20 G00 X15 Y20;
N25 Z3;
N30 G01 Z-1;
N35 X115;
N40 X65 Y70;
N45 X15 Y20;
N50 G00 Z100;
N55 G28 X0 Y0 Z0;
N60 M05;
N65 M30; (End of Program) 23
Example - 03
24
%
O0003
N5 G90 G80 G40 G17 G21 G57 G94;
N10 M06 T03;
N15 M03 S1500 F2.5;
N20 G00 X20 Y10;
N25 Z3;
N30 G01 Z-1.5 F100;
N35 G02 X120 Y10 R50;
N40 G00 Z100;
N45 G28 X0 Y0 Z0;
N50 M05;
N60 M30; (End of Program)
25
Example – 04
26
Example – 04 (Solution)
27
Example - 05
28
Example – 05 (Solution)
29
x
Example - 06
z
30
x
Example – 06 (Solution)
z
31
Example – 07
32
Example – 07 (Solution)
33
Example – 08
34
Example – 08 (Solution)
35
Example – 09
36
Example – 09 (Solution)
37
Example – 10
38
Example – 10 (Solution)
39
Compensation Methods in CNC
40
Tool length compensation
41
Target Z position
42
43
Cutter Compensation
44
Cutter Radius Compensation
45
Cutter Radius Compensation
46
Cutter Radius Compensation
Example – 11
Write a manual part program of peripheral milling using end mill D8
47
Cutter Radius Compensation
Example – 11 (Solution)
Write a manual part program of peripheral milling using end mill D8
O 1234
N171 G00 X-15 Y-15 Z50;
N172 G01 Z0;
N172 G41 X0 Y0 F100 D1; (Start-Up Move)
N173 Y40;
N174 X30 Y80;
N175 X60;
N176 G02 X100 Y40 R40;
N177 G01 Y30;
N178 G03 X70 Y0 R30;
N179 G01X0;
N180 G40 X-15 Y-15; (Cancellation Move)
N190 G00 Z50
48
Fixture Offset Compensation
The fixture offset allows the programmer to use the fixture
offset regardless of the position of the workpiece on the
fixture.
49
Fixture Offset Compensation
The fixture offset
can move the
programmed zero
point of the
machine tool on
each workpiece.
50
51
52
53
54
55
56