Numerical Control Programming
Chapter 2
How Does Numerical Control Work?

N/C Formats and Grammar

An N/C program consists of a series of commands organized in a manner the controller can understand (and in a sequence that will result in an acceptable piecepart). The English language has its rules of spelling, punctuation, and grammar. Likewise, N/C programming has its rules. Each English language sentence has to have a noun and a verb, begin with a capital letter, and end with a period. An essay has to be properly structured to convey the author's thoughts to the reader in a manner the reader can understand and accept. Fewer and simpler (but similar) rules exist for N/C programming. The programmer has to write the program in a structure that the N/C controller can understand and accept. The rules that determine the structure of the program are called program syntax. Program syntax is much more rigid than English syntax because a N/C controller cannot infer the meaning of a command. It can understand a command only if the command is presented to the controller in exactly the form it expects.

Back to the top of this page

Blocks and Statements

The program format is the arrangement of the data that make up the program. Commands are fed to the controller in units called blocks or statements. A block in N/C language is similar to a sentence in the English language. An English sentence constitutes a complete statement. Similarly, an N/C block constitutes a complete statement. English sentences are separated by periods. Similarly, N/C blocks are separated by the End-Of-Block (EOB) character. An N/C block or statement consists of all the information contained between successive EOB characters. The EOB character is usually generated by pressing the Enter or return key on the data-entry terminal. A succession of English sentences makes up an essay. Similarly, a succession of N/C blocks makes up a program. The EOB character signals the controller to execute the commands contained in the block. The same EOB character that ends one block also signals the start of the next block.

Blocks are made up of one or more commands such as axis commands or feedrate commands. The arrangement (format) of command information within each block is very important. There are three such formats that have been used in N/C programming. These are (1) fixed sequential, (2) tab sequential, and (3) word address. Two of the formats, fixed sequential and tab sequential, are obsolete, that is they are not used on new N/C equipment. But there still are many pieces of older N/C equipment in use that use fixed or tab sequential formatting, so it would be wise to be familiar with both of them.

Back to the top of this page

The Fixed Sequential Format

The fixed sequential format requires that specific command data items be organized together in a definite order to form a complete statement or block of information. Every block must have exactly the same number of characters. As shown in Figure 2.6, the significance of each character depends on where it is located in the block.

Figure 2-6

The N/C controller has electronic pigeonholes called registers. Program information in the form of electronic pluses, minuses, and the digits zero (0) through nine (9) are placed into these registers.

The first register, the sequence number register, accepts four data characters, all numerals. The second register, the preparatory function register, receives two numeral characters. The third, fourth, and fifth registers, for the X-axis, Y-axis, and Z-axis drives, respectively, receive seven characters each (the first of which must be a plus or a minus sign). Registers six and seven are for feedrate and miscellaneous commands. These registers receive four and two characters each, respectively.

So with this particular fixed sequential format structure, thirty-three characters must be entered into each and every block and the seventh, fourteenth, and twenty-first characters must be a plus or minus sign to indicate axis motion direction. A decimal point is assumed (but not entered) between the second and third digit of each axis group and the feedrate group. Thus a decimal is assumed to follow the ninth, sixteenth, twenty-third, and twenty-ninth character of each block. The specific number of characters, their order, and the assumed decimal placement can vary according to the make of controller.

No characters can be omitted and no extra characters can be included because doing either will place other characters in the wrong register. Blank spaces, called null characters, must be used if no command data are to be given. Just as the name implies, the fixed sequential format requires that a fixed number of data characters be entered in an exact sequence. No exceptions!

Back to the top of this page

The Tab Sequential Format

The tab sequential format is just like the fixed sequential format except that null characters do not need to be placed into pigeon holes for which there are no data. Instead, a single character that is produced by the TAB key on the data entry terminal is placed into all registers that aren't to receive any data characters. It tells the controller to "skip over" those registers. The nice thing about tab sequential formatting is that program printouts are "columnized." All X-axis data are in one column, Y-axis data in another column, Z-axis in another, etc., making the printout easier to read. Otherwise, the tab sequential format is the same as the fixed sequential format. Both are obsolete--but still in use.

Back to the top of this page

The Word Address Format

The word address format features an address for each data element to permit the controller to assign data to their correct register in whatever order they are received. A single alpha character (said to be a "word") is used to identify each register. The Electronics Industries Association (EIA) has developed, and the American National Standards Institute (ANSI) has adopted, a standard format for N/C data, ANSI/EIA-274-D. This standard is followed by most N/C equipment manufacturers. EIA-274-D assigns specific letters as address words for the various registers. Most N/C controllers use the address words F, G, I, J, K, M, N, S, T, X, Y, and Z.

The more complex N/C machines, such as five-axis machining centers, have more functions to perform and require more registers. Additional address words, such as A, B, and C, are used to indicate rotation about the X, Y, and Z axes. Address words are usually assigned to registers as shown in Table 2.1.
ARotation about the X-axis
BRotation about the Y-axis
CRotation about the Z-axis
FFeedrate commands
GPreparatory commands
ICircular interpolation X-axis offset
JCircular interpolation Y-axis offset
KCircular interpolation Z-axis offset
MMiscellaneous commands*
NSequence number
RArc radius
SSpindle speed
TTool number
XX-axis data
YY-axis data
ZZ-axis data
* Occassionally the letter "O" is used for sequence numbers dealing with secondary axis commands.
Table 2.1 - Address Words

Each data item must be preceded by the address word, which indicates to which register the item is to be assigned. For example, a feedrate command of 1.2 inches per minute might be encoded F012; a cutting tool change command might select tool number 8 by encoding T08; the miscellaneous command to turn the coolant off would be encoded M09.

Word address formatting permits unneeded commands to be omitted; it also permits several different miscellaneous and preparatory function commands to be put in a single block rather than in several successive blocks. The EIA RS-274-D standard establishes a method to specify word address data. This data format specification method is used to indicate (1) which particular address words are used by a given controller, (2) the number of digits required for each register, and (3) where the decimal point is placed. For example:

N4.0 G2.0 XYZIJK2.4 F2.1 S4.0 M2.0

This data format specification is interpreted to mean that sequence numbers (N) have four digits to the left of the decimal point and zero digits to the right; in other words they are four-digit integers and can range in value from 0000 to 9999. The X, Y, Z, I, J, and K commands all have two digits to the left and four digits to the right of the decimal point, permitting command values 0.0000 to 99.9999 inches. A feedrate (F) command has two digits to the left and one to the right of the decimal, permitting feedrate commands from 00.1 to 99.9 inches per minute. Spindle speed (S) commands can have four digits to the left and zero digits to the right of the decimal, a value range from 0001 to 9999 RPM. Miscellaneous (M) commands can have two digits to the right and zero digits to the left of the decimal, a value range from 00 to 99.

Decimal points and trailing zeros, as shown in the preceding example, are sometimes not used in this data format specification system. For example:

N40 G20 XYZIJK24 F21 S40 M20

It is understood in such cases that the first of the two numerals accompanying each register address letter represents the number of digits to the left of the actual or assumed decimal point. The second numeral represents the number of digits to the right of the decimal point.

If only one numeral accompanies the letter, it is understood that the numeral represents the number of digits to the left of the decimal point and there are zero digits to the right; thus, numerical data for that register must consist of only whole numbers. For example:

N4 G2 XYZIJK24 F21 S4 M2

Most word address controllers permit or require decimal points to be entered. This might permit leading and/or trailing zeros to be omitted, called zero suppression. Without a decimal point and zero suppression, a 1-inch X-axis command with a X2.3 format would have to appear as X01000, a five-digit command. The command would appear as X1000 with leading zero suppression. It would appear as X01 with trailing zero suppression. Using a decimal point and with both leading and trailing zero suppression the command would appear X1.

The word address format, in theory, should permit the programmer to enter command data into a block in any order desired, but it usually doesn't work out that way. Most controllers require commands to be entered in a specific order, usually in the EIA-274-D order. Some makes of controllers vary that order somewhat. Likewise, the number of digits to be used and the placement of decimal points (whether they are actually entered or not) can vary from make to make. This is also true for fixed sequential and tab sequential formats. The programmer must always consult the programming manual for the particular N/C machine to determine the required order of data entry.

Back to the top of this page

Next:  Commands

Back to Contents Page

Updated Jan. 9, 2002
Copyright 1988-2002 by George Stanton and Bill Hemphill
All Rights Reserved