AiVibe

CNC & Precision Machining

M-code (Miscellaneous Function)

An M-code is a CNC program word that switches machine functions rather than defining motion, such as starting or stopping the spindle, turning coolant on or off, changing tools and ending the program.

M-codes, or miscellaneous functions, control the auxiliary devices of a machine tool. Widely used examples are M00 for a program stop, M01 for an optional stop, M03 and M04 for spindle rotation clockwise and anticlockwise, M05 for spindle stop, M06 for tool change, M08 and M09 for coolant on and off, and M30 for program end with reset. The CNC usually passes the M-code to the machine's integrated PLC logic, which operates the device and signals completion before the program continues.

Every CNC program uses M-codes to sequence the physical machine around the cutting motions. Machine builders also define their own M-codes for options such as pallet changers, chip conveyors, through-spindle coolant, probes, doors and bar feeders, which lets programs and CAM post-processors drive those devices automatically.

Apart from the common core, M-code numbers and behaviour are specific to the machine builder, so the same number can mean different things on different machines. The builder's programming and operator manuals are the only reliable reference. Because M-codes start and stop real devices, edits to programs and to the machine logic that interprets them should be made only by qualified personnel following OEM documentation.

Key points

Where AiVibe comes in

AiVibe designs and manufactures the AiAmbA AI Factory: edge devices plus AI agents that let people talk to CNC, PLC and robot controllers in plain language. Agents only propose changes, and a trained operator confirms each one.

Explore AiVibe’s work in CNC & Precision Machining →

Related terms

Ask AiMuruga can explain M-code (Miscellaneous Function) for your plant, product or security programme, and draw how it fits.