How to calculate the angle from sparkfun lsm9ds1 IMU sensor ?

hello there,
I'm working on my graduation project which about finds the angles of the IMU sensor.
I'm using sparkfun lsm9ds1 IMU sensor also I'm using sparkfun " LSM9DS1_Setting "code but the result of this code is raw data and I want to convert the gyroscope and accelerometer data into angles.
I tried to use this formula [angle_x= angle_x +(imu.calcGyro(imu.gx)) * Time] and I'm not sure if the result was correct and I have this formula [angle_accel = arctg( Ay / sqrt( Ax^2 + Az^2 ) )] but I didn't use it yet.
so, I'm wondering if it is right to use these formulas and how to write their codes right?

The raw values from a MEMS gyro sensor is the acceleration and de-acceleration of the rotation [see post of MarkT]. It is not the classic gyroscope that you might expect.
For a digital spirit level, you only need the accelerometer and a low-pass filter to measure the earth gravity. That is a "static" value, a spirit level is not a flying drone.

Do you want the dynamic values of yaw, pitch and roll ?

Have a look at this: LSM9DS1/LSM9DS1_MS5611_BasicAHRS_t3.ino at master · kriswiner/LSM9DS1 · GitHub (line 539).

Adafruit has a tutorial: Overview | How to Fuse Motion Sensor Data into AHRS Orientation (Euler/Quaternions) | Adafruit Learning System.
Sensor fusion combines all sensors and eliminates the weakness of each sensor.

Koepel:
The raw values from a MEMS gyro sensor is the acceleration and de-acceleration of the rotation. It is not the classic gyroscope that you might expect.

No, the raw values from a MEMS gyro sensor are rates of turn, which is why its called a "rate gyro". For instance
10 degress/second is a rate of turn.

Koepel:
Do you want the dynamic values of yaw, pitch and roll ?

sorry, but I don't know what these are?

See this introduction to 3D orientation (Euler) angles.

atan2() is the function you need for converting cartesian pairs to an angle. For instance if your
sensor has x, y, z outputs, the angle from vertical would be

atan2(sqrt(xx+yy), z)

√(x^2+y^2) is simply the magnitude of the gravity component in the sensor's xy plane, z is
the gravity component in the sensor's z direction.

atan2() uses the signs of both arguments to determine the correct quadrant for the resultant
angle (which of course is in radians, not degrees, as its a mathematical function). Sometimes
the signs matter, for instance telling you if you are upside down or not(!)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.