NC Programming

54
Programming concepts 1 Cadem Technologies Pvt. Ltd. Lathe Programming 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 program’s 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.

Transcript of NC Programming

Programming concepts 1

Cadem Technologies Pvt. Ltd. Lathe Programming

Programming conceptsFor 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 program’s syntax through a dry run and make necessary changes.• Verify the correctness of the tool path and make necessary changes.• Run the program.

NC codesA 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 Gand M respectively.

G-codesPreparatory functions which involve tool motions like rapid motions, feed motions, circular motions, dwells,and canned cycle codes.

M-codesMiscellaneous functions which involve machine actions, like spindle on and off, tool change, coolant on off,program stops.

Programming concepts 2

Cadem Technologies Pvt. Ltd. Lathe Programming

Addresses used in a program

N Block number - specifies the star of the blockG Preparatory functionsM Miscellaneous functionsX X-axis co-ordinateZ Z-axis co-ordinateI X-axis location of arc centerK Z-axis location of arc centerR Radius of arc centerS Spindle speed or Cutting speedF Feed rateT Tool to be used

Examples of block formats

Rapid traverse blockN10 G00 X100. Z100.

Feed traverse (linear interpolation) blockN100 G01 X150. Z50. F0.3

Circular motion blockN200 G02 X200. Z100. I50. K50. F0.3

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.

Block number

End point of the motion

Command for rapid traverse motion

Feed rate 0.3 mm/rev.

X and Z co-ordinates ofarc center point

Programming concepts 3

Cadem Technologies Pvt. Ltd. Lathe Programming

Phases of a CNC programThere are 4 major phases in a CNC program

1. Program start2. Tool change3. Material removal4. Program end

The following program shows the phases.

%MPF2121G71 G95

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

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

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

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

N4 X300. Z200.X300. Z200.M30

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

Program startContains program start flag, program number,inch metric code and feed rate mode etc.

Tool changeContains tool number, tool change code andthe spindle speed / cutting speed with spindledirection

Material removalThis phase contains commands for rapid,linear and circular motions, canned cyclesand other functions required to cut the part

Tool change

Program endThis phase contains G and M codes which turnoff all the functions and get the machine readyfor the next part cycle

Material removal

Programming concepts 4

Cadem Technologies Pvt. Ltd. Lathe Programming

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

135 deg.

M30 x 3P60

30 deg.

25

60

35

7

5

C4

25

Program zero

Programming concepts 5

Cadem Technologies Pvt. Ltd. Lathe Programming

Canned cyclesCanned, or fixed program, cycles are programming aids that simplify programming. Canned cyclescombine many programming operations and are designed to shorten the program length, minimizemathematical calculations, and use minimal tool motions.Examples of canned cycles are facing, contour turning, grooving and threading.

Raw material blank size :Dia 70 X 70L

Operations :1. Facing2. Contour turning3. Threading

135 deg.

M30 x 3P60

30 deg.

25

60

35

7

5

C4

25

Example program with cycles%MPF2223G71 G95N1 G00 X300. Z200.(EXTERNAL TURN)T1 D1 (PCLNL 2020 K09 R 0.8)G92 S3000G96 S139 M04( PLAIN FACE )G00 X100. Z7. M08X74.F0.3R20=1 R21=-2. R22=7. R24=0. R25=0.5 R26=2. R29=32L95G00 X100.( CONTOUR TURN )G00 Z2.5X74.F0.3R20=2 R21=22. R22=2.5 R24=0.5 R25=0.3 R26=2.R29=31 L95G00 X100.M05N2 X300. Z200.N3 G00 X300. Z200.(EXTERNAL THREAD)T2 D3 (THREAD 16 X 16, 60, DEPTH 3.0, RH)G97 S764 M03(THREADING)

G00 X100. Z0. M08

X34.Z0.857R20=3. R21=30. R22=-0. R23=2 R24=-2.R25=0. R26=0 R27=0 R28=15 R29=30. R31=30. R32=-35.L97 P1X100.M05N4 X300. Z200.X300. Z200.M30

L0001N1 G01 X-2. Z5.N2 Z0.N3 X70.X74. Z0.M17

L0002N4 G01 X22. Z0.5N5 Z0.N6 X30. Z-4.N7 Z-35.N8 X60. Z-50.N9 X70.X74. Z-50.M17%

Programming concepts 6

Cadem Technologies Pvt. Ltd. Lathe Programming

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

