You are on page 1of 39

Manual CNC programming(PART

PROGRAMMING)
 Part program: A computer program to

specify
- Which tool should be loaded on the
machine spindle?
- What are the cutting conditions (speed,
feed, coolant ON/OFF etc)?
- The start point and end point of a motion
segment?
- how to move the tool with respect to the
machine?

Word address format

Sequence and format of words:
N5 G2 X+53 Y+53 Z+53 U V W I J K
Sequence no. destination coordinates
preparatory function

F5 S4 T4

M2
tool

dist to center of circle
feed rate

spindle speed

miscellaneous function

26

Word address format
 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.

 G-codes: Preparatory Functions – involve actual tool
moves.

M-codes: Miscellaneous Functions – involve actions

necessary for machining (i.e. spindle on/off, coolant

on/off).

Letter Codes (G Codes) G00 Rapid traverse G01 Linear interpolation G02 Circular interpolation. G40 Cutter compensation – cancel G41 Cutter compensation – G04 Dwell G08 Acceleration G09 Deceleration G17 X-Y Plane G18 Z-X Plane G19 Y-Z Plane G20 Inch Units (G70) G21 Metric Units (G71) G70 Inch format G71 Metric format G80 Fixed-cycle cancel G81-G89 Fixed cycles G90 Absolute dimensions G91 Incremental dimensions G92 absolute presetting CCW left G42 Cutter right compensation- . CW G03 Circular interpolation.

reset to start .Letter Codes (M Codes) M00 M01 M02 M03 M04 M05 M06 M08 M09 M10 M11 M30 Program stop Optional program stop Program end Spindle Spindle Spindle on clockwise on counterclockwise stop Tool change Coolant Coolant Clamps Clamps on off on off Program stop.

 The number may require that a specific format be used (i.4 means three numbers before the decimal and four numbers after the decimal). .Letter Codes  N-codes: Gives an identifying number for each block of information. and Z codes are used to specify the coordinate axis.e. 3. Y. 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.  Number following the code defines the coordinate at the end of the move relative to an incremental or absolute reference point.

 F-code: used  S-code: used T-code: used  to specify to specify to specify the feed rate the spindle speed the tool identification number associated with the tool to be used in subsequent operations.  The number may require that a specific format be used (i.Letter Codes  I. and K codes are used to specify the coordinate axis when defining the center of a circle. J. 3.  Number following the code defines the respective coordinate for the center of the circle. .4 means three numbers before the decimal and four numbers after the decimal).e.

.  Radius when used with G02 and G03. 82.  P-code: Used to specify the dwell time associated with G04. and 83.Letter Codes  R-code:  Retract distance when used with G81.

.  :1025 Program identification number.Program Start Flag and Program Identification Number  % Program start flag. Placed at the beginning of each program.  Only two commands that don’t start with a letter.  Follows the program start flag at the beginning of each program.

Block Format  Sample Block         N135 G01 X1.0 Z0.0 Y1.125 F5 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 .

 These commands are called “modal”.Modal G-Codes  Most G-codes set the machine in a “mode” which stays in effect until it is changed or cancelled by another G code. .

CW G03 Circular Interpolation.Modal G-Code List G00 Rapid Transverse G01 Linear Interpolation G02 Circular Interpolation. CCW G17 XY Plane G18 XZ Plane G19 YZ Plane G20/G70 Inch units G21/G71 Metric Units G40 Cutter compensation cancel G41 Cutter compensation left G42 Cutter compensation right G43 Tool length (plus) compensation G44 Tool length compensation (minus) G49 Tool length compensation cancel G80 Cancel canned cycles G81 Drilling cycle G82 Counter boring cycle G83 Deep hole drilling cycle G90 Absolute positioning G91 Incremental positioning 36 .

It is a modal command. as to do so would seriously damage the tool and ruin the workpiece. This command is not to be used for cutting any material. remaining in effect until canceled by another GCode command .Tool Motion Command . A rapid tool move is used to move the tool linearly from position to position without cutting any material.G00 Positioning in Rapid Format: N_ G00 X_ Y_ Z_ The G00 command is a rapid tool move.

