Skip to main content
Graduate
July 13, 2023
Solved

STWINKT1B STREAMING USB

  • July 13, 2023
  • 1 reply
  • 2705 views

Hi,

I bought the STEVAL-STWINKT1B hoping to be able to store and plot real-time data from my accelerometer, both in the time domain and in the frequency domain (performing FFT) for the purpose of developing my project. I bought it thinking that it would provide a more ready-to-use solution to collect this data and analyze it in real-time. Can it really do that with USB streaming? I would like to connect it via USB, give the command to start, continuously store the data, and see the generated graph in real-time, similar to a serial plotter. And when I want to stop, I would give the command to stop. Can someone please help me?

Thanks!

Best regards,

Thales Vignoli

    This topic has been closed for replies.
    Best answer by SimonePradolini

    Hello @Thales Vignoli 

    As on today, we don't have a ready-to-use example that can fit all your requirements.

    What @niccolò suggested is the best approach we can propose. Resuming:

    • Flash the bard with FP-SNS-DATALOG1 firmware.
    • The package contains also a complete suite in Python you can use to control the board via USB and acquire data in time domain (i.e.: see hsdatalog_cli.py scripts; python hsdatalog_cli.py -h can help you). In this use case, SD card is not used nor necessary.
    • Data are saved directly on PC, so that you can post process them by writing your own Python script (suggestion from previous post are valid).

    Please have a look also on User Manual and Quick Start Guide for FP-SNS-DATALOG1 for the full procedure.

    Just for your knowledge: we are working to add the support for STWIN on FP-SNS-DATALOG2, the evolution of the one described above, where we'll provide also a real time GUI. We can also evaluate to add the possibility to show both data in time domain and FFT. It is a work in progress, we don't already have a precise plan.

    Best regards

    Simone

    1 reply

    ST Employee
    July 13, 2023

    Hi @Thales Vignoli ,

    there is a function pack that sends data via USB, it is the FP-SNS-DATALOG1
    you can download it from the link and you will have a data streaming via USB, you can find all the documentation needed in the zip file (the new version will be available in a few days)

    I'm not sure to understand the part about the real time data analysis, it seems to me that you want to plot Acc data and the related FFT, with basic commands given by a program.
    I think you have 2 options:

    1. modify the Function pack project to include FFT calculation and send both FFT and Acc data via USB, the plotting it with something like Serialplot.
    2. develop a program (I would suggest to use python) to read the data coming from USB, isolate the Accelerometer data, perform the FFT and plot everything

    If this answers your question, please, mark this as "best answer", by clicking on the "accept as solution" to help the other users of the community

    Niccolò

    Graduate
    July 13, 2023

    This package called FP-SNS-DATALOG1, I'm already using it and I flashed the firmware of the STWIN to datalog.bin. My question is, can't the STWIN give me values via USB after performing the FFT? Does it only return the triaxial accelerometer time series?

    Another question: Does the STWIN not have a ready interface to view this data via USB in real-time? Like, for example, the serial plotter in the Arduino IDE (roughly speaking). What I would like to obtain is the output shown via BLE in the ST BLE SENSOR app. However, with this method, the accelerometer is limited to 50 Hz, which doesn't meet my needs.

    If it's necessary to create software to perform FFT and analyze this data via Python, it's not what I expected from the product... Can you please help me with these doubts?

    ST Employee
    July 14, 2023

    Hi @Thales Vignoli ,

    yes, the STWIN can perform the FFT with the STM32U5 on the board, but there is no package that already performs it and do exactly what you want. Luckily there are easy to use functions that you can implement in the project code, here is an example of a function that performs the FFT based on ARM builtin functions:

     

     

    int32_t Function_FFT_Run2(float32_t *data_input, uint32_t size_buffer, float32_t *fft_output, float32_t *max, uint32_t *index)
    {
     int32_t ret = APP_MANAGER_OK;
    
     /* Process the data through the CFFT/CIFFT module */
     arm_cfft_radix4_f32(&fft_instance, data_input);
    // arm_cfft_f32(&fft_instance_new, data_input, ifftFlag, doBitReverse);
     /* Process the data through the Complex Magnitude Module for calculating the magnitude at each bin */
     arm_cmplx_mag_f32(data_input, fft_output, size_buffer);
     fft_output[0]=0; //debug
     /* Calculates maxValue and returns corresponding BIN value */
     arm_max_f32(fft_output, size_buffer, max, index);
    
     return ret;
    }

     

    Regarding the toll for viewing USB data in real time, yes, there is a software, and it is inside the package that you downloaded. there is the python installer and executables that you need if you never used python, then you can launch the program to see the USB data (the documentation is inside the package as well).
    also, having access to the source code of those softwares, you can implement the FFT calculation also in python, that should be easier, if you don't have much experience with STM32 programming.

    If this answers your question, please, mark this as "best answer", by clicking on the "accept as solution" to help the other users of the community.

    Niccolò