I've been learning a lot from your code, thanks very much for putting it on here.

I have a board with single axis gyro with 3 axis accelerometer, analogue outputs.

I'm looking to find the Roll angle, so the single gyro board will need to be orientated up on its end so that the Roll axis goes through the middle of the gyro. The accelerometers with then be: X=up/down, Y=left/right, Z=forward/backward.

In this configuration which combination of the X,Y and Z accelerometers should I be using in the code?

I am guessing that it's the X and Y as the Z axis accelerometer is not effected by roll when the board is mounted on it's end

Your code uses X and Z and Y and Z in the arctan function, so I should use X and Y, correct?

@richardtheboffinIt depends on your gyro - some have to be orientated up others don't.Regarding which axis you should use on your accelerometer: I can't say for sure. It depends on how it's orientated. Either it's X and Z or Y and Z.Try to modify this code: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/LPR530AL_%20LY530ALH_%20ADXL335/LPR530AL_%20LY530ALH_%20ADXL335.ino, so it's uses the correct sensitivity values for your setup.Then afterwards you can easily see which angles should be fused together. You might also need to invert some of the readings, as I have done here: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/LPR530AL_%20LY530ALH_%20ADXL335/LPR530AL_%20LY530ALH_%20ADXL335.ino#L51

i was able to implement the filter thanks for this guide it was really helpful...thank you very muchbut i dont know how to relate these values to motor's rpm of a quadcopter so i will stabilize, can anybody post links to guides like this?

i was able to implement the filter thanks for this guide it was really helpful...thank you very muchbut i dont know how to relate these values to motor's rpm of a quadcopter so i will stabilize, can anybody post links to guides like this?

You will need to use a PID controller to give roll,pitch,yaw outputs when the orientation deviates from 0,0,0. However, I have used these filters on a quadcopter and they suffer from the problem of linear acceleration affecting the pitch and roll. The filters are fast enough, smooth and very stable (calculation time was 80micros for twin Kalmans on an Arduino Due) but you'd probably be better off using Mahonys DCM or Madgwicks filter - they're less sensitive to linear acceleration but a bit more prone to noise (vibration from the motors).

The setup is very similar just note that if you are using an Arduino running at 5V you might damage the IMU as it's only running at 3.3V, but some breakout boards have a logic level circuit built-in. If not use have to use a logic level converter like this one: https://www.sparkfun.com/products/8745.

To connect the Arduino with the MPU-6050, you need to connect it as it says in the following comment: https://www.sparkfun.com/products/11028#comment-50b3c165ce395f484d000000.

Hopes this helps you out for now, as I havn't got time to write a guide at the moment.

delay(100);}According to the example "compass.a.x","compass.a.y" and "compass.a.z" are for reading the acc data.I will really appreciate if you take another look of my code.I think that when i was customising your source i might have deleted something important.Thank you again for your time. P.S. Now i rememberd that i deleted part of the source for getting the data of acc and gyro.For example "readAccX" function was something like this:

Sorry I was in a hurry when I wrote the first reply.First of all I think it will be easier for you to if you modify this example: https://github.com/pololu/LSM303/blob/master/LSM303/examples/Serial/Serial.ino to your needs.

First of all you should NOT subtract the zeroValues, as they are specific for the IMU used in the example.I think you can use your values directly, so you don't even have to subtract any zeroValue.Take a look at this example: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/MPU6050.ino

Also you assume that the gyro has the same sensitivity as the one used in the example which is most likely not the case (take a look at your datasheet)!