N240 G0 X29. Z-2.269N245 Z2.N250 X22.931N255 G01 Z0.N260 Z-0.234N265 X31. Z-4.269N270 Z-25.6N275 Z-32.6N280 Z-35.269N285 X61. Z-50.269N290 Z-60.N295 X70.N300 G0 X74.N305 X80.N310 (OPERATIONEND)N315 M09N320 M05N325 G28 U0 W0N330 M01N335 (EXTERNALGROOVE 2)N340 T0202(OG1616LH2W)N345 G50 S3000N350 G96 S120 M04N355 (EXTERNALGROOVE)N360 G0 X80. Z-31.9M07N365 X35.2N370 G01 X30. F0.12N375 X25.2N380 Z-31.157N385 X27.229 Z-29.4N390 G0 X35.2N395 Z-26.9N400 G01 X30.115N405 X27.229 Z-29.4N410 G0 X35.2N415 X80.N420 (OPERATIONEND)N425 M09N430 M05N440 M01N445 (EXTERNALTHREAD 3)N450 T0303(OT2020LH)N455 G97 S1167 M04N460 (THREADING)N465 G0 X80. Z1. M07N470 X34.N475 Z1.897N480 G01 X29.106 F3.

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

N765 G0 X34.N770 Z1.N775 Z1.224N780 G01 X26.775N785 G32 Z-28. K3.N790 G0 X34.N795 Z1.N800 Z1.189N805 G01 X26.653N810 G32 Z-28. K3.N815 G0 X34.N820 Z1.N825 Z1.155N830 G01 X26.536N835 G32 Z-28. K3.N840 G0 X34.N845 Z1.N850 Z1.122N855 G01 X26.422N860 G32 Z-28. K3.N865 G0 X34.N870 Z1.N875 Z1.09N880 G01 X26.312N885 G32 Z-28. K3.N890 G0 X34.N895 Z1.N900 Z1.059N905 G01 X26.205N910 G32 Z-28. K3.N915 G0 X34.N920 Z1.N925 Z1.029N930 G01 X26.101N935 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 (OPERATIONEND)N1015 M09N1020 M05N1030 M30%

Programming concepts 7

Cadem Technologies Pvt. Ltd. Lathe Programming

SubprogramsWhen a program contains certain fixed sequences or frequently repeated patterns , these sequences may beentered 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 thesubprogram in turn calls another subprogram, it is the second loop and so on.

Sub program call format

LXXX PXX

Example of applicationMultiple grooves on OD using a subprogram

15 typ. 105 typ.

95

10080

Example of program with sub program

%2121N5 G71N10 G0 X300. Z200N15 G95N20 (EXTERNAL GROOVE 1)N25 T0101 (OG2020LH6W)N30 G92 S3000N35 G96 S175 M04N40 (EXTERNAL GROOVE)N45 G0 X110. Z-6.5 M07N50 L100 P4N55 X104.N60 M09N65 M05N70 G0 X300. Z200.N75 M30

Sub program number

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

Number of times the subprogram is to berepeated

Main program Sub program

Programming concepts 8

Cadem Technologies Pvt. Ltd. Lathe Programming

Same example withoutsubprogram%2121N5 G71N10 G0 X300. Z200.N15 G95N20 (EXTERNAL GROOVE 1)N25 T01 D1 (OG2020LH6W)N30 G92 S3000N35 G96 S175 M04N40 (EXTERNAL GROOVE-1)N45 G0 X104. Z-20.2 M07N50 G01 X80. F0.12N55 G0 X104.N60 Z-25.N65 G01 X100.N70 X80.N75 Z-20.5N80 G0 X104.N85 Z-16.N90 G01 X100.N95 X80.N100 Z-20.5N105 G0 X104.N110 (EXTERNAL GROOVE-2)N115 G0 Z-40.2N120 G01 X80.N125 G0 X104.N130 Z-45.N135 G01 X100.N140 X80.N145 Z-40.5N150 G0 X104.N155 Z-36.N160 G01 X100.N165 X80.

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

Programming concepts 9

Cadem Technologies Pvt. Ltd. Lathe Programming

ProgrammingFor the Sinumerik 810T controller

Axes convention

Z Axis

X Axis

Absolute and Incremental co-ordinatesIn the absolute programming, the end point of a motion is programmed with reference to the program zeropoint. In incremental programming, the end point is specified with reference to the current tool position.

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

Absolute traverse to N1, incremental to N2G90 X20.0 Z50.0G91 X15.0 Z-20.0

Z

X

50

5030

20 N1

N2

0,0

Programming concepts 10

Cadem Technologies Pvt. Ltd. Lathe Programming

List of G-codes

G-code FunctionG00 Positioning rapid traverseG01 Linear interpolation (feed)G02 Circular interpolation CWG03 Circular interpolation CCWG04 DwellG70 Inch unitG71 Metric unitG32 / G33 Thread cutting (single motion)G40 Tool nose radius compensation cancelG41 Tool nose radius compensation leftG42 Tool nose radius compensation rightG53 Machine co-ordinate systemG54 Work co-ordinate system 1 selectionG55 Work co-ordinate system 2 selectionG56 Work co-ordinate system 3 selectionG57 Work co-ordinate system 4 selectionG90 Absolute commandG91 Incremental commandG94 Feed per minuteG95 Feed per revolutionG96 Constant surface speed controlG97 Constant surface speed control cancel

List of M codesM codes vary from machine to machine depending on the functions available on it and the manufacturer ofthe machine decides them. The M codes listed below are the common ones.

