You are on page 1of 54

Programming concepts

Programming concepts
For Sinumerik turn controls Steps involved in programming
Develop the part drawing. Decide which machine will produce the part. Choose the tooling required. Decide the machining sequence. List co-ordinates required for programming. Decide the cutting parameters based on the tooling and part material. Estimate the time required for manufacturing a part. Write the NC program. Prepare the setup sheet and tool list. Send the program to the machine. Verify the programs syntax through a dry run and make necessary changes. Verify the correctness of the tool path and make necessary changes. Run the program.

NC codes
A CNC program consists of a number of lines, called blocks. Each block contains a number of commands. G01 X100.0 Z50.0 F0.2 is a block. A block consists of a set of words. Each word is a command. G95 is a word. A word consists of an alphabet called the address, followed by a number. In G95, G is an address. The most commonly used words in a program are called G-codes and M-codes. They use the addresses G and M respectively. G-codes Preparatory functions which involve tool motions like rapid motions, feed motions, circular motions, dwells, and canned cycle codes. M-codes Miscellaneous functions which involve machine actions, like spindle on and off, tool change, coolant on off, program stops.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Addresses used in a program


N G M X Z I K R S F T Block number - specifies the star of the block Preparatory functions Miscellaneous functions X-axis co-ordinate Z-axis co-ordinate X-axis location of arc center Z-axis location of arc center Radius of arc center Spindle speed or Cutting speed Feed rate Tool to be used

Examples of block formats


Rapid traverse block N10 G00 X100. Z100.
End point of the motion Command for rapid traverse motion Block number

Feed traverse (linear interpolation) block N100 G01 X150. Z50. F0.3 Circular motion block N200 G02 X200. Z100. I50. K50. F0.3
Feed rate 0.3 mm/rev.

X and Z co-ordinates of arc center point

Restrictions on block format


Each may contain only one tool move. Each may contain any number of non-tool move G-codes, provided they do not conflict with each other (for example, G02 and G03, which are circular interpolation CW and CCW respectively) Each may contain only one feed rate. Each may contain only one tool command Each may contain only one spindle speed.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Phases of a CNC program


There are 4 major phases in a CNC program 1. 2. 3. 4. Program start Tool change Material removal Program end

The following program shows the phases.


%MPF2121 G71 G95

Program start Contains program start flag, program number, inch metric code and feed rate mode etc. Tool change Contains tool number, tool change code and the spindle speed / cutting speed with spindle direction

N1 G00 X300. Z200. (EXTERNAL TURN) T1 D1 (PCLNL 2020 K09 R 0.8) G92 S3000 G96 S139 M04

( CONTOUR TURN ) G00 X100. Z7. M08 X74. F0.3 R20=1 R21=22. R22=7. R24=0.5 R25=0.3 R26=2. R29=31 L95 G00 X100. M05

Material removal This phase contains commands for rapid, linear and circular motions, canned cycles and other functions required to cut the part

N2 G00 X300. Z200. (DRILLING) T2 D2 (TWIST DRILL DIA. 14.0) G97 S796 M03

Tool change

( DRILLING ) G00 X0. Z7. G01 Z-14.206 F0.2 G00 Z10. M05

Material removal

Program end
N4 X300. Z200. X300. Z200. M30

This phase contains G and M codes which turn off all the functions and get the machine ready for the next part cycle

L0001 N1 G01 X22. Z5. N2 Z0. N3 X30. Z-4. N4 Z-35. N5 X60. Z-50. N6 X70. X74. Z-50. M17 %

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Program Zero
Program zero allows the programmer to specify a position from which to start or to work. Once program zero is defined, all co-ordinates that go into a program will be referenced from this point.
60 35 7 25 5

135 deg. 30 deg. 25 60

C4

M30 x 3P

Program zero

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Canned cycles
Canned, or fixed program, cycles are programming aids that simplify programming. Canned cycles combine many programming operations and are designed to shorten the program length, minimize mathematical calculations, and use minimal tool motions. Examples of canned cycles are facing, contour turning, grooving and threading.
60 35 7 25 Raw material blank size : Dia 70 X 70L 135 deg. 30 deg. 25 60 C4 Operations : 1. Facing 2. Contour turning 3. Threading 5

M30 x 3P

Example program with cycles


%MPF2223 G71 G95 N1 G00 X300. Z200. (EXTERNAL TURN) T1 D1 (PCLNL 2020 K09 R 0.8) G92 S3000 G96 S139 M04 ( PLAIN FACE ) G00 X100. Z7. M08 X74. F0.3 R20=1 R21=-2. R22=7. R24=0. R25=0.5 R26=2. R29=32 L95 G00 X100. ( CONTOUR TURN ) G00 Z2.5 X74. F0.3 R20=2 R21=22. R22=2.5 R24=0.5 R25=0.3 R26=2. R29=31 L95 G00 X100. M05 N2 X300. Z200. N3 G00 X300. Z200. (EXTERNAL THREAD) T2 D3 (THREAD 16 X 16, 60, DEPTH 3.0, RH) G97 S764 M03 (THREADING)

X34. Z0.857 R20=3. R21=30. R22=-0. R23=2 R24=-2. R25=0. R26=0 R27=0 R28=15 R29=30. R31=30. R32=35. L97 P1 X100. M05 N4 X300. Z200. X300. Z200. M30 L0001 N1 G01 X-2. Z5. N2 Z0. N3 X70. X74. Z0. M17 L0002 N4 G01 X22. Z0.5 N5 Z0. N6 X30. Z-4. N7 Z-35. N8 X60. Z-50. N9 X70. X74. Z-50. M17 %

G00 X100. Z0. M08

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Same example without cycles


%MPF2223 G71 G95 N1 G00 X300. Z200. (EXTERNAL TURN) T1 D1 (PCLNL 2020 K09 R 0.8) G92 S3000 G96 S139 M04 N40 (PLAIN FACE) N45 G0 X80. Z7. M07 N50 X74. N55 Z2. N60 G01 X-2. F0.31 N65 G0 X-1. Z2.5 N70 X74. N75 Z0. N80 G01 X-2. N85 G0 X-1. Z0.5 N90 X80. N95 (CONTOUR TURN) N100 G0 Z2. N105 X74. N110 X64. N115 G01 Z-60. N120 G0 X65. Z-59.5 N125 Z2. N130 X58. N135 G01 Z-48.769 N140 G0 X59. Z-48.269 N145 Z2. N150 X52. N155 G01 Z-45.769 N160 G0 X53. Z-45.269 N165 Z2. N170 X46. N175 G01 Z-42.769 N180 G0 X47. Z-42.269 N185 Z2. N190 X40. N195 G01 Z-39.769 N200 G0 X41. Z-39.269 N205 Z2. N210 X34. N215 G01 Z-36.769 N220 G0 X35. Z-36.269 N225 Z2. N230 X28. N235 G01 Z-2.769

