5.CNC Part Programming Notes
5.CNC Part Programming Notes
The machine zero is a fixed point set by the machine manufacturer. Usually it cannot be
changed. Any tool movement is measured from this point. The controller always
remembers tool distance from the machine origin.
The position on the machine which is specified by the manufacturer and with respect to
which all other point are defined is called as machine zero.
For Milling
Work piece zero (Program zero)
It is the position of cutting tool on the work piece (with respect to the wok piece).
It can be selected anywhere on the work piece.
Generally it is the left corner near the operator of the work piece in case of milling. In
case of turning, it is in the front face and at the center of the cylindrical work piece (i.e.
extreme right position away from the chuck).
This position is specified by the part programmer and may vary for different program.
The entire program is written with respect to the work piece zero position.
After the work piece mounted on the table, the work piece zero is to be informed to the
controller by setting offset through the control panel.
A Program:
A program consists of a series of blocks and normally contains a complete set of coded
instructions required to completely machine a part or a predetermined portion of a part.
The program contains all the instructions and information necessary for the computer to
command the machine to perform specified functions, ultimately resulting the complete
machining of a part.
Part Programming:
The shape, size and dimensional accuracy of a desired component depends mainly upon
how accurately the program is prepared.
The part program is actually a set of instructions about the processing steps to be
sequentially performed on the workpiece.
The part program is preceded by the design/development procedures viz. designing of the
component, detailed drawing and process planning.
A group of commands given to the CNC for operating the machine is called the program.
It consists of:
1. Information about part geometry
2. Motion statements to move the cutting tool
3. Cutting speed
4. Feed
5. Auxiliary functions such as coolant on and off, spindle direction
Axis Codes: X,Y,Z - Used to specify motion of the slide along X, Y, Z direction
Feed and Speed Codes: F and S- Specify feed and spindle speed
Program Description
N10 G28 U 0.00 W 0.00; Return to machine reference position
N20 G90 G21 G95; Absolute positioning Input in mm, feed mm/rev,
N30 M03 S800 M08; Spindle on clockwise , spindle speed 800 rpm,
Coolant on
N40 G00 X0.00 Z 2.00 Rapid travel at X0 Z 2, (P0)
N50 G01 X0.00 Z0.00 F0.2; Linear interpolation at X0 Z0,feed rate
0.2mm/rev. (P1)
N60 X60.00 Z0.00; Move to X60 Z 0 .(P2)
N70 X80.00 Z -40.00; Move to X80 Z-40. (P3)
N80 X90.00; Move to X90. (P4)
N90 Z -65; Move to Z-50. (P5)
N100 X95; Move to X95. (P6)
N110 G00 G28 U0.00 W0.00; Rapid, return to reference position
N120 M05 M09; Spindle stop, coolant off
N130 M30; Program end
2. Calculate the cutting parameters and prepare process sheet for the component shown in
Fig.No.1 with neat diagram. All the dimensions are in mm.
Given: Raw material - Aluminum, Stock Size – Dia.14 X 42 length, Feed ( f ) = 0.2 mm/rev.,
Cutting Speed (V) = 90 m/min., Consider work zero (W) as per Fig. No. 1.
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
Part Program
3. Prepare a part program to machine the workpiece shown in Fig. on CNC lathe.
Assuming S=1500 rpm and Feed= 0.2 mm /rev
Point X Co- Z Co-
ordinate ordinate
P0 0.00 2.00
P1 0.00 0.00
P2 20 -10
P3 20 -30
P4 30 -50
P5 30 -100
P6 40 -100
Program Description
N10 G28 U 0.00 W 0.00; Return to machine reference position
N20 G90 G21 G95; Absolute positioning, Input in mm, feed mm/rev,
N30 M06 T01: Tool change and tool no 1
N40 M03 S1500 M08; Spindle on clockwise , spindle speed 1500 rpm,
Coolant on
N50 G00 X0.00 Z 2.00; Rapid travel at X0 Z 2, (P0)
N60 G01 X0.00 Z0.00 F0.2; Linear interpolation at X0 Z0,feed rate
0.2mm/rev. (P0 to P1)
N70 G03 X 20 Z-10; Anticlockwise circular interpolation, (P1to P2)
N80 G01 X20 Z-30 ; Linear interpolation (P2 to P3)
N90 G01 X30 Z-50; Linear interpolation (P3 to P4)
N100 G01 X30 Z-100 Linear interpolation (P4 to P5)
N110 G00 X40 Z-100 Rapid interpolation (P5 to P6)
N120 G28 U0.00 W0.00 Return to machine reference position
N130 M05 M09; Spindle off , Coolant off
N140 M30; Program end
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.
Program Description
O 1234 Program Number
N10 G28 U 0.00 V0.00 W 0.00; Return to machine reference position
N20 G90 G21 G94, G40; Absolute positioning, Input in mm, feed
mm/min, cutter diameter compensation
cancel
N30 M06 T01: Tool change and tool no 1
N40 M03 S1200; Spindle on clockwise , spindle speed 1200
rpm
N45 G41 D01; Cutter radius compensation left (G41),
value stored in D01
N50 G00 X-10 Y0 Z 4; Rapid travel of cutter to position 1
N60 G00 X0 Y0; Rapid travel of cutter to position 2
N70 G01 Z -3 M08 F 60; Cutter position (2) moves depth 3 mm in Z,
coolant on, feed 60 mm/min
N80 G01 Y50; Cutter travel at position - 3
N90 G02 X10 Y60 R10 F60; Circular interpolation clockwise, Cutter
travel at position 4
N100 G01 X60 Y60; Cutter travel at position 5
N110 G01 Y10; Cutter travel at position 6
N120 G01 X50 Y0; Cutter travel at position 7
N130 G01 X0 Y0; Cutter travel at position 2
N140 G01 Z 4; Tool moves positive 4 upward
N145 G40; Cutter compensation cancel
N150 G28 U0.00 V 0.00 W0.00; Return to machine reference position
N160 M05 M09; Spindle off , Coolant off
N170 M30; Program end
2) Write CNC programme for milling a component as shown in fig. no. 2 with
end mill of 20 mm diameter, thickness of plate 10 mm, feed 90 mm/min,
spindle rpm 450. Assume suitable data if necessary.
Point X Co- Y Co-
ordinate ordinate
P1 -10 -10
P2 0 0
P3 0 40
P4 40 40
P5 40 80
P6 105 80
P7 120 65
P8 120 15
P9 105 0
Program Description
O 3678 Program Number
N10 G28 U 0.00 V0.00 W 0.00; Return to machine reference position
N20 G90 G21 G94, G40; Absolute positioning, Input in mm, feed
mm/min, cutter diameter compensation
cancel
N30 M06 T01: Tool change and tool no 1
N40 M03 S450; Spindle on clockwise , spindle speed
450rpm
N45 G41 D01; Cutter radius compensation left (G41),
value stored in D01=10 mm
N50 G00 X-10 Y-10 Z 4; Rapid travel of cutter to position 1
N60 G00 X0 Y0; Rapid travel of cutter to position 2
N70 G01 Z -10 M08 F 90; Cutter position (2) moves depth 10 mm in
Z, coolant on, feed 90 mm/min
N80 G01 Y40; Cutter travel at position 3
N90 G01 X40; Cutter travel at position 4
N100 G01 Y80; Cutter travel at position 5
N110 G01 X 105 Y80; Cutter travel at position 6
N120 G02 X120 Y65 R15; Circular interpolation clockwise G02, Cutter
travel at position 7
N130 G01 Y15; Cutter travel at position 8
N140 G02 X105 Y0 R15; Circular interpolation clockwise G02, Cutter
travel at position 9
N150 G01 X0 Y0; Cutter travel at position 2
N160 G01 Z4; Tool moves positive 4 upward
N170 G40; Cutter compensation cancel
N180 G28 U0.00 V 0.00 W0.00; Return to machine reference position
N190 M05 M09; Spindle off , Coolant off
N200 M30; Program end
3) Write a part program to machine the part given in fig in a CNC milling machine.
Assumption-
Program Description
O 9999 Program Number
N10 G28 U 0.00 V0.00 W 0.00; Return to machine reference position
N20 G90 G21 G94, G40; Absolute positioning, Input in mm, feed
mm/min, cutter diameter compensation
cancel
N30 M06 T01: Tool change and tool no 1
N40 M03 S1000; Spindle on clockwise , spindle speed
1000rpm
N50 G41 D01; Cutter radius compensation left (G41),
value stored in D01=3 mm
N60 G00 X0 Y0 Z3; Rapid travel of cutter to position 1
N70 G00 X67.5 Y0 Z3; Cutter position moves at point (2)
N80 G01 Z-3 M08 F400; Cutter position (2) moves depth 3 mm in Z,
coolant on, feed 400 mm/min
N90 G01 Y30; Cutter travel at position 3
N100 G03 X52.5 Y45 R15; G03-Circular interpolation anticlockwise,
Cutter travel at position 4
N110 G01 X 0 Y45; Cutter travel at position 5
N120 G01 Y60 ; Cutter travel at position 6
N130 G01 X82.5 ; Cutter travel at position 7
N140 G01 Y0; Cutter travel at position 8
N150 G01 X67.5; Cutter travel at position 2
N160 G01 Z 3; Tool moves positive 4 upward
N170 G40; Cutter compensation cancel
N180 G28 U0.00 V 0.00 W0.00; Return to machine reference position
N190 M05 M09; Spindle off , Coolant off
N200 M30; Program end
1. Canned cycle-
When the same operation has to be repeated for number of times then the program
becomes lengthy, time consuming, tedious and uses more computer memory space.
All these factor are eliminated by the use of canned cycle.
Canned cycle written in the main program, but it reduces the length of program.
The canned cycle may be defined as a set of instruction stored in the memory of the
system, to perform a fixed sequence of operations.
Canned cycle is used for repetitively and common used machining operations. And it is
stored under the G code.
It s used for repetitive operation where material is to be cut in multiple passes.
It reduces the length of program and its complexity,
Canned cycles should be cancelled after their use by using G80.
G81- For Drilling Cycle
G71- stock removal in turning
G78-Threading cycle
G85-Boring cycle.
2. Subroutine (Subprogram)-
When the identical machining operation is to be performed repeatedly then the general
methods of program will be lengthy, time consuming, tedious and uses more computer
memory space.
In such case subroutine is a powerful time saving technique.
The subprogram is stored at the end of main program and can be called at any time and
for any number of times during the execution of main program.
In order to call the subroutine in the main program, the miscellaneous code M98 is used
and the block of instruction is as shown below:-
N35 M98 P95 L1;
M98-instucts the controller to jump to subroutine
P95- tells the controller that 95 (example) is the program number
L1 instructs the controller to execute the subroutine one time.
In order to end the subroutine and return back to the main program a miscellaneous code
M99 is used.
3.Do -loops
(BEGIN LOOP)
N211 M30;
4. Macros-
Use of Macro
• Trigonometric calculations
• Logical operations
Example-1
Example-2
Where-
G43-Positive tool length compensation/offset
G44-Negative tool length compensation/offset
G49- Tool length compensation/offset Cancel
H_-Tool length offset number.
Tool radius compensation is a function of the CNC controller to automatically shift the
tool from cutter center line to the cutter edge along the programmed cutter path.
A part program is developed for the exact size of the cutter to be used on machine.
But during actual machining, if a smaller diameter cutter is selected, it will result in a
larger workpiece. Similarly a larger diameter cutter will result smaller workpiece.
It is therefore necessary to compensate for the different diameter cutter by using cutter
radius compensation.
Compensation is done by offsetting the tool path by the distance equal to the radius of the
cutter.
This value is entered into the memory of the control system under the address of D01,
D02 etc.
Format- G41 X__Y___D___;
G42 X__Y___D___;