Användarmanual för ST X-CUBE-MEMS1 Sensor- och rörelsealgoritmprogramvaruexpansion

X-CUBE-MEMS1 Sensor- och rörelsealgoritmprogramvaruexpansion

Produktinformation

Specifikationer

  • Product Name: MotionPW Real-time Pedometer
  • Kompatibilitet: X-CUBE-MEMS1 expansion för STM32Cube
  • Tillverkare: STMicroelectronics
  • Library: MotionPW Middleware Library
  • Data Acquisition: Accelerometer
  • Sampling Frekvens: 50 Hz

Produktanvändningsinstruktioner

Överview

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.

Kompatibilitet

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

Genomförande

A sample implementation is available for X-NUCLEO-IKS4A1 and
X-NUCLEO-IKS01A3 expansion boards mounted on specified development
brädor.

Teknisk information

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

API:er

  • 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)

Vanliga frågor (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.

F: Vilka är nödvändiga accelerometerdataamplånga
frekvens?

S: Den obligatoriska 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.

"`

UM2350
Användarmanual
Getting started with MotionPW real-time pedometer for wrist library in X-CUBEMEMS1 expansion for STM32Cube
Introduktion
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 sampen implementering som körs på X-NUCLEO-IKS4A1 eller X-NUCLEO-IKS01A3 expansionskort på ett NUCLEO-F401RE, NUCLEO-U575ZI-Q eller NUCLEO-L152RE utvecklingskort.

UM2350 – Rev 4 – maj 2025 För mer information, kontakta ditt lokala STMicroelectronics-försäljningskontor.

www.st.com

UM2350
Akronymer och förkortningar

1

Akronymer och förkortningar

Förkortning API BSP GUI HAL IDE

Tabell 1. Lista över akronymer

Applikationsprogrammeringsgränssnitt Kortstödspaket Grafiskt användargränssnitt Hårdvaruabstraktionslager Integrerad utvecklingsmiljö

Beskrivning

UM2350 – Rev 4

sida 2/16

2
2.1 2.2 XNUMX XNUMX XNUMX XNUMX
2.2.1
2.2.2
Notera:

UM2350
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.
Biblioteket är endast utformat för ST MEMS. Funktionalitet och prestanda vid användning av andra MEMS-sensorer analyseras inte och kan skilja sig väsentligt från vad som beskrivs i dokumentet.
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 finns i mappen Dokumentation.

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

·

igenkänning endast baserat på accelerometerdata

·

nödvändiga accelerometerdataamplingfrekvens på 50 Hz

·

resurskrav:

Cortex-M3: 3.7 kB kod och 1.8 kB dataminne

Cortex-M33: 3.5 kB kod och 1.8 kB dataminne

Cortex-M4: 3.5 kB kod och 1.8 kB dataminne

Cortex-M7: 3.6 kB kod och 1.8 kB dataminne

·

tillgänglig för ARM® Cortex®-M3, ARM® Cortex®-M33, ARM® Cortex®-M4 och ARM® Cortex®-M7

arkitekturer

MotionPW APIs

The MotionPW library APIs are:

·

uint8_t MotionPW_GetLibVersion(char *version)

hämtar biblioteksversionen

*version är en pekare till en array med 35 tecken

returnerar antalet tecken i versionssträngen

·

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

sida 3/16

UM2350
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-parametern är en pekare till en struktur med indata

­ the parameters for the structure type MPW_input_t are:

AccX är accelerometerns sensorvärde i X-axeln i g

AccY är accelerometerns sensorvärde i Y-axeln i g

AccZ är accelerometerns sensorvärde i Z-axeln i 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

sida 4/16

2.2.3

API-flödesschema

UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Figure 1. MotionPW API logic sequence
Start
Initiera
GetLibVersion
Vänta Utgångstimer Dataläsningsavbrott

Läs accelerometerdatauppdatering
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

sida 5/16

2.2.5

UM2350
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

Tabell 2. Algoritmförloppstid (µs) Cortex-M4, Cortex-M3

Cortex-M4 STM32F401RE vid 84 MHz

Min

Genomsnittlig

Max

38

49

616

Cortex-M3 STM32L152RE vid 32 MHz

Min

Genomsnittlig

Max

296

390

3314

UM2350 – Rev 4

sida 6/16

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

Tabell 3. Algoritmförloppstid (µs) Cortex-M33 och Cortex-M7

Cortex- M33 STM32U575ZI-Q vid 160 MHz

Min

Genomsnittlig

Max

57

63

359

Cortex- M7 STM32F767ZI vid 96 MHz

Min

Genomsnittlig

Max

61

88

1301

2.3

Sample ansökan

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

A sampApplikationen finns i programmappen. Den är utformad för att köras på ett NUCLEO-F401RE-, NUCLEOU575ZI-Q- eller NUCLEO-L152RE-utvecklingskort anslutet till ett X-NUCLEO-IKS4A1- eller X-NUCLEO-IKS01A3-expansionskort.

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

Figur 3. STM32 Nucleo: lysdioder, knapp, bygel

Bilden ovan visar användarknappen B1 och de tre lysdioderna på NUCLEO-F401RE-kortet. När kortet är påslaget tänds LED LD3 (PWR).
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 och så småningom andra sensordata, i realtid, med hjälp av MEMS-Studio.

2.4

MEMS Studio-applikation

Sample application uses MEMS-Studio application, which can be downloaded from www.st.com.

Steg 1. Se till att nödvändiga drivrutiner är installerade och att STM32 Nucleo-kortet med lämpligt expansionskort är anslutet till datorn.

UM2350 – Rev 4

sida 7/16

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

Steg 2.

Starta programmet MEMS-Studio för att öppna programmets huvudfönster.
Om ett STM32 Nucleo-kort med stöd för firmware är anslutet till datorn, detekteras det automatiskt. Tryck på knappen [Anslut] för att upprätta anslutning till utvärderingskortet.

Figur 4. MEMS-Studio – Anslut

Steg 3. När den är ansluten till ett STM32 Nucleo-kort med stöd för firmware öppnas fliken [Library Evaluation].

För att starta och stoppa dataströmning, växla mellan lämplig vertikal verktygsfält [Start].

eller [Stopp]-knappen på den yttre

Data som kommer från den anslutna sensorn kan vara viewed välja fliken [Data Table] på den inre vertikala verktygsraden.

Figur 5. MEMS-Studio – Biblioteksutvärdering – Datatabell

UM2350 – Rev 4

sida 8/16

UM2350
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

Steg 5.

Klicka på [Spara till File] to open the dataloging configuration window. Select the sensor and pedometer data to be saved in the fileDu kan starta eller stoppa sparandet genom att klicka på motsvarande
knapp.

Figur 7. MEMS-Studio – Biblioteksutvärdering – Spara till File

UM2350 – Rev 4

sida 9/16

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

Steg 6.

Datainjektionsläget kan användas för att skicka tidigare inhämtade data till biblioteket och ta emot
resultat. Välj fliken [Datainjektion] i den vertikala verktygsfältet för att öppna den dedikerade view för denna funktion.

Figur 8. MEMS-Studio – Biblioteksutvärdering – Datainjektion

Steg 7.

Klicka på knappen [Bläddra] för att välja file med tidigare insamlad data i CSV-format. Data kommer att laddas in i tabellen i strömmen viewAndra knappar blir aktiva. Du kan klicka på:
[Offlineläge]-knapp för att slå på/av den inbyggda programvarans offlineläge (läge som använder tidigare insamlad data).
Knapparna [Start]/[Stopp]/[Step]/[Repeat] för att styra dataflödet från MEMS-Studio till biblioteket.

UM2350 – Rev 4

sida 10/16

UM2350
Referenser

3

Referenser

Alla följande resurser är fritt tillgängliga på www.st.com. 1. UM1859: Komma igång med X-CUBE-MEMS1 rörelse-MEMS och programvara för miljösensorer
expansion för STM32Cube 2. UM1724: STM32 Nucleo-64-kort (MB1136) 3. UM3233: Komma igång med MEMS-Studio

UM2350 – Rev 4

sida 11/16

UM2350

Revisionshistorik

Tabell 4. Dokumentrevisionshistorik

Datum

Versionsändringar

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 Added X-NUCLEO-IKS01A3 expansion board compatibility information.

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
prestanda, avsnitt 2.3: Sample-applikationen, avsnitt 2.4: MEMS Studio-applikationen

UM2350 – Rev 4

sida 12/16

UM2350
Innehåll
Innehåll
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-applikationen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 MEMS Studio-applikationen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Referenser . ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11

UM2350 – Rev 4

sida 13/16

UM2350
Lista över tabeller

Lista över tabeller

Tabell 1. Tabell 2. Tabell 3. Tabell 4.

List of acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Algorithm elapse time (µs) Cortex-M4, Cortex-M3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Algorithm elapse time (µs) Cortex-M33 and Cortex-M7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

UM2350 – Rev 4

sida 14/16

UM2350
Lista över figurer

Lista över figurer

Figur 1. Figur 2. Figur 3. Figur 4. Figur 5. Figur 6. Figur 7. Figur 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

sida 15/16

UM2350
VIKTIGT MEDDELANDE LÄS NOGGRANT STMicroelectronics NV och dess dotterbolag (“ST”) förbehåller sig rätten att göra ändringar, korrigeringar, förbättringar, modifieringar och förbättringar av ST-produkter och/eller av detta dokument när som helst utan föregående meddelande. Köpare bör skaffa den senaste relevanta informationen om ST-produkter innan de lägger beställningar. ST-produkter säljs i enlighet med ST:s försäljningsvillkor som gäller vid tidpunkten för ordererkännande. Köparen är ensam ansvarig för val, urval och användning av ST-produkter och ST tar inget ansvar för applikationshjälp eller design av köparens produkter. Ingen licens, uttrycklig eller underförstådd, till någon immateriell rättighet beviljas av ST häri. Återförsäljning av ST-produkter med bestämmelser som skiljer sig från den information som anges häri upphäver all garanti som beviljats ​​av ST för sådan produkt. ST och ST-logotypen är varumärken som tillhör ST. För ytterligare information om ST-varumärken, se www.st.com/trademarks. Alla andra produkt- eller tjänstnamn tillhör sina respektive ägare. Informationen i detta dokument ersätter och ersätter information som tidigare tillhandahållits i tidigare versioner av detta dokument.
© 2025 STMicroelectronics Alla rättigheter reserverade

UM2350 – Rev 4

sida 16/16

Dokument/resurser

ST X-CUBE-MEMS1 Sensor and Motion Algorithm Software Expansion [pdf] Användarmanual
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

Referenser

Lämna en kommentar

Din e-postadress kommer inte att publiceras. Obligatoriska fält är markerade *