. thus allowing for quick tool positioning.The G00 command is used to move the tool quickly from one point to another without cutting.

the G00 command always goes up in the Z axis first.The G00 rapid move should have two distinct movements to ensure that vertical moves are always separate from horizontal moves. Then. When rapiding out of a part. . In a typical rapid move toward the part. it feeds down in the Z axis. then laterally in the XY plane. the tool first rapids in the flat. horizontal XY plane.

Y. in any combination of the X.G01 Linear Interpolation Format: N_ G01 X_ Y_ Z_ F_ The G01 command is specifically for the linear removal of material from a workpiece. or Z axes. The machine tool follows a linear trajectory. . The G01 is modal and requires a user variable feedrate (designated by the letter F followed by a number).

All diagonal feed moves are a result of a G01 command. using multi-axis feed moves. on the flat XY plane (no Z values are specified). where two or more axes .Linear Interpolation. or straight-line feed moves. G01 command.

G02 Circular Interpolation (clockwise) Format: N_ G02 X_ Y_ Z_ I_ J_ K_ F_         or N_ G02 X_ Y_ Z_ R_ F_ Circular Interpolation is more commonly known as radial (or arc) feed moves. The G02 command is specifically used for all clockwise radial feed moves. as long as they lie in any one plane. or complete circles. The G02 command is modal and is subject to a user-definable . whether they are quadratic arcs. partial arcs.

