Back to GSM Code List

M06: the tool change

M06 runs the tool change: the control takes the machine to its change position and the arm or the carousel puts the tool called by the T word into the spindle. On most machines the T only stages the magazine and the M06 is what makes the change, which is why they are written together (T3 M06) or the T goes in an earlier block to get the search started. After the change you have to turn the tool length offset back on with G43 H.

For reference only: syntax changes with the control, the post-processor and the machine parameters. Check the official manual and run a simulation before cutting. Legal notice.

Family
Tooling
Machine
Milling, Mill-turn
Risk
High
Example
T3 M06

Syntax by control

Fanuc (milling)

T3 M06

On most Fanuc mills you have to go up first with G91 G28 Z0. (and on some machines send X and Y to the reference point too) and cancel G41/G42, G80 and the spindle. If you do not, the control alarms or the arm swings with the tool still in the part.

Haas (milling)

T3 M06

Haas takes the Z axis to the change position by itself, though plenty of programs still write G91 G28 Z0. first. With Setting 15 (H & T Code Agreement) on, the H you use afterwards has to match the T number.

Fanuc / Haas (turning)

T0303

On a lathe you usually do not need M06: the T word carries two pairs of digits, the first is the turret station and the second the offset that goes active (T0303 = tool 3 with offset 3). The turret index happens at a safe position you program yourself.

Siemens 840D / 828D

T3 M6 D1

Siemens writes M6 with no leading zero and the tool can be called by number or by name. Length and radius come in with the D edge number of that tool, not with G43 H.

Heidenhain TNC (Klartext)

TOOL CALL 3 Z S3000

A single instruction calls the tool, applies its length and its radius from the TOOL.T table and starts the spindle: in Klartext there is no M06 separate from the compensation flow.

Address letters used with it

LetterWhat it setsUnit
TNumber of the magazine tool that is going into the spindle. On many machines the T only searches for it and M06 changes it.integer
T nextOn machines with a changer arm you can stage the next tool by writing its T right after the M06, so the magazine searches for it while the current one cuts.integer
H (with G43, after M06)Length offset that has to be turned on after the change. Shop practice is the same number as the T that has just come in.integer

Worked example

Going from the face mill (T1) to the spot drill (T2) in a Fanuc mill program. This is the block worth copying as it stands between operations: safe retract, cancel the offsets, change and new tool length offset.

G00 Z50. M09
( Retracts the previous tool and turns the coolant off. )
G40 G80
( Cancels cutter compensation and any canned cycle. Reaching the change with G41 or with a cycle active means an alarm or the offset left on in the new tool. )
M05
( Stops the spindle. Plenty of machines do it themselves at the change, but not all of them. )
G91 G28 Z0.
( Sends the Z axis to the reference point in incremental: that is the safe change position. Under G90 the block would go down to the part zero Z0 first. )
G91 G28 X0. Y0.
( Some machines want X and Y at the reference point to change as well; on others it is pointless and only lengthens the cycle. Depends on the changer. )
M01
( Optional stop: if the operator has the switch on, the part can be measured between operations. )
T2 M06
( Change to the spot drill. The change clears the length offset of the previous tool. )
G90 G54 G00 X20. Y20. S4500 M03
( Back to absolute, work offset on, rapid over the first point and spindle started during the move. )
G43 H02 Z25.
( Applies the T2 length. H02 goes with T2: keeping that pairing prevents most Z crashes. )
M08
( Coolant on. )
T3
( Stages the next tool in the magazine while T2 cuts. Only worth doing on machines with a changer arm. )
G99 G81 Z-3. R2. F200
( Now you can cut: spot the first hole. )
Open the simulator to check the example

Practical keys to using M06 in the workshop

When and how you program the change

The change always goes in a transition block between operations, never in the middle of a contour. The sensible sequence is: retract in Z, coolant off, cancel cutter compensation and canned cycles, stop the spindle, go up to the reference point with G91 G28 Z0. and then T and M06. After the change you rebuild the state: G90, the G54 work offset, the positioning, the spindle and G43 H. Writing that whole block in every tool also lets you start the program part way through, at the block for any operation, without inheriting the previous state.

How it works with T, G43 H and the magazine

T and M06 are two things: T says which tool and M06 puts it in. On most machines the T on its own only stages the pocket, so the two go in the same block, or the T goes earlier so the magazine indexes while the machine finishes the previous operation. On machines with a changer arm you can write the T of the next tool right after the M06 and save a few seconds per change. And after the M06 you need the matching G43 H: the change clears whatever length offset was on.

What the machine does and what depends on the builder

What physically happens during an M06 is not the same on every machine: some take the Z axis to the change position by themselves and others alarm if it is not at the reference point; some stop the spindle and drop the coolant on their own and others expect the program to do it; some want X and Y at the reference point and others do not. Magazine handling differs too, arm or carousel, and whether the machine has oversize tools that block the neighboring pockets. That is why the change block is tuned to each machine manual and not copied between models unchecked.

Mistakes that cost you a part (or a tool)

  • Calling the change without taking Z up: on machines that do not take the axis to the change position by themselves, the arm swings with the tool still down in the part.
  • Writing G90 G28 Z0. instead of G91 G28 Z0.: under G90 the machine goes to the part zero Z0 first, that is, to the face of the part, and only then goes up to the reference point.
  • Reaching the M06 with G41 or G42 on or with a canned cycle not cancelled: cancel with G40 and G80 before the change.
  • Forgetting the G43 H after the change: the machine works with the length of the previous tool and the program Z0 stops being the face of the part.
  • Putting an H that does not match the T (T5 with H04): the length difference between the two tools turns straight into extra or missing depth.
  • Programming a T that is not loaded in the magazine, or the same tool declared in two pockets: changer alarm and, at worst, the arm tries to put the tool back where it does not fit.
  • Leaving the spindle running or the coolant on in machines that do not shut them off themselves: a change with the spindle turning wrecks the changer.

Frequently Asked Questions (FAQ)

Why are T3 and M06 written in the same block?

Because they are two different orders: T selects and searches for the tool in the magazine and M06 puts it in the spindle. Together they work on any machine. Splitting them, with the T a few blocks earlier, is only done to get the magazine search started and save cycle time.

Do I have to go to the reference point before M06?

It depends on the machine: Haas takes the Z axis to the change position by itself, while plenty of Fanucs alarm or change wherever they are. Writing G91 G28 Z0. before the change works on both and costs a second, so it is the safest habit.

Are M06 and M6 the same?

Yes: the control ignores the leading zero, so M6 and M06 are the same function. Writing it with two digits is only a readability convention, and it is the one almost every post processor uses.

Why should the H number match the T number?

Because it is the only way the error jumps out at you when you read the program. The control does not require it, but a T5 with H04 drops by the length difference between the two tools with no warning at all. On Haas you can enforce the match with Setting 15.

Is M06 used on lathes too?

On most lathes it is not needed: the T word carries the tool and the offset in a single code (T0303) and the turret index happens at a safe position you program yourself. On lathes with a magazine or a sub spindle you have to check the manual, because the flow changes.

Related codes

Related tools