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?
i was able to implement the filter thanks for this guide it was really helpful...thank you very much
but 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?
tensa:
i was able to implement the filter thanks for this guide it was really helpful...thank you very much
but 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).
You'll find plenty of links via Google for any of this stuff.
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.
Hi Lauszus,
I make a little customisation of your source for digital IMUs so it can work with Minimu-9 board , hope you don't mind.But there is something wrong here is what i get:
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:
int readAccX(void) {
int data;
data = i2cRead(adxlAddress, 0x32);
data |= i2cRead(adxlAddress,0x33)<<8;
return data;
}
and i didn't understand what "data |= i2cRead(adxlAddress,0x33)<<8;" is for so i deleted it.
now it looks like this:
int readAccX(void) {
int data;
data = compass.a.x;
return data;
}
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)!
Hi again Lauzurus ,
Thank you verry much for your answer ,but i am afraid that I won't need your source anymore.I just found out this link it is a source for Arduino and MinIMU-9 board wich is exactly what i have.Once again I am really sorry for wasting your time. I hope you that you won't get angry at me.
I was hoping to learn something about using IMU effectively with the help of Kalman filtering as I came across this wonderful tutorial. The only problem I have is I have 2 separate gyro and accelerometer modules (L3G4200D and ADXL 335). How do I combine and use them according to your pin config.
gyro has pins GND, VIN, SCL, SDA, SDD, INT1, INT2 and accelerometer pins are VCC, GND,X,Y,Z,ST. Where do these pins go?
@psyoptica
The gyroscope is a digital gyroscope so you need to connect it to the SDA and SCL on the Arduino. See the following page for more information: Wire - Arduino Reference. Then connect VIN to 3.3V and GND to GND on the Arduino.
Your accelerometer is a analog one, so you need to connect X, Y, and Z to your analog inputs. And yet again connect VIN to 3.3V and GND to GND on the Arduino.