cancel
Showing results for 
Search instead for 
Did you mean: 

SensorTile.box PRO : Record human activity and pedometer

pierre63
Associate II

Hello, 

@Andrea VITALI,

After using the WESU board (https://community.st.com/t5/mems-sensors/lsm6ds3-lis3mdl-calibration/td-p/762534)

we decided to move forward with the sensor tile box PRO. 

We want to record human activity recognition and pedometer information in the SD card, with a timestamp. 

We managed to record HAR and pedometer information separetly, on BLE or in a SD card file, but :

* If we add the RTC value (for timestamp) to the HAR example, we got the message FLOW_COMPATIBILITY_ERROR

* If we enable pedometer, adding gyroscope and accelerometer (60Hz, same as HAR example) in input, add HAR in function, there is no data in the SD card (only header in the csv file), and no updates in Bluetooth (event when SD_Log is updated in log status)

Is it possible to get timestamped HAR + pedometer data in a SD card file ?

Bonus : if We can also log raw data (ACC, GYR, MAG + BARO) at 240, 100 and 1Hz, that's will great.

 

For now, we can't use this eval board for our need.

PS : 

FW version : 1.2.0

brd name : STEVAL-MKBOXPRO

Please find attached : 

* the json for HAR + RTC Screenshot for the configuration.

 

Regards,

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @pierre63 , 

Glad to hear that it worked for you. MotionPW is designed for wrist worn applications. As mentioned by @Andrea VITALI it reduces the false positives if used with MotionAW. MotionPM is designed for belt-worn or generic applications. MotionPW should be the right choice for you. 

I have set the ODR for the sensor hub as 52Hz. The project should work for ODR >= 50Hz. Tried 160Hz that I think you had set for your project and it works. 

 

View solution in original post

11 REPLIES 11
Andrea VITALI
ST Employee

You have reached the limit of the no-code ecosystem.

Time to move to the low-code ecosystem: download MEMS Studio and look into AlgoBuilder. You can select the target platform (Sensortile.Box PRO) and how it is connected (BLE or USB). Then drag-and-drop the blocks you need: first the sensorHub block which represents the main loop, then pick the pedometer library that you want (PM generic, PW specialized for wrist worn devices), then pick the sensors you want to log (mind that sensor data is raw, if you need calibrated and compensated data you need to use MotionMC for example to get hard-iron compensated data), connect in the appropriate way, mux the sensor signals and feed them to the SD card block. You can also add plots for real time display. Each block has a description and few configuration parameters, click on the block and look at the panes on the right.

See attached screenshots.

AlgoBuilder will generate an STM32 project for you. The code is well structured and human-friendly, start from ab_sensor_hub.c to see how it is organized. There you will find how the various functions are called when appropriate.

From AlgoBuilder you will be able to compile and build the binary (STM32CubeIDE needs to be installed), and program/flash the target device (STM32CubeProg needs to be installed).

You should be able to build a customized FW that does what you need very quickly.

pierre63
Associate II

Hello Andrea,

thanks a lot for this fast answer.

Ok understood. I will check this. I leave the topic open for now and I will update it if it is resolved or I need more help.

Regards,

pierre63
Associate II

Hello Andrea,

We managed to get data with the MEMS configurator. But we have main issues.

We configurated the sensor HUB ODR to 240Hz, but we managed to get data at approx 166Hz

Timestamp variation are pretty important : 

* The most common timestamp delta is approx 6ms (approx 166Hz ODR)

* There is a lot of variation on our dataset

* Pedometer value and activity value shows no changes.

 

Please check the json configuration, the result file and the timestamp delta graph.

We walked approx 30s, device in the hand.

 

What is your tought about that ?

Thanks for your help,

Regards, 

 

I have created a small Matlab script (.m.txt attached) to load and plot the frequency extracted from the timestamps in your csv (frequency plot attached) - looking at the histogram, it seems the system is trying to keep up with the high datarate but cannot do it. Here is the plot of the frequency from your csv:

frequency_plot.png

Then I have tested your json design (very well done by the way) with my SensorTile.Box PRO. I took the log with MEMS Studio (ST_Data_Log...) while also the log was being saved onto the SD card (ST_test_....). I used the same small Matlab script to load and plot the frequency extracted from timestamp.

Now look at the plot of the csv from MEMS Studio: when the system is NOT writing to the SD card, the timestamps indicates the target 240Hz is achieved. When the system starts writing, the issue happens and the average drops down. Values in the log on the SD card do match the second part of the log taken from MEMS Studio.

ST_Data_Log_plot.pngST_test_design_plot.png

In the end it seems that the AlgoBuilder FW cannot handle the slow write process to the SD Card. The safest way to go around this would be to use FreeRTOS and have an independent task with dedicated buffers to handle the writing to SD card. While the main task/loop handles the data readout process (this is how the DATALOG2 firmware is designed to handle high data rate log).

So, it seems that you would need to take another step up and code your own application. No-code and low-code solutions are not enough for your case. Use the AlgoBuilder generated code as a reference.

Could not attach the matlab script. Copying here for reference:

% ST logs
data = importdata('ST_Data_Log_25_02_24_09_23_20.csv');
%data = importdata('ST_test design.json_001.csv');

timestamp_us = data.data(:,1);
timestamp_s = timestamp_us / 1e6;
deltats_s = diff(timestamp_s);
freq_Hz = 1./ deltats_s;

figure;
subplot(121);
plot(freq_Hz); grid on;
xlabel('sample'); ylabel('Hz');
title('frequency from delta timestamp');

avg_freq_Hz = mean(freq_Hz);
line([0 length(freq_Hz)], avg_freq_Hz*[1 1], 'Color', [0 0 0]);
text(length(freq_Hz), avg_freq_Hz, sprintf('avg %.3f Hz', avg_freq_Hz));

subplot(122);
histogram(freq_Hz); grid on;
xlabel('Hz'); ylabel('count');

pierre63
Associate II

Hello Andrea, 

we focused on HAR and pedometer only in order to limite data rate in SD card. 

Unfortunetly,we didn't managed to have pedometer information update ou HAR update in this scenario : 

* Pedometer (PW)+ timestamp only

* HAR + timestamp only

* Pedometer (PW) + Pedometer (PM) + HAR + timestamp only

Timestamp is pretty nice now.

During test, I walked at least 1 minutes in the building, sensor tile tied to a wrist with velcro, naturally.

I also reduced the sensor hub datarate de 160Hz, which is above minimum datarate for algorithm.

This is our last chance before we move to another manufacturer or to come back with hardware modification on the WESU.

Is there any setting that I need to do in mems studio ?

Also, we can't start software POC without any functional demo, our customer will not continue the project without any recorded scenario (use case : last meter delivery).

Please check data for the pedometer PW record + settings.

We can also arrange a call.

Again, thanks a lot for your help.

WESU is not recommended for new designs - sensors utilized there such as LIS3MDL are also not recommended for new designs because they are approaching end of life, other sensors in there are also pretty old and will reach end of life soon - firmware packages are no more supported and developed - meaning that you would need to plan to develop your own firmware, and if you do succeed then you will face difficulty in procuring the parts that are no more manufactured - it becomes clear that any development effort is better spent with up to date platform and sensors.

In the CSV I can see the column with the step count but it is always zero. So, the pedometer was logged but no valid step was detected and recorded. MotionPW (pedometer on wrist) has better accuracy when coupled with MotionAW (activity on wrist). Check the respective user manuals for more info and look into AlgoBuilder generated source code to see how they are coupled. Steps are counted only when a regular pace is detected. If you take 1 step and stop, this step is discarded. Try to take more than 10 steps at a regular pace and check that the output counter does record the steps.

 

Hello @pierre63 ,

I have a working project for the MotionPW which is built using the AlgoBuilder available on the MEMS Studio. In the project, I have enabled the MotionPW block and the data is being recorded on the SD card. I have recorded the data for ~27 steps, you can find the attached .json and the .csv below. 

pierre63
Associate II

Hello @Vaidehi_Deshpande ,

thanks for the project, it work like a charm.

We managed to adjust it and we finally got the file that we want.

Two questions before closing the topic (and start our custom firmware) : 

* For a armband wear, should we use PW ou PM ?

* Is the 56Hz a magic value for sensor hub ?

Regards,