To find the radius.Y4) and the endpoint is (X4.) The G02 command requires an endpoint and a radius in order to cut the arc. To avoid confusion. these values are assigned variables.Y1). simply measure the incremental distance from the start point to the center point.G02 Circular Interpolation (cont'd. The start point of this arc is (X1. called I and . This radius is written in terms of the X and Y distances.

J. K specify the radius) The G03 command is used for all counterclockwise radial feed moves. or complete circles. as long as they lie in any one plane. The G03 command is modal and is subject to a userdefinable feed rate .G03 CIRCULAR INTERPOLATION (CCW) Format: N_ G03 X_ Y_ Z_ I_ J_ K_ F_ (I. whether they are quadratic arcs. partial arcs.

To avoid confusion. simply measure the incremental distance from the start point to the center point of the arc. 5.EXAMPLE: G03 X1 Y1 I0 J-1 The G03 command requires an endpoint and a radius in order to cut the arc.) The start point of this arc is (X2. these values are assigned variables called I and J. Y1). respectively.7. Y2) and the end-point is (X1. This radius is written in terms of the X and Y distances. (See Fig. To find the radius. .

Y4). respectively. This radius is written in terms of the X and Y distances.G03 Circular Interpolation (cont'd) The G03 command requires an endpoint and a radius in order to cut the arc. . The start point of this arc is (X4. To avoid confusion. simply measure the incremental distance from the start point to the center point. To find the radius. these values are assigned variables I and J.Y1) and the endpoint is(X1.

However.G20 or G70 Inch Units Format: N_ G20 or G70 The G20 or G70 command defaults the system to inch units. When a program is being run and the G20 command is encountered. This command is usually found at the beginning of a program. all coordinates are stated as inch units. on some controllers it can be used to switch from metric units .

all coordinates are stated in as millimeter units. it can be used to switch between metric and inch units in the . or SI. This command is usually found at the beginning of a program. However.G21 or G71 Metric. When a program is being run and the G21 command is encountered. Units Format: N_ G21 or G71 The G21 or G71 command defaults the system to metric units.

G40 Cutter Compensation Cancel Format: N_ G40 Usually. so it must be canceled when it is no longer needed. CNC programs are written so that the tool center follows the toolpath. NOTE: Cutter compensation is modal. This is the sole function of the G40 command . Cutter compensation is used whenever tool centerline programming is difficult. It is also used to compensate for significant tool wear or tool substitution. The G40 command cancels any cutter compensation that was applied to the tool during a program and acts as a safeguard to cancel any cutter compensation applied to a previous program or G-codes.

so it compensates each successive tool move the same specified distance until it is overridden by a G40 command or receives . The G42 command is modal.G42 CUTTER COMPENSATION RIGHT Format: N_ G42 D_ The G42 command compensates the cutter a specified distance to the righthand side of the programmed tool path. It is used to compensate for excessive tool wear or substitute a tool to profile a part.

Canned cycles include tapping. and drilling. spot facing. boring. Note: On most controllers the G00 command will also cancel any canned cycles. . Because the canned cycles are modal (refer to the canned cycles on the following pages). they will remain active until canceled by the G80 command.G80 Cancel Canned Cycles Format: N_ G80 The G80 command cancels all previous canned cycle commands.

and mold sprues. drilled patterns. among other tasks. This cycle can be used for bolt holes. Z depth and Z retract plane parameters. This command is modal and so remains active until overridden by another move command or canceled by the Invoking the G81 command requires invoking the Z initial plane. .G81 Drilling Cycle Format: N_ G81 X_ Y_ Z_ R_ F_ The G81 command invokes a drill cycle at specified locations.

with the addition of a dwell.G82 Spot Drilling or Counter Boring Cycle Format: N_ G82 X_ Y_ Z_ R_ P_ F_ This cycle follows the same operating procedures as the G81 drilling cycle. The dwell is specified by the P letter address. . The dwell time is measured in seconds. Z depth and Z retract. followed by the dwell time in The same Z levels apply to the G82 cycle as to the G81 cycle: Z initial plane. The dwell is a pause during which the Z axis stops moving but the spindle continues rotating. This pause allows for chip clearing and a finer finish on the hole.

The next peck takes the tool deeper. This process is repeated until the final Z depth is reached. then rapids back out to the Z Retract plane. When pecking. the tool feeds in the specified distance (peck distance or depth of cut). the tool positions itself as in a standard G81 drill cycle. The peck is the only action that distinguishes the deep hole drilling cycle from the G81 cycle. In the G83 cycle. When this command is invoked. and then it rapids out of the hole. .G83 Deep Hole Drilling Cycle Format: N_ G83 X_ Y_ Z_ R_ Q_ F_ The G83 command involves individual peck moves in each drilling operation. Q is the incremental depth of cut.

Z0) and expressed in terms of X.G90 Absolute Positioning Format: N_ G90 The G90 command defaults the system to accept all coordinates as absolute coordinates. and Z distances. . Y0. Y. These coordinates are measured from a fixed origin (X0.

G91 Incremental Positioning Format: N_ G91 The G91 command defaults the system to accept all coordinates as incremental. coordinates. or relative. .

Generally. but rather a reference point to which the coordinates relate. the origin point is located at a prominent point or object (for example.G92 Reposition Origin Point Format: N_ G92 X_ Y_ Z_ The G92 command is used to reposition the origin point. front top left corner of the part) so that it is easier to . The origin point is not a physical spot on the machine tool.

M03 SPINDLE ON CLOCKWISE Format: N_ M03 S_ The M03 command switches the spindle on in a clockwise rotation. The spindle speed is designated by the S letter address. followed by the spindle speed in revolutions per minute .

. The spindle speed is designated by the S letter address. followed by the spindle speed in revolutions per minute.M04 SPINDLE ON COUNTERCLOCKWISE Format: N_ M04 S_ The M04 command switches the spindle on in a counterclockwise rotation.

and all axes motion stops—so that it is safe to change the tool. the spindle is turned off and oriented for the tool change. Second. Although other M-codes turn off all functions (for example. First.M05 SPINDLE STOP Format: N_ M05 The M05 command turns the spindle off. The M05 command appears at the end of a program. It is actually a two-fold command. M06 TOOL CHANGE Format: N_ M06 T_ The M06 command halts all program operations for a tool change. it actually changes the tool . M00 and M01). this command is dedicated to shutting the spindle off directly. it stops all machine operations—for example.

M06 TOOL CHANGE Format: N_ M06 T_ .

. M09 COOLANT OFF Format: N_ M09 The M09 command shuts off the coolant flow. The coolant should be shut off prior to tool changes or when you are rapiding the tool over long distances.M07/M08 COOLANT ON Format: N_ M07 or N_ M08 The M07 and M08 commands switch on the coolant flow.

M08 Coolant On or M09 Coolant Off Format: N_ M08 or N_ M09 .