CNC Machine Programming Course
CNC Machine Programming Course
PATIALA
1
INDEX
SN Topic Page No.
1 Introduction to NC/CNC machines and Part Programming 03-06
2 Programming Modes 07-09
3 PREPARATORY (G) FUNCTIONS ISO 646 10
4 MISCELLANEOUS (M) FUNCTION ISO 646 11
5 MISCELLANEOUS & CODES & ADDRESSES FOR LATHE MACHINES 12-13
6 SAMPLE PROGRAMS FOR CNC TURNING MACHINES 14-33
2
NC / C N C
Numerical Control (NC) is a method for control of slide motions and auxiliary
motions of machine tools in form of numerical data.
3
Since a single machining center can perform many operations, large floor area
is saved which otherwise would be required to install a number of
conventional machines.
Since the input instruction can be easily modified, design changes in the
products can easily be incorporated. This is very advantageous in prototype
manufacture or in manufacture of similar parts in small batch size.
Operator’s skill is no longer important since the accuracy is dependent on the
program. This reduces scrap and rework.
Sudden change in demand can be easily handled because the system has in
built flexibility.
Work in progress, handling time and errors due to a number of set ups, as in
conventional manufacture, are reduced to a very large extent when machining
centers are used.
Since mostly all conditions are under control, the estimation of costs involved
can be done quite accurately.
NC essentially calls for very high investment. But this should be carefully
considered in the light of numerous advantages and over a period of time.
Special skills in programming and maintenance are essential.
Redundancy in labour may be there. But this again needs careful consideration.
When planning for NC, retraining of staff for newer requirements must be taken
into account.
Down time of NC systems is very expensive, therefore, it is very essential that
that staff is adequately trained in operation and maintenance at the supplier’s
place before the machine is delivered.
Part Programming
The preparation of a set of instructions to carry out the machining of a work piece
is called part programming. This work is carried out by a part programmer. He
prepares the planning sheet and writes the instructions in a coded form which is
acceptable to the controller of machine tool. Part programming is of two types:-
Manual
Computer assisted
In the former, the programmer prepares the program and uses the tele type to
prepare the punched tale version of the program. In the later, the tape is produced
by the computer after it has been fed simple instructions in proper format which
are different from the one used in manual part programming. Various symbols used
in programming are given below.
4
N : Operation sequence number address
B : Preparatory function address
X, Y, Z, A, B, C : Dimension address with axis Identification.
S : Spindle speed address
G : Feed rate address
T : Tool address
M : Miscellaneous function address.
5
Spindle speed (S)
Tool No. (T)
Tool offset function (D)
Miscellaneous functions (M, H etc.)
End of block (EOB).
Block Example
N1234 G.. X.. Y.. S.. M.. F.. T.. D.. LF
The Word Addressed system is method generally use for writing part program for
the numerical control of the wide range of machines. In this system there is an
identifying letter (alpha character) preceding each data? This alpha character in the
world is known as the address, e.g. G2, N2, etc. A control unit recognizes a word
through its address. A number of the word makes up a block and two blocks are
separated by a marker. Generally, the words need not be programmed in a
particular order. Different word may have a different number of digits; some have
only one digits and other may have up to seven digits. Whenever a word represents
machine movement data, a + or a- may be required between the latter and the
number
Example of a Block
N 1234 G-- X--Y-- S-- M-- F-- T-- D-- LF
Block Address
Block numbers
Preparatory functions
Transient information
Spindle speed functions
Miscellaneous functions
Feed functions
Tool functions
Compunction function
End of block
6
Programming Modes
To prepare the manuscript for manual part programming, the programmer needs to
collect some data pertaining to the work to be carried out.
8
G2 X0 Y0 R2.0
G3 X0 Y0 R2.0
Graphical Simulation
It is advisable to verify all programs in memory using the tool path simulation
facility. This will display immediately, any dimensional program errors by
displaying the bar stock being machined step by step on the VDU.
9
COMMON CODES & ADDRESSES
PREPARATORY (G) FUNCTIONS ISO 646
10
MISCELLANEOUS (M) FUNCTION ISO 646
M 00 Program stop
M 01 Intermediate stop
M 02 Program end
M 03 Spindle rotation clock wise
M 04 Spindle rotation counter clock wise
M 05 Spindle off: coolant off
M 06 Tool change
M 07 Coolant No. 1 on (e.g. Mist coolant)
M 08 Coolant No. 2 on (e.g. flood coolant)
M 09 Coolant
M 10 Clamping (e.g. tables, slide, work piece, fixture, spindle etc)
M 11 Clamping released
M12 Free 1)
M 19 Spindle stop in specified angular orientation
M 20-M29 Continuous free 2)
M 30 Program end, stop and return to start character
M 31 Clamping override
M32-M39 Free 1)
M40-M45 Change of gear ratio if this required. Otherwise free 1)
M46-M47 Free 1)
M48 Cancels M 49
M 49 Deletion of manually adjusted feed rate or rotation speed, i.e. return to
programmed values
M50-M57 Free 1)
M 58 Cancels M 59
M 59 Maintains the spindle speed constant even though a G 36 initiated (const.
surface speed)
M 60 Work piece change
11
Lay out of new turning program
1 Part program Program manager—part program---New(File Name)--ok
2 Work piece Select Various – Blank—(Input of work piece) --Accept
3 Starting Program Enter –(Starting Program)
4 Contour cal(Cycle Select Cont. Turn. -Contour –contour cal—(name of sub program)
62) Accept
5 Stock Select Back -Stock Removal (M/C control of program)-Accept
Removal(cycle952)
6 End program Enter-(end program)
7 Sub program E_LAB_A_(Name of sub program): -enter (sub program or turning tool
path from 1st point to end point of job)
8 Numbering Numbering select(10 or 2) OK
9 simulation Reset-simulation-edit
10
Tool offset MDA---MDI, G75x0z0,M06 T01D1 M30–-(Feed 0 check)-cycle start( Go to
home position)--Jog Mode-- measuring tool—manually- touch tool on z
axis- -z 0 –Input --set length-save position-- touch tool on x axis-X25 ( job
diameter)—input-- set length-- save position
11 Execute Select Program –execute–( check feed switch 0 position)-- auto mode -
-cycle start---Feed increase by manually feed switch
JOG Manual machine movement by feed switch in x or z axis with +or- button
MDA Manual machine movement by G or M Code in x or z axis - MDA mode (machine data
input ---MDI, G75x0z0, M30 - cycle start( Go to home position)--
AUTO Program auto start for execute
RESET Machine reset start from beginning
SBK Check program in Single block check
MPG Manual pulls generate MPG-VAR-Select plus co-ordinate-Use hand wheel for x or z axis
WCS Work coordinate system
MCS Machine coordinate system
12
CODES & ADDRESSES FOR LATHE MACHINES
13
Simple Turning (Using turning cycle 952)
Part Description (file name)
MPF/0RST
program
XA 26 Dia of work piece
Work
Cylinder ZA 0 Start- point in z axis
piece
ZL -70 total length of work piece
ZB -40 machining length
2 G71 G95; Metric unit, feed mm/ revolution
4 G75 X0 Z0; Going to home position
6 T1 D1; Tool Change position no.1
8 MO3 S1500; Spindle speed clockwise
10 G00 X26 Z3F.1; Rapid tool movement
12 Contour call ST Sub program call by name
(Cycle 62)
14 Stock PRG OD Removal [Link]
Removal for SC 2.00 Safety distance/clearance
turning (Cycle F .1 Feed mm/revolution
952) Machining ▼+▼▼▼ Roughing & Finishing
FS .01 Finishing feed
Longitudinal Outside For turning outside
D 0.1 Depth of cut
UX .020 Finishing allowance X-axis
UZ .020 Finishing allowance Z-axis
DL 0 Dwell time
BL Cylinder Select Blank( types of job)
XD 26 Datum point X-axis-stock start
ZD 2.0 Datum point Z-axis-stock start
Relief cut NO Machine relief cut
Limit NO Limit machining area
Accept
16 G75 X0 Z0; Going to home position
18 M05; Spindle stop
20 M30 Program stop
22 E_LAB_A_ST: Code (sub prog.+Part prog)
24 G01 X15 Z0 Linear movement
26 G01X15 Z-25 Linear movement
28 G01 X20Z-25 Linear movement
30 G01X20Z-40 Linear movement
32 G01X26Z-40 Linear movement
34 M17 Sub program Exit
14
15
Tapper Turning (Using turning cycle 952)
Part Description (file name)
MPF/0RTT
program
XA 26 Dia of work piece
Work
Cylinder ZA 0 Start- point in z axis
piece
ZL -70 total length of work piece
ZB -40 machining length
2 G71 G95; Metric unit , feed mm/
revolution
4 G75 X0 Z0; Going to home position
6 T1 D1; Tool Change position no.1
8 MO3 S1500; Spindle speed clockwise
10 G00 X26 Z3F.1; Rapid tool movement
12 Contour call TT Sub program call by name
(Cycle 62)
14 Stock PRG OD Removal [Link]
Removal for SC 2.00 Safety distance/clearance
turning F .1 Feed/revolution
(Cycle 952) Machining ▼+▼▼▼ Roughing & Finishing
FS .01 feed mm/ revolution
Longitudinal Outside For turning outside
D 0.1 Depth of cut
UX .020 Finishing allowance X-axis
UZ .020 Finishing allowance Z-axis
DL 0 Dwell time
BL Cylinder Select Blank type(job)
XD 26 Datum point X-axis-stock start
ZD 2.0 Datum point Z-axis-stock start
Relief cut NO Machine relief cut
Limit NO Limit machining area
Accept
16 G75 X0 Z0; Going to home position
18 M05; Spindle stop
20 M30 Program stop
22 E_LAB_A_TT: Code (sub prog.+Part prog)
24 G01 X4 Z0 Linear movement
26 G01X5 Z-1 Linear movement
28 G01 X20 Z-35 Linear movement
30 G01X24 Z-35 Linear movement
32 G01X26 Z-40 Linear movement
34 M17 Sub program Exit
16
17
Radius Turning (Using turning cycle 952)
Part Description (file name)
MPF/0RADIUS
program
XA 26 Dia. of work piece
Work
Cylinder ZA 0 start point in Z axis
piece
ZL -70 total length work piece
ZB -40 machining length
2 G71 G95; Metric unit , feed mm/ revolution
4 G75 X0 Z0; Going to home position
6 T1 D1; Tool Change position no.1
8 MO3 S1500; Spindle speed clockwise
10 G00 X26 Z3F.1; Rapid tool movement
12 Contour call RD Sub program( Name) call
14 Stock PRG OD Removal [Link]
Removal SC 2.00 Safety distance/clearance
for turning F .1 Feed mm/ revolution
(Cycle 952) Machining ▼+▼▼▼ Roughing & Finishing
FS .01 Finishing feed
Longitudinal Outside Machining direction position
D 0.4 Depth of cut
UX .020 Finish allowance X-axis
UZ .020 Finishing allowance Z-axis
DI 0 Continuous cut at θ
BL Cylinder Select Blank type (job)
XD 26 Datum point X-axis-stock start
ZD 2.0 Datum point Z-axis-stock start
Relief cut NO Machine relief cut
Limit NO Limit machining area
Accept
16 G75 X0 Z0; Going to home position
18 M05; Spindle stop
20 M30 Program stop
22 E_LAB_A_RD: Code (sub prog.+Part prog)
24 G01 X6 Z0; Linear movement
26 G03 X16 Z-5 CR=5; Circular Linear movement
28 G01X16 Z-35; Linear movement
30 G02 X26 Z-40 CR=5 Circular Linear movement
32 M17 Sub program Exit
18
19
Multi Turning (Using turning cycle 952)
Part Description(file name)
MPF/0RMT
program
XA 26 Dia of work piece
Work Cylinder
ZA 0 Start- point in Z axis
piece
ZL -70 total length of work piece
ZB -40 machining length
2 G71 G95; Metric unit , feed / revolution
4 G75 X0 Z0; Going to home position
6 T1 D1; Tool Change position no.1
8 MO3 S1500; Spindle speed clockwise
10 G00 X26 Z3F.1; Rapid tool movement
12 Contour call MT Sub program( Name) call
(Cycle 62)
14 Stock PRG OD Removal [Link]
Removal for SC 2.00 Safety distance/clearance
turning F .1 feed mm/ revolution
(Cycle 952) Machining ▼+▼▼▼ Roughing & Finishing
FS .01 Finishing feed
Longitudinal Outside For turning outside
D 0.4 Depth of cut
UX .020 Finish allowance X-axis
UZ .020 Finishing allowance Z-axis
DL 0 Dwell time
BL Cylinder Select Blank type(job)
XD 25 Datum point X-axis-stock start
ZD 2.0 Datum point Z-axis-stock start
Relief cut NO Machine relief cut
Limit NO Limit machining area
Accept
16 G75 X0 Z0; Going to home position
18 M05; Spindle stop
20 M30 Program stop
22 E_LAB_A_MT: Code (sub prog.+Part prog)
24 G01 X16 Z0 Linear movement
26 G01 X17 Z-1 Linear movement
28 G01X17 Z-13 Linear movement
30 G03X21 Z-15 CR=2 Linear movement
32 G01 X25 Z-25 Linear movement
34 G01X26 Z-33 Linear movement
36 M17 Sub program Exit
20
21
Threading External (Using threading cycle 99)
22
23
Grooving (Using grooving cycle 930)
24
25
Multi function turning
Part Description(file name)
MPF/0RMF
program
XA 26 Dia of work piece
Work Cylinder
ZA 0 Start- point in Z axis
piece
ZL -70 total length of work piece
ZB -40 machining length
2 G71 G95; Metric unit , feed / revolution
4 G75 X0 Z0; Going to home position
6 T1 D1; Tool Change position no.1
8 MO3 S2000; Spindle speed clockwise
10 G00 X26 Z3 F.1; Rapid tool movement
12 Contour call MFT Sub program( Name) call
(Cycle 62)
14 Stock PRG OD Removal [Link]
Removal for SC 2.00 Safety distance/clearance
turning(Cycle F .1 feed mm/ revolution
952) Machining ▼+▼▼▼ Roughing & Finishing
FS .01 Finishing feed
Longitudinal Outside For turning outside
D 0.1 Depth of cut
UX .020 Finish allowance X-axis
UZ .020 Finishing allowance Z-axis
DL 0 Dwell time
BL Cylinder Select Blank type(job)
XD 26 Datum point X-axis-stock start
ZD 2.0 Datum point Z-axis-stock start
Relief cut NO Machine relief cut
Limit NO Limit machining area
Accept
16 G75 X0 Z0; Going to home position
18 M05; Spindle stop
20 T7D1 Tool Change position no.2
22 M03 S600 Spindle speed clockwise
24 G00X17.5 Z-13F.1; Rapid tool movement
28 Grooving SC 2.00 Safety distance/clearance
cycle (Cycle F .01 feed mm/ revolution
930) Machining ▼+▼▼▼ Roughing & Finishing
Pos. Position of machining
Reference point
X0 17 Reference point X
Z0 -10 Reference point Z
B1 3 Groove width
T1 10 Un machined up to groove
D .5 Depth of each cut
UX 0.1 Finishing allowance of X-axis
UZ 0.1 Finishing allowance of Z-axis
N 01 No. of groove
Accept
30 G75 X0 Y0 Going to home position
26
32 M05 Spindle stop
34 T5D1 Tool Change position no.3
36 M04 S600 Spindle speed clockwise
38 G00 X17 Z5 Rapid tool movement
40 External Table ISO
Threading select M 10 Select table value
cycle
P 1.5 pitch
(Cycle952)
Machining ▼+▼▼ Roughing & Finishing
▼
Linear
External-thread
X 17 Reference point X for thread
Z 0 Reference point Z for thread
ZI -10 length of thread
LW 2 Thread advance distance
LR 0 Thread run out distance
HI 0.920 Height of thread
αP 30˚ Slope angle of thread
DI 0.1 In feed depth
U 0.01 Finishing allowance
NN 2 No. of idle pass after thread
UR 1 Return safety distance
allowance
Multi-pal No Starting No. of thread
αθ 0.000 Starting angle of thread
Accept
42 G75X0Y0 Going to home position
44 M05 Spindle stop
46 M30 Program stop
22 E_LAB_A_MFT: Code (sub prog.+Part prog)
24 G01 X16 Z0 Linear movement
26 G0X17 Z-1 Linear movement
28 G01X17 Z-13 Linear movement
30 G03X21 Z-15 CR=2 Linear movement
32 G01 X25 Z-25 Linear movement
34 G01X26 Z-33 Linear movement
36 M17 Sub program Exit
27
28
Drilling (Using drilling cycle 83)
Part Function
MPF/ 0R DRILLING
program
XA 32 Dia. of work piece
Work
Cylinder ZA 0 Start- point in Z axis
piece--
ZL -70 total length work piece
ZB -50 machining length
2 G71 G95; Metric Unit , feed / revolution
3 G75 X0 Z0; Going to home position
4 T4 D1; Tool Change position no.1
5 MO3 S1000; Spindle speed clockwise
6 G00 X0 Z5F.1; Rapid tool movement
9 Centering PL G17 XY Machining plane
drill RP 5.00 Retraction plane
(Cycle 81) SC 2.00 Safety distance
Z0 0.0 Reference point Z
1. Shank Select Drilling depth up to shank
2. Tip Drilling depth up to tip
Z1 -2 Length of drilling depth
DT 0.00 Dwell time at final depth
Accept
10 G75 X0 Z0; Going to home position
11 M05; Spindle stop
Going to home position
12
6 T6 D1; Tool Change position no.1
8 MO3 S800; Spindle speed clockwise
10 G00 X0 Z5F.5; Rapid tool movement
Drilling cycle PL G17 XY Machining plane
(Cycle 83) RP 5.00 Retraction plane
SC 2.00 Safety distance/clearance
Chip removal
Z0 0 Reference point Z
Shank select Drilling depth up to shank
Z1 -24 Length of drilling depth
D -1.00 1st drilling depth stroke
12.
D1 50.00% Feed percentage for 1st in feed
DF 100% Percentage for every further in feed
Lead distance Automatically / Manually
DTB 0.00 s Dwell time at drilling depth in
second
DT 0.00 s Dwell time at final depth in second
DTS 0.00 s Dwell time for removing chips in
second
14 G75 X0 Z0; Going to home position
16 M05 Program stop
18 M30
29
30
Drilling Boring
Part Function
progra MPF/0RDB
m
XA 32 Dia. of work piece
Work
Cylinder ZA 0 Start- point in Z axis
piece--
ZL -70 total length work piece
ZB -40 machining length
2 G71 G95; Metric Unit, feed / revolution
3 G75 X0 Z0; Going to home position
4 T4 D1; Tool Change position no.1
5 MO3 S1000; Spindle speed clockwise
6 G00 X0 Z5F.1; Rapid tool movement
9 Centering drill PL G17 XY Machining plane
(Cycle 81) RP 5.00 Retraction plane
SC 2.00 Safety distance/clearance
Z0 0.0 Reference point Z
1. Shank Select Drilling depth related to shaft
2. Tip Drilling depth related to Tip
Z1 -2 Final drilling depth
DT 0.00 Dwell time at final depth
Accept
10 G75 X0 Z0; Going to home position
11 M05; Spindle stop
12 G75 X0 Z0; Going to home position
6 T6 D1; Tool Change position no.1
8 MO3 S800; Spindle speed clockwise
10 G00 X0 Z5F.5; Rapid tool movement
Drilling cycle PL G17 XY Machining plane
(Cycle 83) RP 5.00 Retraction plane
SC 2.00 Safety distance/clearance
Chip removal
Z0 0 Reference point Z
Shank select Drilling depth up to shank
Z1 -24 Length of drilling depth
D -1.00 1st drilling depth stroke
D1 50.00% Feed percentage for 1st in feed
12.
DF 100% Percentage for every further in
feed
Lead distance Automatically / Manually
DTB 0.00 s Dwell time at drilling depth in
second
DT 0.00 s Dwell time at final depth in
second
DTS 0.00 s Dwell time for removing chips in
second
14 G75 X0 Z0; Going to home position
16 M05 Program stop
18 M30
31
20 T2 D1; Tool Change position no.1
22 MO3 S1500; Spindle speed clockwise
24 G00 X0 Z5; Rapid tool movement
Contour call BOR Code name( sub prog.+prog)
26
(Cycle62)
Stock PRG ID Removal [Link]
Removal for
SC 2.00 Safety distance/clearance
boring
F .1 feed mm/ revolution
(Cycle 952)
Machining ▼+▼▼ Roughing & Finishing
▼
FS .01 Finishing feed
Longitudinal Inside
RP 0.5 Retraction plane
28 D 0.1 Depth of cut
UX 0.02 Finishing allowance in X-axis
UZ 0.02 Finishing allowance in Z-axis
DI 0.00 Continuous cut
BL cylinder Select blank (job)
XD 12 Datum point X-axis-stock start
ZD 2.000 Datum point Z-axis-stock start
Relief cut NO Machine relief cut
Limit NO Limit machining area
30 G75 X0 Z0; Going to home position
32 M05; Spindle stop
46 M30 Contour( sub program) Name
48 E_LAB_A_BOR: Code (sub prog.+Part prog)
50 G00 X26 Z0; Rapid movement
52 G02 X22Z-2 CR=2 Linear movement
54 G01X22Z-12 Linear movement
56 G01 X16Z-18; Linear movement
58 G01 X12Z-18 Linear movement
60 M17 Sub program Exit
32
33