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 (optional)
- Number of blocks
- Program end
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)
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.