2013-11-27 06:26 AM
Hi,
I need to read the accelerometer data from LSM303DLHC. I use the STM32F401 Discovery board and the ''stm32f401_discovery_lsm303dlhc.c'' library.I read carefully the datasheet, especially the section 7.1 in page 24 with the register setup but I would like to know if someone has any project example that could help me to understand how to use the sensor.Thank you in advance.Kind regards,Antho2013-11-27 08:01 AM
Hello Antho,
We are currently creating a section of this forum to contain examples of applications using ST's MEMS. I will add one example for you application too. Once we have the codes, I can also post it here as a reference. Thank you very much, Thiago Reis2013-11-28 12:41 AM
Hi Thiago,
Thank you for your time. I think that this new section is a good idea, it might be very helpful for beginners like me.Antho2013-12-15 09:31 PM
Antho,
Just in case that you are still looking some additional information about the LSM303 usage, I would recommend that you look the selftest.c file in the F401 demonstration folder. There you have the code to read the sensor data (such as LSM303DHLC_CompassReadAcc) using the I2C connection. Once you have the accelerometer and compass data, you should combine that with the gyro data (from L3GD20). The accelerometer has a lot of short term noise, but good long term stability. The gyro has little noise, but it has a bad drift. You can use a Kalman filter to combine the data streams, simple low pass and high pass filters, or add-hoc methods (such as model based bias adjustment).2013-12-19 04:23 PM
Hi Thiago,
Good to know that you are adding a separate section for the applications. The link2014-01-08 08:49 AM
Hi,
Thanks for your time Ollie, your reply has been very helpful.Actually, I am trying to test the accuracy of the Inertial Measurement Unit for a school project. That is why I need to get the output data from both the accelerometer and the gyroscope.But first, I am trying to exploit the output data to turn on the LED matching with the acceleration direction (as in the demo of the gyroscope). I set the linear acceleration range at 8g in the register but I have not been able to determine which kind of data is returned by the function ''LSM303DLHC_Read(ACC_I2C_ADDRESS,LSM303DLHC_OUT_X_L_A,6,tmpbuffer)''.In the data sheet, it is mentioned that the 16 bit data output is expressed in 2's complement. this data is then converted into a float. The buffer declaration is : float buffer[6]. However, in the different programs I read, the X and Y values were define by Xval = buffer[0] and Yval = buffer[1] or buffer[2].But, aren't we supposed to get only the Xval by the function above (parameter : LSM303DLHC_OUT_X_L_A) ? And why is the float value converted in 8 bit for the test (''if((int8_t)Buffer[0] < -2)'') ?About the data filtering, I will look into the Kalman filter, thank you for the idea.Kind regards,Antho2014-01-17 04:33 AM
Hello Sudhi,
Were you able to download the software that you needed? If not, please send me a message with your contact information and project description at thiago.reis@st.com Thank you, Thiago