Mazak M-codes: reference table

Mazak M-codes for machining centers and Integrex multitasking machines: everyday codes, program chaining with M998/M999, and a full list grouped by function.

Mazatrol controls switch machine functions such as spindles, coolant, pallets and chucks with M-codes. This reference lists the common M-codes for Mazak machining centers and Integrex multitasking machines in EIA/ISO programs.

Machine-dependent assignment

Many M-codes are set by the machine builder per model. Some codes in this list are missing on a given machine, and others may be used for different functions. The codes for spindle 1 and 2, tailstock, steady rest and bar feeder only exist on machines with that equipment. When in doubt, the documentation of your machine applies.

Rules for M-codes in a block

An M-code has up to three digits after the address M. One block can carry up to four M-codes. If more are written, only the last four are valid.

When an M-code shares a block with an axis move, it depends on the machine whether the M function runs after the move or together with it.

The control stops reading ahead at M00, M01, M02, M30, M98, M99, M998 and M999. The next block is only loaded into the buffer once the current one is processed.

M98 and M99 are handled inside the control. They do not send an M signal to the machine.

Essential M-codes

CodeDescription
M00Program stop
M01Optional stop
M02End of program
M03Milling spindle on, clockwise
M04Milling spindle on, counterclockwise
M05Milling spindle stop
M06Tool change
M08Coolant on
M09Coolant and air blow off
M19Milling spindle orientation
M30End of program with reset
M98Subprogram call
M99Subprogram end

A typical program section using the essential M-codes:

T12 M06            (Tool change to tool 12)
G90 G54 G00 X0 Y0
S2500 M03          (Spindle clockwise, 2500 rpm)
G43 H12 Z50.
M08                (Coolant on)
G01 Z-5. F300
M09                (Coolant off)
M05                (Spindle stop)
G28 G91 Z0
M30                (End of program)

Program end and program chaining

M02 and M30 end the program. The control runs the tool life processing and then resets, which cancels modal states and offsets. After a restart, the last interpolation mode from the previous run can still be active. The first move in a program should therefore carry its own G-code (G00 or G01).

M998 and M999 also end the program, and additionally update the parts counter and call a follow-up program. The follow-up can be an EIA/ISO program or a Mazatrol program.

CodeEffect
M998Parts count, then start the named program and continue
M999Parts count, then select the named program and stop

The follow-up program is given by name in angle brackets, or with address S if the name is purely numeric. Q1 updates the parts counter, Q0 skips it.

M998 <FLANGE-OP2> Q1   (Count part, continue with program FLANGE-OP2)
M999 S2041 Q0          (No count, select program 2041 and stop)

Full reference

Program control

CodeDescription
M00Program stop
M01Optional stop (only with the optional stop function switched on)
M02End of program (EIA/ISO)
M30End of program with reset (EIA/ISO)
M98Subprogram call (EIA/ISO)
M99Subprogram end (EIA/ISO)
M120Automatic power off
M998Program chaining: parts count, call next program, continue
M999Program chaining: parts count, call next program, stop

Milling spindle and tool

CodeDescription
M03Milling spindle rotation, normal
M04Milling spindle rotation, reverse
M05Milling spindle stop
M06Tool change (EIA/ISO)
M10Tool clamp in milling spindle
M11Tool unclamp in milling spindle
M19Milling spindle orientation
M36Milling spindle gear change: L
M37Milling spindle gear change: L/L
M38Milling spindle gear change: L/MH
M39Milling spindle gear change: H
M40Milling spindle gear change: neutral
M48Spindle speed and feed override enabled
M49Spindle speed and feed override disabled
M58Tool life control: use spare tool
M107B-axis clamp
M108B-axis unclamp
M110Turning tool clamp in milling spindle
M111Turning tool unclamp in milling spindle
M139Heavy-tool ATC mode cancel
M140Heavy-tool ATC mode on
M149Tool magazine switching

Coolant and air

CodeDescription
M07Mist coolant on
M08Coolant on
M09All coolant and air blow off
M50Air blow on
M51Coolant through milling spindle on
M52Coolant through tap on
M130Flood coolant on
M131Jet coolant on
M132Air through milling spindle on

Measurement and monitoring

CodeDescription
M23Error detection on
M24Error detection off
M33Tool length measuring unit advance
M34Tool length measuring unit retract
M35Tool breakage detection
M122Gap skip on
M123Gap skip off
M169Cancels M170
M170AFC cancel
M187Status check for laser measurement

Mirror image (Mazatrol programs)

CodeDescription
M90Mirror image cancel
M91Mirror image on X
M92Mirror image on Y
M93Mirror image on 4th axis

Magazine, doors and pallets