N240 G0 X29. Z-2.269 N245 Z2. N250 X22.931 N255 G01 Z0. N260 Z-0.234 N265 X31. Z-4.269 N270 Z-25.6 N275 Z-32.6 N280 Z-35.269 N285 X61. Z-50.269 N290 Z-60. N295 X70. N300 G0 X74. N305 X80. N310 (OPERATION END) N315 M09 N320 M05 N325 G28 U0 W0 N330 M01 N335 (EXTERNAL GROOVE 2) N340 T0202 (OG1616LH2W) N345 G50 S3000 N350 G96 S120 M04 N355 (EXTERNAL GROOVE) N360 G0 X80. Z-31.9 M07 N365 X35.2 N370 G01 X30. F0.12 N375 X25.2 N380 Z-31.157 N385 X27.229 Z-29.4 N390 G0 X35.2 N395 Z-26.9 N400 G01 X30.115 N405 X27.229 Z-29.4 N410 G0 X35.2 N415 X80. N420 (OPERATION END) N425 M09 N430 M05 N440 M01 N445 (EXTERNAL THREAD 3) N450 T0303 (OT2020LH) N455 G97 S1167 M04 N460 (THREADING) N465 G0 X80. Z1. M07 N470 X34. N475 Z1.897 N480 G01 X29.106 F3.

N485 G32 Z-28. K3. N490 G0 X34. N495 Z1. N500 Z1.79 N505 G01 X28.735 N510 G32 Z-28. K3. N515 G0 X34. N520 Z1. N525 Z1.707 N530 G01 X28.451 N535 G32 Z-28. K3. N540 G0 X34. N545 Z1. N550 Z1.638 N555 G01 X28.211 N560 G32 Z-28. K3. N565 G0 X34. N570 Z1. N575 Z1.577 N580 G01 X28. N585 G32 Z-28. K3. N590 G0 X34. N595 Z1. N600 Z1.522 N605 G01 X27.809 N610 G32 Z-28. K3. N615 G0 X34. N620 Z1. N625 Z1.472 N630 G01 X27.634 N635 G32 Z-28. K3. N640 G0 X34. N645 Z1. N650 Z1.424 N655 G01 X27.47 N660 G32 Z-28. K3. N665 G0 X34. N670 Z1. N675 Z1.38 N680 G01 X27.317 N685 G32 Z-28. K3. N690 G0 X34. N695 Z1. N700 Z1.338 N705 G01 X27.172 N710 G32 Z-28. K3. N715 G0 X34. N720 Z1. N725 Z1.298 N730 G01 X27.034 N735 G32 Z-28. K3. N740 G0 X34. N745 Z1. N750 Z1.26 N755 G01 X26.902 N760 G32 Z-28. K3.

N765 G0 X34. N770 Z1. N775 Z1.224 N780 G01 X26.775 N785 G32 Z-28. K3. N790 G0 X34. N795 Z1. N800 Z1.189 N805 G01 X26.653 N810 G32 Z-28. K3. N815 G0 X34. N820 Z1. N825 Z1.155 N830 G01 X26.536 N835 G32 Z-28. K3. N840 G0 X34. N845 Z1. N850 Z1.122 N855 G01 X26.422 N860 G32 Z-28. K3. N865 G0 X34. N870 Z1. N875 Z1.09 N880 G01 X26.312 N885 G32 Z-28. K3. N890 G0 X34. N895 Z1. N900 Z1.059 N905 G01 X26.205 N910 G32 Z-28. K3. N915 G0 X34. N920 Z1. N925 Z1.029 N930 G01 X26.101 N935 G32 Z-28. K3. N940 G0 X34. N945 Z1. N950 G01 X26. N955 G32 Z-28. K3. N960 G0 X34. N965 Z1. N970 G01 X26. N975 G32 Z-28. K3. N980 G0 X34. N985 Z1. N990 G01 X26. N995 G32 Z-28. K3. N1000 G0 X34. N1005 X80. N1010 (OPERATION END) N1015 M09 N1020 M05 N1030 M30 %

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Subprograms
When a program contains certain fixed sequences or frequently repeated patterns , these sequences may be entered into memory as subprograms to simplify programming. A subprogram can call another subprogram. When the main program calls a subprogram, it is regarded as a one loop subprogram call. When the subprogram in turn calls another subprogram, it is the second loop and so on.

Sub program call format


LXXX PXX
Number of times the subprogram is to be repeated Sub program number

Example of application
Multiple grooves on OD using a subprogram
5 typ. 15 typ. 10

80

100

95

Example of program with sub program


Main program
%2121 N5 G71 N10 G0 X300. Z200 N15 G95 N20 (EXTERNAL GROOVE 1) N25 T0101 (OG2020LH6W) N30 G92 S3000 N35 G96 S175 M04 N40 (EXTERNAL GROOVE) N45 G0 X110. Z-6.5 M07 N50 L100 P4 N55 X104. N60 M09 N65 M05 N70 G0 X300. Z200. N75 M30

Sub program
%SPF100 N5 G91 Z-14. N10 G90 G01 X80. F0.12 N15 G0 X104. N20 G91 Z-4.5 N25 G90 G01 X100. N30 X80. N35 G91 Z4.5 N40 G90 G0 X104. N45 G91 Z4.5 N50 G90 G01 X100. N55 X80. N60 G91 Z-4.5 N70 G90 G0 X104. N75 X110. N80 M17

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Same example without subprogram


%2121 N5 G71 N10 G0 X300. Z200. N15 G95 N20 (EXTERNAL GROOVE 1) N25 T01 D1 (OG2020LH6W) N30 G92 S3000 N35 G96 S175 M04 N40 (EXTERNAL GROOVE-1) N45 G0 X104. Z-20.2 M07 N50 G01 X80. F0.12 N55 G0 X104. N60 Z-25. N65 G01 X100. N70 X80. N75 Z-20.5 N80 G0 X104. N85 Z-16. N90 G01 X100. N95 X80. N100 Z-20.5 N105 G0 X104. N110 (EXTERNAL GROOVE-2) N115 G0 Z-40.2 N120 G01 X80. N125 G0 X104. N130 Z-45. N135 G01 X100. N140 X80. N145 Z-40.5 N150 G0 X104. N155 Z-36. N160 G01 X100. N165 X80.

N170 Z-40.5 N175 G0 X104. N180 (EXTERNAL GROOVE-3) N185 G0 Z-60.2 N190 G01 X80. N195 G0 X104. N200 Z-65. N205 G01 X100. N210 X80. N215 Z-60.5 N220 G0 X104. N225 Z-56. N230 G01 X100. N235 X80. N240 Z-60.5 N245 G0 X104. N250 (EXTERNAL GROOVE-4) N255 G0 Z-80.2 N260 G01 X80. N265 G0 X104. N270 Z-85. N275 G01 X100. N280 X80. N285 Z-80.5 N290 G0 X104. N295 Z-76. N300 G01 X100. N305 X80. N310 Z-80.5 N315 G0 X104. N320 (OPERATION END) N325 X110. M09 N330 M05 N335 G0 G28 U0 W0 N340 M30 %

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Programming
For the Sinumerik 810T controller

Axes convention

X Axis

Z Axis

Absolute and Incremental co-ordinates


In the absolute programming, the end point of a motion is programmed with reference to the program zero point. In incremental programming, the end point is specified with reference to the current tool position. X
N2

50

20

N1

0,0

30

Z 50

Absolute traverse to N1, then to N2 G90 X20.0 Z50.0 X50.0 Z30.0 Absolute traverse to N1, incremental to N2 G90 X20.0 Z50.0 G91 X15.0 Z-20.0

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

