# Which is give better result for find angular position of device using 9-axis IMU snesor.?

I'm Using LSM9DSO 9 axis Sensor Which gives output of Accelerometer , gyroscope , Magnetometer Output data. i want to find the angular position of the device using this sensor.

currently i'm trying to find an angle of device of x-axis but data is fluctuate so , i have refer some websites and documents which show that it is find using Accelerometer data also but i have little confuse about to which is better solution to find angular position of device.

• This is rather complicated. You need to tell us a lot more about what you are trying to do. – mkeith Jan 12 '17 at 8:32
• Hello I have implemented to find the pitch and roll using both accelero meter and gyroscope when i am rortating device from 0 to 90 degree but it displayed only from 0 to 82 degree only in both pitch and roll . – Kalarav Parmar Jan 17 '17 at 12:40

Generally you determine angle by using the accelerometer readings. This only works is the unit is not accelerating at the time but you can do a quick sanity check that sqrt(x*x + y *y + z *z) = 1g +/- some error margin. If that is true then you probably aren't accelerating.

For any given axis the amount it is away from pointing straight up will be given by angle = cos-1(reading in g).

If you know how far each axis is from vertical then you can work out your orientation relative to the ground.

If you are accelerating then assuming you knew your orientation before hand you can calculate your current orientation by using the gyro readings to measure the change in orientation. However anything calculated this way will drift away from the correct answer so you will need to correct it once you stop accelerating.

You can use the magnetometer as a sanity check and a method of tracking rotation but it's not very reliable for calculating absolute heading without first being calibrated for your current environment.

All of the readings from an IMU will be very noisy unless you are using a very expensive one, expect to have to average and filter a lot to get smooth results out. In this situation expensive means the price has at least 4 digits before the decimal point.

You need some kind of algorithm to fuse the acceleration, rotational rate and magnetic field readings. There are several different ways to do this, from simple complementary HP/LP-filters to more advanced quaternion based non-linear Kalman-filters.

I have, with great success, used Sebastian Madgwicks open source AHRS-algorithm with a LSM9DS1 and STM32F405 processor. You can download a paper describing it and some source code from here:

http://x-io.co.uk/open-source-imu-and-ahrs-algorithms/

Thanks a lot to all for your greater Support. I have found some interesting Reference website. which give the best method to implement both to find meaningful data like, pitch & Roll.

Guide to using accelerometer

Guide to using gyroscope