AI and Self-learning on Esp32-C6, teaching the MCU to detect CNC tool breakage

A project log for Esp32-C6-Bug + Esp32-Bug-Eth

Playing with the new Esp32-C6FH4:

allexokallexoK 04/23/2024 at 12:500 Comments

Maybe a little bit off topic, but I was recently experimenting with training decision trees directly on the MCU.  For those unfamiliar, decision tree is a machine learning algorithm and you can teach it to perform some classification task.

Problem definition 

We have a huge CNC machine that we use to process wood or aluminum. Sometimes CNC tool breaks during CNC processing, but the machine can't detect it and just keeps going forward without touching the material. (Just moving above it). So when sometimes we leave the machine working and go somewhere, we return and the job is undone. It would be good from a practical standpoint to get alerted, when such error occur(via some messenger app or sms ), so the process can be stopped and restarted.

Other requirement


So based on the requirements I made a simple smart accelerometer that can learn the tool breakage state from vibrations. The device is made around bno055, Esp32-C6-Bug and a solar shield. I decided to use Esp32-C6-Bug because it's currently the only board I have that has battery support, Stemma QT connector, SD card for saving the data and a sim card module. 

Classified states: 

Both the code and my learning data are available. For now the device was trained with only one tool and only wood. The classification result is printed to UART, of course it you can send info about state change via SMS, some messenger (like Telegram) up or control a relay to automatically turn of the CNC machine.

 The accuracy was 0.89 after learning on 24 minutes of data.

Device states and events that trigger state transfers are on the picture: