Program CNCs

Program CNCs

Xun Xu (University of Auckland, NZ)
DOI: 10.4018/978-1-59904-714-0.ch009
OnDemand PDF Download:


A CNC machine can be programmed in different ways to machine a workpiece. In addition to creating the cutting program, many other factors also need to be considered or programmed. These include workholding devices, cutting tools, machining conditions as well as the machining strategy. The first generation CNCs were programmed manually and punched tapes were used as a medium for transferring the machine control data (MCD), that is, G-codes into a controller. Tapes were later replaced by RS232 cables, floppy disks, and finally standard computer network cables. Today’s CNC machines are controlled directly from files created by CAD/CAM or CAM software packages, so that a part or assembly can go directly from design to manufacturing without the need of producing a drafted paper drawing of the component. This means that for the first time, bringing design and manufacturing under the same automation regime becomes a reachable target. Error detection features give CNC machines the ability to alert the operator in different ways including giving a ring to the operation’s mobile phone if it detects that a tool has broken. While the machine is awaiting replacement on the tool, it would run other parts that are already loaded up to that tool and wait for the operator. The focus of this chapter is on a detailed account of the basics of CNC programming, and the emphasis is on G-code and Automatic Programming Tool (APT). G-code is still the dominant manual programming language for CNC machine tools. It is also the main form of control commands many CAD/CAM (or CAM) systems output. APT was developed soon after G-codes and CNC machine tools were developed to alleviate the drudgery work of straight G-code programming. Modern CAD/CAM systems these days are now becoming the main-stream tools for CNC programming.
Chapter Preview

Program Basics

Today’s full-blown machining centres allow the programmer to control just about any function required through programmed commands. This section lists the things that the programmer can usually control within a program. Also explained is how each function is controlled. The MCD format discussed here conforms to ISO 6983-1 (1982).

Program Format

The CNC machine program is structured in blocks of data. A fixed set of alphabetic, numeric and special characters is used. Any characters that are not to be processed are included within parenthesis. Characters “:” or “%” can be used for display purposes. To identify a machine program, an identifier may be placed immediately after the program start character and before the first “end of block” character.

A block of data consists of a sequence number word and one or more than one data words (also known as NC words). Tab characters, which are optional for the tabulation of a printed copy of the data, may be inserted between words but are usually ignored by the control system. A data word always starts with an address character. The characters are usually presented in the following sequence and are not repeated within one block,

  • Preparatory words “G”;

  • “Dimension” words. These words are arranged in the following sequence: X, Y, Z, U, V, W, P, Q, R, A, B, C;

  • “Interpolation or thread cutting lead words” I, J and K;

  • “Feed function (F)” word;

  • “Spindle speed function (S)” word;

  • “Tool function (T)” word; and

  • “Miscellaneous function (M)” words.

Some words may be omitted in a specific block of data, indicating that there is no change in the condition of the machine with respect to the function denoted by the omitted word. This word is named as a “modal” word. Table 1 summarises the address characters commonly used in a modal word.

Table 1.
Commonly used address characters
AAngular dimension about X axis
BAngular dimension about Y axis
CAngular dimension about Z axis
DSecond tool function
ESecond feed function
FFirst feed function
GPreparatory function
IInterpolation parameter of thread lead parallel to X
JInterpolation parameter of thread lead parallel to Y
KInterpolation parameter of thread lead parallel to Z
MMiscellaneous function
NSequence number
PTertiary dimension parallel to X or parameter
QTertiary dimension parallel to Y or parameter
RTertiary dimension parallel to Z or parameter
SSpindle speed function
TFirst tool function
USecondary dimension parallel to X
VSecondary dimension parallel to Y
WSecondary dimension parallel to Z
XPrimary dimension X
YPrimary dimension Y
ZPrimary dimension Z

Complete Chapter List

Search this Book: