The basic unit of the nc program is the 'block', which is seen in printed form as a 'line' of text. Each block can contain one or more 'words', which consist of a letter, describing a setting to be made, or a function to be performed, followed by a numeric field, supplying a value to that function. A permissible block of input is currently restricted to a maximum of 256 characters.
The following order is required for the construction of a block.
An example of a program block would be
N0001 G0 X123.05
This block is constructed using three words, N0001, G0, and X123.05. The meanings of each of these words is described in detail below. In essence, the n word numbers the line, the g0 word tells the machine to get to its destination as quickly as it can, and the final position of the x axis is to be 123.05. Since it is constructed with a preceding slash, this block could be deleted during a run if optional block delete were activated.
There are some general considerations when writing nc code for the EMC:
There are a number of limitations about the number or types of words that can be strung together into a block. The interpreter uses the following rules:
For now it is enough to remember that a program block is more than the words that are written in it. Various words can be combined to specify multi-axis moves, or perform special functions. While a block of code has a specific order of execution, it must be considered to be a single command. All of the words within a block combine to produce a single set of actions which may be very different from the actions assigned to the same words were they placed in separate blocks. A simple example using axis words should illustrate this point.
n1 x6 - moves from the current x location to x6
n2 y3 - moves from current y location to y3 at x6
n3 z2 - moves from current z location to z2 at x6 and y3
n10 x6 y3 z2 - moves on a single line from current x, y, z to x6 y3 z2
The final position of the first three blocks (n1-n3) and the (n10) block are the same. The first set of blocks might be executed in sequence to move the tool around an obstacle while the path of the tool for the combined block (n10) might run it into the part or the fixture.
To make the specification of an allowable line of code precise, NIST defined it in a production language (With Syntax Notation). These definitions appear as Table *** at the end of this chapter. In order that the definition in the appendix not be unwieldy, many constraints imposed by the interpreter are omitted from that appendix. The list of error messages elsewhere in the Handbook indicates all of the additional constraints.