CNC tool change and spindle: T, M6, S, M3 and M5
Updated on October 22, 2026
You control the tool change and the spindle in a CNC program with a few words: T, M6, S, M3 and M5. A kitchen mixer has different attachments: whisk, dough hook, blade. You fit the right one and set the speed. A CNC machine does the same. It has a magazine with tools and a spindle that turns the chosen tool. In the program you say which tool and how fast it turns.
Selecting and changing a tool
The spindle is the rotating part of the machine that holds the tool. Two words belong together:
T2selects tool number 2 in the magazine.M6carries out the tool change: the selected tool goes into the spindle.
The magazine in the examples has six tools. The first three are T1 centre drill Ø6, T2 drill Ø6 and T3 drill Ø8.5. The tap, the countersink and the end mill for milling come later.
(Load tool 2 and start the spindle)G90 G21 G17T2 (select tool 2)M6 (change the tool)S1500 (speed 1500 rpm)M3 (spindle on, clockwise)M5 (spindle off)M30Speed and direction
S1500 sets the spindle speed: 1500 revolutions per minute. The spindle is not running yet, though. For that you write:
M3: spindle on, turning clockwise. All drills turn this way.M4: spindle on, turning counter-clockwise. You only need that for tapping with several tools.M5: spindle off.
Without a tool in the spindle or without S the machine shows an alarm.
The right speed
The thicker the tool, the slower it has to turn, because its edge runs through the material faster. Too fast makes the tool hot, too slow and the cutting edge is not guided properly. How to calculate the speed exactly is shown in calculating spindle speed and feed. For the start a rule of thumb is enough:
- T2 (Ø6) in aluminium: 1000 to 2000 rpm.
- T3 (Ø8.5) in aluminium: 700 to 1400 rpm.
(The thicker the drill, the slower)G90 G21 G17T2 M6S1500 M3 (6 mm drill: 1000 to 2000 rpm)M5T3 M6S900 M3 (8.5 mm drill: 700 to 1400 rpm)M5M30Changing safely
When you change the tool, it must stand above the material, at Z0 or higher. The order is always: move up, spindle off, change, set speed, spindle on. The lines with G01 in the example drill a hole. How they work is explained in drilling with G01 and feed rate.
(Change safely: up, spindle off, change, spindle on)G90 G21 G17T2 M6S1500 M3G00 X20 Y20G00 Z2G01 Z-8 F100 (drilling, see the G01 article)G00 Z50 (up to the safe height)M5 (spindle off)T3 M6 (change the tool)S900 M3 (new speed, spindle on)M5M30Common mistakes
Only T, no M6
T2alone only selects the tool. It goes into the spindle withM6. If you writeM3after it, you get the alarm "no tool loaded".Spindle without speed
M3withoutSdoes not run. Write the speed before switching on.Changing inside the material
The machine refuses a change at depth. First move up with rapid traverse, best to
Z50.Wrong tool for the hole
If you forget the change, you drill with the old tool. The hole then has the wrong diameter. Before every hole, check which tool is in the spindle.
Tasks on this topic
Practise what you learned right in your browser. Tests check your solution instantly.
Related articles
- Drilling by handCNC drilling without a cycle: one hole in four steps with G00, G01 and feed rate F. With G-code examples for one and several holes and common mistakes.Read article
- Cutting values and short pathsCalculate spindle speed from cutting speed, get the feed in mm/min and plan short paths: with formulas, G-code examples and the common mistakes.Read article
- Multiple toolsMultiple tools in one CNC program: centre drill, drill, countersink and tap with G84 in the right order. With G-code examples and the common mistakes.Read article