Tool change and spindle commands – T, M6, M3/M4/M5, S

Tool change and spindle commands in NC code: tool call with T and M6, spindle speed S, and M3, M4 and M5 clearly explained – with a G-code example.

In CNC programming, T, M and S commands control central functions of the machine: selecting and changing the tool, and switching the spindle on and off with the desired direction and speed.

Tool call with T and M6

The tool is called with the T command (e.g. T1, T2, etc.), which selects a specific tool from the tool magazine – comparable to a chef picking the right kitchen tool for a task. The M6 command then performs the actual tool change: the tool selected with T is loaded into the spindle.

Spindle control with S, M3, M4 and M5

M functions are control commands that switch various machine functions – much like the switches and buttons in a vehicle. Three of them are central to the spindle:

CommandFunction
M3Start the spindle clockwise
M4Start the spindle counterclockwise
M5Stop the spindle

The spindle speed is set with the S command, e.g. S1500 for 1500 revolutions per minute. It determines how fast the tool rotates.

Example

T5 M6      ; select and load tool 5
S1200 M3   ; start the spindle clockwise at 1200 rpm
...        ; machining
M5         ; stop the spindle

Together, these commands give you full control over the tool and the spindle: from the tool change through direction and speed of rotation to stopping the spindle.