Skip to main content
Visitor II
December 29, 2017
Question

IIS2DH Raw data to convert into G unit

  • December 29, 2017
  • 2 replies
  • 1208 views
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.

    This topic has been closed for replies.

    2 replies

    Graduate II
    December 29, 2017
    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

    Visitor II
    December 30, 2017
    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.

    December 31, 2017
    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

    January 3, 2018
    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