Structure of an NC Program

An NC program is a text that is normally stored as a sequence of ASCII codes in a file on the hard disk. It consists of a sequence of NC blocks separated by line breaks (Return). Usually it is executed by being interpreted and worked through, character by character and line by line.

Program structure

The NC program is thus composed of three parts

Program start

At the beginning of an NC program the character "%" can represent the start of the program. The name of the program is then found following this character. The block for the program start does not necessarily have to be programmed.

Sample:

% Test1 (program start)
N10 G0 X100 Y100 Z0
M30 (program end)

NC block

Each NC block consists of one or several NC words, or even of none (an empty line), separated by spaces or tab characters. It is therefore not possible to use a space within a word.

Sample:

N10 G0 X100 Y100 Z0 

NC word

The first character of an NC word specifies its meaning. It is either a letter or a special character.

Upper/lower case has, in general, no significance. Uniform use of upper case is, however, recommended for the sake of better readability. The optional following characters specify the meaning more precisely, or supply parameters for the execution.

In order to manage with such a limited supply of characters, an expression is not available for every variation of every function. It is rather the case that the significance and effect of many NC words is determined partly by the context. This can be a matter of the foregoing words in the block, but it can also depend on previous NC blocks. In a few cases the effect of NC words even depends on the machine data.

Program end

The end of the program is indicated by an M-function. Either M2 or M30 is used for this.

Effective Duration of Words

Commands such as G0 or G17, that have effects beyond the end of the block, are known, according to DIN 66025, as modal. These commands are effective as long as they are neither cancelled nor altered by another command.

Comments

If either parts of an NC block, or the whole of it, is not to be interpreted, the region concerned is to be placed within curved brackets.

Sample:

N10 G0 X100 (comment) 

Notice A comment ends with the closing bracket, or, at the latest, at the end of the block. This means that a comment can’t continue over a number of lines. Nested comments are also not possible.

Block numbers

Each block can be identified by a block number. The block number is accompanied by "N" for subordinate blocks and ":" for main blocks.

Notice The block number is not essential. A block not identified by a block number can not, however, be used as the target of a jump command. An error message, moreover, can only approximately report the location of the error (the last block number).