2017-12-28 07:40 PM
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.
2017-12-29 07:05 AM
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
2017-12-29 10:39 PM
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.
2017-12-31 06:29 AM
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
2018-01-02 08:29 PM
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.
2018-01-03 02:58 AM
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: