1. Algorithm description
NeuraVibe library is a general-purpose vibration monitoring solution that aims to extrapolate periodical information about frequencies of vibration through the combination of a Fast Fourier Transform (FFT) and a peak detection analysis on the frequency spectrum. The logic exploits acceleration data, measured in [mg] units.The library can also be used to analyse the frequency contribution of signals other than the acceleration measurement, such as an acoustic signal measured by a microphone or a magnetic signal measured by a magnetometer.
The library uses optimized ARM CMSIS DSP library functions, allowing to compute an optimized FFT on a data array of the following available FFT_size lengths: [32, 64, 128, 256, 512, 1024, 2048, 4096]. A library for each specific FFT_size length is provided, and is therefore mandatory to use the right FFT_size length for each specific library. If FFT_size length is to be changed runtime, an “all FFT sizes” library is also provided and can be used. This distinction han been done because of flash memory occupation, as reported in Requirements. For proper use of the library, MCU target family and series informations have to be provided. Configuration of library parameters must be completed before running the filter. With VIB_ResetParameters default parameters are configured, while with VIB_SetParameters desired customized parameters can be set. VIB integration requires only 3 lines of code, which implement the following functionalities:
- VIB_Init. It must be invoked before running the logic and after each VIB_Update call. It allows to set and initialize all the algorithm internal variables. Sampling frequency Fs has to be provided in this step,It must be used with compiled library of a certain FFT size;
- VIB_Init_Set_FFT_Size. Similar behaviour of VIB_Init function. It must be used with “all FFT sizes” compiled library.
- VIB_Update. It runs the vibrational analysis evaluation on the data array of FFT_SIZE length;
- VIB_Get_Vib_Output. It returns the vibrational results as VIB_TypeDef struct.
- VIB_Get_Vib_Array. It returns the vibrational results with 16 bits of resolution.
2. Flowchart
The following block diagram describes the flow of operations that implement the NeuraVibe logic.
FIGURE 2.1 ALGORITHM FLOWCHART
3. References
The following lines contain general information about the library, such as version and date of publication, together with the contact details of the 221e internal staff responsible for maintaining and managing the library.
-
Authors and Referents
Giorgio Barzon -
Library Version
v1.0.0 -
Date
July 2022 -
Copyright
Copyright (c) 2020 All Rights Reserved by 221e srl. [email protected]
4. Requirements
The following lines contain information about the library size occupation and time execution. Tests and measurements have been perfomed with a NUCLEO-L476RG board, clocked @64MHz, and including within Atollic TrueSTUDIO project the NeuraVibe static library compiled for NUCLEO-L476RG as well as library header files. No optimization (i.e., -O0) has been applied during library compilation. Results are reported in the following tables.
FFT_SIZE | FLASH Occupation [kB] | RAM Occupation [kB] |
---|---|---|
32 | 10.25 | 0.33 |
64 | 10.57 | 0.33 |
128 | 11.12 | 0.33 |
256 | 12.42 | 0.33 |
512 | 15.04 | 0.33 |
1024 | 19.22 | 0.33 |
2048 | 29.88 | 0.33 |
4096 | 49.8 | 0.33 |
All sizes | 87.88 | 0.33 |
TABLE 4.1 NEURADRIVE MEMORY OCCUPATION
FFT_SIZE | Timing [clock hits] | Timing @64MHz [ms] | |
---|---|---|---|
VIB_Update | 32 | Average: 7575, Maximum: 9568 | Average: 0.118, Maximum: 0.150 |
64 | Average: 14206, Maximum: 16563 | Average: 0.222, Maximum: 0.259 | |
128 | Average: 25941, Maximum: 28952 | Average: 0.405, Maximum: 0.452 | |
256 | Average: 50355, Maximum: 53965 | Average: 0.787, Maximum: 0.843 | |
512 | Average: 101055, Maximum: 102605 | Average: 1.579, Maximum: 1.603 | |
1024 | Average: 183753, Maximum: 185661 | Average: 2.871, Maximum: 2.901 | |
2048 | Average: 386112, Maximum: 388417 | Average: 6.033, Maximum: 6.069 | |
4096 | Average: 794858, Maximum: 797118 | Average: 12.420, Maximum: 12.455 | |
VIB_Init | / | Average: 1786, Maximum: 1850 | Average: 0.028, Maximum: 0.029 |
TABLE 4.2 NEURADRIVE EXECUTION TIMINGS
5. Example Documentation
10.1 VIB_Example.c
This is an example of library usage for vibrational analysis with accelerometer data. Necessary parameters are defined outide main loop. This is an example of library usage for NeuraVibe logic with accelerometer data. The data were acquired with the 221e Muse device, installed on a loudspeaker. The test was performed reproducing some sounds of known frequencies (i.e., 382 and 469 Hz), generating same frequency vibrations in acceleration signals. Results of the logic were saved to file and depicted in the following ExampleFigure. The following lines show how the library was executed on the collected data.
FIGURE 10.1 OUTPUT EXAMPLE
10.2 VIB_Example.c
#include <stdio.h> // Include C standard libraries #include <string.h> #include "VIB_Parameters.h" // Include VIB_Tracker.h #include "VIB_Tracker.h" // Include VIB_Parameters.h #include "arm_math.h" // Include CMSIS DSP Library #define ARM_MATH_CM4 // To be added in order to use math libraries on Cortex-M4 float inAxl = 0; // Initialize input data int inputfrequency = 400; // Data sampling frequency int FFT_Size = 1024; // Data array size volatile float data_array[FFT_Size]; // Data array uint16_t count_array_fill = 0; // Data array counter VIB_TypeDef output_struct; // Initialize output struct as VIB_TypeDef type int main(void) { FILE *fin = fopen("input_file.txt", "r"); // Open input file FILE *fout = fopen("output_file.txt", "w"); // Open output file VIB_ResetParameters(); // Initialize default parameters VIB_Init(Fs,FFT_Size); // VIB_Init call // While Loop while (feof(fin) == 0) { fscanf(fin, "%f", &inAxl); // Read current data if (count_array_fill < FFT_Size) { data_array[count_array_fill] = inAxl; // Fill data array } // Data array is filled and ready to be processed if (countFFT_Repet == (FFT_Size - 1)) { VIB_Update(data_array); // VIB_Update call output_struct = VIB_Get_Vib_Output(); // VIB_Get_Vib_Output call fprintf(fout, "%fnt%fnt%fnt%fnt%fnt%fnt%fnn", output_struct.Frequencies_peaks[0], // Print frequency value of 1st most intense peak output_struct.Frequencies_peaks[1], // Print frequency value of 2nd most intense peak output_struct.Frequencies_peaks[2], // Print frequency value of 3rd most intense peak output_struct.Amplitudes_peaks[0], // Print amplitude value of 1st most intense peak output_struct.Amplitudes_peaks[1], // Print amplitude value of 2nd most intense peak output_struct.Amplitudes_peaks[2], // Print amplitude value of 3rd most intense peak output_struct.Max_axl_value); // Print maximum value of data_array VIB_Init(Fs,FFT_Size); // VIB_Init call, mandatory for next evaluation count_array_fill = 0; // Erase counter } else { count_array_fill++; // Increase counter } } // Close I/O files fclose(fIn); fclose(fOut); return 0; } ;