3 CNC PART PROGRAMMING Co Develop part program





























































- Slides: 61

3. CNC PART PROGRAMMING Co: -Develop part program for CNC Turning, Milling and verify on simulation software. Visit for more Learning Resources

PART PROGRAM • A part program is a series of coded instructions required to produce a part. It controls the movement of the machine tool and the on/off control of auxiliary functions such as spindle rotation and coolant. The coded instructions are composed of letters, numbers and symbols and are arranged in a format of functional blocks as in the following example N 10 G 01 X 5. 0 Y 2. 5 F 15. 0 | | | Feed rate (15 in/min) | | | Y-coordinate (2. 5") | | X-coordinate (5. 0") | Linear interpolation mode Sequence number

PROGRAM INPUT DEVICE • The program input device is the mechanism for part programs to be entered into the CNC control. The most commonly used program input devices are keyboards, punched tape reader, diskette drivers, throgh RS 232 serial ports and networks.

MACHINE CONTROL UNIT The machine control unit (MCU) is the heart of a CNC system. It is used to perform the following functions: • • • Read coded instructions Decoded instructions Implement interpolations (linear, circular, and helical) to generate axis motion commands • Feed axis motion commands to the amplifier circuits for driving the axis mechanisms • Receive the feedback signals of position and speed for each drive axis • Implement auxiliary control functions such as coolant or spindle on/off, and tool change

CNC PROGRAMMING • Offline programming linked to CAD programs. • Conversational programming by the operator. • MDI ~ Manual Data Input. • Manual Control using jog buttons or `electronic handwheel'. • Word-Address Coding using standard Gcodes and M-codes.

The position of the tool is described by using a Cartesian coordinate system. If (0, 0, 0) position can be described by the operator, then it is called floating zero.

In defining the motion of the tool from one point to another, either absolute positioning mode or incremental positioning mode can be used.

1. Absolute positioning. In this mode, the desired target position of the tool for a particular move is given relative to the origin point of the program. 2. Incremental positioning. In this mode, the next target position for the tool is given relative to the current tool position.

Structure of an NC Part Program: Commands are input into the controller in units called blocks or statements. Block Format: 1. Fixed sequential format 2. Tab sequential format 3. Word address format

EXAMPLE: Assume that a drilling operation is to be programmed as: 1. The tool is positioned at (25. 4, 12. 5, 0) by a rapid movement. 2. The tool is then advanced -10 mm in the z direction at a feed rate of 500 mm/min. , with the flood coolant on. 3. The is then retracted back 10 mm at the rapid feed rate, and the coolant is turned off.

1. Fixed sequential format 0050 00 +0025400 +0012500 +0000000 00 0060 01 +0025400 +0012500 -0010000 0500 08 0070 00 +0025400 +0012500 +0000000 09 2. Tab sequential format 0050 TAB 00 TAB +0025400 TAB +0012500 TAB +0000000 TA 0060 TAB 01 TAB TAB -0010000 TAB 0500 TAB 08 0070 TAB 00 TAB TAB -0000000 TAB 09 3. Word address format N 50 G 00 X 25400 Y 125 Z 0 F 0 N 60 G 01 Z-10000 F 500 M 08 N 70 G 00 Z 0 M 09

Modal commands: Commands issued in the NC program that will stay in effect until it is changed by some other command, like, feed rate selection, coolant selection, etc. Nonmodal commands: Commands that are effective only when issued and whose effects are lost for subsequent commands, like, a dwell command which instructs the tool to remain in a given configuration for a given amount of time.

INFORMATION NEEDED by a CNC 1. Preparatory Information: units, incremental or absolute positioning 2. Coordinates: X, Y, Z, RX, RY, RZ 3. Machining Parameters: Feed rate and spindle speed 4. Coolant Control: On/Off, Flood, Mist 5. Tool Control: Tool and tool parameters 6. Cycle Functions: Type of action required 7. Miscellaneous Control: Spindle on/off, direction of rotation, stops for part movement This information is conveyed to the machine through a set of instructions arranged in a desired sequence – Program.

BLOCK FORMAT Sample Block N 135 G 01 X 1. 0 Y 1. 0 Z 0. 125 F 5 • • • Restrictions on CNC blocks Each may contain only one tool move Each may contain any number of non-tool move G-codes Each may contain only one feedrate Each may contain only one specified tool or spindle speed • The block numbers should be sequential • Both the program start flag and the program number must be independent of all other commands (on separate lines) • The data within a block should follow the sequence shown in the above sample block

WORD-ADDRESS CODING Example CNC Program • • • N 5 G 90 G 20 N 10 M 06 T 3 N 15 M 03 S 1250 N 20 G 00 X 1 Y 1 N 25 Z 0. 1 N 30 G 01 Z-0. 125 F 5 N 35 X 3 Y 2 F 10 N 40 G 00 Z 1 N 45 X 0 Y 0 N 50 M 05 N 55 M 30 Each instruction to the machine consists of a letter followed by a number. Each letter is associated with a specific type of action or piece of information needed by the machine. Letters used in Codes N, G, X, Y, Z, A, B, C, I, J, K, F, S, T, R, M

G Codes • G 00 Rapid traverse • G 01 Linear interpolation • G 02 Circular interpolation, CW • G 03 Circular interpolation, CCW • G 04 Dwell • G 08 Acceleration • G 09 Deceleration • G 17 X-Y Plane • G 18 Z-X Plane • G 19 Y-Z Plane • G 20 Inch Units (G 70) • G 21 Metric Units (G 71) • G 40 Cutter compensation – cancel • G 41 Cutter compensation – left • G 42 Cutter compensation- right • G 70 Inch format • G 71 Metric format • G 74 Full-circle programming off • G 75 Full-circle programming on • G 80 Fixed-cycle cancel • G 81 -G 89 Fixed cycles • G 90 Absolute dimensions • G 91 Incremental dimensions

M Codes • • • M 00 M 01 M 02 M 03 M 04 M 05 M 06 M 08 M 09 M 10 M 11 M 30 Program stop Optional program stop Program end Spindle on clockwise Spindle on counterclockwise Spindle stop Tool change Coolant on Coolant off Clamps on Clamps off Program stop, reset to start

N Codes • Gives an identifying number for each block of information. • It is generally good practice to increment each block number by 5 or 10 to allow additional blocks to be inserted if future changes are required.

X, Y, and Z Codes • X, Y, and Z codes are used to specify the coordinate axis. • Number following the code defines the coordinate at the end of the move relative to an incremental or absolute reference point.

I, J, and K Codes • I, J, and K codes are used to specify the coordinate axis when defining the center of a circle. • Number following the code defines the respective coordinate for the center of the circle.

F, S, and T Codes • F-code: used to specify the feed rate • S-code: used to specify the spindle speed • T-code: used to specify the tool identification number associated with the tool to be used in subsequent operations.

Application of Some Codes G 01 Linear Interpolation Format: N_ G 01 X_ Y_ Z_ F_ • Linear Interpolation results in a straight line feed move. • Unless tool compensation is used, the coordinates are associated with the centerline of the tool.

Application of Some Codes G 01 Linear Interpolation • . As an example, for the motion that occurs in x-y plane with the same maximum speed for the x- and y-axis, initial motion is at an angle of 45 o to the axes until motion in one of • the axes is completed and then the balance of the motion occurs in the other axis. This is called point-to-point motion.

Application of Some Codes G 01 Linear Interpolation

G 01 Linear Interpolation X Z N 10 G 00 X 1 Z 1 N 15 Z 0. 1 N 20 G 01 Z-0. 125 F 5 N 25 X 2 Z 2 F 10

G 02 Circular Interpolation • G 02 is also a preparatory function to specify that the tool should be moved to a specified location along a circular path in a clockwise direction. In order to specify the path to the MCU, the end point of the arc and the location of the center of the arc should be specified. Within the block in which the G 02 code is programmed, the center of the arc is given by specifying its location relative to the start of the arc.

G 02 Circular Interpolation (CW) • The G 02 command requires an endpoint and a radius in order to cut the arc. • I, J, and K are relative to the start point. N_ G 02 X 2 Y 1 I 0 J-1 F 10 or N_ G 02 X 2 Y 1 R 1

G 02 Circular Interpolation (CW)

Canned Cycles The sequence of some machining operations is may be the same for any part and for any machine. For example, drilling a hole involves the following steps: Position the tool above the point where the hole will be drilled Set the correct spindle speed Feed the tool into the workpiece at a controlled feed rate to a predetermined depth Retract the tool at a rapid rate to just above the point where the hole started

Some Commonly Used Canned Cycle Code Function Down feed G 81 Drilling Continuous No action feed Rapid G 82 Spot face, counterbore Continuous Dwell feed Rapid G 83 Deep hole drilling Peck No action Rapid G 84 Tapping Continuous Reverse feed spindle Through boring(in Continuous No action & out) feed Feed rate G 85 G 86 At bottom Retracti on Through boring(in Continuous Stop spindle Rapid only) feed

G 81 ILLUSTRATION

Three Main parts of a CNC program Part 1 - Program Petup • N 5 G 90 G 21 (Absolute units, metric) • N 10 M 06 T 2 (Stop for tool change, use tool # 2) • N 15 M 03 S 1200 (Turn the spindle on CW to 1200 rpm)

Three Main parts of a CNC program Part 2 - Chip Removal • N 20 G 00 X 1 Y 1 • • • (Rapid to X 1, Y 1 from origin point) N 25 Z 0. 125 (Rapid down to Z 0. 125) N 30 G 01 Z-0. 125 F 100 (Feed down to Z-0. 125 at 100 mm/min) N 35 G 01 X 2 Y 2 (Feed diagonally to X 2, Y 2) N 40 G 00 Z 1 (Rapid up to Z 1) N 45 X 0 Y 0 (Rapid to X 0, Y 0)

Three Main parts of a CNC program Part 3 - System Shutdown • N 50 M 05 (Turn the spindle off) • N 55 M 00 (Program stop)

EXAMPLE OPERATION on CNC MILLING MACHINE

G-CODE PROGRAM • First pass : conventional mill to a depth of 0. 125 around edge profile. Tool 1 is a ½ inch dia. end mill. % : 1002 N 5 G 90 G 20 N 10 M 06 T 1 N 15 M 03 S 1200 N 20 G 00 X 0. 125 Y 0. 125 N 30 Z 0. 125 N 35 G 01 Z-0. 125 F 5 N 40 X 3. 875 N 45 Y 4. 125 N 50 X 0. 125 N 55 Y 0. 125

• Second pass: conventional mill to a depth of 0. 25 around edge profile. N 35 Z-0. 250 N 40 X 3. 875 N 45 Y 4. 125 N 50 X 0. 125 N 55 Y 0. 125 N 60 Z 0. 125

• Third pass: conventional mill to a depth of 0. 125 around pocket profile. N 65 G 00 X 1. 25 Y 1. 0 N 70 G 01 Z-0. 125 F 5 N 75 X 1. 75 N 80 Y 2. 5 N 85 X 1. 25 N 90 Y 1. 0 N 95 Z 0. 125

• Fourth pass: climb mill to a depth of 0. 125 across remaining material. N 100 Y 2. 125 N 105 X 2. 625 N 110 Z 0. 125 N 115 G 00 X-5 Y-5 Z 5 N 120 M 05 N 125 M 30

Advanced features: • Execution of the part of the program in a rotated or mirrored position. • Ability to scale the program and produce larger or smaller programs. • Three dimensional circular interpolation which produces a helical shape. • Parabolic and cubic interpolation.

Computer Aided Part Programming: • NC program preparation may be tedious and difficult if the part to be machined has a complex geometry. The main difficulty is to find out the cutter locations during the machining. Computers may be used to assist the programmers in preparing the NC codes.

Advantages of applying computer-aided part programming include the following: • 1. It reduces the manual calculations involves in determining the geometric characteristics of the part. • It provides the cutter path simulation. • It provides tool collision checking. • It shortens the program preparation time. • It makes the program preparation easier.

• The Aerospace Industries Association sponsored the work that led to the first part programming language, developed in MIT in 1955. • This was called: Automatically Programmed Tools (APT). • APT is an English like simple programming language which basically produce the Cutter Location (CL) data. • Using the cutter location data, the program can generate the actual NC codes by using a postprocessor.

CAD/CAM Based Part Programming: • The output of any CAD package include the geometric data of the part to be machined. Therefore, many CAD/CAM package can produce cutter location (CL) data to be used for NC code generation. • There is still to be a process planning module for a workable NC code generation. • Some of the CAD/CAM packages that have the NC code generation capabilities are Computervision, CATIA, CADAM, Pro. Engineer, Mechanical. Desktop (Auto Desk).

CNC Programming Basics Program structure Every program consists of: 1. Program Start The program start is the program number. The program number begins with character/letter O. 2. Program Contents NC blocks 3. Program End M 30 for a main program M 17 for a sub-program CNC Prg. Basics 45

CNC Program Numbers O 6999 . . . O 0256 O 0255 . . . O 0000 CNC Prg. Basics 46

CNC Program Blocks (1) • • • N is the address Block numbers from N 0000 to N 9999 A block consists of number and words Words are contents of a block Block numbers are selected in the jumps of ten for the purpose of insertion CNC Prg. Basics 47

CNC Program Blocks (2) • • • A block consists of one or more blocks A Word consists of a character (address) and a number. Every address has a certain meaning, on which the corresponding number depends CNC Prg. Basics 48

CNC Prg. Syntax Regulations • • • The maximum block length must not exceeded four lines. If max. length exceeded alarm 650 occurs. Every block starts with a block number. After the block numbers follows the G command. Words consists of coordinates X(U), Z(W). For G 02, G 03 program interpolation parameter I and K are placed after X(U), Z(W). The F word (feed, thread pitch). The S word (cutting speed). The T word (tool address). The M word (additional functions). CNC Prg. Basics 49

Absolute Value Programming Example: P 0 P 1 P 2 P 0 P 1 P 2 N… … N… G 01 X 40. Z 25. F… N… G 01 X 60. Z-40. F… N… … Absolute coordinate system CNC Prg. Basics 50

Incremental Value Programming Example: P 0 P 1 P 2 P 0 P 1 P 2 N… … N… G 01 U 5. W-25. F… N… G 01 X 10. Z-15. F… N… … Incremental coordinate system CNC Prg. Basics 51

Mixed Programming Example: P 0 P 1 P 2 P 0 P 1 P 2 N… … N… G 01 U 5. W-25. F… N… G 01 X 60. Z-15. F… N… … Mixed coordinate system CNC Prg. Basics 52

Self-holding Functions (1) • • The majority of G and M commands and other words are self-holding, remain active until overwritten or deactivated/deselected. Aimed to simplify and to reduce programming tasks. Example: G 41 can be deactivated by issuing G 40 command. CNC Prg. Basics 53

Self-holding Functions (2) Take-over of G 00 commands in block N 0110 In block N 0120 G 00 is deactivated by G 01 is active. Example 1: Example 2: N 0100 G 00 N 0110 X 36. N 0120 G 01 N 0050 N 0060 … N 0120 M 03 … X 50. Z+2. X 40. Z+10. Z-10. F… M 03 activated at N 0050 and effective from N 0050 through N 120. M 03 deactivated at N 0120 by M 04 command M 04 CNC Prg. Basics 54

Reference Points M = Machine zero point. (unchangeable ref. Point determined by machine manufacturer) N = Tool mounting reference point W = Work piece zero point. (can be freely determined by the programmer and can be moved within program CNC Prg. Basics 55

Work piece (1) CNC Prg. Basics 56

Work piece (2) CNC Prg. Basics 57

G & M Commands G 00: Rapid traverse G 01: Linear interpolation G 02: Circular interpolation clockwise G 03: Circular interpolation counter clockwise G 70: Measuring in Inch (USA) G 71: Measuring in mm (Other countries) M 03: Spindle ON clockwise M 04: Spindle ON counter clockwise M 20: Tailstock back M 21: Tailstock forward CNC Prg. Basics 58

G 00, Rapid Traverse Tool position X 69 Z 5 Absolute dimensions of the target point coordinates: N 030 G 90 N 040 G 00 X 48 Z-26 An absolute X coordinate related to the diameter. Incremental dimensions of the target point coordinates: N 030 G 91 N 040 G 00 X-10, 5 Z-31 CNC Prg. Basics 59

G 01, Linear Interpolation G 90: N 030 G 00 X 39 Z 2 N 040 G 01 X 39 Z 0 N 050 G 90 N 060 G 01 X 48 Z-37 G 01 X… Z… G 91: N 030 G 00 X 39 Z 2 N 040 G 01 X 39 Z 0 N 050 G 91 N 060 G 01 X 4. 5 Z-37 P 0: tool position CNC Prg. Basics 60

G 90 & G 91 Commands G 90 G 01 X+140 Z-90 Target point abs. G 91 G 01 X+40 Z-60 Target point incr. PO: Start Point P 1: Target Point CNC Prg. Basics 61 For more detail contact us