Editorial by Industrial Quick Search

Computer Numerical Control (CNC) and CNC M-Codes

Contact Companies

Please fill out the following form to submit a Request for Quote to any of the following companies listed on


Get Your Company Listed on this Power Page


Computer numerical control (CNC) is a fundamental part of modern manufacturing. The majority of machines operate using instructions and guidelines that have been downloaded using a CNC program controller. For a machine to interpret the commands from CNC, the commands have to be entered using G and M codes. CNC operators are required to know the appropriate codes and instructions as well as how to use them. Both types of coding are necessary for the system of a CNC device to perform correctly.

CNC Machining

M-code is a part of the language that AutoCAD and CAM, computer aided manufacturing, use to input instructions into CNC machines. G-codes and M-codes work in unison for positioning a workpiece and guiding the machine‘s actions. M-codes, miscellaneous or machine codes, control the operations of the equipment telling it when to operate or cease operation. While the G-code can direct a machine to move in a line or arc, once the tool is positioned, it won‘t know to stop, change tools, add coolant, or complete any other actions, which are provided by M-codes. Instructions for a tool to turn on or off is part of the M-code language.

The use of M-codes varies depending on the machine. During programming, one M-code is required per code block giving the commands for a tool to turn on or off and activate other operations. Having more than one M-code in a code block can cause problems. The definition of M-code functions and their uses is spelled out by the machine‘s manufacturer.

Operators use M-codes to tell a machine to change tools, turn on the spindle, load coolant, or open and close a door. There are several M-codes that operators need to know for a machine to perform properly. Also, each machine has a different method for downloading the M-codes. One controller may require a zero between the M and the number while others don‘t need the zero. The particular method for a machine is clearly laid out in the instructions from the manufacturer.

Leading Manufacturers and Suppliers

GET YOUR COMPANY LISTED ABOVE

The types of commands programmed into a CNC machine

M-codes are an important component of the operation of a CNC machine. While G-codes describe the positioning for an operation, M-codes provide data for a machine‘s actions. For the proper functioning of a CNC machine, G and M codes have to be entered. They work in tandem and together to instruct, guide, and program the responses of a CNC device. As with any computer, CNC machines have a controller for data input. Though most computer languages are built on C or C++, there are variations for each type of controller.

Fanuc manufactures robotic controllers that use M-codes for commands for CNC machines. Their controllers use the M zero number form of M-codes. Below are several of the Fanuc controller M-codes.

  • M00 Program stop
  • M01 Optional program stop
  • M02 End of program
  • M03 Spindle start forward CW
  • M04 Spindle start backward CCW
  • M05 Spindle stop
  • M08 Coolant on
  • M09 Coolant off
  • M29 Rigid tap mode
  • M99 End of program

M commands are part of an information group that determines how and when a machine should start or stop an action. Beginning with M00 they continue in an arithmetic progression to M99, which ends the program. How an M-code is used differs between vendors and producers. In many cases, not every M-code is programmed into the machine. Knowing the codes and how they make the machine function is critical. In some cases, when a code is not used or programmed, the definition of the code is left to the discretion of the user.

Examples of the programmable codes for a lathe and milling operation are listed below. Table 1 has codes for a lathe while table 2 has the M-codes for a milling operation. Both tables are examples of M-codes for Fanuc controllers.

Fanuc M-Code List (Lathe)

Table data source
M code Description
M00 Program stop
M01 Optional program stop
M02 End of program
M03 Spindle start forward CW
M04 Spindle start reverse CCW
M05 Spindle stop
M08 Coolant on
M09 Coolant off
M29 Rigid tap mode
M30 End of program reset
M40 Spindle gear at middle
M41 Low Gear Select
M42 High Gear Select
M68 Hydraulic chuck close
M69 Hydraulic chuck open
M78 Tailstock advancing
M79 Tailstock reversing
M94 Mirrorimage cancel
M95 Mirrorimage of X axis
M98 Subprogram call
M99 End of subprogram

Fanuc M-Code List (Mill)

Table data Source
M code Description
M00 Program stop
M01 Optional program stop
M02 End of program
M03 Spindle start forward CW
M04 Spindle start reverse CCW
M05 Spindle stop
M06 Tool change
M07 Coolant ON – Mist coolant/Coolant thru spindle
M08 Coolant ON – Flood coolant
M09 Coolant OFF
M19 Spindle orientation
M28 Return to origin
M29 Rigid tap
M30 End of program (Reset)
M41 Low gear select
M42 High gear select
M94 Cancel mirrorimage
M95 Mirrorimage of X axis
M96 Mirrorimage of Y axis
M98 Subprogram call
M99 End of subprogram

There may be some confusion regarding the codes for CNC machines since some operators refer to all codes as being G-codes even though they input both G and M codes. To avoid misinformation and misunderstandings, it is important to know that every code block has to have one M-code to begin and end a function. The G-code tells the machine where and when to do a job. M-codes stop an operation, end a programmed task, or begin a movement after the tool has been positioned.

Custom CNC Machining

Most parts and products produced by CNC machines are programmed using CAD or CAM software that give directions for CNC machines using alphanumeric programming. Even though engineers are fluent in those two forms of software, it is still important for them to have an understanding of how G and M codes direct a CNC machine.

Leading Manufacturers and Suppliers

GET YOUR COMPANY LISTED ABOVE

What is CNC Machining?

CNC machining is an electromechanical process that manipulates tools around three to five axes, with high precision and accuracy, cutting away excess material to produce parts and components. The initial designs to be machined by CNC machining are created in CAD, which is then translated into CNC codes to provide programmed instructions to the tools in a CNC machine.

CNC machining produces cutting edge quality on turned components using a wide variety of applications that require vertical and horizontal machining.

CNC Machine Parts

The multitasking ability of CNC machines allows for the completion of a component or part in a single operation, with ease and efficiency. The types of applications performed by CNC machines include bushings, collars, fasteners, fittings, inserts, machined components, machined washers, pins, nuts, spacers, spindles, standoffs, drive shafts, and splined shafts to name a few.

The CNC Machining Process

CNC or Computer Numerical Control machining is a logical and rational process that is planned and designed for the efficient production of parts. The computer controlled machines perform a variety of tasks that have been programmed into the equipment, which begins with creating a two or three dimensional rendering on a computer.

Once the design file is loaded and coded, the machine performs each operation according to the design parameters.

The CNC Machining Process

The difference between CNC machining and other manufacturing processes is that it is a subtractive process that removes layers of material to achieve a particular shape.

Computer Programming

The key to the success of CNC manufacturing is the initial programming. The software must be coded with the proper instructions keeping the machine within its limitations. The processes for CNC equipment are derived from the person who creates its instructions. Care is taken in the development of the programmed instructions to avoid errors and loss of production time.

CAD CAM Part Program

Computer Aided Design (CAD) and Computer Aided Manufacturing (CAM)

CAD-CAM is a descriptive term for the software used for designing and machining parts and components using a CNC machine. CAD is software used to design, draw, create, and shape parts through the use of geometric shapes and constructs. CAM, on the other hand, takes the information from CAD and translates it into machine language, which is referred to as G-Code.

Before the CAD designed model can be changed into machine language, the CAM software determines the cutting paths for the tools for the removal of the excess material from the workpiece. CAD and CAM work together to provide the CNC machine with the proper and accurate instructions to perform the necessary cutting operations.

CAD-CAM Process

CNC Machine Setup

Before the CAD-CAM program can be downloaded into the machine, it has to be set up with the proper cutting tools. There are two methods for completing tool changing. The first method is by pulling tools from the tool cart and placing them in the machine.

The second method is an ATC or automatic tool changer, which has tools stored on a drum or chain. When programmed with the required tools, the ATC removes the old tool and inserts the new one. The purpose of an ATC is to save time and increase efficiency.

An important part of CNC machine setup is the establishment of the gage point, which is how long the tip of the tool is from a point of reference. The proper setting of this part of the process ensures that the tool will cut to the appropriate depth. One of the final steps in CNC machine setup is the testing of coolant or lubricant. Coolant is delivered by either air, mist, flood, or high pressure. An essential part of checking the coolant is determining the pressure at which it is delivered. The wrong pressure can lead to tool damage, while the wrong amount can damage the machine and equipment.

