Manuale d'usu di u software di espansione di l'algoritmu di muvimentu è di sensori ST X-CUBE-MEMS1

Espansione di u Software di Sensore è Algoritmu di Muvimentu X-CUBE-MEMS1

Informazione di u produttu

Specificazioni

  • Product Name: MotionPW Real-time Pedometer
  • Compatibilità: espansione X-CUBE-MEMS1 per STM32Cube
  • Produttore: STMicroelectronics
  • Library: MotionPW Middleware Library
  • Data Acquisition: Accelerometer
  • Sampling Frequenza: 50 Hz

Istruzzioni per l'usu di u produttu

Overview

The MotionPW library expands the functionality of the
X-CUBE-MEMS1 software by acquiring data from the accelerometer to
provide information about the number of steps and cadence performed
with the wearable device.

Cumpatibilità

The library is designed for ST MEMS sensors only. Using other
MEMS sensors may result in different functionality and
prestazione.

Implementazione

A sampl'implementazione di le hè dispunibule per X-NUCLEO-IKS4A1 è
X-NUCLEO-IKS01A3 expansion boards mounted on specified development
tavule.

Informazioni tecniche

For detailed functions and parameters of the MotionPW APIs,
refer to the MotionPW_Package.chm compiled HTML file situatu in u
Documentation folder.

API

  • MotionPW_GetLibVersion(char *version)
  • MotionPW_Initialize(void)
  • MotionPW_Update(MPW_input_t *data_in, MPW_output_t
    * data_out)
  • MotionPW_ResetPedometerLibrary(void)
  • MotionPW_ResetStepCount(void)
  • MotionPW_UpdateEnergyThreshold(float *energy_threshold)

Domande Frequenti (FAQ)

Q: Can I use MotionPW library with non-ST MEMS sensors?

A: The library is designed for ST MEMS sensors only.
Compatibility with other MEMS sensors is not guaranteed.

Q: Cosa hè u dati accelerometer nicissarii sampling
frequenza?

A: U sampling frequency is 50 Hz for accurate
detection of steps and cadence.

Q: How do I initialize the MotionPW library?

A: Call the MotionPW_Initialize() function before using the
fitness activity library. Ensure the CRC module in the STM32
microcontroller is enabled.

"'

UM 2350
Manuale d'usu
Getting started with MotionPW real-time pedometer for wrist library in X-CUBEMEMS1 expansion for STM32Cube
Introduzione
The MotionPW middleware library is part of the X-CUBE-MEMS1 software and runs on STM32 Nucleo. It provides real-time information about the number of steps and cadence which the user just performed with the wearable device (e.g. a smart watch). This library is intended to work with ST MEMS only. The algorithm is provided in static library format and is designed to be used on STM32 microcontrollers based on the ARM® Cortex®-M3, ARM Cortex®-M33, ARM® Cortex®-M4, ARM® Cortex®-M7 architecture. It is built on top of STM32Cube software technology to ease portability across different STM32 microcontrollers. The software comes with sampl'implementazione di le in esecuzione nantu à una scheda di espansione X-NUCLEO-IKS4A1 o X-NUCLEO-IKS01A3 nantu à una scheda di sviluppu NUCLEO-F401RE, NUCLEO-U575ZI-Q o NUCLEO-L152RE.

UM2350 – Rev 4 – Maghju 2025 Per più infurmazioni, cuntattate u vostru ufficiu di vendita lucale STMicroelectronics.

www.st.com

UM 2350
Acronimi è abbreviazioni

1

Acronimi è abbreviazioni

Acronym API BSP GUI HAL IDE

Table 1. Lista di acronimi

Interfaccia di prugrammazione di l'applicazione Pacchettu di supportu di bordu Interfaccia d'utilizatore grafica Strata di astrazione di hardware Ambiente di sviluppu integratu

Descrizzione

UM2350 - Rev 4

pagina 2/16

2
2.1 2.2
2.2.1
2.2.2
Nota:

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube

MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube

MotionPW overview
The MotionPW library expands the functionality of the X-CUBE-MEMS1 software.
The library acquires data from the accelerometer and provides information about the number of steps and cadence the user just performed with the wearable device.
A biblioteca hè pensata solu per ST MEMS. A funziunalità è u rendiment quandu si usanu altri sensori MEMS ùn sò micca analizati è ponu esse significativamente sfarente da ciò chì hè descrittu in u documentu.
A sample implementation is available for X-NUCLEO-IKS4A1 and X-NUCLEO-IKS01A3 expansion boards, mounted on aNUCLEO-F401RE, NUCLEO-U575ZI-Q or NUCLEO-L152RE development board.

MotionPW library
Technical information fully describing the functions and parameters of the MotionPW APIs can be found in the MotionPW_Package.chm compiled HTML file situatu in u cartulare Documentazione.

MotionPW library description

The MotionPW pedometer library manages the data acquired from the accelerometer; it features:

·

possibility of detecting the number of steps, cadence and confidence

·

ricunniscenza basatu solu nantu à dati accelerometer

·

data accelerometer required sampfrequenza di ling di 50 Hz

·

esigenze di risorse:

Cortex-M3: 3.7 kB di codice è 1.8 kB di memoria di dati

Cortex-M33: 3.5 kB di codice è 1.8 kB di memoria di dati

Cortex-M4: 3.5 kB di codice è 1.8 kB di memoria di dati

Cortex-M7: 3.6 kB di codice è 1.8 kB di memoria di dati

·

available for ARM® Cortex®-M3, ARM® Cortex®-M33, ARM® Cortex®-M4 and ARM® Cortex®-M7

architetture

MotionPW APIs

The MotionPW library APIs are:

·

uint8_t MotionPW_GetLibVersion(char *version)

­ retrieves the library version

­ *version is a pointer to an array of 35 characters

­ returns the number of characters in the version string

·

void MotionPW_Initialize(void)

­ performs MotionPW library initialization and setup of the internal mechanism including the dynamic memory allocation

This function must be called before using the fitness activity library and the CRC module in the STM32 microcontroller (in RCC peripheral clock enable register) has to be enabled.

UM2350 - Rev 4

pagina 3/16

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube

·

void MotionPW_Update(MPW_input_t *data_in, MPW_output_t *data_out)

­ executes pedometer for wrist algorithm

­ *data_in parameter is a pointer to a structure with input data

­ the parameters for the structure type MPW_input_t are:

AccX hè u valore di u sensoru di l'accelerometru in l'assi X in g

AccY hè u valore di u sensoru di l'accelerometru in l'assi Y in g

AccZ hè u valore di u sensoru di l'accelerometru in l'assi Z in g

­ CurrentActivity is the enumerated input type MPW_activity_t with the following values:

MPW_UNKNOWN_ACTIVITY = 0x00

MPW_WALKING = 0x01

MPW_FASTWALKING = 0x02

MPW_JOGGING = 0x03

­ *data_out parameter is a pointer to a structure with output data

­ the parameters for the structure type MPW_output_t are:

Nsteps is number of steps performed by user

Cadence is the cadence of user steps

Confidence is the confidence of calculated output parameter

·

void MotionPW_ResetPedometerLibrary(void)

­ resets the library internal variables and mechanism into default values (including current step count)

·

void MotionPW_ResetStepCount(void)

­ resets the current step count

·

void MotionPW_UpdateEnergyThreshold(float *energy_threshold)

­ updated energy threshold to fine tune step detection algorithm

­ *energy_threshold parameter is a pointer to energy threshold value

UM2350 - Rev 4

pagina 4/16

2.2.3

Diagramme de flux de l'API

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Figure 1. MotionPW API logic sequence
Principià
Inizializà
GetLibVersion
Aspettate l'interruzione di lettura di dati di u timer di scadenza

Read Accelerometer Data Update
Get Outputs

2.2.4

