LinuxCNC M6

M6 is a LinuxCNC M-code that performs a tool change, replacing the tool currently in the spindle with the tool most recently selected by a T word. When the change completes, the spindle is stopped and the selected tool is in the spindle; a tool removed from the spindle is returned to the tool changer magazine if it was not already there. The tool changer itself must be configured in HAL and possibly ClassicLadder for the change to occur.

Source checked3/3 values · 2026-10-26

Specification

1 source
Languagegcode
CodeM6
SyntaxM6
DialectLinuxCNC

Study notes

  • The tool to load is the one most recently selected with a T word, either on the same line as M6 or on any line after the previous tool change.
  • The T word is an integer designating the tool pocket number in the carousel, not its index.
  • If the HAL component hal_manualtoolchange is loaded, M6 stops the spindle and prompts the user to change the tool based on the last T number programmed.
  • No changes other than the tool change are made; for example coolant keeps flowing during the change unless an M9 has turned it off.
  • If configured in the INI file, some axis positions may move when M6 is issued; see the EMCIO section for tool change options.
  • Programming a change to the tool already in the spindle is permitted but not useful.
  • If the selected slot holds no tool, the spindle is empty after the tool change; if slot zero was last selected there is definitely no tool in the spindle afterwards.
  • The tool changer will have to be set up to perform the tool change in HAL and possibly ClassicLadder.

Safety

  • Warning: the tool length offset is not changed by M6; use G43 after the M6 to change the tool length offset.
↑↓ navigate↵ openesc close