M-codes FunctionM00 Optional program stop automaticM01 Optional program stop requestM02 Program endM03 Spindle ON clock wise (CW)M04 Spindle ON counter clock wise (CCW)M05 Spindle stopM06 Tool changeM07 Mist coolant ON (coolant 1 ON)M08 Flood coolant ON (coolant 2 ON)M09 Coolant OFFM30 End of program, Reset to startM17 Sub program end

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

Programming concepts 11

Cadem Technologies Pvt. Ltd. Lathe Programming

G00 Rapid traverseWhen the tool being positioned at a point preparatory to a cutting motion, to save time it is moved along astraight 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.

FormatN_ 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, thefeed rate.

Format N__ G01 X__ Z__ F__

Feed motion

Programming concepts 12

Cadem Technologies Pvt. Ltd. Lathe Programming

G02/03 Circular interpolation

CW arc CCW arc

Format

N__ G02/03 X__ Z__ I__ K__ F__ using the arc centerOR

N__ G02/03 X__ Z__ R__ F__ using the arc radius

G02 moves along a CW arcG03 moves along a CCW arc

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 centerwith reference to the arc start point.

Z

X

Arc center

Arc endArc start

- I

- K

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

Programming concepts 13

Cadem Technologies Pvt. Ltd. Lathe Programming

Arc radiusThe radius is specified with address R.

Z

X

Arc center

Arc endArc start

Arc radius

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 includedangle greater than 180 deg. must be specified in two blocks.

Tool nose radius compensationG40 Tool nose radius compensation CancelG41 Tool nose radius compensation LeftG42 Tool nose radius compensation Right

X axis

Z axis

Right side G42

Left side G41

Right side G42

Left side G41

Programming concepts 14

Cadem Technologies Pvt. Ltd. Lathe Programming

Theoretical tool tip (TTT)The Theoretical Tool Tip is the point on the tool that is used as the reference point for determining tooloffsets. When a motion is commanded, the TTT point on the tool moves to the commanded point. The pathof 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 noseradius is tangential to the contour.

A

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 inthe figure.

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

Programming concepts 15

Cadem Technologies Pvt. Ltd. Lathe Programming

Thread cutting motion G32

Thread cutting is done by moving the tool along the thread repeatedly at different depths tiil the final threadprofile 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 motionis programmed, the linear motion of the tool starts when this pulse is detected. This ensures that every cutstarts at the same angular position.

Thread cutting must be done at constant spindle speed.

Block formatN__ 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 relationshipFeed rate = Pitch x Spindle speed

Each threading cut involves 4 motions: 1 threading motion and 3 rapid traverse motions. Since a threadnormally requires multiple cuts, G32 results in a long program and is not normally used. The G76 cannedcycle is normally used for threading.

G32

Programming concepts 16

Cadem Technologies Pvt. Ltd. Lathe Programming

Canned cyclesA Canned cycle is a single block command, which replaces a series of repetitive motions of the tool. Acycle eliminates tedious calculations, which may otherwise be required for programming certain complexoperations.

For example, to turn the part shown in fig. 3.10 from a cylindrical blank, a series of roughing cuts wouldfirst have to be performed to obtain the rough shape of the part, with a finishing allowance so as to leavesome material for the final finish cut. A finish cut would then have to be performed to obtain the final pardimensions. Each of the roughing cuts involves calculation of the destination co-ordinate till which the toolshould move along the axis. This can be an extremely lenthy process and the resulting program would bevery long. With a canned cycle the same of operations can be programmed in a fraction of the time thatwould 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

R26

R24

C B

A R21/22

45°*1mm

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 specifiedR 21 is the X co-ordinate of the starting point of the contourR 22 is the Z co-ordinate of the starting point of the contourR 24 is the finishing allowance in XR 25 is the finishing allowance in ZR 26 is the depth of roughing cutR 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.

Programming concepts 17

Cadem Technologies Pvt. Ltd. Lathe Programming

Thread cutting cycle L97

This cycle enables external and internal threads to be cut with multiple passes:The format of the cycle block is:

R32 R22

R27

M60

*2

R21

*R31

R20

R29

R26

AD

C

B

R 20=. . R 21=. . R 22=. . R 24=. . R 25=. . R 32=. . L 97

R 20: Thread leadR 21: X co-ordinate of starting point of threadR 22: Z co-ordinate of starting point of threadR 24: Depth of thread, incremental. Enter + for internal thread,

- For male thread.R 25: Finishing allowanceR 28: Number of cutsR 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. Thedepth of cut calculated is such that the cross – sectional area of cut is the same for every cut. This ensuresthat 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 efficientchip breaking and removal. The drill is held in the tool holder for axial tools.

Programming concepts 18

Cadem Technologies Pvt. Ltd. Lathe Programming

AR22

R26

R25-4*R24R25-3*R24

R25-2*R24

R25-R24

R25

A

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 distance3. Dwell for chip breaking4. Rapid in +Z direction to start position5. Dwell for chip removal6. Rapid in –Z direction7. Repeat steps 2 to 6 till the final drill depth is reached8. 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, secondsR 28: Dwell at drilling depth for chip breaking, seconds

