I’ve been building a CNC Router, and now I’d like to add the rack of tools and toolchanger support.

According to the LinuxCNC community, the best way to implement this style of tool changer is by remapping the relevant G-code commands (e.g. M6), as shown in this example.

When the interpreter encounters M6, the selected tool (via the T word: M6 T1) is placed into the spindle (if different from the current tool). The tool length offset is not applied until G43 is executed (e.g. G43 H1).

Note: I think it’s possible to write M6 T1 G43 to change to tool #1, and set its offset.

Remapping M6

Remapping M6 is more complicated than remapping other Gcode commands.

We start by specifying in the INI file that we’d like to remap M6:

[RS274NGC]
REMAP=M6 modalgroup=6 python=rackchange

This says that upon encountering M6, the interpreter should execute the Python function rackchange, defined as described in the next section.

Defining the Python Tool Change Function

http://linuxcnc.org/docs/devel/html/remap/remap.html#remap:embedded-python