3. CNC program structure
There are four basic terms used in CNC programming. These are a follows:
Character -> Word -> Block -> Program
- Character is the smallest unit of CNC program. It can have Digit / Letter / Symbol.
- Word is a combination of alpha-numerical characters. This creates a single instruction to the CNC machine. Each word begins with a capital letter, followed by a numeral. These are used to represent axes positions, federate, speed, preparatory commands, and miscellaneous functions.
- A program block may contain multiple words, sequenced in a logical order of processing.
- The program comprises of multiple lines of instructions, ‘blocks’ which will be executed by the machine control unit (MCU).
Figure 7.1.7 shows a sample CNC program. It has basically three sections viz. initial commands section; main section and end commands section. In the initial commands section, the program number, its ID, initial safety preparatory codes such as ‘cancel all the activated cycles by previous program’ are to be specified.
In the main section, commands/instructions related the machine tool axes movements, tool change etc. are to be mentioned. At the end, the commands instructing cancellation of cycles, homing the tool and program end are to be provided.

Figure 7.1.7 Sample CNC program.
The address G identifies a preparatory command, often called G-code. This is used to preset or to prepare the control system to a certain desired condition or to a certain mode or a state of operation. For example G01 presets linear interpolation at given feed but doesnot move any axis.
The address M in a CNC program specifies miscellaneous function. It is also called as machine function. These functions instruct the machine tool for various operations such as: spindle rotation, gear range change, automatic tool change, coolant operation, etc.
The G and M codes are controller manufacturers’ specific. In this course, we will be following the G and M codes used for FANUC, Japan controller. Other controllers such as SINUMERIC, MITSUBHISHI etc. are also being used in CNC technology.
It is suggested to the readers to study the following G and M codes for milling and turning operations. Programming exercises will be carried out in the next lectures.