Glossary Updates12 new terms added to the glossaries · October 2, 2026, 22:44 CEST
AI TechDocKnowledge

Glossary · CNC and machine tools

M-code

Also known as: Miscellaneous function, M word

German: M-Code

In CNC programming, an M-code is a miscellaneous function, written with the address letter M and a number, that switches machine functions such as spindle start and stop, coolant, tool change or program end.

  • CNC
  • Standards

In one sentence

An M-code is a miscellaneous function in a CNC program that switches machine functions such as spindle, coolant, tool change or program end.

Example

M03 S2000 starts the spindle clockwise at 2,000 rpm, M08 switches on the coolant and M30 ends the program.

How it applies

  • Engineering: Some M-codes are common across controls (M03, M05, M30), but many are assigned by the machine builder and executed by the PLC part of the CNC, for example to clamp a pallet or open a door. Their meaning is machine-specific.
  • Commissioning: Machine-specific M-codes must be tested together with the interlocks they depend on, such as door or clamping state, before the machine is released.
  • Documentation: Every machine-specific M-code belongs in the machine's programming or Operating manual with its function, preconditions and effects. Keep this list under change control: when the PLC program changes an M-code, the document must change in the same release.

M-code vs. G-code

G-codes define how the tool moves; M-codes switch machine functions. A single Program block (NC) can contain both, and the control defines the order in which they take effect within the block.

By knowledge.aitechdoc.world · Published September 26, 2026 · Last reviewed

Source: ISO 6983-1:2009, Automation systems and integration — Numerical control of machines — Program format and definitions of address words — Part 1: Data format for positioning, line motion and contouring control systems

Definitions follow the cited standards and specifications. Where a source is a copyrighted publication, such as an ISO, IEC or EN standard, the definition is a close paraphrase, not a verbatim quotation, so as not to infringe copyright. We recommend reading the original publication. The sections “How it applies” are editorial commentary by AI TechDoc Knowledge and are not part of any standard.

Seen a mistake? Send us a note!