10

List of G-codes
G-code G00 G01 G02 G03 G04 G70 G71 G32 / G33 G40 G41 G42 G53 G54 G55 G56 G57 G90 G91 G94 G95 G96 G97 Function Positioning rapid traverse Linear interpolation (feed) Circular interpolation CW Circular interpolation CCW Dwell Inch unit Metric unit Thread cutting (single motion) Tool nose radius compensation cancel Tool nose radius compensation left Tool nose radius compensation right Machine co-ordinate system Work co-ordinate system 1 selection Work co-ordinate system 2 selection Work co-ordinate system 3 selection Work co-ordinate system 4 selection

Absolute command Incremental command


Feed per minute Feed per revolution Constant surface speed control Constant surface speed control cancel

List of M codes
M codes vary from machine to machine depending on the functions available on it and the manufacturer of the machine decides them. The M codes listed below are the common ones.
M-codes M00 M01 M02 M03 M04 M05 M06 M07 M08 M09 M30 M17 Function Optional program stop automatic Optional program stop request Program end Spindle ON clock wise (CW) Spindle ON counter clock wise (CCW) Spindle stop Tool change Mist coolant ON (coolant 1 ON) Flood coolant ON (coolant 2 ON) Coolant OFF End of program, Reset to start Sub program end

There are other M-codes for functions like gear change, tail stock quill in/out, chuck clamp/unclamp, chip conveyor forward/backward, door open / close etc.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

11

G00 Rapid traverse


When the tool being positioned at a point preparatory to a cutting motion, to save time it is moved along a straight line at Rapid traverse, at a fixed traverse rate which is pre-programmed into the machine's control system. Typical rapid traverse rates are 10 to 25 m /min., but can be as high as 80 m/min. Format N_ G00 X_ Z_

Rapid traverse

G01 Linear interpolation (feed traverse)


The tool moves along a straight line in one or two axis simultaneously at a programmed linear speed, the feed rate. Format N__ G01 X__ Z__ F__

Feed motion

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

12

G02/03 Circular interpolation

CW arc

CCW arc

Format
N__ G02/03 X__ Z__ I__ K__ F__ OR N__ G02/03 X__ Z__ R__ F__ G02 moves along a CW arc G03 moves along a CCW arc using the arc center using the arc radius

Arc center
The arc center is specified by addresses I and K. I and K are the X and Z co-ordinates of the arc center with reference to the arc start point.
Arc start Arc end -K -I Arc center

Z I = X coord. of center - X coord. of start point K = Z coord. of center - Z coord. of start point I and K must be written with their signs.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

13

Arc radius
The radius is specified with address R.

Arc end

Arc radius

Arc start

Arc center

Z N__ G02 X__ Z__ B__ F__ N__ G03 X__ Z__ B__ F__ If the radius is used, only arcs of less than 180 deg. can be programmed in a block. An arc with included angle greater than 180 deg. must be specified in two blocks.

Tool nose radius compensation


G40 G41 G42 Tool nose radius compensation Cancel Tool nose radius compensation Left Tool nose radius compensation Right

Right side G42 Left side G41

Right side G42 Left side G41

X axis

Z axis

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

14

Theoretical tool tip (TTT)


The Theoretical Tool Tip is the point on the tool that is used as the reference point for determining tool offsets. When a motion is commanded, the TTT point on the tool moves to the commanded point. The path of the TTT point (point A in the figure) normally will not match with the co-ordinates in the program. To get an accurate contour during machining, the TTT point must move in such a manner that the nose radius is tangential to the contour.

Effect of tool nose radius on the part


1. If tool nose radius compensation is not used for motion from P2 to P3, material is left out as shown in the figure.

2.

If tool nose radius compensation is not used for the motion from P1 to P2, excess cutting occurs as shown in the figure

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

15

Thread cutting motion G32

G32

Thread cutting is done by moving the tool along the thread repeatedly at different depths tiil the final thread profile is formed. Each cut must start at the same angular position on the part. The spindle has an encoder, which generates a pulse at exactly the same angular position in every revolution. When a threading motion is programmed, the linear motion of the tool starts when this pulse is detected. This ensures that every cut starts at the same angular position. Thread cutting must be done at constant spindle speed. Block format N__ G32 X__ Z__ F__ X, Z are the end point of the thread and F is the pitch of the thread. The controller calculates feed rate through the following relationship Feed rate = Pitch x Spindle speed Each threading cut involves 4 motions: 1 threading motion and 3 rapid traverse motions. Since a thread normally requires multiple cuts, G32 results in a long program and is not normally used. The G76 canned cycle is normally used for threading.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

16

Canned cycles
A Canned cycle is a single block command, which replaces a series of repetitive motions of the tool. A cycle eliminates tedious calculations, which may otherwise be required for programming certain complex operations. For example, to turn the part shown in fig. 3.10 from a cylindrical blank, a series of roughing cuts would first have to be performed to obtain the rough shape of the part, with a finishing allowance so as to leave some material for the final finish cut. A finish cut would then have to be performed to obtain the final par dimensions. Each of the roughing cuts involves calculation of the destination co-ordinate till which the tool should move along the axis. This can be an extremely lenthy process and the resulting program would be very long. With a canned cycle the same of operations can be programmed in a fraction of the time that would otherwise have been required.

Rough turning cycle L95


The L95 cycle turns a part with a specified contour from a blank. The depth of out, finishing allowance, etc., are specified in the cycle block in the main program and the part contour is specified in a subroutine.
R25 C 45*1mm

B R26

R24 A R21/22

The format of the cycle block is: R20=. . R21=. . R22=. . R24=. . R25=. . R26=. . L95

R 20 is the subroutine number in which the contour is specified R 21 is the X co-ordinate of the starting point of the contour R 22 is the Z co-ordinate of the starting point of the contour R 24 is the finishing allowance in X R 25 is the finishing allowance in Z R 26 is the depth of roughing cut R 29 is the type of machining operation required (R 29 = 31) R 24 and R 25 are incremental values. R 24 should be entered as the radius value.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

17

Thread cutting cycle L97


This cycle enables external and internal threads to be cut with multiple passes: The format of the cycle block is:
R20 D R21*R31 M60*2 C R27 A R26 B R29

R32

R22

R 20=. .

R 21=. .

R 22=. .

R 24=. .

R 25=. .

R 32=. .

L 97

R 20: Thread lead R 21: X co-ordinate of starting point of thread R 22: Z co-ordinate of starting point of thread R 24: Depth of thread, incremental. Enter + for internal thread, - For male thread. R 25: Finishing allowance R 28: Number of cuts R 32: Z co-ordinate of end point of thread The controller uses the thread depth and number of cuts to determine the depth of cut for each pass. The depth of cut calculated is such that the cross sectional area of cut is the same for every cut. This ensures that the cutting force is constant for all the cuts.

Peck drilling cycles L 98


The peck drilling cycle enables deep holes to be drilled in a sequence of short pecks, which help in efficient chip breaking and removal. The drill is held in the tool holder for axial tools.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

18

AR22

R26

A R25 R25-R24 R25-2*R24 R25-3*R24 R25-4*R24

