# Standard G Code and M Code | CNC programming basics

Table of Contents

# Standard G Code and M Code | CNC programming basics

## CNC part Programming :

The part programming contains the list of coordinate values along the X, Y and Z directions of the entire tool path to finish the component. The program should also contain information, such as feed and speed. Each of the necessary instructions for a particular operation given in the part program is known as an NC word. A group of such NC words constitutes a complete NC instruction, known as block. The commonly used words are N, G, F, S, T, and M. The same is explained later on through examples.

Hence the methods of part programming can be of two types depending upon the two techniques as below

(a) Manual part programming,and
(b) Computer aided part programming

Read more : Bobcad CAM – CNC programming software for Machining ,Turning

## STANDARD G AND M CODES

The most common codes used when programming NC machines tools are G-codes (preparatory functions), and M codes (miscellaneous functions). Other codes such as F, S, D, and T are used for machine functions such as feed, speed, cutter diameter offset, tool number, etc. G-codes are sometimes called cycle codes because they refer to some action occurring on the X, Y, and/or Z-axis of a machine tool. The G-codes are grouped into categories such as Group 01, containing codes G00, G01, G02, G03, which cause some movement of the machine table or head. Group 03 includes either absolute or incremental programming. A G00 code rapidly positions the cutting tool while it is above the work piece from one point to another point on a job. During the rapid traverse movement, either the X or Y-axis can be moved individually or both axes can be moved at the same time. The rate of rapid travel varies from machine to machine.

The total numbers of these codes are 100, out of which some of important codes are given as under with their functions :

## G-Codes (Preparatory Functions)

1. G00 Rapid positioning
2. G01 Linear interpolation
3. G02 Circular interpolation clockwise (CW)
4. G03 Circular interpolation counterclockwise (CCW)
5. G20 Inch input (in.)
6. G21 Metric input (mm)
7. G24 Radius programming
8. G28 Return to reference point
9. G29 Return from reference point
10. G32 Thread cutting
11. G40 Cutter compensation cancel
12. G41 Cutter compensation left
13. G42 Cutter compensation right
14. G43 Tool length compensation positive (+) direction
15. G44 Tool length compensation minus (-) direction
16. G49 Tool length compensation cancels
17. G 53 Zero offset or M/c reference
18. G54 Settable zero offset
19. G84 canned turn cycle
20. G90 Absolute programming
21. G91 Incremental programming

M-Codes (Miscellaneous Functions)

M or miscellaneous codes are used to either turn ON or OFF different functions, which control certain machine tool operations. M-codes are not grouped into categories, although several codes may control the same type of operations such as M03, M04, and M05, which control the machine tool spindle. Some of important codes are given as under with their functions

• M00 Program stop
• M02 End of program
• M03 Spindle start (forward CW)
• M04 Spindle start (reverse CCW)
• M05 Spindle stop
• M06 Tool change
• M08 Coolant on
• M09 Coolant off
• M10 Chuck – clamping
• M11 Chuck – unclamping
• M12 Tailstock spindle out
• M13 Tailstock spindle in
• M17 Tool post rotation normal
• M18 Tool post rotations reverse
• M30 End of tape and rewind or main program end
• M98 Transfer to subprogram
• M99 End of subprogram

Sachin Thorat

Sachin is a B-TECH graduate in Mechanical Engineering from a reputed Engineering college. Currently, he is working in the sheet metal industry as a designer. Additionally, he has interested in Product Design, Animation, and Project design. He also likes to write articles related to the mechanical engineering field and tries to motivate other mechanical engineering students by his innovative project ideas, design, models and videos.

This site uses Akismet to reduce spam. Learn how your comment data is processed.