Programming concepts 19

Cadem Technologies Pvt. Ltd. Lathe Programming

Verifying NC programs

Safety prioritiesSafety priorities must be followed when verifying programs.

Operator safety - priority 1Safety of the person operating the machine

Machine tool safety - priority 2Prevention of damage to the machine

Workpiece safety - priority 3Prevention of part rejection

Typical errorsSyntax errorsThis prevents the machine controller from executing a command. E.g., writing G101 instead of G01

Motion errorsMachine 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; improperincremental/absolute mode selection.

Omission errorsOmitting decimal points, forgetting to program feed rates, forgetting to turn on the coolant

Setup errorsWrongly measured work offset and tool offsets, or correct measurement and wrong entry

Program verification proceduresA new program is checked by executing it in some or all of the verification modes.

Dry run with Machine lockUsed 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.

Programming concepts 20

Cadem Technologies Pvt. Ltd. Lathe Programming

Dry run with air cuttingUsed 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 cuttingUsed 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 executionUsed 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.

Programming concepts 1

Cadem Technologies Pvt. Ltd. Milling Programming

Programming conceptsFor 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 program’s 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 codesA 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 Gand M respectively.

G-codesPreparatory functions which involve tool motions like rapid motions, feed motions, circular motions, dwells,and canned cycle codes.

M-codesMiscellaneous functions which involve machine actions, like spindle on and off, tool change, coolant on off,program stops.

Programming concepts 2

Cadem Technologies Pvt. Ltd. Milling Programming

Addresses used in a program

N Block number - specifies the star of the blockG Preparatory functionsM Miscellaneous functionsX X-axis co-ordinateY Y-axis co-ordinateZ Z-axis co-ordinateI X-axis location of arc centerJ Y-axis location of arc centerK Z-axis location of arc centerR Radius of arc centerS Spindle speedF Feed rateT Tool to be used

Examples of block formats

Rapid traverse blockN10 G00 X100. Y100.

Feed traverse (linear interpolation) blockN100 G01 X150. Y50. F0.3

Circular motion blockN200 G02 X200. Y100. I0. J-100. F0.3

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.

Block number

End point of the motion

Command for rapid traverse motion

Feed rate 0.3 mm/rev.

X and Z co-ordinates ofarc center point

Programming concepts 3

Cadem Technologies Pvt. Ltd. Milling Programming

Phases of a CNC program1. Program start2. Tool change3. Material removal (cutting)4. Program end

The following program shows the phases.

%O2121

N5 G80 G40 G0 G91 G28 Z0N10 G28 X0 Y0N15 T1 M6 (FMC-63-C)N20 T2

N25 G90 G54 G00 X91.5 Y21.1 S757 M03N30 G43 H1 Z100.N35 Z5. (FACE MILLING)N40 G01 Z0. F2000.N45 X-50. F378.9N50 Y-21.1N55 X50.N60 G00 Z5.N65 Z100.

N70 M09N75 G80 G0 G91 G28 Z0 M05N80 G28 X0 Y0N85 T2 M06 ( DRILL DIA 10.5)

N90 G90 G54 X30. Y0. S818 M03N95 G43 H2 Z100.N100 Z3. (DRILLING)N105 G98 G81 R3. Z-28.155 F122.8N110 X15. Y25.981N115 X-15.N120 X-30. Y0.N125 X-15. Y-25.981N130 X15.N135 G80 G00 Z3.

N140 M9N145 G0 G91 G28 Z0 M5N150 G28 X0 Y0N155 M30%

Program startContains program start characters, programnumber

Tool changeContains motion to tool change position, toolnumber, tool change command

Material removalContains commands for rapid, linear andcircular motions, canned cycles and otherfunctions required to cut the part

Tool change

Program endContains G and M codes which turn off all thefunctions and get the machine ready for the nextpart cycle

Material removal

Programming concepts 4

Cadem Technologies Pvt. Ltd. Milling Programming

Program ZeroThe Program zero is a point on the part or fixture with reference to which all coordinates in the program arespecified.

Programzero

M6 x 1P on 140 PCD

280

220

200

180

300

15040

10

100

40

10

120

Programming concepts 5

Cadem Technologies Pvt. Ltd. Milling Programming

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

Programzero

M6 x 1P on 140 PCD

280

220

200180

300

15040

10

100

40

10

120

Dia 17 x 4 No.

Dia 80

Dia 160

Programming concepts 6

Cadem Technologies Pvt. Ltd. Milling Programming

Program with canned cycles

%O2323N5 G80 G40 G0 G91 G28 Z0N10 G28 X0 Y0

N15 M6 T1 (CENTER DRILL)N20 G90 G54 G00 X40. Y40. S1212 M03N25 G43 H1 Z100.N30 Z3.( CENTERING BOLT HOLE)N35 G98 G81 R3. Z-7.819 F145.5N40 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.5N70 X150. Y170.N75 X80. Y100.N80 X150. Y30.N85 G80 G00 Z3.N90 G0 Z150. M9N95 G80 G0 G91 G28 Z0 M05N100 G28 X0 Y0