The sequence of tool motions is as follows: 1. Rapid to the Z co-ordinate of the starting position at the current X co-ordinate. 2. Feed in Z direction by the peck depth distance 3. Dwell for chip breaking 4. Rapid in +Z direction to start position 5. Dwell for chip removal 6. Rapid in Z direction 7. Repeat steps 2 to 6 till the final drill depth is reached 8. Rapid to the start position Format (fig. 3.14): R 22=. . R 24=. . R 27=. . R 28=. . L 98

R 22: Z co-ordinate of starting point (absolute) R 24: Peck depth (incremental, without sign) R 26: Final drilling depth (absolute) R 27: Dwell at starting point for chip removal, seconds R 28: Dwell at drilling depth for chip breaking, seconds

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

19

Verifying NC programs
Safety priorities
Safety priorities must be followed when verifying programs. Operator safety - priority 1 Safety of the person operating the machine Machine tool safety - priority 2 Prevention of damage to the machine Workpiece safety - priority 3 Prevention of part rejection

Typical errors
Syntax errors This prevents the machine controller from executing a command. E.g., writing G101 instead of G01 Motion errors Machine does not generate an error, so these are difficult to diagnose. E.g., Writing X instead of Z; wrong co-ordinates; reversing CW and CCW commands; improper incremental/absolute mode selection. Omission errors Omitting decimal points, forgetting to program feed rates, forgetting to turn on the coolant Setup errors Wrongly measured work offset and tool offsets, or correct measurement and wrong entry

Program verification procedures


A new program is checked by executing it in some or all of the verification modes. Dry run with Machine lock Used for checking syntax errors. Motion errors are not checked. Set Machine lock ON and Dry run ON. Set feed rate override switch to maximum to execute the cycle fast. The spindle rotates, the turret indexes and the display changes as per program, but axes do not move. Tool and work offsets need not be set.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

20

Dry run with air cutting Used for checking motion errors and correctness of spindle direction. Since execution is at dry run feed, difference between rapid and feed motions is not known. Collisions cannot be checked. Set the tool offsets. Set the work offset so that all motions occur away from work holding devices like the chuck.. Do not load a part. Set Machine lock OFF and Dry run ON. All machine functions and motions are active. Set feed rate override switch to minimum for safety. Normal cycle with air cutting Used for checking collisions. Set the tool offsets. Set the work offset so that all motions occur away from work holding devices like the chuck.. Do not load a part. Set all functions for normal machine execution. For safety, when in doubt set the feed rate override switch to minimum. Carefully watch for motions, which result in tool colliding with the part or work holding device. Single block execution Used for checking motion errors and part dimensional accuracy. Set the work offset normally, and load a part. Set the tool offsets to leave excess stock on the part. Set all functions for normal machine execution. For safety, when in doubt set the feed rate override switch to minimum. Check the Distance to go value to detect potential motion errors. Check all dimensions. For critical dimensions alter the tool offsets and rerun the tool again to check whether the dimension is within tolerance. Repeat till tolerance is achieved.

Cadem Technologies Pvt. Ltd.

Lathe Programming

Programming concepts

Programming concepts
For Fanuc mill controls
Steps involved in programming
Develop the part drawing. Decide which machine will produce the part. Select the tooling required. Decide the machining sequence. List co-ordinates required for programming. Decide the cutting parameters based on the tooling and part material. Estimate the time required for manufacturing a part. Write the NC program. Prepare the setup sheet and tool list. Send the program to the machine. Verify the programs syntax through dry run and make necessary changes. Verify the correctness of the tool path and make necessary changes. Machine the part or parts.

NC codes
A CNC program consists of a number of lines, called blocks. Each block contains a number of commands. G01 X100.0 Y100.0 F0.2 is a block. A block consists of a set of words. Each word is a command. G01 is a word. A word consists of an alphabet called the address, followed by a number. In G01, G is an address. The most commonly used words in a program are called G-codes and M-codes. They use the addresses G and M respectively. G-codes Preparatory functions which involve tool motions like rapid motions, feed motions, circular motions, dwells, and canned cycle codes. M-codes Miscellaneous functions which involve machine actions, like spindle on and off, tool change, coolant on off, program stops.

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

Addresses used in a program


N G M X Y Z I J K R S F T Block number - specifies the star of the block Preparatory functions Miscellaneous functions X-axis co-ordinate Y-axis co-ordinate Z-axis co-ordinate X-axis location of arc center Y-axis location of arc center Z-axis location of arc center Radius of arc center Spindle speed Feed rate Tool to be used

Examples of block formats


Rapid traverse block N10 G00 X100. Y100.
End point of the motion Command for rapid traverse motion Block number

Feed traverse (linear interpolation) block N100 G01 X150. Y50. F0.3 Circular motion block N200 G02 X200. Y100. I0. J-100. F0.3
Feed rate 0.3 mm/rev.

X and Z co-ordinates of arc center point

Restrictions on block format


Each may contain only one tool move. Each may contain any number of non-tool move G-codes, provided they do not conflict with each other (for example, G02 and G03, which are circular interpolation CW and CCW respectively) Each may contain only one feed rate. Each may contain only one tool command Each may contain only one spindle speed.

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

Phases of a CNC program


1. 2. 3. 4. Program start Tool change Material removal (cutting) Program end The following program shows the phases.
% O2121

Program start Contains program start characters, program number Tool change Contains motion to tool change position, tool number, tool change command

N5 G80 G40 G0 G91 G28 Z0 N10 G28 X0 Y0 N15 T1 M6 (FMC-63-C) N20 T2 N25 G90 G54 G00 X91.5 Y21.1 S757 M03 N30 G43 H1 Z100. N35 Z5. (FACE MILLING) N40 G01 Z0. F2000. N45 X-50. F378.9 N50 Y-21.1 N55 X50. N60 G00 Z5. N65 Z100. N70 M09 N75 G80 G0 G91 G28 Z0 M05 N80 G28 X0 Y0 N85 T2 M06 ( DRILL DIA 10.5) N90 G90 G54 X30. Y0. S818 M03 N95 G43 H2 Z100. N100 Z3. (DRILLING) N105 G98 G81 R3. Z-28.155 F122.8 N110 X15. Y25.981 N115 X-15. N120 X-30. Y0. N125 X-15. Y-25.981 N130 X15. N135 G80 G00 Z3. N140 M9 N145 G0 G91 G28 Z0 M5 N150 G28 X0 Y0 N155 M30 %

Material removal Contains commands for rapid, linear and circular motions, canned cycles and other functions required to cut the part

Tool change

Material removal

Program end

Contains G and M codes which turn off all the functions and get the machine ready for the next part cycle

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

Program Zero
The Program zero is a point on the part or fixture with reference to which all coordinates in the program are specified.

280 10 220

180 120 200

100 40 10 M6 x 1P on 140 PCD 40 150 300

Program zero

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

Canned cycles
Canned or fixed cycles are programming aids that simplify programming. Canned cycles combine many programming operations and are designed to shorten the program length, minimize mathematical calculations, and use minimal tool motions. Examples : drilling, peck drilling, tapping, boring, back spot facing.

280 10 220

Dia 17 x 4 No.

Dia 160

Dia 80 200 120 180 100 40 10 M6 x 1P on 140 PCD 40 150 300

