Introduction
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
computer numerical control (CNC) software. It is the task
of preparing a program sheet from a drawing sheet. All
data is fed into the CNC system using a standardized
format. Programming is where all the machining data are
compiled and where the data are translated into a
language which can be understood by the control system
of the machine tool.
Basic concepts of part programming, NC words,
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
Types of Part programming
The types of part programming can be of two
types depending upon the two techniques as
below : (a) Manual part programming, and (b)
Computer aided part programming
While preparing a part program, need
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
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
Decode coded 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 G-codes 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.
Part programming formats,
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
Type Programming Format Both
EIA and ISO
formats for compiling of NC data into suitable blocks
of information with slight difference.
Word Address Format This type of tape format uses
alphabets called address, identifying the function of
numerical data followed. This format is used by most
of the NC machines, also called variable block
format. A typical instruction block will be as below :
N20 G00 X1.200 Y.100 F325 S1000 T03 M09
<EOB> or N20 G00 X1.200 Y.100 F325 S1000 T03
M09; The MCU uses this alphabet for addressing a
memory location in it.
Tab Sequential Format
Here the alphabets are replaced by a Tab code, which is
inserted between two words. The MCU reads the first Tab and
stores the data in the first location then the second word is
recognized by reading the record Tab. A typical Tab sequential
instruction block will be as below :
>20 >00 >1.200 >.100 >325 >1000 >03 >09
Fixed Block Format
In fixed block format no letter address of Tab code are
used and none of words can be omitted. The main
advantage of this format is that the whole instruction
block can be read at the same instant, instead of reading
character by character. This format can only be used for
positioning work only. A typical fixed block instruction
block will be as below:
20 00 1.200 .100 325 1000 03 09 <EOB> 4
Manual part programming:
Axis Designation
The programmer also determines how many axes are availed on
machine tool. Whether machine tool has a continuous path and point-
to-point control system .
NC Words
The NC word is a unit of information, such as a dimension or feed rate
and so on. A block is a collection of complete group of NC words
representing a single NC instruction. An end of block symbol is used to
separate the blocks. NC word is where all the machining data are
compiled and where the data are translated in to a language, which
can be understood, by the control system of the machine tool.
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 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
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
N50 G00 X25400 Y125 Z0 F0
N60 G01 Z-10000 F500 M08
N70 G00 Z0 M09
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
N135 G01 X1.0 Y1.0 Z0.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
WORD-ADDRESS CODING
Example CNC Program
N5 G90 G20 Each instruction to the machine
N10 M06 T3 consists of a letter followed by a
N15 M03 S1250 number.
N20 G00 X1 Y1
N25 Z0.1
N30 G01 Z-0.125 F5 Each letter is associated with a
N35 X3 Y2 F10 specific type of action or piece of
N40 G00 Z1 information needed by the machine.
N45 X0 Y0
N50 M05 Letters used in Codes
N55 M30
N,G,X,Y,Z,A,B,C,I,J,K,F,S,T,R,M
G Codes
G00Rapid traverse G40 Cutter compensation –
G01 Linear interpolation cancel
G02 Circular interpolation, G41 Cutter compensation – left
CW G42 Cutter compensation-
G03 Circular interpolation, right
CCW G70 Inch format
G04 Dwell G71 Metric format
G08 Acceleration G74 Full-circle programming off
G09 Deceleration G75 Full-circle programming on
G17 X-Y Plane G80 Fixed-cycle cancel
G18 Z-X Plane G81-G89 Fixed cycles
G19 Y-Z Plane G90 Absolute dimensions
G20 Inch Units (G70) G91 Incremental dimensions
G21 Metric Units (G71)
M Codes
M00 Program stop
M01 Optional program stop
M02 Program end
M03 Spindle on clockwise
M04 Spindle on counterclockwise
M05 Spindle stop
M06 Tool change
M08 Coolant on
M09 Coolant off
M10 Clamps on
M11 Clamps off
M30 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
G01 Linear Interpolation
Format: N_ G01 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
G01 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 45o 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
G01 Linear Interpolation
25
B C
20
15
10 Positioning motion from A to C
A N10 G00 X30000 Y20000 F0
5
5 10 15 20 25 30
G02 Circular Interpolation
G02 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 G02 code is programmed,
the center of the arc is given by specifying its location
relative to the start of the arc.
G02 Circular Interpolation (CW)
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
G02 Circular Interpolation (CW)
Circular interpolation from A to B
about a circle centered at C
N10 G02 X20000 Y10000
25 I5000 J15000 F2500
I=5 A C
20
15
J=15
10 B
C
5
5 10 15 20 25 30