---
title: M6 (Tool Change)
slug: m6-tool-change
docTags: 
createdAt: 2022-03-25T00:03:51.000Z
---

To change a tool in the spindle from the tool currently in the spindle to the tool most&#x20;

recently selected (using a T word - see Section 3.7.3), program `M6`. When the tool change is complete:&#x20;

- The spindle will be stopped.&#x20;
- The tool that was selected (by a T word on the same line or on any line after the previous tool change) will be in the spindle. The T number is an integer giving the changer slot of the tool (not its id).&#x20;
- If the selected tool was not in the spindle before the tool change, the tool that was in the spindle (if there was one) will be in its changer slot.&#x20;
- The coordinate axes will be stopped in the same absolute position they were in before the tool change (but the spindle may be re-oriented).&#x20;
- No other changes will be made. For example, coolant will continue to flow during the tool change unless it has been turned off by an M9.&#x20;

The tool change may include axis motion while it is in progress. It is OK (but not useful) to program a change to the tool already in the spindle. It is OK if there is no tool in the selected slot; in that case, the spindle will be empty after the tool change. If slot zero was last selected, there will definitely be no tool in the spindle after a tool change.&#x20;

The tool change command will call the `change_tool` subroutine inside *macro.cnc*.

You can adapt  the behavior for your own needs in this function e.g:

- Perform automatic tool-length measurement
- Perform tool change with an automatic tool changer.

For a (non-functional)  example of how to implement automatic tool change for a 16-tool changer.  see the contents of the *default\_macro.cnc&#x20;*&#x66;ile at the end of this document. It checks whether the current tool is already in the spindle. It checks that the tool number is in the range of 1-4. Then it first drops the current tool and picks the new tool:



