Lesson 5: Tools, Spindle and Coolant – T, M06, G43 H, M03 and M08
Updated
A tool is changed with T and M06, and its length is applied with G43 plus an H number that must match the tool number, together with a Z move; G49 cancels the length offset. S, M03, M04 and M05 control the spindle, M08 and M09 the coolant, and M00 and M01 stop the program.
In this lesson you will learn:
- how to change tools with T and M06;
- how to apply and cancel tool length offset with G43 H and G49;
- how to control the spindle (S, M03, M04, M05) and coolant (M08, M09);
- how to use the program stops M00 and M01;
- how to write a safe program start for tool T1.
As throughout the course, we use a Fanuc-style milling control (e.g. 0i-MF) in metric mode (G21). Other controls, and even different machine builders using the same control, may behave differently, so your machine manual is always the authoritative source.
Tool change: T and M06
The T address gives the tool number in the magazine and M06 performs the change. On most vertical machining centres T1 only prepares the tool (the magazine indexes to the pocket) and M06 loads it into the spindle, so both are usually written in one block: T1 M06. The tool change macro written by the machine builder normally moves Z to the change position and stops the spindle by itself, but some machines require you to program G91 G28 Z0 before M06. For tool clamping see tool holders.
The offset table: H and D
The control does not know tool sizes – the operator enters them in the offset table (the Fanuc OFFSET screen). Each row holds a length (H) and a radius (D) value, usually split into geometry and wear. In the program, H1 means take the length from row 1 and D1 means take the radius from row 1. The control does not link these numbers to T by itself – that is the programmer's job. The usual rule is therefore: H and D numbers equal the tool number.
| Tool | Description | H | D | S, rpm | F, mm/min |
|---|---|---|---|---|---|
| T1 | Ø10 mm 3-flute carbide end mill | H1 | D1 (5.000) | 6000 | 1200 (plunge 300) |
| T2 | Ø8 mm 90° spot drill | H2 | – | 3000 | 300 |
| T3 | Ø6.8 mm drill (M8 tap drill) | H3 | – | 4000 | 500 |
| T4 | M8×1.25 tap | H4 | – | 500 | 625 |
These are example values for aluminium EN AW-6082; the tool maker's data takes priority. How they are derived is explained in cutting speed and rpm and feed per tooth: for T1, Vc = π × 10 × 6000 / 1000 ≈ 188 m/min and fz = 1200 / (6000 × 3) ≈ 0.067 mm.
Length offset G43 H and G49
Tools of different lengths put their tips at different heights. G43 H1 Z50.0 tells the control to take the length stored in row H1 into account, so that all following Z coordinates describe the position of the tool tip in G54, i.e. the height above the top of the part. The offset is applied together with a Z move, so G43 is written in a block with a Z coordinate, at a safe height above the part. G49 cancels the length offset and is part of the safe start block. After every M06 a new G43 with that tool's H number is programmed.
Why H must match T
If you activate H2 while T1 is in the spindle, the control calculates with the length of T2. If the H2 value is greater than the real length of T1, the cutter stays higher and cuts air; if it is smaller, the tool goes lower than programmed and can crash into the part or the vise. This is one of the most common causes of collisions.
How tool length is measured
In this course the H row holds the tool length from the spindle gauge line to the tip, and the G54 Z value locates the top of the part. Length is usually measured with a tool setter – a contact probe or a laser on the machine table – whose measuring cycle writes the value into the H row automatically. Alternatives are presetting in a fixture away from the machine, or manually touching the tool off on a surface of known height. Whatever the method, all tools on one machine must be measured the same way.
Spindle, coolant and stops
| Code | Action | Note |
|---|---|---|
| S6000 | Spindle speed 6000 rpm | Modal, valid until the next S |
| M03 | Spindle clockwise | Right-hand tools – most end mills and drills |
| M04 | Spindle counter-clockwise | Left-hand tools |
| M05 | Spindle stop | At program end and before manual work |
| M08 | Coolant on | Flood; M07 on some machines is mist or air |
| M09 | Coolant off | Before tool change and at the end |
| M00 | Program stop | Always; resume with CYCLE START |
| M01 | Optional stop | Only when the OPTIONAL STOP switch is on |
Direction of rotation is viewed from the spindle towards the tool, on a vertical machine from above. Whether the spindle and coolant stop at M00 is set by the machine builder. M00 is used when the operator must do something (clear chips, re-clamp the part), while M01 is often placed before each tool change so a new program can be stopped and checked. See M-codes and coolant and MQL.
Program start for tool T1
O1005 (LESSON 5 - T1 START)
N10 G21 G17 G40 G49 G80 G90
N20 T1 M06 (END MILL D10 Z3)
N30 G54 G00 X-10.0 Y-10.0 S6000 M03
N40 G43 H1 Z50.0 M08
N50 Z5.0
(... MACHINING ...)
N100 G00 Z50.0 M09
N110 G91 G28 Z0
N120 G90
N130 M05
N140 M30
N10 is the safe start: millimetres, XY plane, cutter radius and length offsets and canned cycles cancelled, absolute coordinates (see G-code basics). N20 changes the tool. N30 selects G54, rapids the cutter outside the X0 Y0 corner of the part and starts the spindle. N40 applies the length offset: the tip ends up 50 mm above the part and coolant comes on. N50 brings the cutter down to 5 mm above the surface. At the end, G91 G28 Z0 sends Z incrementally straight up to the machine reference point, G90 restores absolute mode, M05 stops the spindle and M30 ends the program. Run a new program the first time in single block with reduced rapid override, watching the distance-to-go display.
Exercise
The offset table holds H1 = 82.350 mm and H2 = 96.120 mm. Find the error in this program, calculate where the cutter tip will actually be in block N60, and correct the program.
O1015 (EXERCISE 5)
N10 G21 G17 G40 G49 G80 G90
N20 T1 M06
N30 G54 G00 X-10.0 Y-10.0 S6000 M03
N40 G43 H2 Z50.0 M08
N50 Z5.0
N60 G01 Z-2.0 F300
The answer is in the FAQ. Next lesson: Lesson 6: cutter radius compensation G41, G42 and G40.
Frequently asked questions
Can T and M06 be written in separate blocks?
Yes. On many machines with a magazine, T prepares the next tool in advance and M06 loads it, so T2 can be programmed while T1 is still cutting to shorten the change time. How this works on a given machine is described in its manual.
What is the difference between M00 and M01?
M00 always stops the program, while M01 stops it only when the OPTIONAL STOP switch on the operator panel is on. In both cases the program resumes with CYCLE START.
What happens if I forget G43?
When tool length is stored in the H register, without G43 the control applies Z coordinates to the spindle gauge line instead of the tool tip, so the tip ends up one tool length lower and crashes. That is why G43 is programmed after every tool change.
Exercise answer
The error is in block N40: H2 is used with T1. The control assumes the tool is 96.120 − 82.350 = 13.770 mm longer, so in N60 the tip will be at Z11.77 instead of Z-2 and the cutter cuts air. Fix: N40 G43 H1 Z50.0 M08. If the wrong H value were smaller than the real length, the cutter would go lower and crash.
Looking for someone to do this job? Find a manufacturer on the marketplace or post a request.
Services offered I need a service