Demo code The following demonstration code example reads data from the accelerometer sensor, obtains the current activity from MotionAW library and gets the number of steps, cadence and confidence from MotionPW library.
[…] #define VERSION_STR_LENG 35 […] /* Initialization */ char lib_version[VERSION_STR_LENG];
/* Pedometer API initialization function */ MotionPW_Initialize();
/* Activity recognition API initialization function */ MotionAW_Initialize();
/* Optional: Get version */ MotionPW_GetLibVersion(lib_version);
[…] /* Using Pedometer for wrist algorithm */ Timer_OR_DataRate_Interrupt_Handler() {
MPW_input_t MPW_data_in; MPW_output_t MPW_data_out;

UM2350 - Rev 4

pagina 5/16

2.2.5

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
MAW_input_t MAW_data_in; MAW_output_t MAW_data_out;
/* Get acceleration X/Y/Z in g */ MEMS_Read_AccValue(&MAW_data_in.Acc_X, &MAW_data_in.Acc_Y, &MAW_data_in.Acc_Z);
/* Get current activity */ MotionAW_Update(&MAW_data_in, &MAW_data_out, Timestamp);
MPW_data_in.Acc_X = MAW_data_in.Acc_X; MPW_data_in.Acc_Y = MAW_data_in.Acc_Y; MPW_data_in.Acc_Z = MAW_data_in.Acc_Z;
if (MAW_data_out.current_activity == MAW_WALKING) {
MPW_data_in.currentActivity = MPW_WALKING; } else if (MAW_data_out.current_activity == MAW_FASTWALKING) {
MPW_data_in.currentActivity = MPW_FASTWALKING; } else if (MAW_data_out.current_activity == MAW_JOGGING) {
MPW_data_in.currentActivity = MPW_JOGGING; } else {
MPW_data_in.currentActivity = MPW_UNKNOWN_ACTIVITY; }
/* Run pedometer for wrist algorithm */ MotionPW_Update(&MPW_data_in, &MPW_data_out); }
Algorithm performance The pedometer for wrist algorithm uses data from the accelerometer only and runs at a low frequency (50 Hz) to reduce power consumption. When replicating fitness activity with the STM32 Nucleo board, ensure the board is oriented perpendicularly to the forearm, to simulate the wristband position.
Figure 2. Orientation system for wrist-worn devices

Table 2. Algorithm elapse time (µs) Cortex-M4, Cortex-M3

Cortex-M4 STM32F401RE à 84 MHz

Min

Avg

Max

38

49

616

Cortex-M3 STM32L152RE à 32 MHz

Min

Avg

Max

296

390

3314

UM2350 - Rev 4

pagina 6/16

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube

Tabella 3. Algorithm elapse time (µs) Cortex-M33 è Cortex-M7

Cortex-M33 STM32U575ZI-Q à 160 MHz

Min

Avg

Max

57

63

359

Cortex-M7 STM32F767ZI à 96 MHz

Min

Avg

Max

61

88

1301

2.3

Sampl'applicazione

The MotionPW middleware can be easily manipulated to build user applications.

A sample application is provided in the Application folder. It is designed to run on a NUCLEO-F401RE, NUCLEOU575ZI-Q or NUCLEO-L152RE development board connected to an X-NUCLEO-IKS4A1 or X-NUCLEO-IKS01A3 expansion board.

The application recognizes the steps, cadence and confidence in real-time. The data can be displayed through a GUI.

Figura 3. STM32 Nucleo: LED, buttone, jumper

A figura sopra mostra u buttone d'utilizatore B1 è i trè LED di a scheda NUCLEO-F401RE. Una volta chì a scheda hè alimentata, u LED LD3 (PWR) si accende.
A USB cable connection is required to monitor real-time data. The board is powered by the PC via USB connection. This working mode allows the user to display detected steps, cadence and confidence, accelerometer data, time stamp è eventualmente altri dati sensori, in tempu reale, usendu u MEMS-Studio.

