NC Programming
NC 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 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.
Lathe Programming
Programming concepts
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.
Lathe Programming
Programming concepts
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 %
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
C4
M30 x 3P
Program zero
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
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 %
Lathe Programming
Programming concepts
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 %
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.
Example of application
Multiple grooves on OD using a subprogram
5 typ. 15 typ. 10
80
100
95
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
Lathe Programming
Programming concepts
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 %
Lathe Programming
Programming concepts
Programming
For the Sinumerik 810T controller
Axes convention
X Axis
Z Axis
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
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
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.
Lathe Programming
Programming concepts
11
Rapid traverse
Feed motion
Lathe Programming
Programming concepts
12
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.
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.
X axis
Z axis
Lathe Programming
Programming concepts
14
2.
If tool nose radius compensation is not used for the motion from P1 to P2, excess cutting occurs as shown in the figure
Lathe Programming
Programming concepts
15
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.
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.
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.
Lathe Programming
Programming concepts
17
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.
Lathe Programming
Programming concepts
18
AR22
R26
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
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
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.
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.
Milling Programming
Programming concepts
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.
Milling Programming
Programming concepts
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
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
Program zero
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
Program zero
Milling Programming
Programming concepts
Milling Programming
Programming concepts
Milling Programming
Programming concepts
N695 G00 Z5. N700 G0 Z150. M9 N705 G80 G0 G91 G28 Z0 M05 N710 G28 X0 Y0
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
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 %
Milling Programming
Programming concepts
11
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 %
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.
+ Z + X + -Y -Z -X +X +Z +Y
Y -
Milling Programming
Programming concepts
14
+ Y X + Z +
Part X
Machine table
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
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.
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
Milling Programming
Programming concepts
17
Feed
Feed
Part Part
Milling Programming
Programming concepts
18
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.
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__
G41
G41
G42
G42
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
Program Zero
Milling Programming
Programming concepts
21
Gauge line
Length offset
Length offset
Boring tool
Part
Milling Programming
Programming concepts
22
Machine table
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.
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
Milling Programming
Programming concepts
23
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
Milling Programming
Programming concepts
24
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
Milling Programming
Programming concepts
25
Final depth
Final depth
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
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
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
Final depth
Final depth
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
Final depth
Final depth
Spindle stop
Spindle stop
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
Spindle orientation
Lateral shift
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
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
Milling Programming
Programming concepts
31
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
Lateral shift
Lateral shift
Final depth Dwell at bottom Lateral shift Spindle Orientation Dwell at bottom
Final depth
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
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
Milling Programming
Programming concepts
34
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.
Milling Programming