Program zero

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

Program with canned cycles


% O2323 N5 G80 G40 G0 G91 G28 Z0 N10 G28 X0 Y0 ( M10 TAPPING) N245 G98 G84 R-17. Z-40. F716.197 N250 X150. Y170. N255 X80. Y100. N260 X150. Y30. N265 G80 G00 Z5. N270 G0 Z150. M9 N275 G80 G0 G91 G28 Z0 M05 N280 G28 X0 Y0

N15 M6 T1 (CENTER DRILL)


N20 G90 G54 G00 X40. Y40. S1212 M03 N25 G43 H1 Z100. N30 Z3. ( CENTERING BOLT HOLE) N35 G98 G81 R3. Z-7.819 F145.5 N40 X260. N45 Y160. N50 X40. N55 G80 G00 Z3. N60 G00 X220. Y100. ( CENTERING M10 TAP) N65 G98 G81 R-17. Z-25.819 F145.5 N70 X150. Y170. N75 X80. Y100. N80 X150. Y30. N85 G80 G00 Z3. N90 G0 Z150. M9 N95 G80 G0 G91 G28 Z0 M05 N100 G28 X0 Y0

N285 M06 T5 (79 ROUGH BORE)


N290 G90 G54 X150. Y100. S483 M03 N295 G43 H5 Z100. N300 Z3. ( DIA 79 ROUGH BORE) N305 G98 G85 R3. Z-40. F96.7 N310 G80 G00 Z3. N315 G0 Z150. M9 N320 G80 G0 G91 G28 Z0 M05 N325 G28 X0 Y0

N330 M06 T6 ( 80 FINISH BORE)


N335 G90 G54 X150. Y100. S517 N340 G43 H6 Z100. N345 Z3. ( DIA 80 FINISH BORE) N350 G98 G76 R3. Z-42. Q0.1 F51.7 P2000 N355 G80 G00 Z3. N360 G0 Z150. M9 N365 G0 G91 G28 Z0 M5 N370 G28 X0 Y0 N375 M30 %

N105 M06 T2 (DIA 17 DRILL)


N110 G90 G54 X40. Y40. S748 M03 N115 G43 H2 Z100. N120 Z20. (DRILL DIA 17 BOLT HOLE) N125 G98 G81 R3. Z-35.107 F112.3 N130 X260. N135 Y160. N140 X40. N145 G80 G00 Z20. N150 G0 Z150. M9 N155 G80 G0 G91 G28 Z0 M05 N160 G28 X0 Y0

N165 M06 T3 (DRILL DIA 8.5)


N170 G90 G54 X220. Y100. S1310 M03 N175 G43 H3 Z100. N180 Z5. (PRE DRILL FOR M10) N185 G98 G83 R-17. Z-57.554 Q12. F157.3 N190 X150. Y170. N195 X80. Y100. N200 X150. Y30. N205 G80 G00 Z5. N210 G0 Z150. M9 N215 G80 G0 G91 G28 Z0 M05 N220 G28 X0 Y0

N225 M06 T4 (M10 TAP)


N230 G90 G54 X220. Y100. S477 M03 N235 G43 H4 Z100. N240 Z5.

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

Program without canned cycles


% O2424 N5 G80 G40 G0 G91 G28 Z0 N10 G28 X0 Y0 N270 G00 Z20. N275 X40. N280 Z3. N285 G01 Z-35.107 N290 G00 Z20. N295 G0 Z150. M9 N300 G80 G0 G91 G28 Z0 M05 N305 G28 X0 Y0

N15 M6 T1 (CENTER DRILL)


N20 G90 G54 G00 X40. Y40. S1212 M03 N25 G43 H1 Z100. N30 Z3. N35 ( CENTERING BOLT HOLE) N40 G01 Z-7.819 F145.5 N45 G00 Z3. N50 X260. N55 G01 Z-7.819 N60 G00 Z3. N65 Y160. N70 G01 Z-7.819 N75 G00 Z3. N80 X40. N85 G01 Z-7.819 N90 G00 Z3. N95 X220. Y100. N100 ( CENTERING M10 TAP) N105 G00 Z-17. N110 G01 Z-25.819 N115 G00 Z3. N120 X150. Y170. N125 Z-17. N130 G01 Z-25.819 N135 G00 Z3. N140 X80. Y100. N145 Z-17. N150 G01 Z-25.819 N155 G00 Z3. N160 X150. Y30. N165 Z-17. N170 G01 Z-25.819 N175 G00 Z3. N180 G0 Z150. M9 N185 G80 G0 G91 G28 Z0 M05 N190 G28 X0 Y0

N310 M06 T3 (DRILL DIA 8.5)


N315 G90 G54 X220. Y100. S1310 M03 N320 G43 H3 Z100. N325 Z5. N330 ( PRE DRILL FOR M10) N335 G00 Z-17. N340 G01 Z-32. F157.3 N345 G00 Z-31.5 N350 G01 Z-42.8 N355 G00 Z-42.3 N360 G01 Z-52.4 N365 G00 Z-51.9 N370 G01 Z-57.554 N375 G00 Z5. N380 X150. Y170. N385 Z-17. N390 G01 Z-32. N395 G00 Z-31.5 N400 G01 Z-42.8 N405 G00 Z-42.3 N410 G01 Z-52.4 N415 G00 Z-51.9 N420 G01 Z-57.554 N425 G00 Z5. N430 X80. Y100. N435 Z-17. N440 G01 Z-32. N445 G00 Z-31.5 N450 G01 Z-42.8 N455 G00 Z-42.3 N460 G01 Z-52.4 N465 G00 Z-51.9 N470 G01 Z-57.554 N475 G00 Z5. N480 X150. Y30. N485 Z-17. N490 G01 Z-32. N495 G00 Z-31.5 N500 G01 Z-42.8 N505 G00 Z-42.3 N510 G01 Z-52.4 N515 G00 Z-51.9 N520 G01 Z-57.554 N525 G00 Z5. N530 G0 Z150. M9 N535 G80 G0 G91 G28 Z0 M05 N540 G28 X0 Y0

N195 M06 T2 (DIA 17 DRILL)


N200 G90 G54 X40. Y40. S748 M03 N205 G43 H2 Z100. N210 Z20. N215 ( DRILL DIA 17 BOLT HOLE) N220 G00 Z3. N225 G01 Z-35.107 F112.3 N230 G00 Z20. N235 X260. N240 Z3. N245 G01 Z-35.107 N250 G00 Z20. N255 Y160. N260 Z3. N265 G01 Z-35.107

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

N545 M06 T4 (M10 TAP)


N550 G90 G54 X220. Y100. S477 M03 N555 G43 H4 Z100. N560 Z5. N565 ( M10 TAPPING) N570 G00 Z-17. N575 G01 Z-40. F716.2 N580 M04 N585 Z-17. N590 G00 Z5. N595 X150. Y170. N600 Z-17. N605 M03 N610 G01 Z-40. N615 M04 N620 Z-17. N625 G00 Z5. N630 X80. Y100. N635 Z-17. N640 M03 N645 G01 Z-40. N650 M04 N655 Z-17. N660 G00 Z5. N665 X150. Y30. N670 Z-17. N675 M03 N680 G01 Z-40. N685 M04 N690 Z-17.

