Leathnú Bogearraí Braiteora agus Algartam Gluaiseachta X-CUBE-MEMS1
“
Eolas Táirge
Sonraíochtaí
- Product Name: MotionPW Real-time Pedometer
- Comhoiriúnacht: Leathnú X-CUBE-MEMS1 do STM32Cube
- Monaróir: STMicroelectronics
- Library: MotionPW Middleware Library
- Data Acquisition: Accelerometer
- SampTeanga Minicíocht: 50 Hz
Treoracha Úsáide Táirge
Tharview
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.
Comhoiriúnacht
The library is designed for ST MEMS sensors only. Using other
MEMS sensors may result in different functionality and
feidhmíochta.
Cur i bhfeidhm
A sample implementation is available for X-NUCLEO-IKS4A1 and
X-NUCLEO-IKS01A3 expansion boards mounted on specified development
boird.
Eolas Teicniúil
For detailed functions and parameters of the MotionPW APIs,
refer to the MotionPW_Package.chm compiled HTML file lonnaithe sa
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)
Ceisteanna Coitianta (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.
C: Cad é na sonraí méadair luasghéaraithe a theastaíonn samplanga
minicíocht?
A: An riachtanas 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
Lámhleabhar úsáideora
Getting started with MotionPW real-time pedometer for wrist library in X-CUBEMEMS1 expansion for STM32Cube
Réamhrá
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 sampan cur i bhfeidhm ag rith ar bhord leathnaithe X-NUCLEO-IKS4A1 nó X-NUCLEO-IKS01A3 ar bhord forbartha NUCLEO-F401RE, NUCLEO-U575ZI-Q nó NUCLEO-L152RE.
UM2350 – Athbhreithniú 4 – Bealtaine 2025 Le haghaidh tuilleadh eolais, déan teagmháil le d’oifig díolacháin STMicroelectronics áitiúil.
www.st.com
UM2350
Acrainmneacha agus giorrúcháin
1
Acrainmneacha agus giorrúcháin
Acrainm API BSP GUI HAL IDE
Tábla 1. Liosta acrainmneacha
Comhéadan ríomhchlárúcháin feidhmchlár Pacáiste tacaíochta boird Comhéadan úsáideora grafach Ciseal teibí crua-earraí Timpeallacht forbartha comhtháite
Cur síos
UM2350 - Rev 4
lch 2/16
2
2.1 2.2
2.2.1
2.2.2
Nóta:
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.
Tá an leabharlann deartha do ST MEMS amháin. Ní dhéantar anailís ar fheidhmiúlacht agus ar fheidhmíocht nuair a bhíonn braiteoirí MEMS eile á n-úsáid agus is féidir leo a bheith difriúil go suntasach ón méid a thuairiscítear sa doiciméad.
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 lonnaithe san fhillteán Doiciméadúcháin.
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
·
aitheantas bunaithe ar shonraí méadair luasghéaraithe amháin
·
sonraí luasmhéadair riachtanach sampminicíocht langa de 50 Hz
·
riachtanais acmhainní:
Cortex-M3: 3.7 kB de chód agus 1.8 kB de chuimhne sonraí
Cortex-M33: 3.5 kB de chód agus 1.8 kB de chuimhne sonraí
Cortex-M4: 3.5 kB de chód agus 1.8 kB de chuimhne sonraí
Cortex-M7: 3.6 kB de chód agus 1.8 kB de chuimhne sonraí
·
ar fáil do ARM® Cortex®-M3, ARM® Cortex®-M33, ARM® Cortex®-M4 agus ARM® Cortex®-M7
ailtireachtaí
MotionPW APIs
The MotionPW library APIs are:
·
uint8_t MotionPW_GetLibVersion(char *version)
aisghabhann leagan na leabharlainne
*is pointeoir chuig eagar de 35 carachtar é leagan
tugann sé líon na gcarachtar sa teaghrán leagan ar ais
·
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
lch 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
Is pointeoir chuig struchtúr le sonraí ionchuir é an paraiméadar *data_in
the parameters for the structure type MPW_input_t are:
Is é AccX an luach braiteoir méadair luasghéaraithe in X ais i g
Is é AccY an luach braiteoir luasmhéadair in Y ais i g
Is é AccZ an luach braiteoir méadair luasghéaraithe in ais Z 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
lch 4/16
2.2.3
Sreabhchairt API
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Figure 1. MotionPW API logic sequence
Tosaigh
Tosaigh
GetLibVersion
Fanacht ag dul in éag Léamh Sonraí Amaire Idirbhriseadh
Léigh Nuashonrú Sonraí Luasmhéadair
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
lch 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
Tábla 2. Algartam caite (µs) Cortex-M4, Cortex-M3
Cortex-M4 STM32F401RE ag 84 MHz
Min
Meán
uas
38
49
616
Cortex-M3 STM32L152RE ag 32 MHz
Min
Meán
uas
296
390
3314
UM2350 - Rev 4
lch 6/16
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Tábla 3. Algartam caite (µs) Cortex-M33 agus Cortex-M7
Cortex- M33 STM32U575ZI-Q ag 160 MHz
Min
Meán
uas
57
63
359
Cortex- M7 STM32F767ZI ag 96 MHz
Min
Meán
uas
61
88
1301
2.3
Sample hiarratas
The MotionPW middleware can be easily manipulated to build user applications.
A sampTá an feidhmchlár ar fáil san fhillteán Feidhmchláir. Tá sé deartha le rith ar bhord forbartha NUCLEO-F401RE, NUCLEOU575ZI-Q nó NUCLEO-L152RE atá ceangailte le bord leathnaithe X-NUCLEO-IKS4A1 nó X-NUCLEO-IKS01A3.
The application recognizes the steps, cadence and confidence in real-time. The data can be displayed through a GUI.
Fíor 3. Núicléas STM32: soilse, cnaipe, geansaí
Taispeánann an figiúr thuas an cnaipe úsáideora B1 agus na trí stiúir den bhord NUCLEO-F401RE. Nuair a bhíonn an bord á thiomáint, casann LED LD3 (PWR) ON.
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 agus sa deireadh sonraí braiteoirí eile, i bhfíor-am, ag baint úsáide as MEMS-Studio.
2.4
Feidhmchlár MEMS Studio
An sample application uses MEMS-Studio application, which can be downloaded from www.st.com.
Céim 1. Cinntigh go bhfuil na tiománaithe riachtanacha suiteáilte agus go bhfuil an bord STM32 Nucleo le bord leathnaithe cuí ceangailte leis an ríomhaire.
UM2350 - Rev 4
lch 7/16
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Céim 2 .
Seoladh an feidhmchlár MEMS-Studio chun príomhfhuinneog an fheidhmchláir a oscailt.
Má tá bord STM32 Nucleo le firmware tacaithe ceangailte leis an ríomhaire, braitear go huathoibríoch é. Brúigh an cnaipe [Ceangail] chun nasc a bhunú leis an mbord meastóireachta.
Fíor 4. MEMS-Studio – Connect
Céim 3. Nuair atá sé ceangailte le bord STM32 Nucleo le firmware tacaithe, osclaítear an cluaisín [Meastóireacht Leabharlainne].
Chun sruthú sonraí a thosú agus a stopadh, roghnaigh an barra uirlisí ingearach [Tosaigh] cuí.
nó an cnaipe [Stop] ar an taobh amuigh
Is féidir na sonraí a thagann ón braiteoir nasctha viewed ag roghnú an táb [Tábla Sonraí] ar an mbarra uirlisí ceartingearach istigh.
Fíor 5. MEMS-Studio – Measúnú Leabharlainne – Tábla Sonraí
UM2350 - Rev 4
lch 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
Céim 5 .
Cliceáil ar an [Sábháil Chun File] to open the dataloging configuration window. Select the sensor and pedometer data to be saved in the fileIs féidir leat tosú nó stop a chur le sábháil trí chliceáil ar an gcnaipe comhfhreagrach.
cnaipe.
Fíor 7. MEMS-Studio – Measúnú Leabharlainne – Sábháil Go File
UM2350 - Rev 4
lch 9/16
UM2350
MotionPW middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
Céim 6 .
Is féidir mód Instealladh Sonraí a úsáid chun na sonraí a fuarthas roimhe seo a sheoladh chuig an leabharlann agus iad a fháil
toradh. Roghnaigh an cluaisín [Instealladh Sonraí] ar an mbarra uirlisí ingearach chun an ceann tiomnaithe a oscailt view don fheidhmiúlacht seo.
Fíor 8. MEMS-Studio – Measúnú Leabharlainne – Instealladh Sonraí
Céim 7 .
Cliceáil ar an gcnaipe [Brabhsáil] chun an file leis na sonraí a gabhadh roimhe seo i bhformáid CSV. Déanfar na sonraí a luchtú isteach sa tábla sa sruth viewBeidh cnaipí eile gníomhach. Is féidir leat cliceáil ar:
Cnaipe [Mód As Líne] chun mód as líne an fhirmware a chasadh air/as (mód ag baint úsáide as na sonraí a gabhadh roimhe seo).
Cnaipí [Tosaigh]/[Stop]/[Céim]/[Athdhéan] chun an fotha sonraí ó MEMS-Studio chuig an leabharlann a rialú.
UM2350 - Rev 4
lch 10/16
UM2350
Tagairtí
3
Tagairtí
Tá na hacmhainní seo a leanas ar fad ar fáil saor in aisce ar www.st.com. 1. UM1859: Ag tosú leis an X-CUBE-MEMS1 gluaisne MEMS agus bogearraí braiteora comhshaoil
leathnú le haghaidh STM32Cube 2. UM1724: Boird STM32 Nucleo-64 (MB1136) 3. UM3233: Ag tosú le MEMS-Studio
UM2350 - Rev 4
lch 11/16
UM2350
Stair athbhreithnithe
Tábla 4. Stair athbhreithniú doiciméad
Dáta
Athruithe Leagan
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
feidhmíocht, Roinn 2.3: Sampfeidhmchlár le, Roinn 2.4: feidhmchlár MEMS Studio
UM2350 - Rev 4
lch 12/16
UM2350
Clár ábhair
Clár ábhair
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 Sampan feidhmchlár . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 Feidhmchlár MEMS Studio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 Tagairtí . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11 Stair athbhreithnithe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
UM2350 - Rev 4
lch 13/16
UM2350
Liosta táblaí
Liosta táblaí
Tábla 1. Tábla 2. Tábla 3. Tábla 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
lch 14/16
UM2350
Liosta figiúirí
Liosta figiúirí
Fíor 1. Fíor 2. Fíor 3. Fíor 4. Fíor 5. Fíor 6. Fíor 7. Fíor 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
lch 15/16
UM2350
FÓGRA TÁBHACHTACH LÉIGH GO CÚRAMACH Coimeádann STMicroelectronics NV agus a fhochuideachtaí (“ST”) an ceart chun athruithe, ceartúcháin, feabhsuithe, modhnuithe agus feabhsuithe a dhéanamh ar tháirgí ST agus/nó ar an doiciméad seo tráth ar bith gan fógra. Ba cheart do cheannaitheoirí an fhaisnéis ábhartha is déanaí maidir le táirgí ST a fháil sula ndéanann siad orduithe. Díoltar táirgí ST de bhun théarmaí agus choinníollacha díolacháin ST atá i bhfeidhm tráth admháil an ordaithe. Is iad na ceannaitheoirí amháin atá freagrach as roghnú, roghnú agus úsáid táirgí ST agus ní ghlacann ST aon dliteanas as cúnamh iarratais ná as dearadh táirgí ceannaitheoirí. Ní dheonaíonn ST anseo ceadúnas, sainráite nó intuigthe, d'aon cheart maoine intleachtúla. Cuirfidh athdhíol táirgí ST a bhfuil forálacha éagsúla acu leis an bhfaisnéis atá leagtha amach anseo ar neamhní aon bharántas arna dheonú ag ST don táirge sin. Is trádmharcanna de chuid ST iad ST agus an lógó ST. Le haghaidh tuilleadh faisnéise faoi thrádmharcanna ST, féach www.st.com/trademarks. Is leis na húinéirí faoi seach gach ainm táirge nó seirbhíse eile. Tagann an fhaisnéis sa doiciméad seo in ionad na faisnéise a soláthraíodh roimhe seo in aon leaganacha roimhe seo den doiciméad seo.
© 2025 STMicroelectronics Gach ceart ar cosaint
UM2350 - Rev 4
lch 16/16
Doiciméid / Acmhainní
![]() |
ST X-CUBE-MEMS1 Sensor and Motion Algorithm Software Expansion [pdfLámhleabhar Úsáideora 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 |