In CNC machining, the reason why machine tools can accurately complete complex processes such as milling, drilling, and turning according to drawings relies on a standardized set of digital instruction languages. Among them, G code and M code are the two most basic and core types of instructions in CNC programs: G code controls the motion trajectory and machining method of the tool, and M code controls the auxiliary actions and switch values of the machine tool. The two work together to form the basic skeleton of the CNC program.
The essence of a numerical control program is to use standardized instructions to tell the machine tool "where the tool is going, at what speed, whether the spindle is rotating, and whether the cooling is turned on or off". The division of labor between G code and M code is clear, and they jointly complete the control of a complete set of machining actions.
G-code: Prepare functional instructions to control motion and processing modes
G code, also known as preparation function instruction, consists of the letter G and two digits. Its core function is to define the motion mode, coordinate system, compensation state, and machining cycle of the tool, and determine the trajectory and mode of cutting the workpiece by the tool.
It controls the relative motion between the tool and the workpiece, directly determining the shape and accuracy of the machining;
Most G-code is a modal instruction that, once activated, continues to persist until it is replaced by other instructions in the same group.
M code: Auxiliary function instruction, controlling switches and processes
M code, also known as auxiliary function instruction, consists of the letter M and two digits. Its core function is to control the auxiliary actions and program flow of the machine tool, such as spindle start stop, cooling switch, tool change, program end, etc. It does not directly participate in tool path control.
It controls the logic switches and auxiliary mechanisms of the machine tool, ensuring the auxiliary conditions for the machining process;
Most M code is a non modal instruction that only takes effect in the current program segment and is executed once to complete.
Simply put, G code is responsible for "how to cut", while M code is responsible for "how to perform machine tool matching actions". Only by combining the two can a complete machining process be formed.
广东省东莞市长安镇涌头社区涌业东路4号2号楼102室
+86 137 3616 7873
sales@richengjm.com
版权所有©Copyright 2023东莞市日诚精密科技有限公司 技术支持:海川科技