Brugermanual til udvidelse af ST X-CUBE-MEMS1-sensor- og bevægelsesalgoritmesoftware

Udvidelse af X-CUBE-MEMS1-sensor- og bevægelsesalgoritmesoftware

Produktinformation

Specifikationer

  • Product Name: MotionPW Real-time Pedometer
  • Kompatibilitet: X-CUBE-MEMS1 udvidelse til STM32Cube
  • Producent: STMicroelectronics
  • Library: MotionPW Middleware Library
  • Data Acquisition: Accelerometer
  • Sampling Frekvens: 50 Hz

Produktbrugsvejledning

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.

Kompatibilitet

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

Implementering

A sample implementering er tilgængelig for X-NUCLEO-IKS4A1 og
X-NUCLEO-IKS01A3 expansion boards mounted on specified development
brædder.

Teknisk information

For detailed functions and parameters of the MotionPW APIs,
refer to the MotionPW_Package.chm compiled HTML file placeret 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)

Ofte stillede spørgsmål (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: Hvad er de nødvendige accelerometerdataampling
frekvens?

A: De påkrævede 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
Brugermanual
Getting started with MotionPW real-time pedometer for wrist library in X-CUBEMEMS1 expansion for STM32Cube
Indledning
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 sampimplementeringen kører på X-NUCLEO-IKS4A1 eller X-NUCLEO-IKS01A3 udvidelseskort på et NUCLEO-F401RE, NUCLEO-U575ZI-Q eller NUCLEO-L152RE udviklingskort.

UM2350 – Rev 4 – maj 2025 Kontakt dit lokale STMicroelectronics-salgskontor for yderligere information.

www.st.com

UM2350
Akronymer og forkortelser

1

Akronymer og forkortelser

Akronym API BSP GUI HAL IDE

Tabel 1. Liste over akronymer

Applikationsprogrammeringsgrænseflade Board-støttepakke Grafisk brugergrænseflade Hardwareabstraktionslag Integreret udviklingsmiljø

Beskrivelse

UM2350 – Rev 4

side 2/16

2
2.1 2.2
2.2.1
2.2.2
Note:

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 er kun designet til ST MEMS. Funktionalitet og ydeevne ved brug af andre MEMS-sensorer analyseres ikke og kan være væsentligt anderledes end det, der er beskrevet 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 findes 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

·

genkendelse kun baseret på accelerometerdata

·

nødvendige accelerometerdataampling frekvens på 50 Hz

·

ressourcekrav:

Cortex-M3: 3.7 kB kode og 1.8 kB datahukommelse

Cortex-M33: 3.5 kB kode og 1.8 kB datahukommelse

Cortex-M4: 3.5 kB kode og 1.8 kB datahukommelse

Cortex-M7: 3.6 kB kode og 1.8 kB datahukommelse

·

tilgængelig til ARM® Cortex®-M3, ARM® Cortex®-M33, ARM® Cortex®-M4 og ARM® Cortex®-M7

arkitekturer

MotionPW APIs

The MotionPW library APIs are:

·

uint8_t MotionPW_GetLibVersion(char *version)

henter biblioteksversionen

*version er en pointer til et array på 35 tegn

returnerer antallet af tegn i versionsstrengen

·

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

side 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 parameter er en pegepind til en struktur med inputdata

­ the parameters for the structure type MPW_input_t are:

AccX er accelerometerets sensorværdi i X-aksen i g

AccY er accelerometerets sensorværdi i Y-aksen i g

AccZ er accelerometerets sensorværdi i Z-aksen 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

side 4/16

2.2.3

API flowdiagram

UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Figure 1. MotionPW API logic sequence
Starte
Initialiser
GetLibVersion
Vent Udløber Timer Data Læs Interrupt

Læs accelerometerdataopdatering
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

side 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

Tabel 2. Algoritmeforløbstid (µs) Cortex-M4, Cortex-M3

Cortex-M4 STM32F401RE ved 84 MHz

Min

Gns

Maks

38

49

616

Cortex-M3 STM32L152RE ved 32 MHz

Min

Gns

Maks

296

390

3314

UM2350 – Rev 4

side 6/16

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

Tabel 3. Algoritmeforløbstid (µs) Cortex-M33 og Cortex-M7

Cortex- M33 STM32U575ZI-Q ved 160 MHz

Min

Gns

Maks

57

63

359

Cortex- M7 STM32F767ZI ved 96 MHz

Min

Gns

Maks

61

88

1301

2.3

Sample ansøgning

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

A sampApplikationen findes i programmappen. Den er designet til at køre på et NUCLEO-F401RE-, NUCLEOU575ZI-Q- eller NUCLEO-L152RE-udviklingskort, der er tilsluttet et X-NUCLEO-IKS4A1- eller X-NUCLEO-IKS01A3-udvidelseskort.

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

Figur 3. STM32 Nucleo: LED'er, knap, jumper

Ovenstående figur viser brugerknappen B1 og de tre LED'er på NUCLEO-F401RE-kortet. Når kortet er tændt, tændes 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 og til sidst andre sensordata, i realtid, ved hjælp af MEMS-Studio.

2.4

MEMS Studio applikation

Sampapplikationen bruger MEMS-Studio-applikationen, som kan downloades fra www.st.com.

Trin 1. Sørg for, at de nødvendige drivere er installeret, og at STM32 Nucleo-kortet med passende udvidelseskort er tilsluttet pc'en.

UM2350 – Rev 4

side 7/16

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

Trin 2.

Start programmet MEMS-Studio for at åbne programmets hovedvindue.
Hvis et STM32 Nucleo-kort med understøttet firmware er tilsluttet pc'en, registreres det automatisk. Tryk på [Connect]-knappen for at oprette forbindelse til evalueringstavlen.

Figur 4. MEMS-Studio – Tilslut

Trin 3. Når den er tilsluttet et STM32 Nucleo-kort med understøttet firmware, åbnes fanen [Library Evaluation].

For at starte og stoppe datastreaming skal du skifte til den relevante [Start] lodrette værktøjslinje.

eller [Stop]-knappen på ydersiden

De data, der kommer fra den tilsluttede sensor, kan være viewed at vælge fanen [Datatabel] på den indvendige lodrette værktøjslinje.

Figur 5. MEMS-Studio – Biblioteksevaluering – Datatabel

UM2350 – Rev 4

side 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

Trin 5.

Klik på [Gem til File] to open the dataloging configuration window. Select the sensor and pedometer data to be saved in the file. Du kan starte eller stoppe med at gemme ved at klikke på den tilsvarende
knap.

Figur 7. MEMS-Studio – Biblioteksevaluering – Gem til File

UM2350 – Rev 4

side 9/16

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

Trin 6.

Datainjektionstilstand kan bruges til at sende de tidligere opsamlede data til biblioteket og modtage
resultat. Vælg fanen [Data Injection] på den lodrette værktøjslinje for at åbne den dedikerede view for denne funktionalitet.

Figur 8. MEMS-Studio – Biblioteksevaluering – Datainjektion

Trin 7.

Klik på knappen [Gennemse] for at vælge file med de tidligere registrerede data i CSV-format. Dataene vil blive indlæst i tabellen i den aktuelle view. Andre knapper bliver aktive. Du kan klikke på:
[Offline-tilstand]-knap til at slå firmware offline-tilstand til/fra (tilstand, der bruger de tidligere registrerede data).
[Start]/[Stop]/[Step]/[Repeat]-knapper til at styre datatilførslen fra MEMS-Studio til biblioteket.

UM2350 – Rev 4

side 10/16

UM2350
Referencer

3

Referencer

Alle følgende ressourcer er gratis tilgængelige på www.st.com. 1. UM1859: Kom godt i gang med X-CUBE-MEMS1 motion MEMS og miljøsensorsoftware
udvidelse til STM32Cube 2. UM1724: STM32 Nucleo-64-kort (MB1136) 3. UM3233: Kom godt i gang med MEMS-Studio

UM2350 – Rev 4

side 11/16

UM2350

Revisionshistorie

Tabel 4. Dokumentrevisionshistorik

Dato

Versionsændringer

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
ydeevne, afsnit 2.3: Sampapplikationen, afsnit 2.4: MEMS Studio applikation

UM2350 – Rev 4

side 12/16

UM2350
Indhold
Indhold
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 Sampen ansøgning. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 MEMS Studio-applikation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Referencer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Revisionshistorik . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12

UM2350 – Rev 4

side 13/16

UM2350
Liste over tabeller

Liste over tabeller

Tabel 1. Tabel 2. Tabel 3. Tabel 4.

Liste over akronymer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Algoritmeforløbstid (µs) Cortex-M4, Cortex-M3 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Algoritmeforløbstid (µs) Cortex-M33 og Cortex-M7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Dokumentrevisionshistorik . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

UM2350 – Rev 4

side 14/16

UM2350
Liste over figurer

Liste over 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

side 15/16

UM2350
VIGTIG MEDDELELSE LÆS OMHYGGELIGT STMicroelectronics NV og dets datterselskaber ("ST") forbeholder sig retten til at foretage ændringer, rettelser, forbedringer, modifikationer og forbedringer til ST-produkter og/eller til dette dokument til enhver tid uden varsel. Købere bør indhente de seneste relevante oplysninger om ST-produkter, før de afgiver ordre. ST-produkter sælges i henhold til STs salgs- og salgsbetingelser på tidspunktet for ordrebekræftelse. Købere er alene ansvarlige for valg, udvælgelse og brug af ST-produkter, og ST påtager sig intet ansvar for ansøgningsassistance eller design af købers produkter. Ingen licens, hverken udtrykkelig eller underforstået, til nogen intellektuel ejendomsret er givet af ST heri. Videresalg af ST-produkter med andre bestemmelser end de oplysninger, der er angivet heri, annullerer enhver garanti givet af ST for et sådant produkt. ST og ST-logoet er varemærker tilhørende ST. For yderligere information om ST-varemærker henvises til www.st.com/trademarks. Alle andre produkt- eller tjenestenavne tilhører deres respektive ejere. Oplysningerne i dette dokument erstatter og erstatter oplysninger, der tidligere er leveret i alle tidligere versioner af dette dokument.
© 2025 STMicroelectronics Alle rettigheder forbeholdes

UM2350 – Rev 4

side 16/16

Dokumenter/ressourcer

ST X-CUBE-MEMS1 Sensor and Motion Algorithm Software Expansion [pdfBrugermanual
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

Referencer

Efterlad en kommentar

Din e-mailadresse vil ikke blive offentliggjort. Påkrævede felter er markeret *