2.4

Applicazione MEMS Studio

U sampl'applicazione usa l'applicazione MEMS-Studio, chì pò esse scaricata da www.st.com.

Passu 1. Assicuratevi chì i drivers necessarii sò stallati è a scheda STM32 Nucleo cù u pianu di espansione adattatu hè cunnessu à u PC.

UM2350 - Rev 4

pagina 7/16

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube

Passu 2.

Lanciari l'applicazione MEMS-Studio per apre a finestra principale di l'applicazione.
Se una scheda STM32 Nucleo cù firmware supportatu hè cunnessu à u PC, hè rilevatu automaticamente. Pulsà u buttone [Connect] per stabilisce a cunnessione à u cunsigliu di valutazione.

Figura 4. MEMS-Studio - Cunnette

Passu 3. Quandu hè cunnessu à una scheda STM32 Nucleo cù u firmware supportatu [Evaluazione Biblioteca] tab hè aperta.

Per inizià è piantà u flussu di dati, cambia a barra di strumenti verticale [Start] adatta.

o buttone [Stop] nantu à l'esterno

I dati chì venenu da u sensoru cunnessu ponu esse viewed selezziunate a tabulazione [Table di Dati] nantu à a barra di strumenti verticale interna.

Figura 5. MEMS-Studio - Valutazione Biblioteche - Data Table

UM2350 - Rev 4

pagina 8/16

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Step 4. Click on the [Pedometer] to open the dedicated application window. Figure 6. MEMS-Studio – Library Evaluation – Pedometer

Passu 5.

Cliccate nant'à [Salvà à File] to open the dataloging configuration window. Select the sensor and pedometer data to be saved in the file. Pudete principià o piantà di salvà clicchendu nant'à u currispundente
buttone.

Figura 7. MEMS-Studio - Valutazione Biblioteche - Salvà à File

UM2350 - Rev 4

pagina 9/16

UM 2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube

Passu 6.

U modu di iniezione di dati pò esse usatu per mandà i dati acquistati prima à a biblioteca è riceve u
risultatu. Selezziunà a tabulazione [Injection di Dati] nantu à a barra di strumenti verticale per apre u dedicatu view per sta funziunalità.

Figura 8. MEMS-Studio - Valutazione di Biblioteca - Iniezione di Dati

Passu 7.

Cliccate nant'à u buttone [Browse] per selezziunate file cù i dati catturati prima in furmatu CSV. I dati seranu carricati in a tavula in u currente view. Altri buttoni diventeranu attivu. Pudete cliccà nant'à:
Pulsante [Modu Offline] per accende / disattiva u modu di firmware offline (modu utilizendu i dati catturati prima).
Pulsanti [Start]/[Stop]/[Step]/[Repeat] per cuntrullà l'alimentazione di dati da MEMS-Studio à a biblioteca.

UM2350 - Rev 4

pagina 10/16

UM 2350
Referenze

3

Referenze

All of the following resources are freely available on www.st.com. 1. UM1859: Getting started with the X-CUBE-MEMS1 motion MEMS and environmental sensor software
expansion for STM32Cube 2. UM1724: STM32 Nucleo-64 boards (MB1136) 3. UM3233: Getting started with MEMS-Studio

UM2350 - Rev 4

pagina 11/16

UM 2350

Storia di rivisione

Table 4. Storia di rivisione di documenti

Data

Variazioni di versione

24-Jan-2018 1 Initial release.

21-Mar-2018 2 Updated Introduction and Section 2.1 MotionPW overview. Updated Section 2.2.5: Algorithm performance and Figure 3. STM32 Nucleo: LEDs, button, jumper.
20-Feb-2019 3 Aggiunta infurmazione di cumpatibilità di a scheda di espansione X-NUCLEO-IKS01A3.

Updated Section Introduction, Section 2.1: MotionPW overview, Section 2.2.1: MotionPW library 20-May-2025 4 description, Section 2.2.2: MotionPW APIs, Section 2.2.4: Demo code, Section 2.2.5: Algorithm
prestazione, Sezione 2.3: Sample application, Section 2.4: MEMS Studio application

