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
Code
Description
M00
Program stop
M01
Optional stop
M02
End of program
M03
Milling spindle on, clockwise
M04
Milling spindle on, counterclockwise
M05
Milling spindle stop
M06
Tool change
M08
Coolant on
M09
Coolant and air blow off
M19
Milling spindle orientation
M30
End of program with reset
M98
Subprogram call
M99
Subprogram end
A typical program section using the essential M-codes:
T12M06(Tool change to tool 12)G90G54G00X0Y0S2500M03(Spindle clockwise, 2500 rpm)G43H12Z50.M08(Coolant on)G01Z-5.F300M09(Coolant off)M05(Spindle stop)G28G91Z0M30(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.
Code
Effect
M998
Parts count, then start the named program and continue
M999
Parts 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)M999S2041Q0(No count, select program 2041 and stop)
Full reference
Program control
Code
Description
M00
Program stop
M01
Optional stop (only with the optional stop function switched on)
M02
End of program (EIA/ISO)
M30
End of program with reset (EIA/ISO)
M98
Subprogram call (EIA/ISO)
M99
Subprogram end (EIA/ISO)
M120
Automatic power off
M998
Program chaining: parts count, call next program, continue
M999
Program chaining: parts count, call next program, stop
Milling spindle and tool
Code
Description
M03
Milling spindle rotation, normal
M04
Milling spindle rotation, reverse
M05
Milling spindle stop
M06
Tool change (EIA/ISO)
M10
Tool clamp in milling spindle
M11
Tool unclamp in milling spindle
M19
Milling spindle orientation
M36
Milling spindle gear change: L
M37
Milling spindle gear change: L/L
M38
Milling spindle gear change: L/MH
M39
Milling spindle gear change: H
M40
Milling spindle gear change: neutral
M48
Spindle speed and feed override enabled
M49
Spindle speed and feed override disabled
M58
Tool life control: use spare tool
M107
B-axis clamp
M108
B-axis unclamp
M110
Turning tool clamp in milling spindle
M111
Turning tool unclamp in milling spindle
M139
Heavy-tool ATC mode cancel
M140
Heavy-tool ATC mode on
M149
Tool magazine switching
Coolant and air
Code
Description
M07
Mist coolant on
M08
Coolant on
M09
All coolant and air blow off
M50
Air blow on
M51
Coolant through milling spindle on
M52
Coolant through tap on
M130
Flood coolant on
M131
Jet coolant on
M132
Air through milling spindle on
Measurement and monitoring
Code
Description
M23
Error detection on
M24
Error detection off
M33
Tool length measuring unit advance
M34
Tool length measuring unit retract
M35
Tool breakage detection
M122
Gap skip on
M123
Gap skip off
M169
Cancels M170
M170
AFC cancel
M187
Status check for laser measurement
Mirror image (Mazatrol programs)
Code
Description
M90
Mirror image cancel
M91
Mirror image on X
M92
Mirror image on Y
M93
Mirror image on 4th axis
Magazine, doors and pallets
Code
Description
M15
Magazine cover close
M16
Magazine cover open
M42
Index table reverse rotation
M64
Pallet door close
M65
Pallet door open
M68
Pallet clamp
M69
Pallet unclamp
M71
Pallet No. 1 set
M72
Pallet No. 2 set
M73
Pallet No. 3 set
M74
Pallet No. 4 set
M75
Pallet No. 5 set
M76
Pallet No. 6 set
M256
Front (upper) door open
M257
Front (upper) door close
M910
Pallet change (Mazatrol)
M911
Pallet change (Mazatrol)
Turning spindle 1
Code
Description
M200
C-axis mode, turning spindle 1
M202
Turning mode, turning spindle 1
M203
Turning spindle 1, normal rotation
M204
Turning spindle 1, reverse rotation
M205
Turning spindle 1 stop
M206
Chuck open, turning spindle 1
M207
Chuck close, turning spindle 1
M210
C-axis clamp, turning spindle 1
M211
C-axis brake, turning spindle 1
M212
C-axis unclamp, turning spindle 1
M219
Spindle orientation, turning spindle 1
M238
Gear change turning spindle 1: MH/M/L
M239
Gear change turning spindle 1: H/H/H
M240
Gear change turning spindle 1: neutral
M241
Winding selection turning spindle 1: high
M243
Winding selection turning spindle 1: low
M258
Chuck air blow on, turning spindle 1
M259
Chuck air blow off, turning spindle 1
M264
Chuck jaw coolant on, turning spindle 1
M265
Chuck jaw coolant off, turning spindle 1
M266
Trickle coolant on, turning spindle 1
M267
Trickle coolant off, turning spindle 1
M268
Coolant through turning spindle 1 on
M269
Coolant through turning spindle 1 off
M270
Air through turning spindle 1 on
M271
Air through turning spindle 1 off
Turning spindle 2
Code
Description
M300
C-axis mode, turning spindle 2
M302
Turning mode, turning spindle 2
M303
Turning spindle 2, normal rotation
M304
Turning spindle 2, reverse rotation
M305
Turning spindle 2 stop
M306
Chuck open, turning spindle 2
M307
Chuck close, turning spindle 2
M310
C-axis clamp, turning spindle 2
M311
C-axis brake, turning spindle 2
M312
C-axis unclamp, turning spindle 2
M319
Spindle orientation, turning spindle 2
M341
Winding selection turning spindle 2: high
M343
Winding selection turning spindle 2: low
M358
Chuck air blow on, turning spindle 2
M359
Chuck air blow off, turning spindle 2
M364
Chuck jaw coolant on, turning spindle 2
M365
Chuck jaw coolant off, turning spindle 2
M366
Trickle coolant on, turning spindle 2
M367
Trickle coolant off, turning spindle 2
M368
Coolant through turning spindle 2 on
M369
Coolant through turning spindle 2 off
M370
Air through turning spindle 2 on
M371
Air through turning spindle 2 off
Tailstock, steady rest and parts catcher
Code
Description
M220
Tailstock coupling to carriage cancel
M221
Tailstock coupling to carriage
M231
Tailstock quill advance
M232
Tailstock quill retract
M248
Parts catcher advance
M249
Parts catcher retract
M251
Steady rest 1 air blow on
M252
Steady rest 1 air blow off
M253
Steady rest 2 air blow on
M254
Steady rest 2 air blow off
M277
Tailstock quill thrust low
M278
Tailstock quill thrust high
M279
Chuck/tailstock barrier cancel
M280
Chuck/tailstock barrier on
M285
Steady rest 1 coolant on
M286
Steady rest 1 coolant off
M287
Steady rest 2 coolant on
M288
Steady rest 2 coolant off
M290
Steady rest coupling to carriage
M291
Steady rest coupling cancel
M292
Steady rest 1 unclamp
M293
Steady rest 1 clamp
M294
Steady rest 2 unclamp
M295
Steady rest 2 clamp
Spindle synchronization and workpiece transfer
Code
Description
M508
Pushing mode on, spindle 2
M509
Pushing mode off, spindle 2
M511
Spindle synchronization, spindle 1 leading
M512
Spindle synchronization, spindle 2 leading
M513
Spindle synchronization cancel
M540
Transfer mode for chuck work on
M541
Transfer mode for chuck work off
M542
Re-chucking mode for bar work on
M543
Re-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.