cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting location data from acceleration values acquired from LSM6DSL

N ORhan
Associate III

Hi everyone.,

We are working on a medical device that will work for rehabilitation of patients who has upper extremity diseases. We have to know the exact location of the device in real time and send it to PC via bluetooth. We will not have a chance to do 6 point calibration because device will move only in x-y plane (on a flat table). So far, first i calibrate the accelerometer as taking 4000 samples, getting median of these samples and subtracting these medians for all measured data samples. I can get around +-1 g for all axes when i do orientation of STEVAL-MKI178V2 accordingly. First of my questions is that, would you suggest any other calibration method for this application which requires precision as much as can be done?

(At that point, I want to mention here non-calibrated, steady accelerometer data values are (-0,441 g), (-0,380 g), (0,582 g) for x,y and z axis respectively. Does these steady state offset values make sense? I could not understand why this values are much far from the expected values such that 0, 0 and 1 g for x,y and z axis respectively.)

My second problem is that when i push STEVAL-MKI178V2 for example 4 cm, i can get position results around 4 cm well but when i pull the device back to the starting point i get lower than 4 cm. If my computations and numerical integrals were wrong, i wouldn't get right result for pushing, right? Why can i not get the right displacement result for pulling device back to the stating point?

I'm working on to improve my algorithms but looking forward to get help and suggestions from experts around here as well.

Thank you.

10 REPLIES 10

While i'm reading the cambridge paper you shared, i can try to answer to other questions you asked. Firstly, i find median of 3 axes when the device is stationary(on a flat table). After that when i checked the median values, i got the absurd things that i wrote before. After subtracting these median values from the data i got 0 g for all axes as you said, but if i rotate LSM6DSL's x-axis towards the axis of gravity i see nearly +-1 g (actually around 9.9-10 m/s2) and this is right for the y-axis, too. But bot for the z-axis, because i got rid of the value of gravity (in this case which is not 1 g !!) when subtract the median, it sees 0 g and -2 g.

Secondly, i'm using SPI at 2.625 MHz. My ODR = 833 Hz at high performance. I do not use FIFO, for every ready data INT1 pulls the line HIGH and i see this as an external interrupt on my MCU (STM32F401RE). I use BDU. LPF1 bandwidth is at ODR/4 and i don't use additional high or low pass filter in the device. I'm averaging 5 data and assuming this average as one data at t = 1/833 * 5 time steps. By the way, before i create my data array for finding median i ignore the first 15 samples. I tried to use HPF but i could only get very very small displacement results (meaning as if device is not moving only vibrating at a constant place for example) due to dc elimination i think. I have not found the problem why i can not get +1 g value for axises at stationary position for 3 different LSM6DSL module yet. I can easily read WHOIAM value correctly to control the reading faults. I am reading MSB first, LSB second and concatenate as follows:

received_data_MSB = SPI2_ReadData(LSM6DSL_REG_OUTX_H_XL);

received_data_LSB = SPI2_ReadData(LSM6DSL_REG_OUTX_L_XL);

X_hex = ((received_data_MSB<<8) | (received_data_LSB & 0x00FF));

received_data_MSB = SPI2_ReadData(LSM6DSL_REG_OUTY_H_XL);

received_data_LSB = SPI2_ReadData(LSM6DSL_REG_OUTY_L_XL);

Y_hex = ((received_data_MSB<<8) | (received_data_LSB & 0x00FF));

received_data_MSB = SPI2_ReadData(LSM6DSL_REG_OUTZ_H_XL);

received_data_LSB = SPI2_ReadData(LSM6DSL_REG_OUTZ_L_XL);

Z_hex = ((received_data_MSB<<8) | (received_data_LSB & 0x00FF));

received_data_MSB and received_data_LSB are 16 bits unsigned integer to have availability to shift 8-bits to the left.

After X_hex, Y_hex and Z_hex calculated, i check the most significant bit of the value and calculate the final results accordingly.

 Also LSM6DSL comprises a gyro too.

Since i'm new to the MEMS modules and navigation systems, please forgive me due to my nonsense questions and configurations if i have any.