We detect you are using an unsupported browser. For the best experience, please visit the site using Chrome, Firefox, Safari, or Edge. X
Maximize Your Experience: Reap the Personalized Advantages by Completing Your Profile to Its Fullest. Update Here
Stay in the loop with the latest from Microchip. Update your profile while you are at it. Update Here
Complete your profile to access more resources. Update Here

SAMD21 Fan State Condition Monitoring Demo

This blog post outlines how to build a predictive maintenance application with the MPLAB Machine Learning Development Suite to create a fan that can run on the SAMD21 microcontroller.


Overview

In this tutorial, the Microchip MPLAB Machine Learning (ML) Development Suite is used to build a predictive maintenance application for a fan that can run entirely on the SAMD21 microcontroller. Specifically, the SAMD21 Machine Learning Evaluation Kit with Bosch IMU, which incorporates a 3-axis accelerometer and 3-axis gyro sensor, will be used to detect fan states of interest.

This tutorial focuses on predictive maintenance, but these technologies are applicable to a variety of domains where classifying time series sensor data is critical, such as gesture recognition, activity recognition, sound classification and keyword spotting.

Objective

  • Highlight a typical industrial use case example for the Microchip MPLAB ML Dev Suite
  • Build a data pipeline to extract features in real time on the SAMD21 ML Eval Kit
  • Train a classification model using the Microchip MPLAB ML Dev Suite’s AutoML feature
  • Evaluate model performance within the MPLAB ML Dev Suite environment
  • Convert the model into a Knowledge Pack that can be tested on the SAMD21 ML Eval Kit

The Demo Setup

To illustrate how the SAMD21 microcontroller can utilize motion/vibration sensors along with the MPLAB ML Dev Suite to create accurate IoT edge inference models, a simple fan apparatus was constructed that can represent a wide range of rotating equipment use case examples. Our demo fan apparatus uses a basic axial cooling fan, some 3D printed assembly parts, a 12 VDC power supply and some off-the-shelf hardware that allows the creation of a number of fan state conditions for measurement and model prediction.

This fan setup will be used to collect state information for fan ON versus OFF states, as well as blocked airflow, mount shocks and fan blade interference events.

The Sensor Dataset

As it is difficult for users to replicate the same physical device themselves, the dataset that was already collected is provided with the device as described above.

  1. Download the dataset here: Fan Demo Dataset.
  2. Unzip the folder on your computer.

Uploading the Dataset With the ML SDK

To upload the example dataset, you will need the MPLAB ML SDK. The installation guide for this is in the Installation Instructions Documentation.

  1. In the unzipped folder, there is a .PROJ file. Upload the dataset by running the following command in the ML SDK.

from mplabml import Client

client = Client()

client.upload_project('<Project-Name>', r'<Project-File-Path.proj>')

 

# Replace <Project-Name> with the name you want to save your project

# Replace <Project-File-Path.proj> with the .PROJ file path location on your computer

Labels

There are five different labels in the fan demo dataset:

Label

Example

Fan OFF

Fan OFF

Fan ON

Fan ON

Flow Blocked (Fan ON)

Flow Blocked Fan ON

Blade Inference (Fan ON)

Blade Inference Fan ON

Mount Shock (Fan OFF)

Mount Shock Fan OFF

Metadata

  • In the Project Properties, you can also define custom metadata to describe your files. As the vibration characteristics can vary considerably depending on the type of surface the fan is resting on, elect to create a metadata field to record what mounting surface type was used for each training file. The options provided include: Concrete, Solid Wood Tabletop, Fabric Covered Surface (like a tradeshow booth table with a skirt), Padded Surface or Unsturdy Tabletop.

Recording this information for each data file captured provides the flexibility to filter data later on or create submodels for each type of surface used.

In addition to this, choose to capture who collected the data. That way, if it is discovered later that a test technician incorrectly understood the data collection methodology or somehow introduced some adverse bias into the dataset, the means to filter that technician’s data from the model without having to reconstruct the entire dataset is available.

Adding a Query

With training data and useful metadata defined, the first step in generating a model within the MPLAB ML Dev Suite application is to create a query to filter the data to use to construct our model.

MPLab Adding Query

Give the query a suitable name, “Fan Monitoring - Solid Surface”, that describes the intent to focus only on the solid wood surface data for model creation. For metadata, ensure that “Mounting Surface” is among the selected criteria. Finally, use the Query Filter line item to define a constraint that only uses data where the metadata field “Mounting Surface” = “Solid Wood Tabletop”. With this subset, a tailored inference model for hard surface fan use is produced.

Building a Pipeline

To build a model, first you need to generate a pipeline that extracts the desired data segments by running the corresponding query. Each pipeline also contains a set of instructions to convert each segment to a set of features that are used in multiple machine learning algorithms.

The MPLAB ML Dev Suite AutoML engine explores multiple combinations of ML algorithms with different features. Then, the five best models are returned based on the adopted evaluation metrics.

To begin building a pipeline, go to the Build Model in the left menu. Name your pipeline, then choose the query you prepared previously from the drop-down menu. A critical parameter to define up front is the segment length for classification.

MPLAB Building Pipeline

While using a sliding window of fixed size, it is important to understand that the labeled segments consist of mostly continuous data for all but the Mount Shock event. Mount Shocks are taps of the finger on the fan assembly; therefore, those events are represented with discrete segments of a uniform length. When the dataset was created, the finger tapping Shock event fit consistently within a 250 msec window. And the sensor sample rate was defined as 400 Hz; therefore, this equates to a 100-sample window. The sliding window for the segment length cannot exceed this event duration (in order to detect it); therefore, also elect to use a window segment size of 100 samples.

Window Segment

Leave the other parameters with their default values, then click OPTIMIZE to generate candidate models.

Optimize Parameters

After several minutes of computation, the MPLAB ML Dev Suite AutoML will provide a number of candidate models to evaluate:

AutoML Optimized Results

With the Explore Model tab, examine each of these candidate models in detail. More information on the data provided in explore model can be found in the Exploring Model Details Documentation: /guides/getting-started/exploring-model-details. Looking across the presented options, the rank_2 model appears to be a good choice. Its confusion matrix is as follows:

Confusion Matrix

Testing and Deploying

After selecting a satisfactory model, test it against model data that was NOT used as part of the training process. Do that in the Test Model tab. Provided the results still look satisfactory, then proceed to the Download Model tab to create the embedded code optimized and suited for the SAMD21 device.

Download Knowledge Pack

Kedar Remane, Oct 17, 2023
Tags/Keywords: AI-ML, Development Tools, Maker

Live Chat

Need Help?

Privacy Policy