An unfortunate error made when setting up a CNC machine is failure to check the coolant, which can smell bad, have an insufficient amount, be of low concentration, or may not be appropriately filtered.

CNC Tool Cart

Work Holding

The work holding is a device that is used to secure, support, and mount the workpiece. Also referred to as a CNC fixture, it ensures conformity and interchangeability as well as smooth operation. Unlike a jig, the work holding device secures, supports, and stabilizes the workpiece.

Much like the tools used on a CNC machine, work holding fixtures come in several different types, which include turning, milling, drilling, boring, and grinding.

Drilling Fixture

Loading the G-Codes

G-codes have been accepted as the universal language for CNC machining. Though there are standard G-codes for all CNC machines, manufacturers will change G-codes to make them specific to their machines. There is a G-code for every movement of the cutting tools in a CNC machine.

Though various forms of software will create G-codes from a CAD design, they can also be handwritten or conversational, which does not require the use of a CAD design. G-codes can be loaded into the CNC machine using a USB, directly from the CAM computer, or programmed directly into the machine.

Program Proofing

Program proofing is the final step before making the actual cuts. The purpose of proofing is to determine if the program is correct, and that the CNC machine setup is accurate to avoid problems with the g-code.

This process is used to examine if there are any errors in the g-code. Proofing can be accomplished by cutting air, where the machine runs through the cutting process without cutting the workpiece. Cutting air is time consuming and ties up the machine. Another method is g-code simulator, a computer program that simulates the CNC process.

Machining the Part

Once all the preparations have been completed, it is time to insert the workpiece and do the cutting. The first workpiece must be watched carefully as it goes through the CNC process. It is the prototype for all of the parts to follow and will provide data and information regarding the success of the programming.

CNC Milling Operations

Execution

After the setup and testing processes are completed, the CNC machine is put into production. CNC machining allows producers to manufacture parts faster, more efficiently, and safely with every part being an exact duplicate of the original design.

Read Next: CNC G-Code Commands

In this article you will learn:

  • G-Codes and their meaning
  • Fanuc G-Codes and their description for a Mill and Lathe
  • The importance of subprograms and macros in CNC programming

Table of Contents

Loading Leading
Category Companies:

  • IQS Homepage
  • All Articles
  • GET YOUR COMPANY LISTED

Related Posts

5 Axis CNC Machining

5 Axis CNC Machining

The normal functioning of CNC machines is done along the three Z, X, and Y axes. The five axes machines have two more axes accessible, which are namely A and B. The addition of the two extra axes makes it easy to cut complex and intricate parts...

CNC Machining

CNC Machining

CNC machining is an electromechanical process that manipulates tools around three to five axes, with high precision and accuracy, cutting away excess material to produce parts and components. The initial designs to be machined by CNC machining are created in CAD...

CNC Milling

CNC Milling

The CNC process was developed in the 1950‘s and took a leap forward in the 1980‘s with the addition of computerization. Unlike other production processes, CNC begins with a rendering by a computer, which creates a two or three dimensional representation of the part to be produced...

G-Code

G-Code

G-code is the name of a plain text language that is used to guide and direct CNC machines. For most modern CNC machines, it isn‘t necessary to know the meaning of G-codes since CAD and CAM software is translated into G or M codes to instruct a CNC machine on how to complete a process...

Types of Machining

Types of Machining

Machining is a manufacturing process used to produce products, parts, and designs by removing layers from a workpiece. There are several types of machining that include the use of a power driven set of machining tools to chip, cut, and grind to alter a workpiece to meet specific requirements...

What is CNC?

What is CNC

The CNC process, computer numerical control, is a method of manufacturing where programmed software directs the operation of factory tools and machinery. It is designed to manage a wide range of complex machines from grinders and lathes to mills and routers...

Contract Manufacturing

Contract Manufacturing

Contract manufacturing is a business model in which a company hires a contract manufacturer to produce its products or components of its products. It is a strategic action widely adopted by companies to save extensive resources and...

© IQS Directory . All Rights Reserved.