Getting started with FP-AI-NANOEDG1

Revision as of 08:33, 7 July 2020 by Registered User

This article is a quick start guide for FP-AI-NANOEDG1, a condition monitoring function pack based on vibration sensor data. It is based on STM32Cube ecosystem and is for STM32 microcontroller family.

Renaming.png This page is a candidate for renaming (move).
The requested new name is: [Getting started with FP-AI-NANOEDG1.
No reason supplied!
No signature supplied!
Wiki maintainers: remember to update the pages that link this page before renaming (moving) it.

This article provides an overview on the following topics.

  • Overview of the required and used hardware and software,
  • Setting up the hardware and software components,
  • Performing the vibration sensor data collection using the provided function pack,
  • Generating, Installing and Testing the NanoEdge™ AI machine learning libraries on the sensor node STM32L562E-DK using the provided function pack, and finally
  • Some links to useful online resources which can help a user to better understand the project and then customize the project to his own needs.

1. Hardware and Software Overview

1.1. Discovery kit with STM32L562QE MCU Hardware Description

The STM32L562E-DK is a complete demonstration and development platform, for Arm® Cortex®-M33 with Arm® TrustZone® and ARMv8-M mainline security extension core-based STM32L562QEI6QU microcontroller. The onboard MCU can run at 110 MHz/165 DMIPS, and has 512 Kbytes of Octo-SPI Flash memory and 256 Kbytes of SRAM. The other key specifications of the board are:

  • 1.54" 240 × 240 pixel-262K color TFT LCD module with parallel interface and touch-control pane, which can be used for standalone demos.
  • iNEMO 3D accelerometer and 3D gyroscope
  • MEMS digital microphones, and a low-power stereo audio CODEC with headphone amplifier,
  • 2 user LEDs
  • User and reset push-buttons
  • Board connectors include :
    • USB Type-C™
    • Bluetooth® V4.1 Low Energy module
    • microSD™ card
    • Stereo headset jack including analog microphone input
    • JTAG debugger

For further details readers can have a look at the data briefs for STM32L562E-DK.

File:STM32L562E-DK.png
An image of STM32L562E-DK Board, with WI-FI®, Grove and mikroBUS™ compatible connectors.

1.2. FP-AI-NANOEDG1 Software Description

The FP-AI-NANOEDG1 is a function pack with basic project to easily jump-start the condition monitoring applications using vibration sensor data. The project is based on the STM32Cube ecosystem and serves as a host, for the AI libraries generated from NanoEdge™ AI Studio, a solution from Cartesiam. The following figure shows the software architecture of the FP-AI-NANOEDG1.

Overall Software Architecture of FP-AI-NANOEDG1

The key features of the software are:

  • Complete firmware to enable a sensor node for data logging, condition monitoring and predictive maintenance applications based on vibration data,
  • Simple LCD user interface,
  • Autonomous mode controlled by user button,
  • Wired interactive Command-Line Interface (CLI) for
    • Node and sensor configurations,
    • AI utility for parsing and conditioning the data logged on a microSD™ card through CLI,
    • Management of the learning and detection phases of Cartesiam Machine Learning solution
  • A free license with user-friendly terms.

2. Project Setup with Example Application

2.1. HW prerequisites and Setup

To use the FP-AI-NANOEDG1 function pack on STM32L562E-DK, following hardware items are required:

  • STM32L562E-DK development kit board,
  • Windows powered Laptop/PC (Windows 7, 8, or 10),
  • A USB cable to connect the PC to the Micro-B USB connector on the board (CN17-STLNK),
  • A micro SD card for data logging,
Required hardware items to use FP-AI-NANOEDG1 on L5 discovery kit.

2.2. Software Requirements

2.2.1. FP-AI-NANOEDG1

2.2.2. STM32CubeIDE

  • STMCubeIDE is an Integrated Development Environment (IDE) for STM32 family.
  • Users need to download the software from STM32CubeIDE link, and install it.

2.2.3. STM32 ST-Link Utility

  • A software interface for programming STM32 microcontrollers. This software is only required to install the prepared binaries provided in the function pack folder at start. Note that this software will be used by not just users to install the already provided binaries but by STM32CubeIDE also to program the boards with the generated binaries.
  • This software can be downloaded from STSW-LINK004 link.

2.2.4. TeraTerm

  • TeraTerm is an open source and freely available software terminal emulator, which is used to host the CLI of the FP-AI-NANOEDG1 through serial connection.
  • Download and install from TeraTerm.

2.3. FP-AI-NANOEDG1 Console Application

FP-AI-NANOEDG1 provides an interactive Command Line Interface (CLI) application. This CLI application provides a user the ability to configure and control the sensor node, to log the data to generate the Cartesiam NanoEdge AI libraries and then perform the condition monitoring by training and testing these libraries on the edge. Following sections provide a small guide on how can a user install this CLI application on sensor board and control it through the CLI on a PC.

2.3.1. Get the Function Pack

The first step is to get the Function Pack. TheFP-AI-NANOEDG1 can be downloaded from ST website. Once the pack is downloaded as a .zip file, the user can unpack it and copy the contents to a folder on the PC. The steps of the process along with the contents of the folder are shown in the following image.

Downloading and Unpacking the FP-AI-NANOEDG1

2.3.2. Installing the CLI Application on the Sensor board STM32L562E-DK

Once the package has been downloaded and unpacked, the next step is to flash the sensor node with the binary of the function pack. For the convenience of the users, the function pack is equipped with a pre-built binary file of the project. The process to install this binary file to the sensor board is shown below in the figure.

File:flash the application.png
Steps to flash the board with FP-AI-NANOEDG1 binary

2.3.3. Use the Command Line Interface (CLI)

Once the sensor board is flashed with the binary of the project, the next step is to set up the serial connection of the board with the PC through TeraTerm. Step ① and ② in the figure below show the process of setting up the serial connection.

File:using command line interface1.png
Using the Command Line Interface (CLI) Application of FP-AI-NANOEDG1.

Once the connection is made the user will see a message

Console command server.
Type 'help' to view a list of registered commands.
$

Typing help will show the list of all available commands as presented in the table below.

Command String Description
CS1 - Generic Commands
help help List all registered commands with brief usage guidelines. Including the list of applicable parameters.
info info Shows firmware details and version.
uid uid Show STM32 UID.
date_set date_set <date&time> Sets date and time of the MCU system.
date_get date_get Gets date and time of the MCU system.
reset reset Resets the MCU System.
start start <"datalog", "neai_learn", or "neai_detect" > Starts an execution phase according to its execution context, i.e. datalog, neai_learn or neai_detect.
stop stop Stops all running execution phases.
CS2 - PdM Specific Commands
neai_init neai_init (Re)initialize the AI model by forgetting any learning. Used in the beginning and / or to create a new NanoEdge AI model.
neai_set neai_set <param> <val> Set a PdM specific parameters in an execution context.
neai_get neai_get <param> Displays the value of the parameters in the execution context.
CS3 - Sensor Configuration Commands
sensor_set sensor_set <sensorID>.<subsensorID> <param> <val> Sets the ‘value’ of a ‘parameter’ for a sensor with sensor id provided in ‘id’.
sensor_get sensor_get <sensorID>.<subsensorID> <param> Gets the ‘value’ of a ‘parameter’ for a sensor with sensor id provided in ‘id’.
sensor_info sensor_info Lists the type and ID of all supported sensors.
Available commands in Command Line Interface (CLI) Application of FP-AI-NANOEDG1

3. Data Collection

Once the user has verified that the binary has been flashed and the serial connection is already setup to the sensor node, user can start the data logging. The following section provides the guide for performing the data log.

3.1. Configure the Sensor for Data Logging

The FP-AI-NANOEDG1 provides the capability of logging the inertial data through onboard accelerometer LSM6DSO in STM32L562E-DK, through the CLI application. The CLI interface provides the user with a capability to not just log the data with the default configurations of the sensor but also equip the user with the capability to configure the sensor by setting different values to the different variables. The configurable options for LSM6DSO include:

  • activate/deactivate the sensor or a sub-senor,
  • set an output data rate (ODR) from the list of available options,
  • set full scale range from the list of available options.

Furthermore, the list of all the available sensors and sub-sensors can be displayed on the CLI console by entering the command,

$ sensor_info

This command will show the supported sensors with their sensor and sub-sensor ids. The detailed information of a given supported sensor or sub-sensor can be shown by typing command:

$ sensor_get <sensor_id.sub-sensor_Id> all

Similarly, the values for any of the available configurable parameters can be set through command

$ sensor_set <sensor_id.sub-sensor_Id> <param> <val>
File:data logging.png
Sensor Configuration and Data logging using FP-AI-NANOEDG1

3.2. Logging the Data

Once the sensor is configured to the wished configuration values, the data logging can be started by simply entering the command

$ start datalog

in the CLI console. While the data logging is under progress the LCD screen on the sensor board shows the active size of the data log in kilobytes as shown in the figure above. Once the data is logged for the required time, the process can be stopped by either pressing the Esc button, or by typing the command

$ stop

in to the CLI console.

With every successful data logging command, a new data folder will be created in the SD card with the name format STM32_DL_XXX, with DeviceConfig.json and LSM6DSO files. These files contain the sensor configuration at the time of start datalog command issued, and the sensor data respectively.

Warning white.png Warning
Note: The data logging requires an SD card present. In the absence of the SD card an error will be reported on the CLI console.

4. Condition Monitoring using NanoEdge AI Machine Learning Library

4.1. Generating a Condition Monitoring Library

The AI libraries for the condition monitoring for this function pack are generated and provided by NanoEdge AI Studio, a solution provided by Cartesiam. This section provides step by step guide on how to generate the condition monitoring libraries for the set up user wants to monitor. Following are the steps involved on generating these libraries, installing them on the sensor node by linking them to provide project in FP-AI-NANOEDG1 and then using them to perform the condition monitoring on the edge, by running first in training and then detection mode.

4.1.1. Data Logging for Normal and Abnormal Conditions

The library generation requires some contextual data to provide the NanoEdge AI Studio with the context of the set up to be monitored. The firs step is to log the data for the normal and abnormal conditions using the data logging application provided in this function pack. Note that this data is to generate the libraries, so the users are advised to record data by exposing all the possible normal and any known abnormal conditions.

4.1.2. Data Preparation for Library Generation with NanoEdge AI Studio

The data logged through the datalogger is in the binary format and is not user readable in its current condition. In order to convert this data to useful form, FP-AI-NANOEDG1 provides python utility scrips. These scripts along with example usage can be found in a Parser_for_HS_Logged_Data.ipynb , a Python Jupyter Notebok, located on the path FP-AI-NANOEDG1/Utilities/AI-resources/DataLog/ as shown in the figure below.

Python Utility Code for Parsing and Preparing the Inertial Data for NanoEdge AI Studio

4.1.3. Library Generation using NanoEdge AI Studio

The process of generating the libraries with Cartesiam NanoEdge AI studio consists of five steps.

  1. Hardware description
    1. Choosing a microcontroller type : ARM® Cortex® M33
    2. Maximum amount of RAM to be allocated for the library: Usually few KBs will suffice (depends on the dataframe length used in the process of data preparation.
    3. Sensor type : 3-axes accelerometer
  2. Providing the sample contextual data to adjust and gauge the performance of the chosen model. This step will require data for:
    1. Nominal or Normal case
    2. Abnormal case
  3. Benchmarking of available models and choosing the one which complies with the requirements.
  4. Validating the model for learning and testing through the provided emulator which emulates the behavior of the library on the edge.
  5. The final step is to compile and download the libraries. In this process the flag mfloatabi has to be unchecked for using libraries with hardware FPU.

The detailed documentation on the NanoEdge AI Studio is available here NanoEdge AI Studio Documentation.

4.2. Installing the NanoEdgeAI Machine Learning Library

Once the libraries are generated and downloaded from Cartesiam NanoEdge AI Studio the next step is to incroporate these libraries to FP-AI-NANOEDG1. To do so the user needs to copy and replace the existing NanoEdgeAI.h file and the libneai.afile in to the folders lib, and bin, respectively located in /FP_AI_NANOEDG1/Middlewares/Third_Party/Cartesiam_NanoEdge_AI_Library/ as shown in the figure below.

Copying Cartesiam generated the libraries to the project.

Once copied these files, to link the libraries the project needs to be rebuild and flashed to the sensor board. For this open the .project file from the FP-AI-NANOEDG1 folder, located at the path FP_AI_NANOEDG1/Projects/STM32L562E-DK/Applications/NanoEdgeConcole/STM32CubeIDE/ as shown in the step 2 in figure below. To install the new firmware after linking the library, connect the sensorboard and rebuild the project using the play button. See the console to for the outputs showing the build and programming progress. Check for the build and Download successful message as shown in step 4 in the figure below.

File:linkingLibrariesToFP.png
Linking the generated libraries to the FP-AI-NANOEDG1.

4.3. Testing the NanoEdgeAI Machine Learning Library

Once this message appears, the generated AI libraries are linked to the firmware on the sensor board and are ready to be tested.

File:testingLibraries.png
Real-time Condition Monitoring on the Edge using STM32L562E-DK and Cartesiam generated libraries.

To test the libraries on the sensor board follow the instructions available on the screen, i.e. long press to start the Learning Process and press the button again to stop. Short press the button to start the detection process. The step 5 in the figure above shows the testing process on the screen. Furthermore, these steps can also be controlled from the console application by typing

 $ start neai_learn 

and stopping it by pressing either Esc button or by typing command

 $ stop 

. Similarly the detection process can be started by started by typing in the command

 $ start neai_detect

.

5. Documents and Related Resources