Um2688 Getting Started With The Stm32cube High Speed Datalog Function Pack Stmicroelectronics
Um2688 Getting Started With The Stm32cube High Speed Datalog Function Pack Stmicroelectronics
User manual
Getting started with the STM32Cube High Speed Datalog function pack
Introduction
The FP-SNS-DATALOG1 function pack implements High Speed Datalog application for STEVAL-MKSBOX1V1, STEVAL-
STWINKT1, and STEVAL-STWINKT1B. It provides a comprehensive solution to save data from any combination of sensors and
microphones configured up to the maximum sampling rate.
The application also allows configuring LSM6DSOX (available on STEVAL-MKSBOX1V1) and ISM330DHCX (available on
STEVAL-STWINKT1 and STEVAL-STWINKT1B) Machine Learning Core unit and reading its output.
Sensor data can be stored onto a microSD™ card (Secure Digital High Capacity - SDHC) formatted with the FAT32 file system,
or streamed to a PC via USB (WinUSB class) using the companion host software (cli_example) provided for Windows and
Linux.
The FP-SNS-DATALOG1 allows configuring the board via a JSON file as well as starting and controlling data acquisition.
Commands can be sent from a host via the command line interface.
The application can be controlled via Bluetooth using the STBLESensClassic app (for both Android and iOS - v4.17 and above)
which lets you manage the board and sensor configurations, start/stop data acquisition on an SD card, control data labeling and
display the output of the Machine Learning Core.
To read sensor data acquired using FP-SNS-DATALOG1, easy-to-use scripts in Python and MATLAB® are provided within the
software package. The scripts have been successfully tested with MATLAB® v2019a and Python 3.10.
The software is available also on GitHub, where the users can signal bugs and propose new ideas through [Issues] and [Pull
Requests] tabs.
Related links
Visit the STM32Cube ecosystem web page on www.st.com for further information
1.1 Overview
FP-SNS-DATALOG1 is an STM32 ODE function pack and expands STM32Cube functionality.
The software package provides a comprehensive solution to save data from any combination of sensors and
microphones configured up to the maximum sampling rate.
The key package features are:
• High-rate (up to 6 Mbit/s) data capture software suite:
– Bluetooth® Low Energy app for system setup and real-time control
– Python and C++ real-time control applications
– Dedicated HSDPython_SDK for sensor data analysis, in common with FP-SNS-DATALOG2
– Host developer's API enables integration into any data science design flow
– Compatible with Unico-GUI which enables configuration of LSM6DSOX (available on STEVAL-
MKSBOX1V1) and ISM330DHCX (available on STEVAL-STWINKT1 and STEVAL-STWINKT1B)
Machine Learning Core unit
– Timestamping for sensor data synchronization
• Embedded software, middleware and drivers:
– FatFS third-party FAT file system module for small embedded systems
– FreeRTOS third-party RTOS kernel for embedded devices
– STWIN low-level BSP drivers
• Based on STM32Cube software development environment for STM32 microcontrollers
1.2 Architecture
The application software accesses the SensorTile.box and the STWIN evaluation kits through the following
software layers:
• the STM32Cube HAL layer, which provides a simple, generic, multi-instance set of application
programming interfaces (APIs) to interact with the upper application, library and stack layers. It has generic
and extension APIs and is directly built around a generic architecture, allowing successive layers, like the
middleware layer, to implement functions without requiring specific hardware configurations for a given
microcontroller unit (MCU). This structure improves library code reusability and guarantees an easy
portability on other devices
• the board support package (BSP) layer, which supports all the peripherals on the STM32 Nucleo except
the MCU. This limited set of APIs provides a programming interface for certain board-specific peripherals
like the LED, the user button, etc. This interface also helps in identifying the specific board version.
User interfaces
ST BLESensorClassic App HSDatalog utilities
and utilities
Applications &
FP-SNS-DATALOG1
demonstrations
STM32L4R9ZIJ6
Hardware
STEVAL-MKSBOX1V1 development kit
STEVAL-STWINKT1 development kit
STEVAL-STWINKT1B development kit
1.4 APIs
Detailed technical information with full user API function and parameter description are in a compiled HTML file in
the “Documentation” folder.
2 Getting started
As HSDatalog application included in the FP-SNS-DATALOG1 function pack is not the default firmware on the
STEVAL-STWINKT1 and STEVAL-MKSBOX1V1, you have to download it on the board, using the pre-compiled
binary provided in the \Projects\STM32L4R9ZI-STWIN\Applications\HSDatalog\Binary or
\Projects\STM32L4R9ZI-SensorTile.box\Applications\HSDatalog\Binary folder.
In any case, the function pack is continuously maintained, so we advise you to update the firmware any time a
newer version is available on st.com.
To update the firmware, follow the procedure below.
Step 1. Connect the board to the STLINK-V3MINI or to the ST-LINK/V2 programmer.
Step 2. Connect both boards to a PC using the proper USB cables.
Step 3. Open STM32CubeProgrammer, select the proper binary file and download the firmware.
Step 4. Reset the board once the proper firmware is flashed.
Related links
For further details, refer to UM2777, Section 3
2.1 How to program the board using the STM32CubeProgrammer USB mode
If an ST-LINK programmer is not available, both SensorTile.box and STWIN boards can also be reprogrammed
via USB using the STM32CubeProgrammer USB mode.
To enter the firmware upgrade mode, follow the procedure below.
Step 1. Unplug the board.
Step 2. Press the USR button on the STWIN or the [BOOT] button on the SensorTile.box.
Step 3. While keeping the button pressed, connect the USB cable to the PC.
Now the board is in DFU mode.
Step 4. You can upgrade the firmware by following the steps below:
Step 4a. Open STM32CubeProgrammer.
Step 4b. Select [USB] on the top-right corner.
If needed, the application can receive a configuration file in .json format, a configuration file for the LSM6DSOX
(available on the SensorTile.box) or for the ISM330DHCX (available on the STWIN) Machine Learning Core unit
in .ucf format and a timeout as parameters.
USB_DataLog_Run.bat for Windows and USB_DataLog_Run.sh for Linux scripts provide a ready-to-use
example. You are free to customize the scripts to run the desired configurations.
The Utilities/HSDatalog/STWIN_config_examples folder also contains some JSON configuration examples that
can be freely modified to save only necessary data and UCF_examples folder which contains UCF configuration
files to enable the Machine Learning Core feature available on the ISM330DHCX sensor.
Similar JSON configuration examples and UCF configuration files for LSM6DSOX are available for SensorTile.box
in the Utilities/HSDatalog/STBOX_config_examples folder.
Other UCF examples are freely available on github: https://github.com/STMicroelectronics/
STMems_Machine_Learning_Core.
By double clicking on the USB_DataLog_Run batch script, the application starts and the following command line
appears, showing information about the connected board.
The application creates a YYYYMMDD_HH_MM_SS (i.e., 20200128_16_33_00) folder containing the raw data,
the JSON configuration file and the UCF configuration file, if loaded.
Related links
2.6.1 DeviceConfig.json on page 21
2.3 SD card
To acquire sensor data and store them onto an SD card, follow the sequence of operations below.
Step 1. Insert an appropriate SD card into the SensorTile.box or into the STWIN board (see Section 2.3.2 SD
card considerations).
Step 2. Reset the board.
The orange LED blinks once per second. If a JSON configuration file (DeviceConfig.json) is present in
the root folder of the SD card, the custom sensor configuration is loaded from the file itself (see
Section 2.6.1 DeviceConfig.json).
If a UCF configuration file is present in the root folder of the SD card, the MLC configuration is loaded
onto the LSM6DSOX or onto the ISM330DHCX component (see Section 2.6.4 MLC configuration file
(.ucf)).
If the AutoMode configuration file is present in the root folder of the SD card (execution_config.json),
Automode is enabled (see Section 2.3.1 Automode).
Step 3. Press the [USR] button to start data acquisition on the SD card
The orange LED turns off and the greed LED starts blinking to signal sensor data is being written into
the SD card.
Step 4. Press the [USR] button again to stop data acquisition.
Important: Do not unplug the SD card or turn the board off before stopping the acquisition or the data on the SD
card will be corrupted.
Step 5. Remove the SD card and insert it into an appropriate SD card slot on your PC.
The log files are stored in STBOX_### or STWIN_### folders, where ### is a sequential number
determined by the application to ensure log file names are unique.
Each folder contains a file for each active sub-sensor called SensorName_subSensorName.dat
containing raw sensor data coupled with timestamps, a DeviceConfig.json with specific information
about the device configuration, necessary for correct data interpretation, an AcquisitionInfo.json
with information about the acquisition and the data labelling and a copy of the .ucf file used to configure
the MLC, if available.
2.3.1 Automode
HSDatalog also features the Automode, which can be initiated automatically at device power-up or reset. To
enable it, a file called execution_config.json (see Section 2.6.3 execution_config.json) must be placed in the root
folder of the SD card before switching on the board.
This mode can be used to start the datalog operations or to pause all the executions for a specific period of time
by putting the sensor node in "idle" phase.
execution_config.json contains the information about the execution phases when the sensor node is working in
autonomous mode (for example, phases, timer, which is the time to run an execution phase, etc.).
To customize properly the execution_config.json file, see Section 2.6.3 for further details
Figure 16. SD “write buffer” instructions - duration measured with a logic analyzer
The application has been tested with the following SD cards, formatted FAT32 with 32 KB allocation table:
• SanDisk 32 GB Ultra HC C10 U1 A1 (p/n SDSQUAR-032G-GN6MA)
The second tab is dedicated to acquisitions settings and control. After clicking on , you can:
• start and stop an acquisition (to an SD card)
• choose which tag classes will be used for the next acquisition (both HW and SW tags)
• handle hardware and software data tagging and labelling of an ongoing acquisition
• set up the acquisition name and description
The battery status and CPU usage are always shown at the top of the two tabs.
Figure 19. HSDatalog demo page - Run tab, acquisition settings and control
If you have enabled the Machine Learning Core, you can also visualize its output values in the Machine Learning
Core page. You just have to open the demo list by tapping the 3 lines on the top left corner of the app or by
swiping from the left, and then selecting Machine Learning Core.
Note: When the acquisition starts, data are saved on the SD card inserted in the board. If the SD card is not available,
data cannot be saved and the START button will be disabled.
Hardware tags allow automatically enabling/disabling a tag according to the logical state of a pin on the STWIN
STMOD+ connector.
This can be extremely useful when the monitored equipment already provides some electrical signals that reflect
the machine status; connecting these signals to the hardware tag pins allows retrieving this information during
data acquisition.
By default, five STMOD+ pins can be used as hardware tags (pins 7, 8, 9, 10 and 11). The pins are set in Pull-up
configuration so that they can be used with an open-drain output pin.
Note: STMOD+ connector is not available on the SensorTile.box board. So, it is not possible to use the hardware tags
for this board.
The AcquisitionInfo.json shown in the following picture contains the resulting tag list for the above example.
The tag labels (by default, SW_TAG_# and HW_TAG_#) can be changed by editing the DeviceConfig.json file or
directly using the STBLESensClassic app.
2.6.1 DeviceConfig.json
The device consists of three attributes, deviceInfo, sensor and tagConfig.
sensor is an array of attributes to describe all the sensors available on board. Each sensor has a unique ID, a
name and sensorDescriptor and sensorStatus attributes.
sensorDescriptor 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 sub-sensor (i.e., name, data type, sensor type, odr and full scale available, samples per unit of time
supported, unit of measurement, etc.).
sensorStatus 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 sub-
sensor (i.e., whether the sensor is active or not, the actual odr, time offset, data transmitted per unit of time, full
scale, etc.).
As an example, the following figure shows the full sensor description of the STTS751 sensor available on the
STWIN core system.
2.6.2 AcquisitionInfo.json
The AcquisitionInfo.json file contains complementary information regarding the acquisition and the list of selected
labels and tags (if labelling is enabled by the user through the STBLESensClassic app or through the CLI).
You can see an example in the following figure.
2.6.3 execution_config.json
execution_config.json configures execution contexts and phases provides the auto-mode activation at reset and
its definition.
The different parameters that can be configured in this file are:
• info: gives the definition of auto-mode as well as each execution context; any field present overrides
firmware defaults
• version: is the revision of the specification
• auto_mode: if true, auto-mode will start after reset and node initialization
• execution_plan: is a sequence of maximum ten execution steps
• start_delay_ms: indicates the initial delay in milliseconds applied after reset and before the first execution
phase starts when auto-mode is selected
• phases_iteration: gives the number of times the execution_plan is executed; zero indicates an infinite loop
• phase step execution context settings:
– datalog
– timer_ms: specifies the duration in ms of the execution phase; zero indicates an infinite time
– idle
– timer_ms: specifies the duration in ms of the execution phase; zero indicates an infinite time
Related links
For further details on the Machine Learning Core setup, refer to AN5392
One file is generated for each sub-sensor. Composite sensors such as ISM330DHCX or HTS221 may thus
generate multiple files. For example, HTS221_HUM.dat contains humidity raw data from the HTS221 sensor, or
ISM330DHCX_GYRO.dat contains gyroscope raw data from the ISM330DHCX sensor.
A .dat file contains raw data and their timestamps. Related sensor configuration information is available in the
DeviceConfig.json file. The data stream has the following structure:
where
• “data k” (k = 1.. N) represents a sample generated by a subsensor_type.
In case of subsensor_type with multiple axis, such as motion and magnetic sensors (i.e., ISM330DHCX,
IIS2DH, IIS2MDC, IIS3DWB) each “data k” packet is one sample for each axis, as in the following schema:
| axis X | axis Y | axis Z |
• length of data, in bytes (1, 2 or 4), is defined in the dataType file available in the attribute
device→sensor→Descriptor→subSensorDescriptor of DeviceConfig.json
• N corresponds to the value of “samplesPerTs” field available in the attribute
device→sensor→sensorStatus→subSensorStatus of DeviceConfig.json
• Timestamp is a double value (8 bytes) calculated in seconds
2.7 PC scripts
The Utilities folder contains MATLAB and Python scripts to automatically read and plot the data saved in the log
files (tested with MATLAB v2019a and Python 3.10).
A MATLAB app (ReadSensorDataApp.mlapp) developed and tested using the MATLAB v2019a App Designer
tool is also available.
2.7.1.1 ReadSensorDataApp.mlapp
The ReadSensorDataApp.mlapp allows selecting the desired data through a GUI
2.7.2 HSDPython_SDK
FP-SNS-DATALOG2 provides a dedicated Python SDK developed in Python 3.10, ready-to-use for integration
into any data science design flow.
The HSDPython_SDK contains many Python scripts, examples and Jupiter notebook that can be used to log and
elaborate data acquired using both FP-SNS-DATALOG1 or FP-SNS-DATALOG2.
The SDK is organized in three dedicated Python modules:
• st_pnpl: Includes a collection of generic Graphical Widgets (based on pySide6) that could represent:
– DTDL components: Component Widget, Property Widget, Telemetry Widget, Command Widget
– or more generic concepts: Connection Widget, Plots Widget, Device Template loading Widget,
Loading Dialogs
• st_dtdl_gui: PnPL messages and DTDL Device Template Models management:
– generates PnP-Like messages with the correct syntax starting from given values
– parses and Pythonize DTDL Device Template Models.
– manages the local USB devices catalog {board_id, fw_id}
• st_hsdatalog (High-Speed Datalog Python SDK). Includes four sub-packages:
– HSD: Data (.dat) management, DataFrames extraction and offline Visualization
– HSD_utils: Converters functions, Errors/Logs management
– HSD_link: Communication with physical devices. It wraps libhs_datalog.DLL/.so libraries
– HSD_GUI: Collection of HSD specific graphical widgets to interact with FW components and manage
a complete acquisition process. (based on pySide6). Inherited from st_dtdl_gui (Log Control Widget,
Tags Information Widget)
In this way, all the required dependencies are automatically solved. No other Python modules must be installed
manually.
Here the list of the available scripts in the examples folder:
• hsdatalog_check_dummy_data.py can be used to debug the complete application and verify that data are
stored or streamed correctly. You must recompile the firmware enabling HSD_USE_DUMMY_DATA define
(set #define HSD_USE_DUMMY_DATA 1 into SensorManager_conf.h).
• hsdatalog_cli.py is the Python version of the CLI described in Section 2.1.1.
• hsdatalog_data_export.py can convert data into CSV or TSV files.
• hsdatalog_data_export_by_tags.py can be used for tagged acquisition to convert data into different files,
one for each tag used.
• hsdatalog_dataframes.py can save data as pandas dataframe for further processing needs.
• hsdatalog_plot.py can plot the desired data.
• hsdatalog_GUI.py provides an example for real time control and plot as described in Section 2.1.2.
• hsdatalog_to_nanoedge.py can prepare data to be imported into NanoEdge AI Studio solution.
• hsdatalog_to_unico.py can prepare data to be imported into Unico-GUI.
• hsdatalog_to_wav.py can convert audio data into a wave file.
• ultrasound_fft_app.py can be used to handle and control the Ultrasound_FFT FW application for STEVAL-
STWINBX1.
You can execute them in your preferred Python environment (use the command python hsdatalog_plot.py).
Each scripts can accept optional parameters. You can see them by executing the example with the –h option
(python hsdatalog_ploy.py –h)
Options:
-s, --sensor_name TEXT name of sensor - use "all" to plot all active sensors
-ss, --sample_start INTEGER Sample Start
-se, --sample_end INTEGER Sample End
-r, --raw_flag raw data flag (no sensitivity)
-l, --labeled use labels
-p, --subplots subplot multi-dimensional sensors
-d, --debug debug timestamps
-h, --help Show this message and exit.
If the script is executed without specifying any option, on the basis of the acquisition folder, it runs in interactive
mode asking the user which sensor to plot.
The script can also be executed in non-interactive mode. As an example, the easiest way to plot all the sensor
data present in the "STWIN_00001" acquisition folder is to run:
python .\hsdatalog_plot.py STWIN_00001 -s all
The notebook is a step-by-step guide that shows the various functions available in the HSDatalog Python SDK.
Jupiter Notebook is interactive: you can easily modify the code to create your custom application, import the
desired data and plot your acquisitions.
3.1 Overview
When dealing with multiple sensors running at high sampling rates on serial buses (i.e., SPI and I²C), data
acquisition in blocking mode might result in long waiting times for the bus operations to end.
This processing time can be significantly reduced by the proposed software architecture, which leverages
FreeRTOS and STM32 hardware capabilities.
• Sensor handler data structure, part of the sensor manager, which contains additional information on the
sensor such as Chip Select PIN/PORT, I²C address, and a pointer to a freeRTOS semaphore used to block
and unblock the user reading task. This data structure is linked to the void pointer of the previous structure:
typedef struct
{
uint8_t WhoAmI;
uint8_t I2C_address;
GPIO_TypeDef* GPIOx;
uint16_t GPIO_pin;
osSemaphoreId * sem;
} sensor_handle_t;
The application layer, for each sensor, declares and initializes these data structures, creating a connection
between the sensor PID, the sensor manager (where the functions are implemented) and the application itself:
sensor_handle_t iis3dwb_hdl_instance = {IIS3DWB_ID, 0, IIS3DWB_SPI_CS_GPIO_Port, IIS3DWB_S
PI_CS_Pin, &iis3dwb_data_read_cmplt_sem_id};
stmdev_ctx_t iis3dwb_ctx_instance = {SM_SPI_Write_Os, &iis3dwb_hdl_instance};
The example above instantiates and first initializes a sensor_handle_t” for IIS3DWB (which is connected via
SPI, so the I2C_address field is left empty); then it creates and initializes an stmdev_ctx_t, linking the correct
sensor read/write functions and the previously declared sensor handler.
This code block represents the IIS3DWB PID reading the callback call shown below.
/**
* @brief Read generic device register
*
* @param ctx read / wirte interface definitions(ptr)
* @param reg register to read
* @param data pointer to buffer that stores the data read(ptr)
* @param len number of consecutive registers to read
* @retval interface status (MANDATORY: return 0 → no Error)
*
*/
int32-t |iis3dwb_read_reg(stmdev_ctx_t *ctx, uint8_t reg, uint8_t* data,
uint16_t len)
{
int32_t ret;
ret = ctx→read_reg(ctx→handle, reg, data, len);
return ret;
}
msg = osPoolAlloc(spiPool_id);
return 0;
}
osEvent evt;
for (;;)
{
evt = osMessageGet(spiReqQueue_id, osWaitForever);
osSemaphoreWait(spiThreadSem_id, osWaitForever);
The HSDatalog application allows you to save data from any combination of sensors and microphones
configured up to their maximum sampling rate. Sensor data are stored on a micro SD card, SDHC, formatted with
the FAT32 file system, or can be streamed to a PC via USB.
At startup, the application tries to load the device configuration from the SD card (if any) and then enters Idle
state, waiting for the start command either via USB or push button.
POWER ON
NO SD Card or
not found
JSON config
SDCard inserted and
JSON config found
LOAD CUSTOM
CONFIG
IDLE
USB cmd
USER Button or START
Bluetooth low energy USB cmd
BLE Command STOP
LOG TO
LOG VIA USB
SDCARD
4.1 USB
Related links
For further information on the WinUSB class, refer to github
Revision history
Table 1. Document revision history
Contents
1 FP-SNS-DATALOG1 software expansion for STM32Cube . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Folder structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.4 APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
2.1 How to program the board using the STM32CubeProgrammer USB mode . . . . . . . . . . . . . . 4
2.2 USB mode - command line example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 SD card . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.3.1 Automode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3.2 SD card considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Bluetooth® Low Energy control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.5 Data labelling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.6 Acquisition folders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.6.1 DeviceConfig.json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.6.2 AcquisitionInfo.json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
2.6.3 execution_config.json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
2.6.4 MLC configuration file (.ucf) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
2.6.5 Raw data files (.dat) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
2.7 PC scripts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.7.1 MATLAB scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
2.7.2 HSDPython_SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3 Firmware sensor acquisition engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .43
3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.2 Sensor Manager implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
3.3 Firmware components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.3.1 Platform indipendent driver (PID) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.3.2 Application layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
3.4 Data structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
3.5 Detailed function call chain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4 Firmware data flow and device configuration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
4.1 USB. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.1.1 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.1.2 WinUSB WCID driver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.1.3 WinUSB WCID driver firmware implementation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
List of figures
Figure 1. FP-SNS-DATALOG1 software architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 2. FP-SNS-DATALOG1 package folder structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 3. STLINK-V3MINI connected to STWIN core system board. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 4. STM32CubeProgrammer - USB mode selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 5. STM32CubeProgrammer - connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 6. STM32CubeProgrammer - programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Figure 7. Device Manager Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 8. STWIN Multi-Sensor Streaming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 9. HSDatalog application - cli_example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 10. HSDatalog application - help . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 11. HSDatalog application - Datalog_Run script . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 12. HSDatalog application - JSON configuration examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 13. HSDatalog application - command line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 14. HSDatalog application - command line received data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 15. HSDatalog application - folder creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 16. SD “write buffer” instructions - duration measured with a logic analyzer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 17. HSDatalog demo page - Configuration tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 18. HSDatalog demo page - Configure MLC, save/load configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 19. HSDatalog demo page - Run tab, acquisition settings and control . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 20. Machine Learning Core demo page - output values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 21. CLI example interface - activating/deactivating software tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Figure 22. ST BLESensor Classic app - activating/deactivating software tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Figure 23. Hardware tag signals - example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Figure 24. Hardware tag signals - resulting tag list . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Figure 25. SD card output folder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Figure 26. SD card folder - JSON and data files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Figure 27. DeviceConfig.json - device attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Figure 28. DeviceConfig.json - deviceInfo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Figure 29. DeviceConfig.json - sensor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Figure 30. DeviceConfig.json - sensorDescriptor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Figure 31. DeviceConfig.json - sensorStatus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Figure 32. DeviceConfig.json - STTS751 sensor description example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Figure 33. DeviceConfig.json - tagConfig attribute . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Figure 34. AcquisitionInfo.json attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Figure 35. execution_config.json . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Figure 36. ucf configuration file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Figure 37. Sensor raw data folder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Figure 38. .dat file - data stream structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
Figure 39. PlotSensorData application - sensor data. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Figure 40. ReadSensorDataapp.mlapp - GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 41. ReadSensorDataApp.mlapp - sensor selection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Figure 42. ReadSensorDataApp.mlapp - sensor signal spectrogram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 43. HSDPython_SDK available scripts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
Figure 44. HSDPython_SDK modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Figure 45. Install Python 3.11.3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Figure 46. Python 3.11.3 setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
Figure 47. HSDPython_SDK options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Figure 48. hsdatalog_plot application - Interactive mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Figure 49. hsdatalog_plot application - plotted data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Figure 50. hsdatalog_check_dummy_data - signal test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Figure 51. hsdatalog_check_dummy_data - signal test results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Figure 52. Jupyter Notebook (1 of 3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
Figure 53. Jupyter Notebook (2 of 3). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41