N105 M06 T2 (DIA 17 DRILL)N110 G90 G54 X40. Y40. S748 M03N115 G43 H2 Z100.N120 Z20.(DRILL DIA 17 BOLT HOLE)N125 G98 G81 R3. Z-35.107 F112.3N130 X260.N135 Y160.N140 X40.N145 G80 G00 Z20.N150 G0 Z150. M9N155 G80 G0 G91 G28 Z0 M05N160 G28 X0 Y0

N165 M06 T3 (DRILL DIA 8.5)N170 G90 G54 X220. Y100. S1310 M03N175 G43 H3 Z100.N180 Z5.(PRE DRILL FOR M10)N185 G98 G83 R-17. Z-57.554 Q12. F157.3N190 X150. Y170.N195 X80. Y100.N200 X150. Y30.N205 G80 G00 Z5.N210 G0 Z150. M9N215 G80 G0 G91 G28 Z0 M05N220 G28 X0 Y0

N225 M06 T4 (M10 TAP)N230 G90 G54 X220. Y100. S477 M03N235 G43 H4 Z100.N240 Z5.

( M10 TAPPING)N245 G98 G84 R-17. Z-40. F716.197N250 X150. Y170.N255 X80. Y100.N260 X150. Y30.N265 G80 G00 Z5.N270 G0 Z150. M9N275 G80 G0 G91 G28 Z0 M05N280 G28 X0 Y0

N285 M06 T5 (φφ79 ROUGH BORE)N290 G90 G54 X150. Y100. S483 M03N295 G43 H5 Z100.N300 Z3.( DIA 79 ROUGH BORE)N305 G98 G85 R3. Z-40. F96.7N310 G80 G00 Z3.N315 G0 Z150. M9N320 G80 G0 G91 G28 Z0 M05N325 G28 X0 Y0

N330 M06 T6 (φφ 80 FINISH BORE)N335 G90 G54 X150. Y100. S517N340 G43 H6 Z100.N345 Z3.( DIA 80 FINISH BORE)N350 G98 G76 R3. Z-42. Q0.1 F51.7 P2000N355 G80 G00 Z3.N360 G0 Z150. M9N365 G0 G91 G28 Z0 M5N370 G28 X0 Y0N375 M30%

Programming concepts 7

Cadem Technologies Pvt. Ltd. Milling Programming

Program without canned cycles

%O2424N5 G80 G40 G0 G91 G28 Z0N10 G28 X0 Y0

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

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

N270 G00 Z20.N275 X40.N280 Z3.N285 G01 Z-35.107N290 G00 Z20.N295 G0 Z150. M9N300 G80 G0 G91 G28 Z0 M05N305 G28 X0 Y0

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

Programming concepts 8

Cadem Technologies Pvt. Ltd. Milling Programming

N545 M06 T4 (M10 TAP)N550 G90 G54 X220. Y100. S477 M03N555 G43 H4 Z100.N560 Z5.N565 ( M10 TAPPING)N570 G00 Z-17.N575 G01 Z-40. F716.2N580 M04N585 Z-17.N590 G00 Z5.N595 X150. Y170.N600 Z-17.N605 M03N610 G01 Z-40.N615 M04N620 Z-17.N625 G00 Z5.N630 X80. Y100.N635 Z-17.N640 M03N645 G01 Z-40.N650 M04N655 Z-17.N660 G00 Z5.N665 X150. Y30.N670 Z-17.N675 M03N680 G01 Z-40.N685 M04N690 Z-17.

N695 G00 Z5.N700 G0 Z150. M9N705 G80 G0 G91 G28 Z0 M05N710 G28 X0 Y0

N720 M06 T5 (φφ79 ROUGH BORE)N720 G90 G54 X150. Y100. S483 M03N725 G43 H5 Z100.N730 Z3.N735 ( DIA 79 ROUGH BORE)N740 G01 Z-40. F96.7N745 Z3.N750 G0 Z150. M9N755 G80 G0 G91 G28 Z0 M05N760 G28 X0 Y0

N770 M06 T6 (φφ 80 FINISH BORE)N770 G90 G54 X150. Y100. S517N775 G43 H6 Z100.N780 Z3.N785 ( DIA 80 FINISH BORE)N790 G01 Z-42. F51.7N795 M19N800 G00 X150.5 Y100.5N805 Z3.N810 X150. Y100.N815 G0 Z150. M9N820 G0 G91 G28 Z0 M5N825 G28 X0 Y0N830 M30%

Programming concepts 9

Cadem Technologies Pvt. Ltd. Milling Programming

SubprogramsWhen a program contains sequences of tool motions which are repeated frequently, these sequences may beentered 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 thesubprogram in turn calls another subprogram, it is the second loop and so on.

Sub program call format

M98 PXXXX XXXXSub program number

Number of times the subprogram is to berepeated

O2121

M98 P00101000

M30

O2000

