M codes

There are four main types of information you need to enter into the computer:

Types of information

Information
Example
Code

Mechanical
The mechanical actions required.

Turning on the spindle or the vacuum pump.

M codes (machine functions)

eg M93, M06

Direction
The direction of each movement.

Movement left or right, back or forward, up and down.

Cartesian (rectangular) co-ordinates expressed as axes (X,Y,Z)

Dimensions
The distance each movement travels.

Appears after every axis designation

Expressed as millimetres and contain a decimal point eg X345.67

Movements
The way movements take place.

A straight line, clockwise and anti-clockwise curves and rapid feed.

G codes (preparatory functions)

eg G01, G02, G03, G00

In this section we will look at Mechanical actions.

Directions for mechanical actions are given to CNC machines using M Codes. M codes are used to direct the action of any mechanical part of the machine. This could be turning the spindle on and off, selecting the spindle or turning the vacuum on and off.

Many machines require you to first select the head, lower it and then switch it on, using a different M code for each command. M codes are also used to end the program (M30) and go between sub-programs (M98, M99).

M codes may differ on each CNC machine. It is vital that you become familiar with the list specific to the machine you are working with. Below is a sample list of M codes.

M code

Function

M00

Program stop

M06

Clamp on (vacuum)

M07

Clamp off (vacuum)

M11

No. 1 spindle down

M12

No. 1 spindle up

M13

No. 1 spindle select

M15

No. 1 spindle off

M21

No. 2 spindle down

M22

No. 2 spindle up

M23

No. 2 spindle select

M25

No. 2 spindle off

M30

End of program / reset and rewind

M92

All spindles up

M93

Spindle on

M95

All spindles off with brake

M98

Go to sub-program

M99

Go to main program