X-CUBE-MEMS1 Sensor ndi Motion Algorithm Software Expansion
“
Zambiri Zamalonda
Zofotokozera
- Product Name: MotionPW Real-time Pedometer
- Kugwirizana: X-CUBE-MEMS1 kukulitsa kwa STM32Cube
- Wopanga: STMicroelectronics
- Library: MotionPW Middleware Library
- Data Acquisition: Accelerometer
- SampNthawi zambiri: 50 Hz
Malangizo Ogwiritsira Ntchito Zogulitsa
Zathaview
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.
Kugwirizana
The library is designed for ST MEMS sensors only. Using other
MEMS sensors may result in different functionality and
ntchito.
Kukhazikitsa
A sample kukhazikitsa kulipo kwa X-NUCLEO-IKS4A1 ndi
X-NUCLEO-IKS01A3 expansion boards mounted on specified development
matabwa.
Zambiri Zaukadaulo
For detailed functions and parameters of the MotionPW APIs,
refer to the MotionPW_Package.chm compiled HTML file ili mu
Documentation folder.
APIs
- 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)
Mafunso Ofunsidwa Kawirikawiri (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: Kodi accelerometer yofunikira data s ndi chiyaniampling
pafupipafupi?
A: Zofunikira 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
Buku la ogwiritsa ntchito
Getting started with MotionPW real-time pedometer for wrist library in X-CUBEMEMS1 expansion for STM32Cube
Mawu Oyamba
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 sampndi kukhazikitsa pa X-NUCLEO-IKS4A1 kapena X-NUCLEO-IKS01A3 bolodi yowonjezera pa NUCLEO-F401RE, NUCLEO-U575ZI-Q kapena NUCLEO-L152RE board board.
UM2350 - Rev 4 - May 2025 Kuti mumve zambiri, funsani ofesi yogulitsa ya STMicroelectronics kwanuko.
www.st.com
UM2350
Acronyms ndi achidule
1
Acronyms ndi achidule
Acronym API BSP GUI HAL IDE
Table 1. Mndandanda wa acronyms
Mawonekedwe a pulogalamu yopangira bolodi Phukusi lothandizira Mawonekedwe a ogwiritsa ntchito Hardware abstraction wosanjikiza Integrated chitukuko chilengedwe
Kufotokozera
Chithunzi cha UM2350
tsamba 2/16
2
2.1 2.2
2.2.1
2.2.2
Zindikirani:
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.
Laibulaleyi idapangidwira ST MEMS yokha. Kugwira ntchito ndi magwiridwe antchito mukamagwiritsa ntchito masensa ena a MEMS sikuwunikidwa ndipo kumatha kukhala kosiyana kwambiri ndi zomwe zafotokozedwa m'chikalatacho.
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 ili mufoda ya Documentation.
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
·
kuzindikira kutengera accelerometer data yokha
·
zofunika accelerometer deta samppafupipafupi pafupipafupi 50 Hz
·
zofunikira zothandizira:
Cortex-M3: 3.7 kB ya code ndi 1.8 kB ya kukumbukira deta
Cortex-M33: 3.5 kB ya code ndi 1.8 kB ya kukumbukira deta
Cortex-M4: 3.5 kB ya code ndi 1.8 kB ya kukumbukira deta
Cortex-M7: 3.6 kB ya code ndi 1.8 kB ya kukumbukira deta
·
zilipo za ARM® Cortex®-M3, ARM® Cortex®-M33, ARM® Cortex®-M4 ndi ARM® Cortex®-M7
zomangamanga
MotionPW APIs
The MotionPW library APIs are:
·
uint8_t MotionPW_GetLibVersion(char *version)
amapezanso laibulale Baibulo
* Mtunduwu ndi cholozera ku mndandanda wa zilembo 35
imabweretsanso chiwerengero cha zilembo mumtundu wamtundu
·
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.
Chithunzi cha UM2350
tsamba 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 ndi cholozera kumapangidwe omwe ali ndi data yolowera
the parameters for the structure type MPW_input_t are:
AccX ndiye sensor ya accelerometer mu X axis mu g
AccY ndiye sensor ya accelerometer mu Y axis mu g
AccZ ndiye mtengo wa sensor ya accelerometer mu Z axis mu 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
Chithunzi cha UM2350
tsamba 4/16
2.2.3
API flow chart
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Figure 1. MotionPW API logic sequence
Yambani
Yambitsani
GetLibVersion
Yembekezerani Nthawi Yomwe Imawerengedwera Kusokoneza Data
Werengani 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;
Chithunzi cha UM2350
tsamba 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
Table 2. Algorithm elapse time (µs) Cortex-M4, Cortex-M3
Cortex-M4 STM32F401RE pa 84 MHz
Min
Avg
Max
38
49
616
Cortex-M3 STM32L152RE pa 32 MHz
Min
Avg
Max
296
390
3314
Chithunzi cha UM2350
tsamba 6/16
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Table 3. Algorithm elapse time (µs) Cortex-M33 ndi Cortex-M7
Cortex- M33 STM32U575ZI-Q pa 160 MHz
Min
Avg
Max
57
63
359
Cortex- M7 STM32F767ZI pa 96 MHz
Min
Avg
Max
61
88
1301
2.3
Sampndi application
The MotionPW middleware can be easily manipulated to build user applications.
A sample application imaperekedwa mufoda ya Application. Zapangidwa kuti ziziyenda pa bolodi lachitukuko la NUCLEO-F401RE, NUCLEOU575ZI-Q kapena NUCLEO-L152RE lolumikizidwa ndi bolodi yowonjezera ya X-NUCLEO-IKS4A1 kapena X-NUCLEO-IKS01A3.
The application recognizes the steps, cadence and confidence in real-time. The data can be displayed through a GUI.
Chithunzi 3. STM32 Nucleo: Ma LED, batani, jumper
Chithunzi pamwambapa chikuwonetsa batani la ogwiritsa B1 ndi ma LED atatu a board ya NUCLEO-F401RE. Bolodi ikayatsidwa, LED LD3 (PWR) imayatsa.
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 ndipo pamapeto pake deta ina ya sensa, mu nthawi yeniyeni, pogwiritsa ntchito MEMS-Studio.
2.4
Pulogalamu ya MEMS Studio
AampPulogalamuyi imagwiritsa ntchito pulogalamu ya MEMS-Studio, yomwe imatha kutsitsidwa kuchokera ku www.st.com.
Khwerero 1. Onetsetsani kuti madalaivala ofunikira aikidwa ndipo bolodi la STM32 Nucleo lomwe lili ndi bolodi lokulitsa loyenera likulumikizidwa ndi PC.
Chithunzi cha UM2350
tsamba 7/16
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Gawo 2.
Yambitsani pulogalamu ya MEMS-Studio kuti mutsegule zenera lalikulu la pulogalamu.
Ngati STM32 Nucleo board yokhala ndi firmware yolumikizidwa ilumikizidwa ndi PC, imangodziwika. Dinani [Lumikizani] batani kuti mukhazikitse kulumikizana ndi gulu lowunika.
Chithunzi 4. MEMS-Studio - Lumikizani
Gawo 3. Mukalumikizidwa ku bolodi la STM32 Nucleo yokhala ndi firmware yothandizidwa [Library Evaluation] tabu imatsegulidwa.
Kuti muyambe ndi kuyimitsa kusanja kwa data, sinthani chida choyenera [Yambani] choyimirira.
kapena [Imani] batani lakunja
Deta yochokera ku sensa yolumikizidwa ikhoza kukhala viewed posankha tabu ya [Data Table] pazida zamkati zowongoka.
Chithunzi 5. MEMS-Studio - Kuunika kwa Library - Table Table
Chithunzi cha UM2350
tsamba 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
Gawo 5.
Dinani pa [Save To File] to open the dataloging configuration window. Select the sensor and pedometer data to be saved in the file. Mutha kuyamba kapena kusiya kusunga podina zofananira
batani.
Chithunzi 7. MEMS-Studio - Kuunika kwa Library - Sungani Ku File
Chithunzi cha UM2350
tsamba 9/16
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Gawo 6.
Data Injection mode angagwiritsidwe ntchito kutumiza deta kale anapeza ku laibulale ndi kulandira
zotsatira. Sankhani tabu [Data Injection] pa vertical tool bar kuti mutsegule odzipereka view za magwiridwe antchito awa.
Chithunzi 8. MEMS-Studio - Kuunika kwa Library - Injection Data
Gawo 7.
Dinani pa [Sakatulani] batani kuti musankhe file ndi data yomwe idajambulidwa kale mumtundu wa CSV. Deta idzakwezedwa patebulo pakali pano view. Mabatani ena ayamba kugwira ntchito. Mutha kudina pa:
[Offline Mode] kuti muyatse/kuyimitsa firmware offline mode (kugwiritsa ntchito deta yomwe inajambulidwa kale).
[Yambani]/[Imani]/[Step]/[Bwerezani] mabatani kuti muwongolere chakudya cha data kuchokera ku MEMS-Studio kupita ku laibulale.
Chithunzi cha UM2350
tsamba 10/16
UM2350
Maumboni
3
Maumboni
Zonse zotsatirazi zikupezeka kwaulere pa www.st.com. 1. UM1859: Kuyamba ndi X-CUBE-MEMS1 motion MEMS ndi pulogalamu ya sensa ya chilengedwe
kukulitsa kwa STM32Cube 2. UM1724: STM32 Nucleo-64 board (MB1136) 3. UM3233: Kuyamba ndi MEMS-Studio
Chithunzi cha UM2350
tsamba 11/16
UM2350
Mbiri yobwereza
Gulu 4. Mbiri yokonzanso zolemba
Tsiku
Kusintha kwa Mabaibulo
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
ntchito, Gawo 2.3: Sample ntchito, Gawo 2.4: MEMS Studio ntchito
Chithunzi cha UM2350
tsamba 12/16
UM2350
Zamkatimu
Zamkatimu
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 Sampndi application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 MEMS Studio ntchito. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Maumboni . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Mbiri yokonzanso . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
Chithunzi cha UM2350
tsamba 13/16
UM2350
Mndandanda wa matebulo
Mndandanda wa matebulo
Table 1. Table 2. Table 3. Table 4.
Mndandanda wa acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Algorithm imatha nthawi (µs) Cortex-M4, Cortex-M3. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Algorithm imatha nthawi (µs) Cortex-M33 ndi Cortex-M7. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Document revision mbiri. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Chithunzi cha UM2350
tsamba 14/16
UM2350
Mndandanda wa ziwerengero
Mndandanda wa ziwerengero
Chithunzi 1. Chithunzi 2. Chithunzi 3. Chithunzi 4. Chithunzi 5. Chithunzi 6. Chithunzi 7. Chithunzi 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
Chithunzi cha UM2350
tsamba 15/16
UM2350
CHIZINDIKIRO CHOFUNIKA KUWERENGA MOCHEMWA STMicroelectronics NV ndi mabungwe ake ("ST") ali ndi ufulu wosintha, kuwongolera, kukulitsa, kukonzanso, ndi kukonza zinthu za ST ndi/kapena ku chikalatachi nthawi iliyonse popanda chidziwitso. Ogula akuyenera kupeza zidziwitso zaposachedwa kwambiri pazogulitsa za ST asanapange maoda. Zogulitsa za ST zimagulitsidwa motsatira mfundo za ST ndi zogulitsa zomwe zilipo panthawi yovomerezeka. Ogula ali ndi udindo wosankha, kusankha, ndi kugwiritsa ntchito zinthu za ST ndipo ST sichikhala ndi udindo pa chithandizo cha pulogalamu kapena kupanga zinthu za ogula. Palibe chilolezo, chofotokozera kapena kutanthauza, ku ufulu uliwonse waukadaulo womwe umaperekedwa ndi ST apa. Kugulitsanso zinthu za ST zomwe zili ndi zosiyana ndi zomwe zafotokozedwa pano sizidzathetsa chitsimikizo chilichonse choperekedwa ndi ST pazogulitsa zotere. ST ndi ST logo ndi zizindikilo za ST. Kuti mumve zambiri za zizindikiro za ST, onani www.st.com/trademarks. Mayina ena onse azinthu kapena ntchito ndi eni ake. Zomwe zili m'chikalatachi zimaloŵa m'malo ndi kulowa m'malo zomwe zidaperekedwa kale m'matembenuzidwe am'mbuyomu a chikalatachi.
© 2025 STMicroelectronics Ufulu wonse ndi wotetezedwa
Chithunzi cha UM2350
tsamba 16/16
Zolemba / Zothandizira
![]() |
ST X-CUBE-MEMS1 Sensor and Motion Algorithm Software Expansion [pdf] Buku Logwiritsa Ntchito 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 |