M98 P00103000

M99

O3000

M98 P00104000

M99

O4000

M98 P00105000

M99

Sub program Sub programSub programSub programMain program

O1000

M98 P00102000

M99

1- loop nesting 2- loop nesting 3- loop nesting 4- loop nesting

Programming concepts 10

Cadem Technologies Pvt. Ltd. Milling Programming

Example of applicationFace milling and pocket milling

Dia 100

150 30

120

50

Program zero

%O2121N5 G80 G40 G0 G91 G28 Z0N10 G28 Y0 X0N15 M6 T1 (DIA 63 FACE MILL CUTTER)N20 G90 G54 G00 X41.5 Y-18.9 S757 M03N25 G43 H1 Z100.N30 Z13.N35 (RECTANGULAR FACE MILL)N40 M98 P00050099N45 Z100.N50 G80 G0 G91 G28 Z0 M05N55 G28 Y0 X0N60 M01N65 M6 T2N70 G90 G54 X-75. Y-60. S1273 M03N75 G43 H2 Z100.N80 Z3.N85 (CIRCULAR POCKET MILL)N90 M98 P00100100N95 Z100.N100 G0 G91 G28 Z0 M5N105 G28 X0 Y0N110 M30%

Main program%O99N5 G91 G01 Z-5. F2000.N10 G90 X-150. F378.9N15 Y-69.3N20 X0.N25 Y-101.1N30 X-150.N35 G91 G00 Z3.N40 G90 X41.5 Y-18.9N45 M99%

%O100N5 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%

Sub programs

Programming concepts 11

Cadem Technologies Pvt. Ltd. Milling Programming

Example of program with sub program

%O2222N5 G80 G40 G0 G91 G28 Z0N10 G28 Y0 X0N15 M6 T1 (DIA 63 FACE MILL CUTTER)N20 G90 G54 G00 X41.5 Y-18.9 S757 M03N25 G43 H1 Z100.N30 Z13.N35 ( RECTANGULAR FACE MILL)N40 G91 G01 Z-5. F2000.N45 G90 X-150. F378.9N50 Y-69.3N55 X0.N60 Y-101.1N65 X-150.N70 G91 G00 Z3.N75 G90 X41.5 Y-18.9N80 G91 G01 Z-5. F2000.N85 G90 X-150. F378.9N90 Y-69.3N95 X0.N100 Y-101.1N105 X-150.N110 G91 G00 Z3.N115 G90 X41.5 Y-18.9N120 G91 G01 Z-5. F2000.N125 G90 X-150. F378.9N130 Y-69.3N135 X0.N140 Y-101.1N145 X-150.N150 G91 G00 Z3.N155 G90 X41.5 Y-18.9N160 G91 G01 Z-5. F2000.N165 G90 X-150. F378.9N170 Y-69.3N175 X0.N180 Y-101.1N185 X-150.N190 G91 G00 Z3.N195 G90 X41.5 Y-18.9N200 G91 G01 Z-5. F2000.N205 G90 X-150. F378.9N210 Y-69.3N215 X0.N220 Y-101.1N225 X-150.N230 G91 G00 Z3.N235 G90 X41.5 Y-18.9

N240 Z100.N245 G80 G0 G91 G28 Z0 M05N250 G28 Y0 X0N255 M01N260 M6 T2 (DIA 20 END MILL)N265 G90 G54 X-75. Y-60. S1273 M03N270 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.

Programming concepts 12

Cadem Technologies Pvt. Ltd. Milling Programming

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 M5N800 G28 X0 Y0N805 M30%

Programming concepts 13

Cadem Technologies Pvt. Ltd. Milling Programming

ProgrammingFor the Fanuc 0M controller

Axes conventionThe 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

Y

-

+

-

+

X-+

+Z

-Z

+Y

-Y

-X +X

Programming concepts 14

Cadem Technologies Pvt. Ltd. Milling Programming

HMC (Horizontal Machining Center)

Y

Z

X

-+

-

+

-+

Part

Machine table

X

YZ

Programming concepts 15

Cadem Technologies Pvt. Ltd. Milling Programming

List of G-codesG-code FunctionG00 Positioning rapid traverseG01 Linear interpolation (feed)G02 Circular interpolation CWG03 Circular interpolation CCWG04 DwellG20 Inch unitG21 Metric unitG28 Automatic zero returnG30 2nd reference point returnG40 Tool nose radius compensation cancelG41 Tool nose radius compensation leftG42 Tool nose radius compensation rightG43 Tool length compensationG52 Local co-ordinate systemG54 Work co-ordinate system 1 selectionG55 Work co-ordinate system 2 selectionG56 Work co-ordinate system 3 selectionG57 Work co-ordinate system 4 selectionG58 Work co-ordinate system 5 selectionG59 Work co-ordinate system 6 selectionG74 Left hand tapping cycleG76 Fine boring cycleG80 Canned cycle cancelG81 Drilling cycleG82 Drilling cycle with dwellG83 Peck drilling cycle / deep drillG84 Tapping cycleG85 Boring / Reaming cycleG86 Boring cycleG87 Back boring cycleG90 Absolute commandG91 Incremental commandG94 Feed per minuteG95 Feed per revolutionG98 Return to initial point in canned cycleG99 Return to R point in canned cycle

