Outline MC Programming I NC Program NC Codes Blocks G and M codes Other codes Programming Basic Motions Rapid travel Linear motion Circular motion Examples NC Program An NC program is a program that defines the entire sequence of a machining operation to be carried out on a particular CNC machine tool: It informs the CNC controller about the trajectory of the cutter(s) employed so as to sculpture the part to the required dimensions and tolerances. It tells the controller which tools to be used through out the machining operation. which h auxillary functions to be performed during the process. Chapter 5a ME 0 2 Chapter 5a ME 0 NC Code Elements of NC Program An NC program is simply the translation of a machining process plan into the NC codes that are understandable by the CNC machine controller. NC code is originally based on recommended industry standard RS-27B of 1965. Even though ISO has issued an international standard on the NC Codes (e.g. ISO 698/1), the controllers made by different manufacturers employ different NC codes. Despite many similarities, an NC program is NOT portable to controllers with different design. Each line of an NC program is referred to as block. Format of a block is <Line #> <Motion Type or Machine Operation Mode> < Coord> < Coord> < Coord> <Feedrate> <Spindle Speed> <Misc. Functions> Chapter 5a ME 0 Chapter 5a ME 0 5
Block The controller reads the program one block at a time. Blocks do not extend past one line. The order of information on a block does not matter: G0 0.0 10.75 is the same as 10.75 G0 0.0 However, most programmers use the following word order: N G I J K U V W A B C P Q R F S T M H We ll go over the meaning of each letter as the course progresses. G and M Codes Machining centers have two basic types of codes: G codes also called preparatory codes Tell the machine what type of movement or function should be performed. For example, rapid moves, linear feed moves, arc feed moves, thread cutting, etc. M codes also called miscellaneous functions Turn the spindle on and off, coolant on and off, etc. Chapter 5a ME 0 6 Chapter 5a ME 0 7 Common G Codes Common M Codes G0 G1 G2 G Rapid travel (point-to-point) t i t) Rectilinear motion Circular motion (clockwise) Circular motion (counter clockwise) G20 G21 G28 G90 G91 G Dwell (wait) mode Imperial units (inch) Metric units (mm) Return to reference point (home) Absolute coordinate mode Incremental coordinate d M0 M M M5 M8/M9 M0 Program stop Start spindle (clockwise) Start spindle (counter clockwise) Turn spindle off Turn coolant on / off End-of-program Chapter 5a ME 0 8 Chapter 5a ME 0 9
Other Codes Specification of Coordinates O N Program number (FANUC) Line or block number,, New coordinates in [mm or inch] F S T Feedrate in [mm/min] or [inch/min] Spindle speed in [rpm] Tool number Let the programming g resolution (BLU) of the machine be 0.001 mm. 1. = 1.0 mm 1 = 0.001 mm (1 BLU) 100 = 0.100 mm (100 BLU) Don t forget to put decimal points on all numbers except 0! Chapter 5a ME 0 10 Chapter 5a ME 0 11 Modal Codes Most codes are modal (sticky). That is, they stay in effect until someone changes them. Preferred N150 G1 10.0 10.0 F00.0 N160 20.0 Easy to read and change. Works but poor style! N150 G1 10.0 10.0 F00.0 N160 G1 10.0 20.0 F00.0 Hard to follow and changes require considerable effort. Notes on Codes! Most machines only allow one M code per block. The M code is generally the one to be executed in a particular line. A program must start out with a name: FANUC: O followed by a five digit number SINUMERIK: name with a maximum of 2 characters The tool code (T) for CNC machining centers is usually two digits representing the tool number. All alphanumeric characters must be in uppercase. Chapter 5a ME 0 12 Chapter 5a ME 0 1
Basic Motions Rapid Travel (Point-to-point) to Rectilinear Motion Circular Motion Helical l Motion Parabolic Motion Complex Motion Bicubic Splines NURBS Chapter 5a ME 0 1 Rapid Travel Each axis G0 x f y f z f independently moves by a (prescribed) maximum speed until it reaches its destination. i i f f Chapter 5a ME 0 15 Rectilinear Motion Programming g Example 1 Move to the destination on a rectilinear path at the specified feedrate. f is usually a five-digit number (positive integer) representing the feedrate in [mm/min] (FANUC). 0 0 100 (not drawn to scale) 100 Material: AISI-100 Tool: HSS End-mill D = 10 mm Four flutes Feedrate: 250 mm/min Spindle Speed: 900 rpm Coolant off Initial Position 20 Chapter 5a ME 0 16 Chapter 5a ME 0 17
NC Program for Example 1 NC Program 1 (Cont d) 0 0 1 1 2 1 1 2 PROG_01 ; PROGRAM NUMBER N01 G21 G90 S900 M ; METRIC / ABS / 900 RPM / CW N02 G0-5.0-1.0 -.0 ; RAPID MOVE TO P1 N0 G1 101.0 F250.0 ; MOVE TO P2 N0 101.0 N05-1.0 2 ; MOVE TO P ; MOVE TO P Chapter 5a ME 0 18 Chapter 5a ME 0 19 NC Program 1 (Cont d) Incremental Version 5 6 5 5 6 5 PROG_01_INCR N01 G21 G90 S900 M N02 G0-5.0-1.0 -.0 N0 G91 G1 106.0 F250.0 N0 102.0 N05-102.0 0 N06-102.0 N07 G90 G0-0.0 0 0 M5 N08 M0 ; PROGRAM NUMBER ; METRIC / ABS / 900 RPM / CW ; RAPID MOVE TO P1 ; MOVE TO P2 ; MOVE TO P ; MOVE TO P ; MOVE TO P5 ; RAPID MOVE TO P6 / SPDL OFF ; END OF PROGRAM N06-1.0 ; MOVE TO P5 N07 G0-0.0 0 0 M5 ; RAPID MOVE TO P6 / SPDL OFF N08 M0 ; END OF PROGRAM Chapter 5a ME 0 20 Chapter 5a ME 0 21
CNCSimulator Example 1 Chapter 5a ME 0 22 Circular Motion Plane: x, y, z are the coordinates of the destination point (absolute or incremental). Plane: Extra parameters such as R, I, J, and K are needed to specify an arc. r is the radius of the circle. Plane: r < 0 if arc angle > 180 o. i,,j, k are the incremental coordinates of the circle center Complete Circle: from the starting position. If any of i, j, k words are omitted, it is assumed 0. G17 G2 20.0 1.5 I10.0 F00.0 ; HERE J=0 Chapter 5a ME 0 2 Direction of Rotation Examples for Circular Motion By definition, G2: Clockwise (CW) rotation G: Counter-clockwise (CCW) Mathematical positive direction. As a simple rule, when the thumb of your right-hand is aligned with a principal axis, the remaining fingers point the direction of G (CCW) rotation in that plane. A C (angle > 180 o ): B c C r (x c, y c ) center A (x a, y a ) A D: (x d,y d ) D c Chapter 5a ME 0 2 Chapter 5a ME 0 25
Examples (Cont d) Programming Example 2 - Smiley C (x c, y c ) (x b, y b ) B r center j (> 0) (x d,y d ) A (x a, y a ) A B: Material: AL-7076 Tool: HSS End-mill (Slot Drill) D = 18 mm Two flutes Feedrate: 00 mm/min Spindle Speed: 1200 rpm Coolant on D i (< 0) where x b = x b x a y b = y b y a Chapter 5a ME 0 26 Chapter 5a ME 0 27 NC Program 2 - Smiley 1, 2 2, 2' 2' 5 PROG_02 N01 G21 G90 S1200 M N02 G0-9.0-8.0 N0 M8 ; PROGRAM NUMBER ; METRIC / ABS / 1200 RPM / CW ; RAPID MOVE TO P1 ; COOLANT ON 1, 2 N0 G17 G2 I59.0 J0 F00.0 ; PLANE / CW FULL CIRCLE N05 G0 5.0 ; RAPID MOVE TO P2 N06 25.0 65.0 ; RAPID MOVE TO P 2 Chapter 5a ME 0 28 Chapter 5a ME 0 29
, 5 5 6 6, 7, 8 8 9, 5 5 6 7 6, 8 9 N07 G1-8.0 N08 5.0 N09 G0 75.0 ; MOVE TO P ; MOVE TO P5 ; RAPID MOVE TO P6 N10 G1-8.0 N11 5.0 N12 G0 5.0 ; MOVE TO P7 ; MOVE TO P8 ; RAPID MOVE TO P9 Chapter 5a ME 0 0 Chapter 5a ME 0 1 9, 10 11 10 9 10 N1 G1-8.0 N1 G2 25.0 5.0 I-25.0 J15.0 11 10 ; MOVE TO P10 ; MOVE TO P11 / CIRC. CW N15 G1 5.0 ; MOVE TO P12 N16 G0-0.0 50.0 M9 ; RAPID MOVE TO P1 / COOLANT OFF N17 0 M5 ; RAPID MOVE TO P1 / SPDL OFF N18 M0 ; END OF PROGRAM Chapter 5a ME 0 2 Chapter 5a ME 0
CNCSimulator - Smiley Helical Interpolation With helical interpolation, two motions are superimposed and executed in parallel: l A plane circular motion on which vertical linear motion o is superimposed Chapter 5a ME 0 Chapter 5a ME 0 5 Notes oeson Tool Rotation oa o Notes on Format Milling type (up- or down-milling) is a consequence of feed motion. It would be a serious mistake to try to control the milling type via changing the rotation of the tool! Remember right-hand tools must rotate t clockwise direction to perform machining (via issuing M command). Otherwise, they will fail to cut! For machining centers, the direction of spindle rotation is determined when the machine is viewed from the upperside. NC programs (to be uploaded!) are usually written via text (TT file) editors (notepad, edit, vi etc.). Format of the program may vary depending on the controller of the CNC machine. For some CNC controllers, line (block) numbers are optional and are mainly used for tagging purposes. If desired, spaces (ASCII character #2) may be omitted in a line. However, it obscures the readability of the program. Line end is usually indicated by either semi-colon (;) or ASCII control character carriage return (#1). NC programs may contain comments that are ignored by the controller. For FANUC Controllers, comments are written in parantheses (...). For Siemens Controllers, comments are written after semicolon (;). Chapter 5a ME 0 6 Chapter 5a ME 0 7