NUMERICAL CONTROL OF MACHINE TOOLS (DE) ME453
UNIT 3
Unit 3
• Manual part programming, programming terms and procedures, programming formats.
• Description of G-M codes
• Lathe operations programming.
• Milling operations programming.
Manual part programming, programming terms and
procedures, programming formats.
• The part program is a sequence of instructions, which describe the work, which has to be done on a part, in the form required by a computer under the control of a numerical control computer program.
• It is the task of preparing a program sheet from a drawing sheet.
• All data is fed into the numerical control system using a standardized format.
• Programming is where all the machining data are compiled
The machining data is as follows :
• Machining sequence classification of process, tool start up point, cutting depth, tool path, etc.
• Cutting conditions, spindle speed, feed rate, coolant, etc.
• Selection of cutting tools.
While preparing a part program, one needs to perform the following steps:
(a)Determine the startup procedure, which includes the extraction of dimensional data from part drawings and data regarding surface quality requirements on the machined component.
(b) Select the tool and determine the tool offset.
(c) Set up the zero position for the workpiece.
(d) Select the speed and rotation of the spindle.
(e) Set up the tool motions according to the profile required.
(f) Return the cutting tool to the reference point after completion of work.
(g) End the program by stopping the spindle and coolant.
Hence the methods of part programming can be of two types depending upon the two techniques as below :
(a) Manual part programming, and
Manual Part Programming
• The programmer first prepares the program manuscript in a standard format.
• Manuscripts are typed with a device known as flexo writer, which is also used to type the program instructions.
• After the program is typed, the punched tape is prepared on the flexo writer.
• Complex shaped components require tedious calculations.
• This type of programming is carried out for simple machining parts produced on point-to-point machine tool.
Computer Aided Part Programming
• If the complex-shaped component requires calculations to produce the component are done by the programming software contained in the computer.
• The programmer communicates with this system through the system language, which is based on words.
• There are various programming languages developed in the recent past, such as APT (Automatically Programmed Tools), ADAPT, AUTOSPOT, COMPAT-II, 2CL, SPLIT is used for writing a computer programme, which has English like statements.
The programmer has to do only following things :
• Define the work part geometry.
• Defining the repetition work.
• Specifying the operation sequence.
• Over the past years, lot of effort is devoted to automate the part programme generation.
• With the development of the CAD (Computer Aided Design)/CAM (Computer Aided Manufacturing) system, interactive graphic system is integrated with the CNC part programming.
• The part programmer can create the geometrical model in the CAM package or directly extract the geometrical model from the CAD/CAM database.
• Built in tool motion commands can assist the part programmer to calculate the tool paths automatically.
• The programmer can verify the tool paths through the graphic display using the animation function of the CAM system.
• It greatly enhances the speed and accuracy in tool path generation.
Computer Aided Part Programming
Software programs can automatically generate CNC data
Make 3D model
Define Tool
CNC data
Simulate cutting
CNC Programming Basics
• Binary digit is called BITS (1,0)
• Out of one ROW- CHARACTER is formed
• Out of sequence of CHARACTER, a WORD is formed
• Out of collection of WORDS, a BLOCK is formed
• BLOCK is one complete NC instructions
Block Configurations
N G X Y Z I J K F S T M EOB
sequence no
preparatory function
destination coordinates
center of circle
feed rate
spindle speed tool
miscellaneous function
End
of Block
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.
Block Configurations
N G X Y Z I J K F S T M EOB
G Codes
• The most common codes used when programming CNC machines tools are G-codes (preparatory functions).
• G-code specifies certain machine preparations such as inch or metric modes, or absolutes versus incremental modes.
• G-codes are sometimes called cycle codes because they refer to some action occurring on the X, Y, and/or Z-axis of a machine tool.
• Generally it is a code telling the machine tool what type of action to perform such as:
• Rapid move; controlled feed move in a straight line or arc, series of controlled feed move-profile shape; set tool information.
Block Configurations
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.
Block Configurations
N G X Y Z I J K F S T M EOB
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.
Block Configurations
N G X Y Z I J K F S T M EOB
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.
Block Configurations
M Codes
M-code specifies miscellaneous machine functions and work like on/off switches for coolant flow, tool changing, or spindle rotation. Other letter addresses are used to direct a wide variety of other machine commands.
Block Configurations
N G X Y Z I J K F S T M EOB
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 feed rate
• Each may contain only one specified tool or spindle speed
• The block numbers should be sequential
G Codes (Preparatory Function)
• G00 Rapid positioning
• G01 Linear interpolation
• G02 Circular interpolation, CW
• G03 Circular interpolation, CCW
• G04 Dwell
• G17, G18,G19 Plane selection
• G20 Inch Units (G70)
• G21 Metric Units (G71)
• G32 Thread cutting
• G40 Cutter compensation –cancel
• G41 Cutter compensation –left
• G42 Cutter compensation- right
• G80 Fixed-cycle cancel
• G81-G89 Fixed cycles
• G90 Absolute dimensions
• G91 Incremental dimensions
• G94 feed (mm/min)
• G95 feed (mm/rev)
• G96 Constant surface speed ON
• G97 Constant surface speed cancel
The total numbers of these codes are 100, out of which some of important codes are given as under with their functions :
M Codes
• M00 Program stop
• M01 Optional
program stop
• M02 Program end
• M03 Spindle on CW
• M04 Spindle on CCW
• M05 Spindle stop
M or miscellaneous codes are used to either turn ON or OFF different functions, which control certain machine tool operations. Some of important codes are given as under with their function s:
• M09 Coolant off
• M10 Clamps on
• M11 Clamps off
• M30 Program stop, reset to start
• M98 Transfer to subprogram
Explanation of commonly used G codes
Positioning (Rapid traverse); G00
G00 – Preparatory code to control final position of the tool and not concerned with the path that is followed in arriving at the final destination.
This command is accompanied by coordinate words. It positions the tool along a linear or non-linear path from the present point as the start point to the end point which is specified by the coordinate words.
Command format G00 Xx Yy Zz
x, y, z, : Represent coordinates, and could be either absolute values or incremental values.
(1) Once this command has been issued, the G00 mode is retained until it is changed by another G function or until the G01, G02, G03 or G33 is used. If the
G00 X-120 Y200 Z300
Linear interpolation; G01
This command is accompanied by coordinate words and a feed rate command.
It makes the tool move (interpolate) linearly from its present position to the end point specified by the coordinate words at the feed specified by address F.
In this case, the feed rate specified by address F always acts as a linear speed in the tool nose center advance direction.
Command format G01 Xx Yy Zz Ff
x, y, z, :Coordinate values and may be an absolute position or
Once this command is issued, the mode is maintained until another G function (G00, G02, G03, G33) which changes the G01 mode is issued.
Therefore, if the next command is also G01 and if the feed rate is the same, all that is required to be done is to specify the coordinate words.
If no F command is given in the first G01 command block, program error results.
Example of program
Cutting in the sequence of P1 → P2 → P3 → P4 → P1 at 300 mm/min feed rate P0 → P1 is for tool positioning
Circular interpolation; G02, G03
G02 (G03) Xx Yy ZZ Ii Jj Kk Ff;
G02 : Clockwise (CW)
G03 : Counterclockwise (CCW)
Xx, Yy ZZ: End point Ii, Jj, Kk : Arc center Ff : Feed rate
For the arc command, the arc end point coordinates are assigned with addresses X, Y or Z, and the arc center coordinate value is assigned with addresses I, J or K).
Either an absolute value or incremental value can be used for the arc end point coordinate value command, but the arc center coordinate value must always be commanded with an incremental value from the start point.
The G02 command requires an endpoint and a radius in order to cut the arc.
I, J, and K are relative to the start point.
N_ G02 X2 Y1 I0 J-1 F10 or
N_ G02 X2 Y1 R1
Plane selection
The planes in which the arc exists are the following three planes, and are selected with the following method.
G17 = XY plane
G18 = XZ plane G19 = YZ plane
G04 Dwell
Format: N_ G04 P_; P=1/1000 seconds N_ G04 X_; X= time in seconds
N_ G04 U_; U=Preferred on lathe (seconds)
The G04 command is a non modal dwell command that halts all axis movement for a specified time while the spindle continues revolving at the specified rpm.
A dwell is used largely in drilling operations
N30 G04 U2 (Dwell for 2 seconds)
Inch/metric command change; G20/G70, G21/G71
G20/G21;
G20/70 : Inch command G21/71 : Metric command
G20/70 and G21/71 selection is meaningful only for linear axes and it is meaningless for rotary axes.
Position command methods ; G90, G91
By using the G90 and G91 commands, it is possible to execute the next coordinate commands using absolute values or incremental values.
The R-designated circle radius and the center of the circle determined by I, J, K are always incremental value commands.
G90 Xx1 Yy1 Zz1
G90 :Absolute value command G91 :Incremental command
(1) Regardless of the current position, in the absolute value mode, it is possible to move to the position of the work piece coordinate system that was designated in the program.
N 1 G90 G00 X0 Y0 ;
In the incremental value mode, the current position is the start point (0), and the
(2) For the next block, the last G90/G91 command that was given becomes the modal.
(G90) N3 X100. Y100.;
The axis moves to the work piece coordinate system X = 100mm and Y = 100mm position.
(G91) N3 X–100. Y50.;
The X axis moves to -100. mm and the Y axis to +50.0 mm as an incremental value, and as a result X moves to 100.mm and Y to 100.mm.
(3) Since multiple commands can be issued in the same block, it is possible to command specific addresses as either absolute values or incremental values.
N 4 G90 X300. G91 Y100.;
The X axis is treated in the absolute value mode, and with G90 is
moved to the work piece coordinate system 300 mm position. The Y axis is moved +100.mm with G91.
As a result, Y moves to the 200.mm position. In terms of the next block, G91 remains as the modal and becomes the incremental value mode.
Synchronous feed; G94, G95
Using the G95 command, it is possible to assign the feed amount per rotation with an F code.
When the G94 command is issued the per-minute feed rate will return to the designated per-minute feed mode.
Command format G94;
G95;
G94 : Per-minute feed (mm/min) F1 = 1mm/min)
G95 : Per-revolution feed (mm/rev) feed) (F1 = 0.01mm/rev)
The G95 command is a modal command and so it is valid until the G94 command (per- minute feed) is next assigned.
G Codes: Canned Cycles
A canned cycle simplifies the program by replacing complex machining sequences, programmed by several blocks of information, with just one or two blocks.
• G73 - G89 – Canned cycles
• G73 - High speed peck drilling cycle G87- Rectangular
• G74 - Left hand tapping cycle pocket canned cycle
• G76 - Precision boring cycle G88- Circular pocket
• G80 – Cancel canned cycle canned cycle
• G81 – Drilling cycle G98 – The tool, after
• G83 – Peck drilling cycle the canned cycle is
• G84 – Right Hand Tapping cycle done, return to the
G Codes: Cutter Compensation
• G40 – Cancel cutter diameter compensation.
• G41 – Cutter compensation left.
• G42 – Cutter compensation right.
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
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. These commands are called
“modal”.
Modal G-Code List
• G00 Rapid Transverse
• G01 Linear Interpolation
• G02 Circular Interpolation, CW
• G03 Circular Interpolation, CCW
• G17 XY Plane
• G18 XZ Plane
• G19 YZ Plane
• G20/G70 Inch units
• G21/G71 Metric Units
• G40 Cutter compensation cancel
• G80 Cancel canned cycles
• G81 Drilling cycle
• G82 Counter boring cycle
• G83 Deep hole drilling cycle
• G90 Absolute positioning
• G91 Incremental positioning
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
1. Fixed sequential format
0050 00 +0025400 +0012500 +0000000 0000 00 0060 01 +0025400 +0012500 -0010000 0500 08 0070 00 +0025400 +0012500 +0000000 0000 09
2. Tab sequential format
0050 TAB 00 TAB +0025400 TAB +0012500 TAB +0000000 TAB TAB 0060 TAB 01 TAB TAB TAB -0010000 TAB 0500 TAB 08
0070 TAB 00 TAB TAB TAB -0000000 TAB 0000 TAB 09
3. Word address format