Here is a video of an example. This was originally done in Grbl_ESP32, but the machine was updated to FluidNC. The code is here...
This demo project was done as an experiment to show what could be done in FluidNC. Tool changing is not a standard feature of FluidNC because we cannot afford to support it. This is a professional level feature and to support it for free in free software would kill us. Please be respectful of our time.
ATCs can save time doing machining, but don't kid yourself. You will probably not save time by building your own ATC. I only recommend this to people who think ATC are really cool and you always wanted to build one just for the fun of it.
There are a lot of safety issues with ATCs. If your machine opens the ATC while spinning, it is likely to throw that tool across the room with a razor sharp bit. That could kill you. It will also likely do serious damage to your spindle. Be careful and never trust your machine or the firmware. You are the sole person responsible for your safety.
There is no generic support of ATCs. You cannot just create a special config file. You need to create a custom splindle class for the firmware. This is due the fact that there is no one size fits all solution to ATCs. Here are a few of the complexities.
FluidNC is written in object oriented c++. You will need strong programming skills and a basic understanding of FluidNC firmware. All spindles are classes. The class is selected in the config file. This allows you to have multiple spindles defined and change between them using M6 and and tool numbers. Each spindle can support a range of tool numbers this allow onew of then to be an ATC.
The main code of FluidNC calls functions in the classes. For normal spindles, many of these calls are ignored. ATC spindles can use these functions to dynamically generate and inject gcode into stream. This means M6 T2 would expand into all the gcode needed to make that tool change. It can also access things like probe touches to generate offset, etc.
Read the code. If it does not make sense to you, you probably are not ready to design your own ATC.
FluidNC is constantly evolving, so the example class not not even compile in the latest version. You may have to update the example or even modify the main code a little.