STMicroelectronics FP-AI-PDMWBSOC User Manual
Publicitate
Publicitate
UM3069
User manual
Getting started with the STM32Cube function pack for
STEVAL-PROTEUS1 evaluation kit for predictive maintenance application based on artificial intelligence (AI)
Introduction
FP-AI-PDMWBSOC is an STM32Cube function pack for the STEVAL-PROTEUS1 evaluation kit. It acquires motion sensor data, process them for anomaly detection, and sends the results to the STBLESensor mobile app and/or a PC terminal console.
The application is based on the vibrometer and accelerometer data, which are used to execute a machine learning algorithm to detect anomaly conditions on industrial assets. You can configure this application remotely through wireless or wired connectivity.
The monitoring of equipment conditions for predictive maintenance applications through the STEVAL-PROTEUS1 allows reducing the loss of productivity, due to machine downtime, and unplanned maintenance costs, improving the performance of the production chain.
Using a binary data logging file, the raw data can be extracted from the sensors within the STEVAL-PROTEUS1 evaluation board and provided into the NanoEdgeAIStudio software, which allows you to extract a machine learning library for anomaly detection.
This NanoEdge AI library, built on the classified dataset, can be easily integrated into the proposed framework architecture, facilitating the early detection of an alert status and, hence, potential failure in the equipment.
FP-AI-PDMWBSOC provides two different HMI communication tools at user level:
• a wireless mobile app ( STBLESensor ) with dedicated pages to configure the node and manage the learning and detection phases
• a wired interactive command line interface (CLI) to provide the same functionalities
To start/stop the learning and detection phases, it is also possible to perform an additional control, indicated by LEDs, simply pressing the user button.
The main software features to manage the NanoEdgeAI library are based on a set of application-level modules (sensor manager, digital processing unit), useful to reuse and easily extendable to build other customized applications.
These application modules implement innovative software design models based on application layers built on an embedded light object-oriented framework (eLooM) middleware for embedded applications powered by STM32.
Related links
Visit the STM32Cube ecosystem web page on www.st.com for further information
UM3069 - Rev 1 - September 2022
For further information contact your local STMicroelectronics sales office.
www.st.com
1
1.1
1.2
UM3069
FP-AI-PDMWBSOC software expansion for STM32Cube
FP-AI-PDMWBSOC software expansion for STM32Cube
Overview
•
•
•
•
•
•
•
•
•
The FP-AI-PDMWBSOC software package features are:
•
•
Firmware to develop a WPAN sensor node for predictive maintenance applications, featuring motion sensors and performing anomaly detection controlled via Bluetooth® Low Energy connectivity
STM32 wireless personal area network middleware developed within the STM32WB framework used to support Bluetooth® Low Energy 5
Compatible with NanoEdgeAIStudio solution to enable AI-based applications
On-board battery status monitor
Compatible with STBLESensor app (Android and iOS) to enable AI library control and monitoring, and firmware update via fast FUOTA
Based on accelerometer data up to 6 kHz bandwitdh
NanoEdge AI library generated to run in the STM32WB module
Firmware modular example based on the embedded light object-oriented framework (eLooM) to enable code reusability at application level
Application for datalogging in binary format
Utilities: Python and CLI real-time control applications
Free, user-friendly license terms
The software gathers:
•
•
• the 3-axis acceleration from the the battery status from the
IIS3DWB
STBC02
or the ISM330DHCX green, red, and blue LEDs to indicate the connection status and NEAI phase
Architecture
The FP-AI-PDMWBSOC software is designed for the STEVAL-PROTEUS1 development kit, respecting the compliance with the STM32Cube architecture, structured into a set of layers of increasing abstraction.
Figure 1. FP-AI-PDMWBSOC software architecture
UM3069 - Rev 1 page 2/69
1.3
UM3069
Folders
The hardware abstraction layer (HAL) interfaces with the hardware and provides the low-level drivers and the hardware interfacing methods to interact with the upper layers (application, libraries, and stacks). It provides APIs for the communication peripherals (I²C, SPI, UART, etc.) for initialization and configuration, data transfer, and communication errors.
There are two types of HAL driver APIs:
•
• generic APIs, which provide common and generic functions to the entire STM32 series extension APIs, which provide specific, customized functions for a particular family or a specific part number
The package extends STM32Cube by providing a set of APIs, which follows the hardware structure, including a component management layer as well as the specific layers of the boards used.
On top of such features, inherited from STM32Cube , the FP-AI-PDMWBSOC is focused on code reusability, according to the eLooM-based application-level architecture.
It is based on several firmware modules that interface and offer data to other application modules according to well defined design patterns and specific APIs.
Each firmware module (sensor manager, digital processing unit) is packed into a folder. They are independent from each other, and they can be added to your firmware application by just including the module folder inside your project.
Every firmware module implements or extends drivers, events, and services made available by the eLooM framework. More specifically, here you can find:
•
•
• drivers - objects that implement the base interface for any low-level subsystem that can be used into the firmware module (SPI, UART) events - objects that handle information about something that happened in the system at a given moment; these files implement the event and source/listener design patterns services - additional utilities for the firmware module
Folders
The FP-AI-PDMWBSOC firmware package folder structure follows the layer-based approach of the STM32Cube architecture.
Figure 2. FP-AI-PDMWBSOC package folder structure
UM3069 - Rev 1
The folders included in the software package are:
•
•
Documentation - contains a compiled HTML file generated from the source code, which details the software components and APIs.
Drivers - contains the HAL drivers and the board-specific drivers for each supported board or hardware platform, including the on-board components and the CMSIS vendor-independent hardware abstraction layer for ARM Cortex-M processor series.
page 3/69
1.4
UM3069
APIs
•
•
Middlewares - contains all the libraries released by ST or a third party, as listed below:
– STM32_WPAN , wireless personal area network middleware developed within the STM32WB framework with protocols for Bluetooth® Low Energy connectivity
– STM32_BLE_Manager , STM32 middleware providing an API to manage the Bluetooth® Low Energy service
– eLooM , embedded light object-oriented framework for STM32 applications
– NanoEdge_AI_Library , default (“stub”) NanoEdge library
– STM32_USB_Device_Library , middleware for USB connectivity
– FreeRTOS™, , third-party free real-time operating system
– Parson , lightweight JSON library
Projects - contains one sample application for the STEVAL-PROTEUS, in source code, for the following toolchains:
– IAR Embedded Workbench for Arm ( IAR-EWARM ).
– Keil® Microcontroller Development Kit for Arm ( MDK-ARM ).
•
– ST integrated development environment for STM32 ( STM32CubeIDE ).
– A binary folder that contains all the applications in a compiled format
Utilities - includes three different folders to support the whole development:
– the Bootloader , which allows updating the firmware by FUOTA; just download the binary files into your smartphone and update the firmware via the STBLESensor mobile app
– the HSDatalog application that provides an easy way to save data from any combination of sensors configured at their maximum sampling rate
The STM32WB_Copro_Wireless_Binaries folder contains the coprocessor wireless firmware binary to be used.
APIs
Detailed technical information with full user API function and parameter description are in a compiled HTML file in the “Documentation” folder and in the "Doc" folder of each firmware module and eLooM middleware.
UM3069 - Rev 1 page 4/69
2
UM3069
Application scenario
Application scenario
The condition monitoring by anomaly detection, based on the STEVAL-PROTEUS, enables the early detection of fault conditions directly on the equipment. This facilitates the implementation of a predictive maintenance program, which reduces the loss of productivity in the production chain due to unplanned downtime.
The STEVAL-PROTEUS evaluation board includes some sensors to acquire vibration data such as the IIS3DWB vibrometer (wide bandwidth up to 6 kHz), or the ISM330DHCX accelerometer (bandwidth up to 3.3 kHz), useful to be processed by the embedded anomaly detection (AD) library.
Bluetooth® Low Energy permits a direct connection with a smartphone and facilitates the WPAN node configuration, data monitoring, equipment status, and firmware upgrade over the air (FUOTA).
The STBLESensor app includes all the commands for learning and detection, plus a complete set of custom commands to configure different parameters for the NEAI library. The CLI (USB) connectivity supports the same functionalities.
Figure 3. FP-AI-PDMWBSOC application overview
UM3069 - Rev 1
You can see the results of the anomaly detection processing using the STBLESensor app or the CLI, which is accessible via a standard USB terminal console.
You can change the AD library settings through the mobile app or the CLI in the same application session.
The example is provided in the “projects” directory, in source code, ready to be built for multiple IDEs.
The application provides:
•
•
• a stable connection via USB with the CLI terminal console and, at the same time, connectivity via
Bluetooth® Low Energy in advertising mode the initialization of all the sensors data handling and the embedded NanoEdge AI library, including all the setting parameters the battery status according to the STBC02 measurements
The package is based on the following mandatory key elements:
• the FreeRTOS™ operating system as a third-party middleware for the real-time execution page 5/69
UM3069
Application scenario
• the eLooM middleware, which implements the object-oriented methodology for the data management and processing with the AI library, easy to use at application level, thanks to the following reusable software modules:
– the sensor manager, which consists of components that retrieve sensor data and set the sensor parameters. It is implemented as an acquisition engine that:
◦
◦
◦ controls multiple task accesses to the sensor bus defines interfaces to avoid implementation dependencies dispatches events to notify when a certain amount of data is available
– the digital processing unit (DPU), which consists of components that provide a set of processing blocks; these blocks can be chained together in order to handle all the sensor data set before the AI library processing. Available processing modules include:
◦
◦ circular buffering anomaly detection processing (AD)
Further details are available in the "documentation" folder.
The STBLESensor design and development follow a specific working flow. This flow is based on the use of different application firmware and of different software tools oriented to datalogging and library generation.
Figure 4. FP-AI-PDMWBSOC working flow
UM3069 - Rev 1 page 6/69
3
3.1
UM3069
System setup guide
System setup guide
STEVAL-PROTEUS1 industrial sensor evaluation kit
The FP-AI-PDMWBSOC software package is tailored for the STEVAL-PROTEUS evaluation board. This is the main board of the STEVAL-PROTEUS1 kit, which embeds an ultra-low-power and small form factor certified 2.4
GHz wireless module ( STM32WB5MMG ). This module supports Bluetooth
®
Low Energy 5.0 and others 802.15.4
proprietary protocols (for further details, refer to UM3000 ).
Figure 5. STEVAL-PROTEUS1 evaluation kit
UM3069 - Rev 1
The module is protocol stack royalty-free. It is featured by a dual Arm ® core, a dedicated Arm ® Cortex ® -M0+ for radio and security tasks and a dedicated Arm ® Cortex ® -M4 CPU with FPU and ART (adaptive real-time accelerator) up to 64 MHz speed. It also comes with 1-Mbyte Flash memory and 256-Kbyte SRAM. These features allow running complex algorithms directly through the board and deliver ready-to-use results.
It includes ST MEMS sensors for battery-operated applications to target IoT as well as Industry 4.0.
Features
Table 1. Hardware platform details
STEVAL-PROTEUS
Board
Size (mm)
Vibration analysis
Connectivity
Datalog and GUI
Development tools
35 x 30 x 7
Up to 6 kHz
Bluetooth ® Low Energy
CLI
STLINK-V3MINI – STLINK-V3MINIE
STBLESensor app (Android/iOS)
Debug terminal via SWD
Debug terminal via UART page 7/69
UM3069
STEVAL-PROTEUS1 industrial sensor evaluation kit
The evaluation board comes with three inertial modules:
•
•
• the the the
IIS3DWB
IIS2DLPC
ultra-wide bandwidth, low-noise, 3-axis digital vibration sensor
high-performance ultra-low-power 3-axis accelerometer
ISM330DHCX 3-axis accelerometer and 3-axis gyroscope with machine learning core (MLC)
The STTS22H low-voltage, ultra-low-power, high accuracy temperature sensor has also been integrated in the board, far from the heat noise sources (the power management and the microcontroller) to provide a more precise temperature measurement. Its exposed pad and the PCB accurate design allow the temperature sensor to be in contact with the surface of the target equipment.
Moreover, the evaluation board integrates the STSAFE-A110 secure element that provides authentication and secure data management services to a local or remote host.
Furthermore, a NOR flash memory is soldered on the board. It is connected via QSPI to the STM32WB5MMG module for data buffering and event storage.
The ST1PS02 400 mA step down converter for low-power applications and the STBC02 Li-Ion linear battery charger feature the power management.
Figure 6. STEVAL-PROTEUS main devices
UM3069 - Rev 1
The STEVAL-PROTEUS can be powered via:
• a LiPo rechargeable battery
•
•
USB (5 V at 500 mA) a primary battery (not included in the kit)
All components are mounted exclusively on the top side of the PCB to ensure easy mounting on other equipment, even when using the plastic case for the board and the LiPo battery (included in the kit).
page 8/69
Figure 7. STEVAL-PROTEUS power connector, SWD, user button, and LED
UM3069
Hardware setup
3.2
Note:
Hardware setup
The hardware prerequisites to prepare the kit are:
•
• two USB Type-A to Micro-B cables: one to monitor the debug console and program the board via the
STDC14 connector, and one to use a CLI via USB an STLINK-V3MINI or STLINK-V3MINIE (not included in the kit) for programming and debugging
The STEVAL-PROTEUS1 kit includes a plastic case with its related screws to host the board and the LiPo battery, allowing an easy fixing (for demo purposes only).
To assemble the kit, follow the procedure below.
1.
Fix the main board to the case bottom ( A ) with the four screws included in the kit.
Pay attention to the board orientation.
2.
Put the LiPo battery in the top case ( B ). Then, insert the battery cable into the dedicated hole.
3.
Put the cover on the battery and close it using two screws.
4.
Plug the LiPo battery connector to the J3 connector.
5.
Close the A and B case parts using four screws.
6.
Use something thin (for example, a needle) to access the holes and press the push buttons.
7.
Power on the board by pushing and hold the S2 button for at least three seconds: the yellow LED turns on, then off. To power off, push and hold the S2 button until the yellow LED turns on.
Figure 8. STEVAL-PROTEUS mounting and power-on
UM3069 - Rev 1 page 9/69
3.3
UM3069
Software setup
•
Software setup
To use the FP-AI-PDMWBSOC , update, and run the application, you need: the STBLESensor app, available for Android and iOS, to handle the data exported by a Bluetooth® Low
Energy device using the BlueST protocol. The app allows running the application and performing the firmware update over-the-air (FUOTA).
Figure 9. QR codes for STBLESensor
3.3.1
•
•
•
•
A Windows™ (v7 or higher) PC, with TeraTerm or another terminal emulator software
NanoEdgeAIStudio (v3.1.0 or higher)
STM32CubeProgrammer software
A development toolchain and compiler. The STM32Cube expansion software supports the three following environments:
– IAR
– Keil®
– STM32CubeIDE
STEVAL-PROTEUS flash memory mapping
The STM32WB5MMG comes with a 1 Mbyte flash memory, shared between the two Arm® cores as the user part to be run into the CPU1 (Cortex® M4) and the secure part to be run into the CPU2 (Cortex® M0+). The user part starts from the beginning of the flash memory, whereas the secure part is placed at the end.
A specific memory mapping helps to develop an application easy to update.
To integrate the FUOTA features, design the firmware package as follows:
•
•
• the bootloader, placed in the first main memory address (0x08000000), must be an OTA application designed to handle the firmware update the user application, placed in the specific memory address (0x08007000), can be updated with the FUOTA and contains the main application the secure sectors include the application running in the CPU2 core; the secure part (FUS) is placed at the end and its size depends on the wireless Bluetooth® Low Energy stack to be used.
You can also update the Bluetooth® Low Energy stack using the same FUOTA functionality.
UM3069 - Rev 1 page 10/69
UM3069
Software setup
Figure 10. STEVAL-PROTEUS memory map for Bluetooth® Low Energy OTA applications
3.3.2
3.3.3
3.3.3.1
For further details on this topic, refer to AN5247 , which describes the procedure for over-the-air (OTA) firmware update on ST32WB devices with Bluetooth® Low Energy connectivity.
Toolchains settings for STM32WB memory mapping
Usually, the binary code generated with default settings, for any toolchain, considers the firmware starting address as the first address of the main memory (0x08000000).
So, to generate the project with OTA capabilities correctly, follow the steps below.
1.
Make sure that the OTA application firmware has already been downloaded into the STEVAL-PROTEUS from the first main memory address.
2.
Open $PROJ_DIR$\..\Src\system_stm32wbxx.c
and:
– Verify that the USER_VECT_TAB_ADDRESS define is uncommented
– Verify that VECT_TAB_OFFSET is defined as 0x00007000U
3.
Apply the following changes for each IDE toolchain:
– IAR EWARM
Open [ Project ]>[ Options ]>[ Linker ] and use $PROJ_DIR$\stm32wb5mxx_flash_cm4_ota.icf
as the linker configuration file
– Keil® MDK
Open [ Project ]>[ Options ]>[ Target ] and set IROM1 as 0x8007000 for start and 0x79000 for size.
Open [ Project ]>[ Options ]>[ Linker ] and use .\stm32wb5mxx_flash_cm4_ota.sct
as the scatter file.
Open [ Project ]>[ Options ]>[ Linker ] and add two lines in the misc controls:
--keep *.o(TAG_OTA_START)
--keep *.o(TAG_OTA_END)
– STM32CubeIDE
Open [ Properties ]>[ C/C++ Build ]>[ Settings ]>[ Tool Settings ]>[ MCU GCC Linker]>[ General ] and use ${workspace_loc:/${ProjName}/STM32WB5MMGHX_FLASH_ota.ld} as the linker script
4.
Download the generated firmware into the STEVAL-PROTEUS that you are using from the address
0x08007000
STEVAL-PROTEUS flash programming via Bluetooth® Low Energy OTA
The STEVAL-PROTEUS comes with a preloaded application firmware, supporting the condition-based maintenance via Bluetooth® Low Energy connectivity ( STSW-PROTEUS ).
This preloaded firmware supports the Bluetooth® Low Energy OTA. So, to use directly the FP-AI-PDMWBSOC application, update the application coprocessor binary or the wireless coprocessor binary through the
STBLESensor app.
Application firmware update
To update the main application via Bluetooth® Low Energy OTA, follow the steps below.
1.
Copy the FP-AI-PDMWBSOC.bin binary file, available in the $PROJ_DIR$\Projects\STM32WB5MMG-
PROTEUS\Applications\FP-AI-PDMWBSOC\Binary folder, inside a mobile device folder.
2.
Launch the mobile app by touching OTA Config in the STBLESensor menu.
3.
Select Application Coprocessor Binary to update the application firmware.
UM3069 - Rev 1 page 11/69
UM3069
Software setup
4.
Select the appropriate binary file stored before inside the mobile device.
5.
Tap on the Reboot button.
The STEVAL-PROTEUS reboots as a new Bluetooth® Low Energy slave (WBFUOTA), so that the
Bluetooth® Low Energy master, that is the mobile device, connects to it.
Figure 11. Start FUOTA and select FP-AI-PDMWBSOC binary application
UM3069 - Rev 1
6.
After the STEVAL-PROTEUS has been rebooted as WBFUOTA, the STBLESensor app shows a new page with the start address for the firmware you are going to download as well as the related file.
page 12/69
UM3069
Software setup
7.
Just tap on the Download button to start the update, which is totally managed through the mobile app and the bootloader preloaded in the main board, until the transfer is completed, as shown in the following picture.
Figure 12. Start WBFUOTA for application binary at specific address
UM3069 - Rev 1
As the upload has been completed, the board reboots as STEVAL-PROTEUS according to the uploaded firmware. It is visible in the list of the Bluetooth® Low Energy connectable devices.
page 13/69
3.3.3.2
UM3069
Software setup
Wireless stack firmware update
To update the wireless stack via Bluetooth® Low Energy OTA, follow the steps below.
1.
Copy the stm32wb5x_BLE_Stack_full_fw.bin binary file, available in the $PROJ_DIR$
\Utilities\STM32WB_Copro_Wireless_Binaries\STM32WB5x folder, inside a mobile device folder.
2.
Launch the mobile app by touching OTA Config in the STBLESensor menu.
3.
Select Wireless Coprocessor Binary and select the appropriate binary file by browsing inside the folders of the mobile device.
The STEVAL-PROTEUS reboots as a new Bluetooth® Low Energy slave (WBFUOTA), so that the
Bluetooth® Low Energy master, that is the mobile device, connects to it.
Figure 13. Start FUOTA and select wireless stack binary
UM3069 - Rev 1
The STBLESensor app shows a new page with the start address for the firmware you are going to download as well as the related file.
page 14/69
4.
Tap on the Download button to start the update.
Figure 14. STM32WB FUOTA for wireless stack firmware
UM3069
Software setup
Note: The process is not yet complete. The firmware is stored in an area of the flash memory buffer. Then, the
FUS copies the binary into the right flash memory area. Do not disconnect the power from the board and do not press any buttons on it. This process can take up to 25 seconds. During this time, the board is no longer visible in the device list of the app. Just tap on the Search button until you see the WBFUOTA board in the list of the Bluetooth® Low Energy connectable devices.
Important: The wireless stack update procedure erases the application firmware. So, you must update the related user application sector just after the stack update (see
Section 3.3.3.1 Application firmware update
).
UM3069 - Rev 1 page 15/69
Figure 15. Searching the WBFUOTA in the device list
UM3069
Software setup
3.3.4
After tapping on the WBFUOTA board, update the application firmware as shown in
Section 3.3.3.1 Application firmware update .
STEVAL-PROTEUS flash memory programming via ST-LINK
The STEVAL-PROTEUS flash memory programming methodology is stack independent.
There are different binaries files for the wireless stack and the application.
Install the STM32CubeProgrammer software on your PC and arrange the connection as shown below.
Figure 16. STEVAL-PROTEUS flash programming scenario
UM3069 - Rev 1 page 16/69
Note:
UM3069
Software setup
You can choose to power the STEVAL-PROTEUS via USB or by a LiPo battery. You can also use both at the same time. When using only the battery, press the power button at least for three seconds to turn on the system.
Launch the STM32CubeProgrammer software and connect the attached board, as highlighted below.
Figure 17. Connecting the board
3.3.4.1
Application firmware update
Step 1.
Launch STM32CubeProgrammer
if not done already (see Figure 17
).
Step 2.
Select Erasing & Programming .
Figure 18. Erasing & Programming selection
UM3069 - Rev 1
Step 3.
Browse to select the application binary file you are going to use (see
page 17/69
UM3069
Software setup
Step 4.
Set the right start address to download the binary (see
Note: The table below shows the right start address to use with the chosen application binary.
Hardware
STEVAL-
PROTEUS
Connectivity
Bluetooth® Low
Energy
Table 2. STM32WB Application Binaries to use
Application
OTA
FP-AI-
PDMWBSOC
HSDatalog
Application binary
Proteus_BLE_FUOTA_reference.bin
FP-AI-PDMWBSOC.bin
Install address
0x08000000
0x08007000
Proteus_HS_Datalog_FUOTA_reference.bin 0x08007000
Step 5.
Check both Verify programming and Run after programming (see
Step 6.
Select Start Programming (see
Step 7.
Wait for all operations to be successfully completed (see
Figure 19. Application firmware installation overview
3.3.4.2
If no error occurs, the application firmware has been correctly downloaded into the STEVAL-PROTEUS flash memory.
Wireless stack firmware update
Step 1.
Launch STM32CubeProgrammer
if not done already (see Figure 17
) and connect the board.
UM3069 - Rev 1 page 18/69
Step 2.
Select Firmware Upgrade Services (see Figure 20, 1).
Figure 20. Firmware upgrade services
UM3069
Software setup
Step 3.
Select Start FUS (see
Note: If a failure message appears ("Start FUS failed!" or "Start FUS Operation Failure! Please, try again"), relaunch the command.
Step 4.
Browse to select the stack binary file you are going to use (see
$PROJ_DIR$
\Utilities\STM32WB_Copro_Wireless_Binaries\STM32WB5x .
Step 5.
Set the right start address to download the binary (see
Hardware
STEVAL-PROTEUS
Table 3. STM32WB coprocessor wireless binaries to use
Connectivity Role
BLE Slave
Wireless coprocessor binary stm32wb5x_BLE_Stack_full_fw.bin (V1.13.0)
Step 6.
Select Firmware Upgrade
, 5).
Install address
0x080C7000
UM3069 - Rev 1 page 19/69
Step 7.
Wait for Firmware Upgrade Success (see
Figure 21. Firmware upgrade overview
UM3069
Software setup
Note: The wireless coprocessor stack firmware update procedure corrupts the data already stored in the first part of the flash memory (OTA application). So, after the stack update procedure, you must
download the OTA application as explained in Section 3.3.4.1 .
UM3069 - Rev 1 page 20/69
4
UM3069
Making and embedding the NEAI library
Making and embedding the NEAI library
The following section shows how to generate an anomaly detection library by using NanoEdgeAIStudio , starting from the data logging, before integrating and testing it on the STEVAL-PROTEUS, using FP-AI-PDMWBSOC .
Figure 22. Dataset acquisition, NEAI library creation, deployment, and integration
4.1
4.1.1
Data acquisition by data log
Uploading HS data log application firmware
The high-speed data log application firmware for STEVAL-PROTEUS comes with Bluetooth® Low Energy and
FUOTA features.
STEVAL-PROTEUS1 kit is already programmed with the Bluetooth® Low Energy stack and OTA application.
So, the high-speed data log application firmware can be downloaded into the MCU via OTA as explained in
Section 3.3.3 STEVAL-PROTEUS flash programming via Bluetooth® Low Energy OTA
.
Via the STBLESensor , a smartphone can discover the new device.
UM3069 - Rev 1 page 21/69
UM3069 - Rev 1
Figure 23. DTLG100 discovered by STBLESensor app
UM3069
Data acquisition by data log
The available demos are limited. The Bluetooth® Low Energy feature just helps you to change the application firmware via OTA smoothly.
Figure 24. DTLG100 Bluetooth® Low Energy available demos for STBLESensor app page 22/69
Figure 25. DTLG100 info showed by STBLESensor app
UM3069
Data acquisition by data log
4.1.2
Creating HS data log by CLI
Te STEVAL-PROTEUS has been programmed with the high-speed data log application firmware.
The following figure shows how to connect the board to retrieve the data log we need.
Figure 26. STEVAL-PROTEUS connected to a PC
4.1.2.1
High-speed data log utility
To retrieve data from the STEVAL-PROTEUS, firstly, create a dedicated folder that contains the utility to use.
UM3069 - Rev 1 page 23/69
Figure 27. High-speed data log utility folder
UM3069
Data acquisition by data log
4.1.2.2
Note:
Note:
•
•
•
• cli_example : contains the binary executables
PROTEUS_config_examples : contains a few device configuration files in json format to be used as parameter for the binary executable
PROTEUS_batch_file_examples : contains a few ready-to-use batch files to call the binary executable with a specific device configuration file to obtain particular datasets
Python_SDK : contains different Python scripts and classes that can be used to handle the obtained datasets
Dataset generation
Proceed to obtain the needed dataset.
•
•
Before starting any new acquisition, if the blue LED of the STEVAL-PROTEUS is not blinking, press the reset button.
You can obtain the dataset by using the executable file running into a cmd.exe Windows shell.
You can locate it in the .\cli_example\bin folder for both x86 and x64 OS system or, only for x64 OS system, in the .\cli_example\bin_64 directory.
Open a cmd.exe shell from any of the previous folders and launch the executable file entering cli_example.exe [-COMMAND [ARGS]] .
The possible commands are: the device configuration file: -f <filename>: Device Configuration file (JSON) the duration of the current acquisition (seconds): -t <seconds>: Duration of the current acquisition (seconds)
All commands are optional. Without any device configuration file, the default configuration stored in the firmware is used. If you do not enter the duration time, the current acquisition can be stopped by pressing the esc key.
The best way to start is to use the ready-to-use batch files located in the folder .\PROTEUS_batch_file_examples\ .
Launch the HS-DL_Run_IIS3DWB.bat
to obtain a dataset coming from the IIS3DWB 3-axis digital vibration sensors.
During an acquisition, the blue LED turns off while the green LED blinks.
UM3069 - Rev 1 page 24/69
Figure 28. USB HS-Datalog CLI ready to start
UM3069
Data acquisition by data log
Press the return key.
Figure 29. USB HS-Datalog CLI acquisition running
UM3069 - Rev 1
While the acquisition is ongoing, a folder is created and updated. Its name is based on the date and time of acquisition. The folder contain a few files:
•
•
•
<SensorName_subSensorType>.dat (IIS3DWB_ACC.dat) , which contains raw sensor data coupled with timestamps
DeviceConfig.json
, which contains specific information about the device configuration that is necessary for the correct data interpretation
AcquisitionInfo.json
, which contains information about the acquisition and the data labelling page 25/69
Figure 30. USB HS-Datalog CLI acquisition completed
UM3069
Data acquisition by data log
Note:
4.1.2.3
As soon as the acquisition has been correctly acquired, the green LED turns off while the blue LED blinks.
Dataset acquisition folder
When an acquisition is performed, the HSDatalog generates a folder, named according to the date and time of acquisition, in which you can find different files: DeviceConfig.json
and AcquisitionInfo.json
.
DeviceConfig.json
It contains specific information about the device configuration, necessary for the correct data interpretation.
Figure 31. DeviceConfig.json - device attributes
UM3069 - Rev 1
The device consists of three attributes: deviceInfo , sensor , and tagConfig .
The deviceInfo attribute identifies the device.
page 26/69
UM3069 - Rev 1
Figure 32. DeviceConfig.json - device info
UM3069
Data acquisition by data log
The sensor attribute is an array of attributes to describe all the sensors available on the board. Each sensor has a unique ID , a name , sensorDescriptor, and sensorStatus attributes.
page 27/69
Figure 33. DeviceConfig.json - sensor
UM3069
Data acquisition by data log
UM3069 - Rev 1
The sensorDescriptor attribute describes the main information about the single sensors through the list of its subSensorDescriptor . Each element of subSensorDescriptor describes the main information about the single subsensor (name, data type, sensor type, ODR, and full scale available, samples per unit of time supported, unit of measurement, etc.).
page 28/69
Figure 34. DeviceConfig.json - sensor descriptor
UM3069
Data acquisition by data log
UM3069 - Rev 1 page 29/69
UM3069
Data acquisition by data log
The sensorStatus attribute describes the actual configuration of the related sensor through the list of its subSensorStatus . Each element of subSensorStatus describes the actual configuration of the single subsensor
(whether the sensor is active or not, the actual ODR, time offset, data transmitted per unit of time, full scale, etc.).
Figure 35. DeviceConfig.json - sensor status
UM3069 - Rev 1
The tagConfig attribute describes the labels activated by the user.
page 30/69
Figure 36. DeviceConfig.json - tag config
UM3069
Data acquisition by data log
Note: The tag attribute is not used for the NEAI library generation.
AcquisitionInfo.json
It contains complementary information regarding the acquisition and the list of selected labels and tags (if labeling is enabled by the user).
UM3069 - Rev 1 page 31/69
Figure 37. AcquisitionInfo.json
UM3069
Data acquisition by data log
UM3069 - Rev 1
Raw data, saved in the SensorName_subSensorType.dat
files, contain sensor data coupled with timestamps.
The name of the file describes the sensor part number and the sensor type, as follows:
• Name: <sensor_name>_<subsensor_type>.dat
– <sensor_name>: component part number
– <subsensor_type>: ACC, GYRO, TEMP
A filename.dat
file contains raw data and their timestamps. The related sensor configuration information is available in the DeviceConfig.json
file.
Figure 38. filename.dat file - data stream structure
The data stream structure consists of:
•
•
•
•
“Data k” (k = 1 ... N) that represents a sample generated by a subsensor_type .
If the subsensor_type has multiple axes, such as acceleration sensors ( IIS3DWB ) each “data k” packet is one sample for each axis, as in the following schema: | axis X | axis Y | axis Z |
The data length, in bytes (1, 2, or 4), which is defined in the dataType field available in the subSensorDescriptor attribute of the DeviceConfig.json
.
N, which corresponds to the value of the samplesPerTs field available in the subSensorStatus attribute of the DeviceConfig.json
.
The timestamp, which is a float value calculated in seconds.
page 32/69
4.1.2.4
4.1.2.5
UM3069
Data acquisition by data log
Custom dataset generation
To customize the DeviceConfig.json
file and pass it as a parameter for the CLI executable file, follow the procedure below.
1.
Save the previous DeviceConfig.json
file as DeviceConfigCustom.json
(this name is not mandatory but is only as an example).
2.
Open the DeviceConfigCustom.json
file with a text editor and move to the attribute: device -> sensor[id_s] -> sensorStatus -> subSensorStatus[id_ss]
3.
Look at the fields:
– FS
– ODR
– isActive
You can change FS (full scale) and ODR (output data rate) for the subsensor, choosing among the possible values that you can find in the corresponding fields of the attribute: Device -> sensor[id_s] -> sensorDescriptor -> subSensorDescriptor[id_ss]
The subsensor can be activated (that is, its dataset is stored) or deactivated (that is, its dataset is not stored) through the isActive Boolean field.
4.
Save the DeviceConfigCustom.json
modified file.
5.
As already shown in Section 4.1.2.2 Dataset generation , open a cmd.exe shell from the
.\cli_example\bin folder or .\cli_example\bin_64 , only for x64 OS system.
6.
Move the DeviceConfigCustom.json
file to this latter folder.
7.
Inside the shell, launch the executable file entering: cli_example.exe -f
DeviceConfigCustom.json -t 120
The dataset is acquired according to the custom device configuration as you can see from the DeviceConfigCustom.json
file, in the related dataset acquisition folder, looking at: device -> sensor[id_s] -> sensorStatus -> subSensorStatus[id_ss]
•
•
Plot the datasets acquired
After acquiring and storing the dataset in the related folder, you can easily plot the data.
In the .\Python_SDK directory, you can find some useful Python scripts, including one to plot the acquired dataset, hsdatalog_plot.py
.
Python 3.7 must be already installed as well as the following modules: asciimatics click
•
•
•
• colorama matplotlib numpy pandas
You can manually install the above modules (through the pip command) or you can exploit the available requirements.txt
file that describes all the libraries used by our SDK with their dependencies and versions, then launch the pip install -r requirements.txt
command from the .\Python_SDK\ folder.
In the .\PROTEUS_batch_file_examples\ folder, you can find a ready-to-use batch file, HS-DL_Plot.bat
, that launches a cmd.exe shell to enter the dataset folder to be analyzed.
UM3069 - Rev 1 page 33/69
Figure 39. HS-DL_Plot.bat shell
UM3069
Data acquisition by data log
Enter the number related to the sensor whose data you want to plot (for example, ‘0’) to display the graph.
Figure 40. IIS3DWB data plot example
UM3069 - Rev 1 page 34/69
4.2
UM3069
Library generation using NanoEdgeAI Studio
Library generation using NanoEdgeAI Studio
The NanoEdge AI Studio can generate libraries of four types:
•
•
•
•
Anomaly detection
1-class classification n-class classification
Extrapolation
To generate the anomaly detection library, using normal and abnormal dataset folders, create the new project by clicking on the button for AD as shown in the figure below.
Figure 41. Start an anomaly detection project
The text shows the information on what the anomaly detection is good for. You can create the project by clicking on the CREATE NEW PROJECT button.
The process to generate the anomaly detection library consists of six steps as shown below.
Figure 42. Six-step workflow
4.2.1
Project settings
1.
Choose the settings for the library generation:
– a project name and description
– the right STM32 platform or a microcontroller type
2.
Select the STEVAL-PROTEUS from the list provided in the drop-down menu under Target .
UM3069 - Rev 1 page 35/69
UM3069
Library generation using NanoEdgeAI Studio
3.
Enter the maximum amount of RAM to be allocated for the library. Usually, a few Kbytes is enough (but it depends on the data frame length used in the process of data preparation;10 Kbytes is a good starting point).
4.
Put a limit or no limits for the maximum flash memory budget (we chose the no limits option).
5.
Select the sensor type, that is the 3-axis accelerometer from the list in the drop-down menu.
Figure 43. Project settings
4.2.2
Note:
Note:
Insert the classified data: regular and abnormal
To insert the classified dataset, follow the procedure below.
1.
Start the data samples selection, for “Regular” class, pushing the “ADD SIGNAL” button.
2.
Select the signal source.
Even if three options are available, we strongly recommend to use the second one, by selecting the “FROM
DATALOGGER (.DAT)” option.
3.
Open the dialog panel to select the directory including the files *.DAT to use.
4.
Select the folder where the dataset previously classified are stored by using the HS Datalog application, including the filename.dat
, DeviceConfig.json
, and AcquisitionInfo.json
files unchanged.
Assign a class label to the imported data in the Name field once the data is imported. This label is used to differentiate the classes and is used in the emulation to show the predicted class.
5.
Select IIS3DWB>ACC or ISM330DHCX>ACC from the sensor list and fill the signal length field, using
512/1024/2048 or more if you want to. Press the CONTINUE button.
The NanoEdge AI library needs a packet of samples named signal. So, the signal length specifies the number of samples contained in a single signal. Signal length must be a power of 2 like 512/1024/2048.
6.
Verify that the “Comma” delimiter is asserted and then click on the IMPORT button.
7.
Check the data import in the last panel, where are exposed the time domain and frequency domain plot, plus some filter settings.
Repeat all the steps to import the data set for abnormal classes.
UM3069 - Rev 1 page 36/69
UM3069
Library generation using NanoEdgeAI Studio
Figure 44. Classified data import
4.2.3
•
•
•
•
Run the benchmark to create the NEAI AD libraries
Benchmark the available models and choose the one that complies with the requirements and provides the best performance.
Click on Run New Benchmark
Select which input files (signal examples) to use
Optional: change the number of CPU cores to use
Start and wait until you see the perspective shown below
UM3069 - Rev 1 page 37/69
Figure 45. Start benchmark
UM3069
Library generation using NanoEdgeAI Studio
UM3069 - Rev 1
This perspective allows you to monitor some indicators like:
•
•
•
•
Score
Balanced accuracy
RAM
Flash memory
Keep in mind that:
•
•
Benchmarks may take a long time (several hours) to complete and find a fully optimized library
Benchmarks can be paused/resumed, or stopped at any time, without canceling the process (the best library found is not lost)
• Benchmark progress in percentage is displayed on the left side of the screen, next to the name/ID of the benchmark, in the benchmark list under the RUN NEW BENCHMARK button.
page 38/69
UM3069
Library generation using NanoEdgeAI Studio
Figure 46. Benchmark execution (1 of 2)
After some hours, you should obtain a result similar to the one of the figures below.
Figure 47. Benchmark execution (2 of 2)
UM3069 - Rev 1
You can choose whether to continue searching an improved library or pause/stop the benchmark to see the results.
page 39/69
4.2.4
UM3069
Library generation using NanoEdgeAI Studio
NEAI libraries evaluation
You can now select one of the proposed ML model sets.
Figure 48. Benchmark results
Note:
4.2.5
Optional: after the library selection, you can validate the library model performance through the provided emulator (
Figure 42 , step 5), which is able to test the library behavior on the STM32 target.
•
•
•
NEAI library deployment
The final step is to compile and download the libraries, using the Deployment section, as follows: set the "Float abi" flag to use the libraries with the hardware FPU set the "fshort-wcharand" flag just to deploy the library for the Keil® toolchain
Leave the other flags in their default state
UM3069 - Rev 1 page 40/69
Figure 49. NEAI compiled library deployment
UM3069
NEAI library integration
4.3
For further details about NanoEdgeAI Studio, see NanoEdge AI Studio Documentation .
NEAI library integration
Integrate the library generated and downloaded from NanoEdgeAIStudio into the FP-AI-PDMWBSOC projects.
Then, run the library on the STEVAL-PROTEUS.
The FP-AI-PDMWBSOC comes with the library stub in the place of the actual library generated by
NanoEdgeAIStudio , to simplify the generated library update.
Copy the generated library and replace the existing stub/dummy library and header files ( NanoEdgeAI.h
and libneai.a
(for IAR and STM32CubeIDE ), or libneai.lib (for Keil®)), placed in the "Inc" and "Lib" folders, respectively.
The relative paths of these folders are: /STM32CubeFunctionPack_AI_PDMWBSOC_v1.0/Middlewares/ST/
NanoEdge_AI_Library as shown below.
Figure 50. NEAI lib update in firmware architecture
UM3069 - Rev 1 page 41/69
5
5.1
5.1.1
5.1.2
5.1.3
UM3069
Running FP-AI-PDMWBSOC
Running FP-AI-PDMWBSOC
Using the STEVAL-PROTEUS with the STBLESensor app
Bluetooth® Low Energy connectivity features
A typical Bluetooth® Low Energy application involves two parts: a Bluetooth® Low Energy master and a
Bluetooth® Low Energy slave.
The STEVAL-PROTEUS plays the role of the slave (or peripheral), acting as the Bluetooth® Low Energy GATT server. It advertises and waits for connection.
A mobile device that runs the STBLESensor app is the master (or central), acting as the Bluetooth® Low Energy
GATT client. It scans for devices and establishes the connection.
The STEVAL-PROTEUS sends data to the Bluetooth® Low Energy GATT client via Bluetooth® Low Energy and to a laptop via UART.
Bluetooth® Low Energy workflow overview
In the Bluetooth® Low Energy workflow, the STEVAL-PROTEUS performs the following actions:
1.
initializes the hardware and software resources, making them ready for Bluetooth® Low Energy connection to a smartphone
2.
sends the library status, battery level and, if a detection is running, also the asset status, inside the
Bluetooth® Low Energy advertising message
3.
accepts the Bluetooth® Low Energy connection request by a mobile device running the STBLESensor app
4.
sends information about the AI library status and allows setting some parameters related to the library and sensors
5.
sends information about the battery status
The mobile device that runs the STBLESensor can start the training and inference phases.
The application also sends information via UART to the PC, through the STDC14+ST-LINK+USB cable.
Bluetooth® Low Energy advertising
Since the evaluation board has been successfully programmed as described in Section 3.3.3
and
sends Bluetooth® Low Energy advertising packets to establish a connection with a Bluetooth® Low Energy central device.
Launching the STBLESensor , you can connect a device.
UM3069 - Rev 1 page 42/69
UM3069 - Rev 1
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 51. Main page of the STBLESensor app for Android
Choosing Connect one Device , a list of the connectable Bluetooth® Low Energy peripheral devices is shown.
Some pieces of information are provided with each listed board.
page 43/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 52. Device list page (for Android STBLESensor)
Active phase and battery level aside, if a detection is running, the STEVAL-PROTEUS sends the Asset Status
(normal or anomaly behavior) to the Bluetooth® Low Energy advertising packet.
Normal behavior
Table 4. Anomaly status icons
Anomaly behavior Detection phase is not running
5.1.4
Connect a Bluetooth® Low Energy device and choose the application demo
To connect a device, just touch it. After that, you can retrieve all the information that the STBLESensor can manage for the selected board.
To see the available demos, touch the three lines placed at the top left and select the demo to use. You can also enable the summary view by just tapping back on any page.
UM3069 - Rev 1 page 44/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 53. Device connection and sensor demo summary
5.1.5
NEAI anomaly detection demo
As soon as the STEVAL-PROTEUS has been connected, the NEAI Anomaly Detection page is shown. You can also choose this demo by touching NEAI Anomaly Detection in the STBLESensor menu.
Figure 54. NEAI anomaly detection demo (IDLE and IDLE TRAINED)
UM3069 - Rev 1
The STEVAL-PROTEUS remains in the idle state until it gets a command to start a processing phase: learning or detecting.
page 45/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
If you launch a learning phase, the library is trained with a number of signals that can be configured through the settings. The minimum amount of signals to ensure the proper operation is a predefined value in /STM32CubeFunctionPack_AI_PDMWBSOC_v1.0//Middlewares/ST/NanoEdge_AI_Library/Inc/NanoEdgeAI.h
.
If a number of signals higher than the minimum value is used, the phase becomes IDLE TRAINED and the
RESET KNOWLEDGE button is activated: by pressing it, the original hyperparameters of the library are restored, which restarts from the IDLE state.
Using the switch and start button, you can launch the learning or detecting phase:
• by tapping the learning switch and then the start button, the learning phase starts; during this phase, the vibration data are generated and sent to the NEAI library to train the ML model.
Figure 55. Learning on the NEAI demo
UM3069 - Rev 1
• by tapping the detecting switch and then the start button, the detecting phase starts; during this phase, the vibration data are generated and sent to the NEAI library to recognize if the asset behavior is normal or abnormal by an indicator that is named similarity , this last assumes (value from 0 to 100%)
If the similarity is greater than the set threshold value, an anomaly occurred. You can also set the threshold value by Board Configuration Demo .
page 46/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 56. Detecting on the NEAI demo
Note:
Note:
In both the learning and detecting phase, the start button is replaced by the stop button to end the processing phase.
The learning phase can be automatically stopped via timer or signal settings (see
learning.
You cannot start both phases at the same time.
The NEAI demo consists of two sections: AI Engine and Signal . These sections provide several info related to the
NEAI library status and the detected signal.
Within AI Engine you can find:
•
•
• the active phase of the NanoEdgeAI library:
– IDLE , if the library is not running
– LEARNING , if the library is learning from the raw data generated by a sensor to train the ML model
– DETECTING , if the library is monitoring the raw data generated by a sensor to detect anomaly behaviors
– IDLE TRAINED , if the library is not running but a learning phase has been done and the minimum signal quantity is learnt the NEAI state, which describes the library operation:
– NOT ENOUGH LEARNING , when you launch a learning or a detecting phase without having learnt the minimum quantity of signals
– MINIMAL LEARNING DONE , when you have launched a learning phase and you have achieved the minimum quantity of signals to learn
– OK , when you have launched a detecting phase and the library works properly the progress bar, which is active only if you have set the learning time or signals to learn; in this case, the progress bar is filled according to the time or signal settings
The Signal section is active during the detecting phase. Within Signal you can find:
• the status of your asset, which can be normal or anomaly according to the similarity indicator provided by the
NEAI library
UM3069 - Rev 1 page 47/69
5.1.6
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
• the similarity indicator, which can assume values in the range of 0-100%; if this indicator is less than the threshold value, the asset status is anomaly, otherwise the status is normal
Board configuration
Touching Board Configuration , the mobile app shows information about the board.
In the board report section, you can retrieve the following information.
• STM32 UID : the unique 96bit ID of STM32WB mounted on the STEVAL-PROTEUS.
Figure 57. Board configuration summary and STM32 unique ID
UM3069 - Rev 1
• the Version firmware : the firmware release loaded on the STEVAL-PROTEUS.
page 48/69
UM3069 - Rev 1
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
• Info : a set of more detailed information about the firmware loaded into the STEVAL-PROTEUS.
Figure 58. Firmware version and info
In the board control section, you can power off the board.
page 49/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Note:
In the board settings section, you can handle the following information:
• Set name : to change the board connected name, keeping it internally, to show it during Bluetooth® Low
Energy advertising.
If you power off the board, the custom board name is erased.
Figure 59. Board name settings
5.1.6.1
• Read custom commands : to open a customized panel containing the commands setting directly built by the firmware, as described in the next section.
•
•
Custom commands
Tap on Read Custom Commands to open the Custom Commands section where the NEAI and Sensors Setting is included, supported by the firmware into a dedicated tab.
This customized menu provides commands to get and set:
NEAI parameters sensor parameters
UM3069 - Rev 1 page 50/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 60. Open NEAI and sensor settings
UM3069 - Rev 1
The Get NEAI parameter command allows you to monitor:
•
•
•
The sensitivity
Signals
Time duration
of the ML model
that are the sample packets that you want to learn in the next learning phase
, expressed in seconds, of the next learning phase
•
•
•
• The similarity threshold value under which a signal is considered normal or abnormal
The Get sensor parameter command allows you to monitor:
•
Sensor name and type
The full scale of the selected sensor
Nominal ODR of the active sensor, that is the output data rate of the sensor; you can set it when using the
ISM330DHCX accelerometer
The latest measured ODR page 51/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 61. Get NEAI and sensor parameters
•
•
The Set NEAI parameters commands allow you to set:
•
•
The sensitivity of the ML model that can be in the range of 0 to 100. A sensitivity value between 0 and 1
(excluded) decreases the sensitivity of the model, while a value between 1 and 100 increases it.
The duration of the next learning phase . After the specified number of seconds, the phase is automatically stopped.
The number of signals you want to learn in the next learning phase.
The similarity threshold value to recognize if a signal is normal or abnormal.
Important: It is not allowed to set the learning time and signals to learn for the same learning session.
UM3069 - Rev 1 page 52/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 62. Set NEAI parameters: library sensitivity and timer
Figure 63. Set NEAI parameters: signals and threshold
UM3069 - Rev 1
The Set sensors parameters commands allow you to set:
•
• which sensor you want to use: the
Select the full scale
ISM330DHCX
for the active sensor
accelerometer or the IIS3DWB vibrometer page 53/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
• Select the output data rate for the active sensor (this feature is available only for the ISM330DHCX accelerometer)
Important: The best sensor setup is the one chosen during the data acquisition phase.
Figure 64. Set sensor parameter: sensor used, FS, and ODR
5.1.7
•
•
•
RSSI & Battery
Touching RSSI & Battery in the STBLESensor menu, the user gets information about: the board name and MAC address the RSSI the battery information such as the level and status of the charge and voltage
UM3069 - Rev 1 page 54/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 65. RSSI and battery status
5.1.8
5.1.9
•
•
•
Use FUOTA to test different libraries
You can easily switch between different application binaries that contain libraries with different performance in terms of score, accuracy, RAM, or flash memory, or generated for different use cases (misalignment, unbalanced, bearing damage).
The best practice could be to: generate several NanoEdge AI libraries for different anomaly detection use cases embed these compiled binaries into the FP-AI-PDMWBSOC , creating several application binaries use the FUOTA to switch through the application, to cover and test different anomaly detection conditions
Debug using a terminal emulator
The STLINK-V3MINI also provides a virtual COM port interface, which allows the host PC to communicate with the target microcontroller through a UART. It also allows the STEVAL-PROTEUS that runs the FP-AI-
PDMWBSOC to send information to a terminal console when connected to a PC.
The figure below shows how to connect the STEVAL-PROTEUS to a PC able to run a terminal emulator such as
Tera Term.
UM3069 - Rev 1 page 55/69
UM3069
Using the STEVAL-PROTEUS with the STBLESensor app
Figure 66. STEVAL-PROTEUS connection with a terminal emulator
Configure the terminal emulator as shown below.
Figure 67. PC terminal setting for the debug console
Note:
This debug terminal allows you to monitor:
•
•
• the system initialization: to check if all the application tasks and application services are properly initialized and started the Bluetooth® Low Energy initialization: to check if all the Bluetooth® Low Energy services and characteristics are properly initialized; it also shows the information about the Bluetooth® Low Energy stack and the FUS version, the Bluetooth® Low Energy address, etc.
the application state machine: to check if state transactions occurred according to the state machine design
You can find more details about application state machine in \Documentation\FP-AI-
PDMWBSOC_Package.chm.
UM3069 - Rev 1 page 56/69
5.2
5.2.1
UM3069
Using the STEVAL-PROTEUS with the command line interface
The following codeblock shows a possible output on the debug terminal.
System Initialization
INIT: reset flags: 0x4000000
SysTS: System timestamp service ready.
INIT: added 7 managed tasks.
INIT: task hardware initialization.
...
DONE.
BCP: initialization done.
SPIBUS: connected device: 1
SPIBUS: connected device: 2
INIT: system initialized.
INIT: free heap = 76824.
INIT: SystemCoreClock = 64000000Hz.
IIS3DWB: start.
ISM330DHCX: start.
SPI: start.
SPIBUS: start the driver.
CTRL: start.
NEAI: start.
UTIL: start.
BLE: start.
SHCI_SUB_EVT_CODE_READY - WIRELESS_FW_RUNNING
***************************************************************************
STMicroelectronics
STM32STM32WB5MMG - Anomaly Detection by NEAI
FP-AI-PDMWBSOC V1.0.0 Compiled Aug 2 2022 09:22:50 (openstm32)
MCU Unique device ID is 0x2032364235505018003B0042
MCU Flash Size is 1024 KB
BD Address 00:80:E1:26:BE:DB
BLE Stack V1.13.0
BLE Stack Branch 0 Type 5
FUS V1.2.0
***************************************************************************
BlueST-SDK V2
Config Service added successfully
Console Service added successfully
BLE Battery features ok
BLE NEAI Anomaly Detection char is ok
BLE Ota features ok
Features Service added successfully (Status= 0x0) aci_gap_set_discoverable OK Filter=0 aci_gap_update_adv_data OK
Using the STEVAL-PROTEUS with the command line interface
The CLI allows you to control the application by sending the same commands, described in the STBLESensor app, via command-line input to be processed on the device.
To use this interface, you need:
•
• a laptop with Tera Term software a micro-B to A USB cable
Set the serial terminal configuration
Start Tera Term and select the proper connection, that is the serial, which indicates the right port connected (USB serial device, COM15 in the example).
UM3069 - Rev 1 page 57/69
UM3069
Using the STEVAL-PROTEUS with the command line interface
Figure 68. Open the CLI via PC terminal console
Use the following parameters for the terminal setup:
•
•
•
New line
Receive: CR
Transmit: CR
Figure 69. Tera Term connection settings
UM3069 - Rev 1
The interactive console can be used with the default values.
page 58/69
5.2.2
UM3069
Using the STEVAL-PROTEUS with the command line interface
Start the FP-AI-PDMWBSOC firmware
Restart the board by pressing the reset button. The following welcome screen is displayed on the terminal.
Figure 70. Start the CLI program execution
From this point, start entering the commands directly or type help to get the list of the available commands along with their usage guidelines.
5.2.3
Execution phases and command summary
The two system execution phases are:
•
•
NanoEdge AI learning : sensor data are transmitted to the NanoEdge AI library to train the model
NanoEdge AI detecting : sensor data are transmitted to the NanoEdge AI library to detect anomalies
Each execution phase can be started and stopped through a user command, $ start <execution phase> , issued through the CLI, where the valid values for the execution phase are:
•
• neai_learn neai_detect
An execution context, which is a set of parameters that control the execution, is associated with each execution phase. One single parameter can belong to more than one execution context. The CLI provides commands to set and get the execution context parameters. The execution context cannot be changed while an execution phase is active.
If you try to set a parameter that belongs to any active execution context, the requested parameter is not modified.
Important: Do not plug/unplug the USB connector during the learning/detecting phase.
Command name Command string help info uid reset start help info uid reset start <phase>
Table 5. CLI commands list
Note
CS1 – Generic commands
Lists all registered commands with brief usage guidelines, including the list of the applicable parameters
Shows the firmware details and version
Shows the STM32 UID
Resets the MCU system
CS2 – AI specific commands
Starts an execution phase according to its execution context. The available execution phases are:
UM3069 - Rev 1 page 59/69
Note:
5.2.4
Note:
UM3069
Using the STEVAL-PROTEUS with the command line interface
Command name Command string neai_init neai_set neai_get sensor_info sensor_set sensor_get neai_init neai_set
<parameter>
<value> neai_get
<parameter> sensor_info sensor_set <id>
<parameter>
<value> sensor_get <id>
<parameter>
•
•
Note
CS1 – Generic commands neai_learn to learn the normal conditions using the NanoEdge AI library for anomaly detection neai_detect to start the detection of the anomalies using the NanoEdge AI library for anomaly detection
(Re)initializes the NanoEdge AI model and forgets any learning made on the device.
Used at the beginning or to reinitialize the NanoEdge AI anomaly detection to start from scratch at any time
•
•
•
•
•
Sets a NanoEdge AI specific parameter. The valid parameters and values are: sensitivity : float [0, 100] threshold : integer [0, 100] signals : integer [0, MAX_SIGNALS] timer : integer [0, MAX_TIME_MS] sensor : integer [0, 1]
•
•
•
•
•
•
Displays the value of the NanoEdge AI parameter. The valid parameters are sensitivity threshold signals timer sensor all
CS3 - Sensor configuration commands
Gets a list of all supported sensors and their ID
•
•
•
Sets the value of a parameter for a sensor with the sensor ID provided in id . The settable parameters are:
FS : full scale
ODR : output data rate enable : active [1 for true (active), 0 for false (disactive) ]
•
•
•
•
•
•
Gets the value of a parameter for a sensor with the sensor ID provided in id . The valid parameters are: enable
ODR
: active [ true (active), false (inactive)]
: output data rate
ODR_List : list of supported ODRs
FS : full scale
FS_List : list of supported FSs all : all sensor configurations
The learning phase can be stopped automatically through a timer or signals setting. However, by default, both are initialized to zero. Therefore, you need to press the escape button to stop the learning.
•
•
•
Configuring the sensors
Through the CLI interface, you can configure the supported sensors for sensing and condition monitoring applications. The list of all the supported sensors can be displayed on the CLI console by entering the command sensor_info . This command prints the list of the supported sensors along with their IDs. The user can configure these sensors using these IDs. The configurable options for these sensors include: enable : to activate or deactivate the sensor
ODR : to set the output data rate of the sensor from the list of available options
FS : to set the full-scale range from the list of available options
The best sensor setup is the one used during the data acquisition phase.
The current value of any of the parameters for a given sensor can be printed using the $ sensor_get
<sensor_id> <param> command.
UM3069 - Rev 1 page 60/69
5.3
5.3.1
Note:
5.3.2
5.3.3
5.3.4
UM3069
Using the STEVAL-PROTEUS with hardware buttons and LEDs
The information about the sensor can be printed using the $ sensor_get <sensor_id> all command.
The values for any of the available configurable parameters can be set through the $ sensor_set
<sensor_id> <param> <val> command.
Using the STEVAL-PROTEUS with hardware buttons and LEDs
Button-operated mode
The button-operated mode for the FP-AI-PDMWBSOC allows running the application on the STEVAL-PROTEUS even in the absence of the CLI console and Bluetooth® Low Energy connection.
In this mode, you can control the sensor node through the user button instead of the interactive CLI console or
STBLESensor . The default values for the node parameters and settings for the operations during the auto mode are provided in the firmware. Based on these configurations the learning and detecting phases can be started and stopped through the user button on the node.
The auto-mode setup provides the IIS3DWB active with the last FS selected (by default, it is 16 G).
Buttons description
The button-operated mode can work with or without the CLI and STBLESensor . It is fully compatible and consistent with the others UI.
The supporting hardware for this function pack version has three buttons:
1.
the user button, the only button usable by the software
2.
the reset button, connected to the STM32 MCU reset pin
3.
the power button, connected to the power management
There are also four LEDs:
1.
the red LED, controlled by software
2.
the green LED, controlled by software
3.
the blue LED, controlled by software
4.
the yellow LED, controlled by hardware, indicates the charging status when powered through a USB cable
Therefore, the basic user interactions for button-operated operations can be done through one button (user) and three LEDs (red, green, and blue).
User button operation and purpose
In the extended autonomous mode, you can trigger any of the four execution phases. The available modes are:
•
• idle : the system is waiting for a command (the library might be already trained or not) neai_learn : sensor data are transmitted to the NanoEdge AI library to train the model
• neai_detect : sensor data are transmitted to the NanoEdge AI library to detect anomalies
To control the execution phases, there are three different button press modes for the user button.
Table 6. User button operation
Press type Description Action
Short press The button is pressed for less than 200 ms and released Stops the running execution phase if any
Long press The button is pressed for more than 200 ms and released Starts the learning for the NanoEdge AI Library
Double press A succession of two short presses Starts the inference for the NanoEdge AI Library
LEDs operation and purpose
The onboard LEDs indicate the status of the current execution phase, assuming a specific configuration.
UM3069 - Rev 1 page 61/69
UM3069
Using the STEVAL-PROTEUS with hardware buttons and LEDs
NEAI lib phase
Idle
Idle trained
Learning
Detecting
Table 7. Red and green LEDs for NEAI phases
Red LED
Off
Off
Off
On, if an anomaly occurs
Green LED
Off
Off
Blink
On, if no anomaly occurs
Connected
Not connected
Table 8. Blue LED for Bluetooth® Low Energy connectivity
Bluetooth® Low Energy connection to a smartphone Blue LED
Slow blink
Fast blink
The LED status allows you to know the state of the sensor node even when the USB is not plugged and/or the smartphone is not connected to the board.
UM3069 - Rev 1 page 62/69
Revision history
Date
20 -Sep-2022
Table 9. Document revision history
Revision
1 Initial release.
Changes
UM3069
UM3069 - Rev 1 page 63/69
UM3069
Contents
Contents
STEVAL-PROTEUS flash programming via Bluetooth® Low Energy OTA . . . . . . . . . . . . 11
STEVAL-PROTEUS flash memory programming via ST-LINK . . . . . . . . . . . . . . . . . . . . . 16
Connect a Bluetooth® Low Energy device and choose the application demo . . . . . . . . . . 44
UM3069 - Rev 1 page 64/69
UM3069
Contents
UM3069 - Rev 1 page 65/69
UM3069
List of tables
List of tables
UM3069 - Rev 1 page 66/69
UM3069
List of figures
List of figures
UM3069 - Rev 1 page 67/69
UM3069
List of figures
UM3069 - Rev 1 page 68/69
UM3069
IMPORTANT NOTICE – READ CAREFULLY
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgment.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of purchasers’ products.
No license, express or implied, to any intellectual property right is granted by ST herein.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. For additional information about ST trademarks, refer to www.st.com/trademarks . All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.
© 2022 STMicroelectronics – All rights reserved
UM3069 - Rev 1 page 69/69
Descarcă
Publicitate