next up previous contents index
Next: 10.2 Numbers Up: 10. G Code Basics Previous: 10. G Code Basics   Contents   Index

10.1 Blocks

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.

  1. An optional block delete character, which is a slash / .
  2. An optional line number.
  3. Any number of segments, where a segment is a word or a comment.
  4. An end of line character.
The interpreter allows words starting with any letter except N (which denotes a line number and must be first) to occur in any order. Execution of the block will be the same regardless of the order.

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:

Whenever you write nc programs, you would do well to be considerate of others who may have to read that code, even though the interpreter itself does not care about white space and case. Unless you are really up against the 256 character block size limit, white space between words and the absence of it within words makes a block much easier to understand.

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:

Don't worry to much about modal codes or the order of execution of the words within a block of nc program just yet. These will become clear as you work your way through the definitions of the permissible words listed in the next unit.

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.


next up previous contents index
Next: 10.2 Numbers Up: 10. G Code Basics Previous: 10. G Code Basics   Contents   Index
root 2003-05-26