mit2sumit

Can u suggest me with these data, that I initially received with my GY-521 module of MPU6050 IMU...I'm not able to distinguish, whether why there's so much of drift...The connections made are:vcc=5vGND=GNDSDA=SDA //dedicated to arduinoSCL=SCL //dedicated to arduino

@mit2sumitPlease connect AD0 to GND as well.And please try to run my example code: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/tree/master/IMU6DOF/MPU6050, so I'm able to help you out.

mit2sumit

Thanks for this info....but, its too late and unuseful....as, i got my sensor worked with the program u mentioned, and even completed my project...though it was not much successful....

I still wonder, whether, why was those variations....even with connecting AD0 to gnd....and later when i uploaded this code: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/tree/master/IMU6DOF/MPU6050 , by myself it worked.I even mapped the value with the range of -20 to 20, so that the horizontal stationary value gives...0 output...

@romit26As Kashif said. Simply just divide by that value. Take a look at the following code: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/MPU6050.ino. But it's even necessary to do this with the accelerometer, as you can just pass in the values directly into atan2 - see: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/MPU6050.ino#L89-L90.

I'm new to the whole arduino programming scene so please pardon my ignorance if this is a dumb question.

I've got and Arduino Uno and a MPU6050 GY-521 that I'm trying to use for a project I'm working on.

I've gotten several different sketches to "work" so far including the one from here:

http://playground.arduino.cc/Main/MPU-6050

And 2 of Jeff Rowberg's ones from here:

https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050

I have trouble tryin to figure out how to use the raw data from the playground code and I've noticed quite a bit of drift with the Rowberg "teapot sketch" so I'm trying to figure out how to use yours.

I keep getting these errors though when verifying your code from here:https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/MPU6050.ino

sketch_oct20a.ino: In function 'void setup()':sketch_oct20a:45: error: 'i2cWrite' was not declared in this scopesketch_oct20a:46: error: 'i2cWrite' was not declared in this scopesketch_oct20a:48: error: 'i2cRead' was not declared in this scopesketch_oct20a:57: error: 'i2cRead' was not declared in this scopesketch_oct20a.ino: In function 'void loop()':sketch_oct20a:78: error: 'i2cRead' was not declared in this scope

I've placed the Kalman.h file in my library. Is there something I'm doing wrong? and why does your code seem so much shorter and simpler than the others?

@RhettYou need to download the I2C.ino file as well: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/MPU6050/I2C.ino. Simply just download the entiry repository - go to the front page: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter and then notice the button labeled: "Download ZIP" and will download all you need.

Quote

and why does your code seem so much shorter and simpler than the others?

Because my is just a minimal code, but it should be plenty for most users. The code on the playground got all the different registers defined - I simply just hardcode them.

The code here: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050 is quite different as it uses the built-in DMP - you can read more about it here: http://www.i2cdevlib.com/devices/mpu6050#source.

You program seems to be a two dimensional implementation, what is that ? I am not sure how quaternions would be useful there.

This is piece of code from original post, this is not my program, I've tried it, and yes, it works for 2D, and I using it for 2D stabilization. I want to have 3D stabilization, so I want to handle z axis as well, just want to add Z axis to listed code. Lets forget about arcsin(2(q0q2-q1q3)) , this was something I did not know what I was talking about....

Question is simple: So what would be formula to convert Z values from accelerometer output to get angle, similar to

It is not possible to calculate the rotation along the z-axis (yaw) using the accelerometer. More information can be found at the following comment on my blog: http://blog.tkjelectronics.dk/2012/09/a-practical-approach-to-kalman-filter-and-how-to-implement-it/comment-page-3/#comment-431999.

Instead you should use the code that you used snippets of, which I believe is this one: https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050, right?

But to get a precise yaw estimate you should use a magnetometer as well.