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
This Article takes an In-depth look at the M-Code Plain Text Language
You will learn more about topics such as:
G-Codes and Their Meaning
Fanuc G-Code List (Lathe)
Fanuc G-Code List (Mill)
The Importance of Subprograms and Macros in CNC Programming
What is CNC Machining Mini Article
G-Codes and Their Meaning
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. When a user gets curious, they may want to look at the commands for their CNC device. Though G-code may not be easily readable for most people, it is possible to examine a file to see the commands that have been programmed for a machine.
Though G-code is a standard language for CNC machines, there are variations between manufacturers regarding how they are used. Different vendors produce controllers designed to receive information from AutoCAD or CAM. How the commands are interpreted depends on how the controller has been programmed.
CNC programs use the various commands in conjunction with other lettered instructions to direct a CNC machine‘s operations. G-codes instruct the machine to perform certain functions for a lathe or mill while M-codes handle the operation of the machine using additional lettered codes representing addresses such as F for feed rate and S for spindle speed.
Although G-codes are generally self-explanatory, a number of conventions are used in CNC programming. Programs start and end with the percent symbol. The program is always named using the format of O0001 to O9999. G-codes are modal. Any command remains active until canceled or reset by another command. Tools move according to interpolation, a combining of changes in both X and Y coordinates. CNC commands are either linear interpolation or circular interpolation where a tool can move along both axes simultaneously.
Setting for work coordinate system or clamp at maximum spindle speed
Return to initial point in canned cycle
Return to R point in canned cycle
The Importance of Subprograms and Macros in CNC Programming
The M98 command calls up a subprogram followed by a number to tell the machine how many times to repeat the subprogram. A M-code, M99, ends the subprogram. M98 P53000 is a subprogram where P indicates the program number O3000, and 5 is the number of times the subprogram will repeat. Another version of a subprogram, as seen on FANUC controllers, follows the form of M98 P3000 L5. As with the previous example, M98 indicates a subprogram. P3000 is the subprogram O3000 while L5 is how many times it will repeat. Subprograms are used for a variety of operations such as indexing the Z-axis between repeating cuts. In both scenarios, M99 returns the controller to the main program or previous subroutine if they are nested. Another common subprogram resets modal statuses before or after a tool change, which is a safety measure.
A M97 subprogram references a line number in a program. The line number must be a machine program line number. The M97 code does not require separate programming and tells the selected line to repeat. As with M98 subprograms, a M97 code ends with M99.
Every CNC machine comes with a set of preprogrammed functions for the convenience of the users. These built in programs are also considered to be subprograms and are called up in G-code. The instructions for a machine describes the pre-existing codes and their function.
Macro programming offers a way to shorten codes and allow repetitive tasks easily and quickly. Feeds, applications for varied materials, and speeds can be adjusted using macro programming. Macro programming can change coordinate data and parameter settings to adjust G-Codes.
Macro programming makes it possible for the same program to machine several part sizes as they appear in a drawing. The variations are assigned addresses located in the program. G00 X#123 tells the machine to move to the location stored in variable address 123. Macros must be used carefully since changes can cause unexpected motions, crashes, and machine malfunctions.. Commanding a machine to perform a function too quickly may damage the part or machine. It is customary for CNC programmers to build checks to avoid such disasters.
G-codes and the other letter codes have become a common part of modern manufacturing. Engineers, operators, and other users need to understand the relationship between these essential codes and the actions of a CNC machine. A complete understanding of their importance can prove to be beneficial.
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.
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.
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.
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.
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.
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.
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 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.
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.
Fanuc M-Codes and their description for a Mill and Lathe
The types of commands programmed into a CNC machine
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 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...
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...
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...
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?
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 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...