CodeDescription
M15Magazine cover close
M16Magazine cover open
M42Index table reverse rotation
M64Pallet door close
M65Pallet door open
M68Pallet clamp
M69Pallet unclamp
M71Pallet No. 1 set
M72Pallet No. 2 set
M73Pallet No. 3 set
M74Pallet No. 4 set
M75Pallet No. 5 set
M76Pallet No. 6 set
M256Front (upper) door open
M257Front (upper) door close
M910Pallet change (Mazatrol)
M911Pallet change (Mazatrol)

Turning spindle 1

CodeDescription
M200C-axis mode, turning spindle 1
M202Turning mode, turning spindle 1
M203Turning spindle 1, normal rotation
M204Turning spindle 1, reverse rotation
M205Turning spindle 1 stop
M206Chuck open, turning spindle 1
M207Chuck close, turning spindle 1
M210C-axis clamp, turning spindle 1
M211C-axis brake, turning spindle 1
M212C-axis unclamp, turning spindle 1
M219Spindle orientation, turning spindle 1
M238Gear change turning spindle 1: MH/M/L
M239Gear change turning spindle 1: H/H/H
M240Gear change turning spindle 1: neutral
M241Winding selection turning spindle 1: high
M243Winding selection turning spindle 1: low
M258Chuck air blow on, turning spindle 1
M259Chuck air blow off, turning spindle 1
M264Chuck jaw coolant on, turning spindle 1
M265Chuck jaw coolant off, turning spindle 1
M266Trickle coolant on, turning spindle 1
M267Trickle coolant off, turning spindle 1
M268Coolant through turning spindle 1 on
M269Coolant through turning spindle 1 off
M270Air through turning spindle 1 on
M271Air through turning spindle 1 off

Turning spindle 2

CodeDescription
M300C-axis mode, turning spindle 2
M302Turning mode, turning spindle 2
M303Turning spindle 2, normal rotation
M304Turning spindle 2, reverse rotation
M305Turning spindle 2 stop
M306Chuck open, turning spindle 2
M307Chuck close, turning spindle 2
M310C-axis clamp, turning spindle 2
M311C-axis brake, turning spindle 2
M312C-axis unclamp, turning spindle 2
M319Spindle orientation, turning spindle 2
M341Winding selection turning spindle 2: high
M343Winding selection turning spindle 2: low
M358Chuck air blow on, turning spindle 2
M359Chuck air blow off, turning spindle 2
M364Chuck jaw coolant on, turning spindle 2
M365Chuck jaw coolant off, turning spindle 2
M366Trickle coolant on, turning spindle 2
M367Trickle coolant off, turning spindle 2
M368Coolant through turning spindle 2 on
M369Coolant through turning spindle 2 off
M370Air through turning spindle 2 on
M371Air through turning spindle 2 off

Tailstock, steady rest and parts catcher

CodeDescription
M220Tailstock coupling to carriage cancel
M221Tailstock coupling to carriage
M231Tailstock quill advance
M232Tailstock quill retract
M248Parts catcher advance
M249Parts catcher retract
M251Steady rest 1 air blow on
M252Steady rest 1 air blow off
M253Steady rest 2 air blow on
M254Steady rest 2 air blow off
M277Tailstock quill thrust low
M278Tailstock quill thrust high
M279Chuck/tailstock barrier cancel
M280Chuck/tailstock barrier on
M285Steady rest 1 coolant on
M286Steady rest 1 coolant off
M287Steady rest 2 coolant on
M288Steady rest 2 coolant off
M290Steady rest coupling to carriage
M291Steady rest coupling cancel
M292Steady rest 1 unclamp
M293Steady rest 1 clamp
M294Steady rest 2 unclamp
M295Steady rest 2 clamp

Spindle synchronization and workpiece transfer

CodeDescription
M508Pushing mode on, spindle 2
M509Pushing mode off, spindle 2
M511Spindle synchronization, spindle 1 leading
M512Spindle synchronization, spindle 2 leading
M513Spindle synchronization cancel
M540Transfer mode for chuck work on
M541Transfer mode for chuck work off
M542Re-chucking mode for bar work on
M543Re-chucking mode for bar work off

The thrust used by M508 to push the workpiece can be reduced with macro variable #3030 (value in percent). The new value only takes effect with the next M508. M30 and reset set #3030 back to 100.

Grinding

CodeDescription
M610Grinding mode on
M611Spindle speed setting for grinding
M612Grinding mode off

Automation and external M-codes

CodeDescription
M43–M45External M-codes 3 to 5
M100External M-code 1
M101External M-code 2
M400–M419External M-codes 1 to 20 (Integrex numbering)
M720–M729Robot service requests 1 to 10
M768Bar feeder request 1
M769Bar feeder request 2