M code is a part of the overall program, often called G code. While G commands describe positions, M code directs the machine's actions. While M represents miscellaneous codes, some refer to it as machine code because it controls particular operations of the equipment.
Both G and M codes have specialized uses in programming a CNC machine.
Without M codes, you may direct tools to a spot and tell them to move in a line or arc, but you won't have any success giving more direct commands, like to stop programs, change tools, flood the system with coolant or other actions beyond the three main movements G codes control. That's why you can think of M codes as directing non-cutting operations.
The dialect used for G and M codes varies by machine.
Using M commands allows the machinist to tell the device to change tools, turn on the spindle, send coolant to the system or open the doors. Dozens of M operations exist, and operators learn how to program to execute desired actions fast.
Other letters have different functions in the program, which tend to be the same, regardless of a machine's dialect.
- N: The N value gives the line number.
- G: The G number tells when the tool to move and stop.
- X, Y, Z: These values indicate the position of the tool in three dimensions — X for horizontal, Y for vertical and Z for depth.
- F: F relates to how quickly the machine feeds the piece.
- S: S tells the machine how quickly to move the spindle.
- T: The T tells the machine which tool to use.
- M: M values give miscellaneous functions or machine functions, telling the device how to act by giving on and off directions.
- I and J: These values indicate the incremental center of any arcs the machine makes.
- R: R gives the radius of arcs made by the machine.
- A: A values direct the tool around the x-axis.
- B: The number with B shows the rotational value around the y-axis.
- C: An auxiliary axis that rotates around the z-axis gets its positional value from the C value.
- D: This number shows how much the system offsets the tool diameter.
- L: L gives the system a value to indicate repeating operations and how many times they need to loop.
- P: The program jumps in time or a delayed time with the P command.
Other alphanumeric designations depend on the machine's capabilities.