Programming concepts 16

Cadem Technologies Pvt. Ltd. Milling Programming

List of M codesM codes vary from machine to machine depending on the functions available on it. They are decided by themanufacturer of the machine. The M codes listed below are the common ones.

M-codes FunctionM00 Optional program stop automaticM01 Optional program stop requestM02 Program endM03 Spindle ON clock wise (CW)M04 Spindle ON counter clock wise (CCW)M05 Spindle stopM06 Tool changeM07 Mist coolant ON (coolant 1 ON)M08 Flood coolant ON (coolant 2 ON)M09 Coolant OFFM19 Spindle orientationM30 End of program, Reset to startM98 Sub program callM99 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-ordinatesIn the absolute programming , the end point of a motion is programmed with reference to the program zeropoint. In incremental programming, the end point is specified with reference to the current tool position.

X

Y

50

5030

20 N1

N2

0,0

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

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

Programming concepts 17

Cadem Technologies Pvt. Ltd. Milling Programming

G00 Rapid traverseWhen the tool being positioned at a point preparatory to a cutting motion, to save time it is moved along astraight 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.

FormatN_ 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, thefeed rate.

Format N__ G01 X__ Y__Z__ F__

Part

Feed

Part

Feed

Programming concepts 18

Cadem Technologies Pvt. Ltd. Milling Programming

G02/03 Circular interpolation

Format

N__ G02/03 X__ Y__Z__ I__ J__K__ F__ using the arc centerOR

N__ G02/03 X__ Y__Z__ R__ F__ using the arc radius

G02 moves along a CW arcG03 moves along a CCW arc

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 arccenter with reference to the arc start point.

X

Y

Arc center

Arc endArc start

- J

- I

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

Programming concepts 19

Cadem Technologies Pvt. Ltd. Milling Programming

Arc radiusThe radius is specified with address R.

X

Y

Arc center

Arc endArc start

Arc radius

Block format

N__ G02 X__Y__ Z__ R__ F__ N__ G03 X__Y__ Z__ R__ F__

Cutter radius compensation (CRC)G40 Tool nose radius compensation CancelG41 Tool nose radius compensation LeftG42 Tool nose radius compensation Right

G41 G41

G42 G42

Programming concepts 20

Cadem Technologies Pvt. Ltd. Milling Programming

Block format

N__ G01 G41/42 X__ Y__ D__ F__

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 usedCutter wear can not compensated

Program Zero

Feed rate mm/min

Linear interpolation command code

CRC command code

CRC start co-ordinates absolute

CRC offset number

Programming concepts 21

Cadem Technologies Pvt. Ltd. Milling Programming

Tool length compensation (G43)Different tools of different lengths are used in machining any part. The lengths of the tools are notconsidered in the part program. They are entered in the machine’s memory, and are consideredautomatically for each motion in the program depending on the tool that is being used. The tool lengths inthe Z direction are called the Tool length offsets.

Gauge line

Length offset Length offset

Length offset

Length offset

Face milling cutter

Back boring tool

T-slot milling cutter

Boring tool

Part

Setting work co-ordinate system (G54 - G59)G54 Work co-ordinate system 1 selection

G55 Work co-ordinate system 2 selection

G56 Work co-ordinate system 3 selection

G57 Work co-ordinate system 4 selection

G58 Work co-ordinate system 5 selection

G59 Work co-ordinate system 6 selection

Programming concepts 22

Cadem Technologies Pvt. Ltd. Milling Programming

Machine table

Work co-ordinatesystem 1 selection

Work co-ordinate system 4selection

Work co-ordinate system 3selection

Work co-ordinate system 6selection

Work co-ordinate system 5selection

Work co-ordinatesystem 2 selection

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

G81 Drilling cycle

G82 Drilling cycle with dwell (Counter bore cycle)

G83 Peck drilling cycle / deep drill

G84 Right hand tapping cycle

G85 Boring / Reaming cycle

G86 Boring cycle

G87 Back boring cycle

G74 Left hand tapping cycle

G76 Fine boring cycle

Programming concepts 23

Cadem Technologies Pvt. Ltd. Milling Programming

Drilling cycle (G81)

FeedRapid

R point / Safe height

With G98 return to initial point

Initialpoint

FeedRapid

R point / Safe height

With G99 return to R point

Infeed feed rate mm/min

Return position codeDrilling cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98/99 G81 R__ Z__ F__

Programming concepts 24

Cadem Technologies Pvt. Ltd. Milling Programming

Counter bore cycle (G82)

FeedRapid

R point / Safe height

With G98 return to initial point

Initialpoint

Dwell at bottom

P

FeedRapid

R point / Safe height

With G99 return to R point

Dwell at bottom

P

Infeed feed rate mm/min

Return position code