UM2350 - Rev 4

pagina 12/16

UM 2350
Cuntenuti
Cuntenuti
1 Acronyms and abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 MotionPW middleware library in X-CUBE-MEMS1 software expansion for
STM32Cube . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3 2.1 MotionPW overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2 MotionPW library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2.1 MotionPW library description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2.2 MotionPW APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.2.3 API flow chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.4 Demo code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 2.2.5 Algorithm performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.3 Sample application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 MEMS Studio application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12

UM2350 - Rev 4

pagina 13/16

UM 2350
Lista di tavule

Lista di tavule

Table 1. Table 2. Table 3. Table 4.

Lista di acronimi. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Algorithm elapse time (µs) Cortex-M4, Cortex-M3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Algorithm elapse time (µs) Cortex-M33 è Cortex-M7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Storia di rivisione di documentu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

UM2350 - Rev 4

pagina 14/16

UM 2350
Lista di figuri

Lista di figuri

Figura 1. Figura 2. Figura 3. Figura 4. Figura 5. Figura 6. Figura 7. Figura 8.

MotionPW API logic sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Orientation system for wrist-worn devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 STM32 Nucleo: LEDs, button, jumper . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 MEMS-Studio – Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 MEMS-Studio – Library Evaluation – Data Table. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 MEMS-Studio – Library Evaluation – Pedometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 MEMS-Studio – Library Evaluation – Save To File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 MEMS-Studio – Library Evaluation – Data Injection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

UM2350 - Rev 4

pagina 15/16

UM 2350
AVVISU IMPORTANTE LEGGIU ATTENTAMENTE STMicroelectronics NV è e so filiali ("ST") si riservanu u dirittu di fà cambiamenti, correzioni, miglioramenti, mudificazioni è migliure à i prudutti ST è / o à stu documentu in ogni mumentu senza avvisu. I cumpratori anu da ottene l'ultime informazioni pertinenti nantu à i prudutti ST prima di fà ordini. I prudutti ST sò venduti in cunfurmità cù i termini è e cundizioni di vendita di ST in vigore à u mumentu di a ricunniscenza di l'ordine. I cumpratori sò solu rispunsevuli di a scelta, a selezzione è l'usu di i prudutti ST è ST ùn assume micca responsabilità per l'assistenza di l'applicazione o u disignu di i prudutti di l'acquirente. Nisuna licenza, espressa o implicita, à qualsiasi dirittu di pruprietà intellettuale hè cuncessa da ST quì. A rivendita di i prudutti ST cù disposizioni diverse da l'infurmazioni stabilite quì annullerà ogni garanzia accordata da ST per tali pruduttu. ST è u logo ST sò marchi di ST. Per infurmazioni supplementari nantu à i marchi ST, riferite à www.st.com/trademarks. Tutti l'altri prudutti o nomi di serviziu sò a pruprietà di i so rispettivi pruprietarii. L'infurmazioni in stu documentu rimpiazzanu è rimpiazzanu l'infurmazioni furnite prima in qualsiasi versione precedente di stu documentu.
© 2025 STMicroelectronics Tutti i diritti riservati

UM2350 - Rev 4

pagina 16/16

Documenti / Risorse

ST X-CUBE-MEMS1 Sensor and Motion Algorithm Software Expansion [pdfManuale d'usu
STM32 Nucleo, X-NUCLEO-IKS4A1, X-NUCLEO-IKS01A3, X-CUBE-MEMS1 Sensor and Motion Algorithm Software Expansion, X-CUBE-MEMS1, Sensor and Motion Algorithm Software Expansion, Motion Algorithm Software Expansion, Algorithm Software Expansion, Software Expansion

Referenze

Lascia un cumentu

U vostru indirizzu email ùn serà micca publicatu. I campi obbligatori sò marcati *