cancel
Showing results for 
Search instead for 
Did you mean: 

IIS2DH Raw data to convert into G unit

Arpan Patel
Associate II
Posted on December 29, 2017 at 04:40

How I convert accelerometer X, Y and Z axis raw data into the unit of G. Can someone provide me the which equation I have to apply on the raw data so I can get the results in G unit. Moreover, how we calculate roll, pitch, and yaw from the accelerometer's raw data.

5 REPLIES 5
Posted on December 29, 2017 at 16:05

You will need to take the 16-bit signed values and apply the scale values described in the data sheet for the assorted FS (Full Scale) settings. Review several messages on this topic.

floatx = (float)intx * scalingfactor

Consider at +/-4G you are scaling a number of span +32767 to -32768, and the units described in mG vs G

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on December 30, 2017 at 06:39

Hi Clive, Just for confirmation I have used following equation for raw data to convert into G. Is it right or wrong?

X = (raw_dataX)*(table_value)  ===> in that formula I have taken table value as per data sheet and according to selected full scale.

Furthermore, can you provide some suggestion for roll, pitch and yaw equations?. I want to develop a door open/close application. So, can you provide some suggestion on this type of application how I use the accelerometer?

Thank you for your time.

Legacy member
Not applicable
Posted on December 31, 2017 at 14:29

Hello,

Yes, your formula is OK. It depends on you, whether you want to use float data types or integer values only (which consume less program memory and you give you less instructions to execute).

Just a note: even though you can get values out of the selected scale boundaries (if you multiply

+32767 and -32768 with the selected mG factor)

, the validity of data is not guaranteed outside the boundaries.

David

Posted on January 03, 2018 at 04:29

Thanks for your clarification. I would like to tell you that I have made some algorithms for my application to detect door open/close with the only accelerometer. The result is in some cases it has worked but not for in all cases. So, can you give some suggestion that if I want to develop door open/close application then should I need some other chip which includes accelerometer+gyaroscope or with the only accelerometer we can achieve this application? Give me some solution regarding this application.

Legacy member
Not applicable
Posted on January 03, 2018 at 11:58

To be honest, it is hard to give you any advice without knowing more detail. Opened / closed doors are usually detected with a reed switch and a magnet. If you need to capture the process of opening, it would require some testing and setting a few parameters, like the acceleration / rotation intensity per some defined period of time. ST provides libraries for movement detection, but I am not sure, whether this would suit, because there are some specific movement types detected - walking, cycling, driving a car etc.

Have a look at the middleware in this pack: 

http://www.st.com/en/embedded-software/fp-sns-motenv1.html