Counter bore drilling cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98/99 G82 R__ Z__ P__ F__

Dwell at bottom

Programming concepts 25

Cadem Technologies Pvt. Ltd. Milling Programming

Peck drill cycle (G83)

FeedRapid

With G98 return to initial point

Initialpoint

Safe height / R point

Final depth

Peck depth

FeedRapid

With G99 return to R point

Initialpoint

Safe height / R point

Final depth

Peck depth

Programming concepts 26

Cadem Technologies Pvt. Ltd. Milling Programming

Infeed feed rate mm/min

Return position code

Peck drilling cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98/99 G83 R__ Z__ Q__ F__

Peck depth

Tapping cycle (G84)Right hand tapping

FeedRapid

R point / Safe height

With G98 return to initial point

Initialpoint

Spindle CW

Spindle CCW

Final depth

Retract feed rateequals infeed feedrate

FeedRapid

R point / Safe height

With G99 return to R point

Initialpoint

Spindle CW

Spindle CCW

Final depth

Retract feed rateequals infeed feedrate

Feedrate = Spindle RPM x Pitch

Programming concepts 27

Cadem Technologies Pvt. Ltd. Milling Programming

Infeed / retract feed rate mm/min

Return position codeRight hand tapping cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98/99 G84 R__ Z__ F__

Spindle direction in RH tappingCW during infeedCCW during outfeed

Reaming cycle (G85)

FeedRapid

R point / Safe height

With G98 return to initial point

Initialpoint

Final depth

FeedRapid

R point / Safe height

With G98 return to R point

Initialpoint

Final depth

Programming concepts 28

Cadem Technologies Pvt. Ltd. Milling Programming

Infeed / retract feed rate mm/min

Return position codeReaming cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98/99 G85 R__ Z__ F__

Boring cycle (G86)

FeedRapid

R point / Safe height

With G98 return to initial point

Initialpoint

Final depth

Spindle stop

Spindle CW

FeedRapid

R point / Safe height

With G99 return to R point

Final depth

Spindle stop

Spindle CW

Programming concepts 29

Cadem Technologies Pvt. Ltd. Milling Programming

Infeed feed rate mm/min

Return position codeBoring cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98/99 G86 R__ Z__ F__

Back boring cycle (G87)

Safe height / R point

Final depth

Initial point Spindle orientation

Lateral shift

Bore axis

Spindle CW

Programming concepts 30

Cadem Technologies Pvt. Ltd. Milling Programming

Infeed feed rate mm/min

Return position code

Back boring cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98 G87 R__ Z__ Q__ F__

Lateral shift

Tapping cycle (G74)Left hand tapping

FeedRapid

R point / Safe height

With G98 return initial point

Initialpoint

Spindle CCW

Spindle CW

Final depth

Retract feed rateequals infeed feedrate

FeedRapid

R point / Safe height

With G99 return R point

Initialpoint

Spindle CCW

Spindle CW

Final depth

Retract feed rateequals infeed feedrate

Programming concepts 31

Cadem Technologies Pvt. Ltd. Milling Programming

Feedrate = Spindle RPM x Pitch

Infeed / retract feed rate mm/min

Return position codeLeft hand tapping cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98/99 G74 R__ Z__ F__

Spindle direction in LH tappingCCW during infeedCW during outfeed

Fine boring cycle (G76)

FeedRapid

R point / Safe height

With G98 return to initial point

Initialpoint

Final depth

Spindle Orientation

Spindle CW

Lateral shift

Lateral shift

Dwell atbottom

FeedRapid

R point / Safe height

With G99 return to R point

Initialpoint

Final depth

Spindle Orientation

Spindle CW

Lateral shift

Lateral shift

Dwell atbottom

Programming concepts 32

Cadem Technologies Pvt. Ltd. Milling Programming

Infeed feed rate mm/min

Return position code

Fine boring cycle code

Safe height / R point

Final depth

Block number

Format

N__ G98 G76 R__ Z__ Q__ F__

Lateral shift

Programming concepts 33

Cadem Technologies Pvt. Ltd. Milling Programming

Verifying NC programs

Safety prioritiesSafety priorities must be followed when verifying programs.

Operator safety - priority 1Safety of the person operating the machine

Machine tool safety - priority 2Prevention of damage to the machine

Workpiece safety - priority 3Prevention of part rejection

Typical errorsSyntax errorsErrors which prevent the machine controller from executing a command. E.g., writing G101 instead of G01

Motion errorsMachine 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; improperincremental/absolute mode selection.

Omission errorsOmitting decimal points, forgetting to program feed rates, forgetting to turn on the coolant

Setup errorsWrongly measured work offset and tool offsets, or correct measurement and wrong entry

Program verification proceduresA new program is checked by executing it in some or all of the verification modes.

Dry run with Machine lockUsed 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.

Programming concepts 34

Cadem Technologies Pvt. Ltd. Milling Programming

• Tool and work offsets need not be set.

Dry run with air cuttingUsed 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 cuttingUsed 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 executionUsed 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.