N695 G00 Z5. N700 G0 Z150. M9 N705 G80 G0 G91 G28 Z0 M05 N710 G28 X0 Y0

N720 M06 T5 (79 ROUGH BORE)


N720 G90 G54 X150. Y100. S483 M03 N725 G43 H5 Z100. N730 Z3. N735 ( DIA 79 ROUGH BORE) N740 G01 Z-40. F96.7 N745 Z3. N750 G0 Z150. M9 N755 G80 G0 G91 G28 Z0 M05 N760 G28 X0 Y0

N770 M06 T6 ( 80 FINISH BORE)


N770 G90 G54 X150. Y100. S517 N775 G43 H6 Z100. N780 Z3. N785 ( DIA 80 FINISH BORE) N790 G01 Z-42. F51.7 N795 M19 N800 G00 X150.5 Y100.5 N805 Z3. N810 X150. Y100. N815 G0 Z150. M9 N820 G0 G91 G28 Z0 M5 N825 G28 X0 Y0 N830 M30 %

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

Subprograms
When a program contains sequences of tool motions which are repeated frequently, these sequences may be entered into memory as subprograms to simplify programming. A subprogram can call another subprogram. When the main program calls a subprogram, it is regarded as a one loop subprogram call. When the subprogram in turn calls another subprogram, it is the second loop and so on. Main program
O2121

Sub program
O1000

Sub program
O2000

Sub program
O3000

Sub program
O4000

M98 P00101000

M98 P00102000

M98 P00103000

M98 P00104000

M98 P00105000

M30

M99 1- loop nesting

M99 2- loop nesting

M99 3- loop nesting

M99 4- loop nesting

Sub program call format


M98 PXXXX XXXX
Sub program number Number of times the subprogram is to be repeated

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

10

Example of application
Face milling and pocket milling Program zero

Dia 100

120

150

30 50

Main program
% O2121 N5 G80 G40 G0 G91 G28 Z0 N10 G28 Y0 X0 N15 M6 T1 (DIA 63 FACE MILL CUTTER) N20 G90 G54 G00 X41.5 Y-18.9 S757 M03 N25 G43 H1 Z100. N30 Z13. N35 (RECTANGULAR FACE MILL)

Sub programs
% O99 N5 G91 G01 Z-5. F2000. N10 G90 X-150. F378.9 N15 Y-69.3 N20 X0. N25 Y-101.1 N30 X-150. N35 G91 G00 Z3. N40 G90 X41.5 Y-18.9 N45 M99 % % O100 N5 G91 G01 Z-6. F2000. N10 G90 X-67. F382. N15 G03 X-83. I-8. J0. N20 X-51. I16. J0. N25 X-99. I-24. J0. N30 X-35. I32. J0. N35 X-115. I-40. J0. N40 X-35. I40. J0. N45 G91 G00 Z3. N50 G90 X-75. N55 M99 %

N40 M98 P00050099


N45 Z100. N50 G80 G0 G91 G28 Z0 M05 N55 G28 Y0 X0 N60 M01 N65 M6 T2 N70 G90 G54 X-75. Y-60. S1273 M03 N75 G43 H2 Z100. N80 Z3. N85 (CIRCULAR POCKET MILL)

N90 M98 P00100100


N95 Z100. N100 G0 G91 G28 Z0 M5 N105 G28 X0 Y0 N110 M30 %

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

11

Example of program with sub program


% O2222 N5 G80 G40 G0 G91 G28 Z0 N10 G28 Y0 X0 N15 M6 T1 (DIA 63 FACE MILL CUTTER) N20 G90 G54 G00 X41.5 Y-18.9 S757 M03 N25 G43 H1 Z100. N30 Z13. N35 ( RECTANGULAR FACE MILL) N40 G91 G01 Z-5. F2000. N45 G90 X-150. F378.9 N50 Y-69.3 N55 X0. N60 Y-101.1 N65 X-150. N70 G91 G00 Z3. N75 G90 X41.5 Y-18.9 N80 G91 G01 Z-5. F2000. N85 G90 X-150. F378.9 N90 Y-69.3 N95 X0. N100 Y-101.1 N105 X-150. N110 G91 G00 Z3. N115 G90 X41.5 Y-18.9 N120 G91 G01 Z-5. F2000. N125 G90 X-150. F378.9 N130 Y-69.3 N135 X0. N140 Y-101.1 N145 X-150. N150 G91 G00 Z3. N155 G90 X41.5 Y-18.9 N160 G91 G01 Z-5. F2000. N165 G90 X-150. F378.9 N170 Y-69.3 N175 X0. N180 Y-101.1 N185 X-150. N190 G91 G00 Z3. N195 G90 X41.5 Y-18.9 N200 G91 G01 Z-5. F2000. N205 G90 X-150. F378.9 N210 Y-69.3 N215 X0. N220 Y-101.1 N225 X-150. N230 G91 G00 Z3. N235 G90 X41.5 Y-18.9 N240 Z100. N245 G80 G0 G91 G28 Z0 M05 N250 G28 Y0 X0 N255 M01 N260 M6 T2 (DIA 20 END MILL) N265 G90 G54 X-75. Y-60. S1273 M03 N270 G43 H2 Z100. N275 Z3. N280 ( CIRCULAR POCKET MILL) N285 G91 G01 Z-6. F200. N290 G90 X-67. F382. N295 G03 X-83. I-8. J0. N300 X-51. I16. J0. N305 X-99. I-24. J0. N310 X-35. I32. J0. N315 X-115. I-40. J0. N320 X-35. I40. J0. N325 G91 G00 Z3. N330 G90 X-75. N335 G91 G01 Z-6. F200. N340 G90 X-67. F382. N345 G03 X-83. I-8. J0. N350 X-51. I16. J0. N355 X-99. I-24. J0. N360 X-35. I32. J0. N365 X-115. I-40. J0. N370 X-35. I40. J0. N375 G91 G00 Z3. N380 G90 X-75. N385 G91 G01 Z-6. F200. N390 G90 X-67. F382. N395 G03 X-83. I-8. J0. N400 X-51. I16. J0. N405 X-99. I-24. J0. N410 X-35. I32. J0. N415 X-115. I-40. J0. N420 X-35. I40. J0. N425 G91 G00 Z3. N430 G90 X-75. N435 G91 G01 Z-6. F200. N440 G90 X-67. F382. N445 G03 X-83. I-8. J0. N450 X-51. I16. J0. N455 X-99. I-24. J0. N460 X-35. I32. J0. N465 X-115. I-40. J0. N470 X-35. I40. J0. N475 G91 G00 Z3. N480 G90 X-75.

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

12

