MachMotion
Blog Technical

SUMMARY OF M-CODES

MachMotion · March 6, 2017
SUMMARY OF M-CODES

Summary

All MachMotion CNC controls run on Mach3 or Mach4 software. This reference lists the standard M-codes operators can use when programming machine functions.

Summary of M-Codes All MachMotion CNC controls use the Mach3 or Mach4 software. Use the M-code list below as a reference.

Mach 3 G-Code Language Reference
Mach 4 G- and M-Code Language Reference

M Code List

M-code

Functions

M0

Program stop

M1

Optional program stop

M3/M4

Rotate spindle clockwise / counterclockwise

M5

Stop spindle rotation

M6

Tool change (by two macros)

M7

Mist on

M8

Flood on

M9

Mist & flood off

M30

Program end and rewind

M47

Repeat program from first line

M48

Enable speed and feed override

M98

Call subroutine

M99

Return from subroutine/repeat

Custom M-code*

Functions

M200

Output 5 on

M201

Output 5 off

M202

Output 6 on

M203

Output 6 off

M204

Output 7 on

M205

Output 7 off

M206

Output 8 on

M207

Output 8 off

M208

Output 9 on

M209

Output 9 off

M210

Output 10 on

M211

Output 10 off

M212

Output 11 on

M213

Output 11 off

M214

Output 12 on

M215

Output 12 off

*These custom M-codes are used to control the relay outputs on the breakout board. Outputs 5-12 must be enabled with the port set to 2 and the pin set to the corresponding relay on the breakout board (R4 = pin 4).

A

A axis of machine

B

B axis of machine

C

C axis of machine

D

Tool radius compensation number

F

Feedrate

G

See G-codes table

H

Tool length offset index

I

X axis offset for arc

X offset in G87 canned cycle

J

Y axis offset for arcs

Y offset in G87 canned cycle

K

Z axis offset for arcs

Z offset in G87 canned cycle

L

Number or repetitions in canned cycles/subroutines

L1/L2: tool offset settings / fixture offset (with G10)

M

See M-codes

N

Line number

O

Subroutine label number

P

Dwell time in a canned cycle

Dwell time with G4

Tool / Fixture number (with G10)

Tool radius (with G41 / G42

Q

Feed increment in G83 canned cycle

Repetitions of subroutine call

R

Arc radius

Canned cycle retract level

S

Spindle speed

T

Tool selection

X

X axis of machine

Y

Y axis of machine

Z

Z axis of machine

Next Step

Is your machine a retrofit candidate?

Tell us what you're running and what's failing. We'll give you a straight answer: retrofit, repair, or replace, before any money changes hands.