Blog post

Keeping Your Machines Well-Oiled with TinyML

Projects
By Nick Bild
Keeping Your Machines Well-Oiled with TinyML

Predictive maintenance is a proactive approach to maintaining equipment and machinery in industrial settings. By using data analysis and advanced technologies such as sensors and machine learning algorithms, predictive maintenance allows companies to predict when equipment is likely to fail and take preventative measures to avoid costly downtime.

One of the key benefits of predictive maintenance is its ability to extend the lifespan of equipment. By identifying and addressing potential issues before they become major problems, companies can avoid costly repairs and replacements. This not only saves money, but it also helps to improve the overall efficiency and productivity of the company.

In addition to extending the lifespan of equipment, predictive maintenance can also improve safety in the workplace. By identifying potential hazards before they occur, companies can take steps to prevent accidents and injuries. This is especially important in industrial settings where the use of heavy machinery can pose a risk to workers.

An AC motor

Implementing a predictive maintenance program can be a complex process, but the benefits are clear. Companies that adopt predictive maintenance can reduce their maintenance costs, improve the reliability and performance of their equipment, and create a safer work environment for their employees. As such, it is an increasingly popular strategy in the industrial sector and one that is likely to continue growing in popularity in the coming years.

With the rise of tools like Edge Impulse Studio that make it simple and inexpensive to deploy machine learning algorithms to resource-constrained edge computing devices, predictive maintenance programs are becoming much easier to implement. Engineer and machine learning enthusiast Shebin Jose Jacob recently developed a device that demonstrates just how simple it can be to get started. His device listens to the sounds an AC motor makes while it is running, then uses a machine learning classifier to determine if it is in need of maintenance.

The Arduino Nano 33 BLE Sense inside the 3D-printed enclosure

Jacob selected the tiny yet powerful Arduino Nano 33 BLE Sense development board for the job. It features a nRF52840 system on a chip from Nordic Semiconductor with a 32-bit Arm Cortex-M4 CPU, 256 KB of SRAM, and 1 MB of Flash memory. These specs are more than sufficient to run a machine learning algorithm that has been highly optimized for edge devices by the Edge Impulse platform. The Arduino board also comes standard with a highly sensitive microphone to capture audio data, which makes it an all-in-one hardware solution for the project.

Since Jacob wanted to be able to recognize different types of abnormal states of operation for the motor, as well as normal operation, he decided to build a neural network classifier.  For that classifier to be able to distinguish between states, it would need audio samples from each state to teach it their characteristics. To make collecting that data as seamless as possible, the Edge Impulse CLI was installed, and the Arduino board was linked to an Edge Impulse Studio project. After that was finished, any samples collected from the onboard microphone were automatically uploaded to Edge Impulse.

Examining the training data in Edge Impulse Studio

By placing the Nano 33 BLE Sense hardware next to an AC motor, Jacob collected a series of two second audio clips to serve as the training data set. These samples all fell into one of four categories — normal motor operation, two types of anomalies, or background noise (indicating that the motor is not running). Each sample was automatically uploaded to Edge Impulse Studio where it was assigned a label and split between a training data set to produce the classification model, and a testing set that would be used later to validate the model’s accuracy.

Having completed the task of collecting sample data, Jacob was ready to build the classification pipeline. Using the intuitive point-and-click web interface of Edge Impulse Studio, he actually found this to be the simplest part of the entire project. Preprocessing blocks were first added to the impulse to split the audio samples into one second segments, then extract time and frequency features from the signal. By extracting these important features, downstream processing steps have less work to do, which reduces the computational complexity of the algorithms that are produced. Finally, a neural network classification block was added to distinguish between operational states of the motor.

Designing a classification pipeline

The model’s hyperparameters were adjusted a bit to produce the best outcome during the training process. Edge Impulse’s data augmentation tool was also turned on — this makes tiny, random tweaks to the training data between cycles which has the effect of preventing overfitting and generating a more robust and generalized model. After making these adjustments, the training process was kicked off with the click of a button.

When the training process completed a short time later, metrics were displayed to help assess the accuracy of the model. It was found that the average classification accuracy had already reached 94.7% on the first attempt. This is quite impressive, but it is good practice to always be wary of overfitting, even when using data augmentation methods, so the model testing tool was used next. This is a more stringent validation step that uses a data set that was excluded from the training process. The test revealed a classification accuracy of just over 95% on average.

Assessing the model training results

Pleased with these results, Jacob was ready to deploy the full classification pipeline to the physical hardware. Doing so removes any dependencies on the cloud, and it also eliminates privacy concerns that crop up when continuously transmitting microphone data over the internet, since all processing can take place on-device. A simple and versatile means for deploying complete analysis pipelines to devices such as the Nano 33 BLE Sense is downloading an Arduino Library using the deployment tool.

After importing the library into Arduino IDE, it is possible to insert one’s own logic that is triggered based on the inferences made by the machine learning model.  In this case, Jacob used the board’s GPIO pins to illuminate a red LED when a maintenance issue was detected, which would alert workers to the fact that a machine needed to be serviced. To put a bit of polish on the design, a simple case was 3D-printed to house the hardware.

Jacob wrote up the details of his project, which are posted in Edge Impulse’s online documentation, so be sure to check it out for all the tips and tricks you need to get started. You can get a head start on building your own, customized version of this device by first cloning Jacob’s public Edge Impulse Studio project.


Want to see Edge Impulse in action? Schedule a demo today.

Comments

Subscribe

Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

Subscribe to our newsletter