N485 G91 G01 Z-6. F200. N490 G90 X-67. F382. N495 G03 X-83. I-8. J0. N500 X-51. I16. J0. N505 X-99. I-24. J0. N510 X-35. I32. J0. N515 X-115. I-40. J0. N520 X-35. I40. J0. N525 G91 G00 Z3. N530 G90 X-75. N535 G91 G01 Z-6. F200. N540 G90 X-67. F382. N545 G03 X-83. I-8. J0. N550 X-51. I16. J0. N555 X-99. I-24. J0. N560 X-35. I32. J0. N565 X-115. I-40. J0. N570 X-35. I40. J0. N575 G91 G00 Z3. N580 G90 X-75. N585 G91 G01 Z-6. F200. N590 G90 X-67. F382. N595 G03 X-83. I-8. J0. N600 X-51. I16. J0. N605 X-99. I-24. J0. N610 X-35. I32. J0. N615 X-115. I-40. J0. N620 X-35. I40. J0. N625 G91 G00 Z3. N630 G90 X-75. N635 G91 G01 Z-6. F200. N640 G90 X-67. F382. N645 G03 X-83. I-8. J0.

N650 X-51. I16. J0. N655 X-99. I-24. J0. N660 X-35. I32. J0. N665 X-115. I-40. J0. N670 X-35. I40. J0. N675 G91 G00 Z3. N680 G90 X-75. N685 G91 G01 Z-6. F200. N690 G90 X-67. F382. N695 G03 X-83. I-8. J0. N700 X-51. I16. J0. N705 X-99. I-24. J0. N710 X-35. I32. J0. N715 X-115. I-40. J0. N720 X-35. I40. J0. N725 G91 G00 Z3. N730 G90 X-75. N735 G91 G01 Z-6. F200. N740 G90 X-67. F382. N745 G03 X-83. I-8. J0. N750 X-51. I16. J0. N755 X-99. I-24. J0. N760 X-35. I32. J0. N765 X-115. I-40. J0. N770 X-35. I40. J0. N775 G91 G00 Z3. N780 G90 X-75. N785 Z3. N790 Z100. N795 G0 G91 G28 Z0 M5 N800 G28 X0 Y0 N805 M30 %

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

13

Programming
For the Fanuc 0M controller

Axes convention
The tool can be moved to any position in a 3 dimensional cartesian co-ordinate system. The Z axis is along the spindle axis. The X and Y axes are perpendicular to Z.

VMC (Vertical Machining Center)

+ Z + X + -Y -Z -X +X +Z +Y

Y -

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

14

HMC (Horizontal Machining Center)

+ Y X + Z +

Part X

Machine table

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

15

List of G-codes
G-code G00 G01 G02 G03 G04 G20 G21 G28 G30 G40 G41 G42 G43 G52 G54 G55 G56 G57 G58 G59 G74 G76 G80 G81 G82 G83 G84 G85 G86 G87 G90 G91 G94 G95 G98 G99 Function Positioning rapid traverse Linear interpolation (feed) Circular interpolation CW Circular interpolation CCW Dwell Inch unit Metric unit Automatic zero return 2nd reference point return Tool nose radius compensation cancel Tool nose radius compensation left Tool nose radius compensation right Tool length compensation Local co-ordinate system Work co-ordinate system 1 selection Work co-ordinate system 2 selection Work co-ordinate system 3 selection Work co-ordinate system 4 selection Work co-ordinate system 5 selection Work co-ordinate system 6 selection Left hand tapping cycle Fine boring cycle Canned cycle cancel Drilling cycle Drilling cycle with dwell Peck drilling cycle / deep drill Tapping cycle Boring / Reaming cycle Boring cycle Back boring cycle

Absolute command Incremental command


Feed per minute Feed per revolution Return to initial point in canned cycle Return to R point in canned cycle

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

16

List of M codes
M codes vary from machine to machine depending on the functions available on it. They are decided by the manufacturer of the machine. The M codes listed below are the common ones.
M-codes M00 M01 M02 M03 M04 M05 M06 M07 M08 M09 M19 M30 M98 M99 Function Optional program stop automatic Optional program stop request Program end Spindle ON clock wise (CW) Spindle ON counter clock wise (CCW) Spindle stop Tool change Mist coolant ON (coolant 1 ON) Flood coolant ON (coolant 2 ON) Coolant OFF Spindle orientation End of program, Reset to start Sub program call Sub program end

There are other M-codes for functions like gear change, pallet change, pallet clamp / unclamp, door open / close etc.

Absolute and Incremental co-ordinates


In the absolute programming , the end point of a motion is programmed with reference to the program zero point. In incremental programming, the end point is specified with reference to the current tool position. Y
N2

50

20

N1

0,0 Absolute traverse to N1, then to N2 G90 X20.0 Z50.0 X50.0 Z30.0

X 30 50

Absolute traverse to N1, incremental to N2 G90 X20.0 Z50.0 G91 X-20. Y30

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

17

G00 Rapid traverse


When the tool being positioned at a point preparatory to a cutting motion, to save time it is moved along a straight line at Rapid traverse, at a fixed traverse rate which is pre-programmed into the machine's control system. Typical rapid traverse rates are 10 to 25 m /min., but can be as high as 80 m/min. Format N_ G00 X__ Y__Z__

G01 Linear interpolation (feed traverse)


The tool moves along a straight line in one or two axis simultaneously at a programmed linear speed, the feed rate. Format N__ G01 X__ Y__Z__ F__

Feed

Feed

Part Part

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

18

G02/03 Circular interpolation

Format
N__ G02/03 X__ Y__Z__ I__ J__K__ F__ OR N__ G02/03 X__ Y__Z__ R__ F__ G02 moves along a CW arc G03 moves along a CCW arc using the arc center using the arc radius

Arc center
The arc center is specified by addresses I, J and K. I, J and K are the X, Y and Z co-ordinates of the arc center with reference to the arc start point.
Arc start Arc end -I -J Arc center

X I = X coord. of center - X coord. of start point J = Y coord. of center - Y coord. of start point K = Z coord. of center - Z coord. of start point I, J and K must be written with their signs.

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

19

Arc radius
The radius is specified with address R.
Arc start

Arc end

Arc radius

Arc center

Block format
N__ G02 X__Y__ Z__ R__ F__ N__ G03 X__Y__ Z__ R__ F__

Cutter radius compensation (CRC)


G40 G41 G42 Tool nose radius compensation Cancel Tool nose radius compensation Left Tool nose radius compensation Right

G41

G41

G42

G42

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

20

Block format
N__ G01 G41/42 X__ Y__ D__ F__ Feed rate mm/min CRC offset number CRC start co-ordinates absolute CRC command code Linear interpolation command code

Necessity of using CRC


Difficult to calculate cutter center co-ordinates If cutter center co-ordinates are used Same diameter of cutter is required to be used Cutter wear can not compensated

Program Zero

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

21

Tool length compensation (G43)


Different tools of different lengths are used in machining any part. The lengths of the tools are not considered in the part program. They are entered in the machines memory, and are considered automatically for each motion in the program depending on the tool that is being used. The tool lengths in the Z direction are called the Tool length offsets.

Gauge line

Length offset Length offset

Length offset

Length offset

Face milling cutter

T-slot milling cutter

Boring tool

Back boring tool

Part

Setting work co-ordinate system (G54 - G59)


G54 G55 G56 G57 G58 G59
Work co-ordinate system 1 selection Work co-ordinate system 2 selection Work co-ordinate system 3 selection Work co-ordinate system 4 selection Work co-ordinate system 5 selection Work co-ordinate system 6 selection

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

22

Work co-ordinate system 3 selection Work co-ordinate system 1 selection

Work co-ordinate system 2 selection

Machine table

Work co-ordinate system 4 selection

Work co-ordinate system 6 selection Work co-ordinate system 5 selection

Canned cycles
Canned or fixed cycles are programming aids that simplify programming. Canned cycles combine many programming operations and are designed to shorten the program length, minimize mathematical calculations, and use minimal tool motions. Examples : drilling, peck drilling, tapping, boring, back spot facing.

G81 G82 G83 G84 G85 G86 G87 G74 G76

Drilling cycle Drilling cycle with dwell (Counter bore cycle) Peck drilling cycle / deep drill Right hand tapping cycle Boring / Reaming cycle Boring cycle Back boring cycle Left hand tapping cycle Fine boring cycle

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

23

Drilling cycle (G81)


With G98 return to initial point Initial point Rapid Feed With G99 return to R point Rapid Feed

R point / Safe height

R point / Safe height

Format
N__ G98/99 G81 R__ Z__ F__ Infeed feed rate mm/min Final depth Safe height / R point Drilling cycle code Return position code Block number

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

24

Counter bore cycle (G82)


With G98 return to initial point Initial point Rapid Feed With G99 return to R point Rapid Feed

R point / Safe height

R point / Safe height

Dwell at bottom

Dwell at bottom

Format
N__ G98/99 G82 R__ Z__ P__ F__ Infeed feed rate mm/min Dwell at bottom Final depth Safe height / R point Counter bore drilling cycle code Return position code Block number

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

25

Peck drill cycle (G83)


With G98 return to initial point Initial point Rapid Feed

Safe height / R point Peck depth

Final depth

With G99 return to R point Initial point Rapid Feed

Safe height / R point Peck depth

Final depth

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

26

Format
N__ G98/99 G83 R__ Z__ Q__ F__ Infeed feed rate mm/min Peck depth Final depth Safe height / R point Peck drilling cycle code Return position code Block number

Tapping cycle (G84)


Right hand tapping With G98 return to initial point Initial point Rapid Feed With G99 return to R point Initial point Rapid Feed

R point / Safe height Spindle CW Retract feed rate equals infeed feed rate Final depth Spindle CCW

R point / Safe height Spindle CW Retract feed rate equals infeed feed rate Final depth Spindle CCW

Feedrate = Spindle RPM x Pitch

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

27

Format
N__ G98/99 G84 R__ Z__ F__ Infeed / retract feed rate mm/min Final depth Safe height / R point Right hand tapping cycle code Return position code Block number

Spindle direction in RH tapping CW during infeed CCW during outfeed

Reaming cycle (G85)


With G98 return to initial point Initial point Rapid Feed With G98 return to R point Initial point Rapid Feed

R point / Safe height

R point / Safe height

Final depth

Final depth

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

28

Format
N__ G98/99 G85 R__ Z__ F__ Infeed / retract feed rate mm/min Final depth Safe height / R point Reaming cycle code Return position code Block number

Boring cycle (G86)


With G98 return to initial point Initial point Rapid Feed With G99 return to R point Rapid Feed

Spindle CW R point / Safe height

Spindle CW R point / Safe height

Final depth

Final depth

Spindle stop

Spindle stop

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

29

Format
N__ G98/99 G86 R__ Z__ F__ Infeed feed rate mm/min Final depth Safe height / R point Boring cycle code Return position code Block number

Back boring cycle (G87)

Initial point Bore axis

Spindle orientation

Lateral shift

Final depth Spindle CW Safe height / R point

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

30

Format
N__ G98 G87 R__ Z__ Q__ F__ Infeed feed rate mm/min Lateral shift Final depth Safe height / R point Back boring cycle code Return position code Block number

Tapping cycle (G74)


Left hand tapping With G98 return initial point Initial point Rapid Feed With G99 return R point Initial point Rapid Feed

R point / Safe height Spindle CCW Retract feed rate equals infeed feed rate Final depth Spindle CW

R point / Safe height Spindle CCW Retract feed rate equals infeed feed rate Final depth Spindle CW

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

31

Feedrate = Spindle RPM x Pitch

Format
N__ G98/99 G74 R__ Z__ F__ Infeed / retract feed rate mm/min Final depth Safe height / R point Left hand tapping cycle code Return position code Block number

Spindle direction in LH tapping CCW during infeed CW during outfeed

Fine boring cycle (G76)


With G98 return to initial point Initial point Rapid Feed With G99 return to R point Initial point Rapid Feed

Lateral shift

Lateral shift

Spindle CW R point / Safe height

Spindle CW R point / Safe height

Final depth Dwell at bottom Lateral shift Spindle Orientation Dwell at bottom

Final depth

Lateral shift Spindle Orientation

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

32

Format
N__ G98 G76 R__ Z__ Q__ F__ Infeed feed rate mm/min Lateral shift Final depth Safe height / R point Fine boring cycle code Return position code Block number

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

33

Verifying NC programs
Safety priorities
Safety priorities must be followed when verifying programs. Operator safety - priority 1 Safety of the person operating the machine Machine tool safety - priority 2 Prevention of damage to the machine Workpiece safety - priority 3 Prevention of part rejection

Typical errors
Syntax errors Errors which prevent the machine controller from executing a command. E.g., writing G101 instead of G01 Motion errors Machine does not generate an error, so these are difficult to diagnose. E.g., Writing X instead of Z; wrong co-ordinates; reversing CW and CCW commands; improper incremental/absolute mode selection. Omission errors Omitting decimal points, forgetting to program feed rates, forgetting to turn on the coolant Setup errors Wrongly measured work offset and tool offsets, or correct measurement and wrong entry

Program verification procedures


A new program is checked by executing it in some or all of the verification modes. Dry run with Machine lock Used for checking syntax errors. Motion errors are not checked. Set Machine lock ON and Dry run ON. Set feed rate override switch to maximum to execute the cycle fast. The spindle rotates, the turret indexes and the display changes as per program, but axes do not move.

Cadem Technologies Pvt. Ltd.

Milling Programming

Programming concepts

34

Tool and work offsets need not be set.

Dry run with air cutting Used for checking motion errors and correctness of spindle direction. Since execution is at dry run feed, difference between rapid and feed motions is not known. Collisions cannot be checked. Set the tool offsets. Set the work offset so that all motions occur away from work holding devices like the chuck.. Do not load a part. Set Machine lock OFF and Dry run ON. All machine functions and motions are active. Set feed rate override switch to minimum for safety. Normal cycle with air cutting Used for checking collisions. Set the tool offsets. Set the work offset so that all motions occur away from work holding devices like the chuck.. Do not load a part. Set all functions for normal machine execution. For safety, when in doubt set the feed rate override switch to minimum. Carefully watch for motions which result in tool colliding with the part or work holding device. Single block execution Used for checking motion errors and part dimensional accuracy. Set the work offset normally, and load a part. Set the tool offsets to leave excess stock on the part. Set all functions for normal machine execution. For safety, when in doubt set the feed rate override switch to minimum. Check the Distance to go value to detect potential motion errors. Check all dimensions. For critical dimensions alter the tool offsets and rerun the tool again to check whether the dimension is within tolerance. Repeat till tolerance is achieved.

Cadem Technologies Pvt. Ltd.

Milling Programming

You might also like