Go Down

### Topic: Guide to gyro and accelerometer with Arduino including Kalman filtering (Read 528142 times)previous topic - next topic

#### Geoffroy

#525
##### May 27, 2014, 07:09 pm
Hi,

As a project for a university course, we are making a 3 axis camera stabilizer. We are using a 6DOF IMU MPU6050 accelerometer and gyroscope. I'm using your code to control the pitch and the roll of the camera (huge thanks by the way for the code and all those explanations you gave to everybody that helped me). As it is impossible to calculate the yaw with this code, I'm trying to combine it with the I2Cdevlib by means of the quaternions.

My idea would be to combine both and so to be able to control the corrected pitch and roll and the non-drifting yaw. But I'm having FIFO overflow problems.
Does anyone try this kind of combination?

#### ozzie2005

#526
##### Jun 01, 2014, 08:24 pmLast Edit: Jun 01, 2014, 08:28 pm by ozzie2005 Reason: 1
Quote

I just updated the MPU-6050 code. The changes newest code can be found in the Github repository: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/tree/master/IMU6DOF/MPU6050.

Hi Lauszus,

The link above seems to be broken, is there anyway you can fix the link?

I searched for your MPU6050 library in google and got the your code for the MPU6050 but I don't know if that is the most recent version. There is something I don't understand from your code:

accX = ((i2cData[0] << 8) | i2cData[1]) + 2000.0;
accY = ((i2cData[2] << 8) | i2cData[3]) + 3319.84;
accZ = ((i2cData[4] << 8) | i2cData[5]) + 664.48;

Where did you get these values in red from? I checked the MPU-6050 datasheet and could not find any of these values. Is there any reason why you add them to the ACCs? and if so, why these values?

Thank you,
Ozzie

#### michinyon

#527
##### Jun 02, 2014, 01:14 am
You obviously didn't read the thread very carefully,   because only a few posts ago,   it was stated that those values are to compensate for the zeroing error of his particular device.    Your device will be different.      If you think that the zeroing error,  or asymetrical response,  of the device matters,   you can do you own experiments to measure it,   and then put those numbers into the equation.

#### ozzie2005

#528
##### Jun 02, 2014, 05:16 am
I must've missed that post but thank you for your time explaining the reason for these values.

cheers.

#### Geoffroy

#529
##### Jun 14, 2014, 10:51 am
I recently bought a 10 DOF IMU from Drotek (MPU6050 gyrometre & accelerometre + HMC5883 magnetometre + MS5611 altimetre )

I wanted to use the library with Kalman filter  you provided for this board (MPU6050_HMC5883L) with my Arduino Uno.
But I get the following error : i2cWrite failed 2.
So I suspect it's a problem of address (I changed the address of the MPU6050 to 0x69 as mentioned by Drotek without success).
Let's acknowledge that I can run the MPU6050 code without a problem setting the address to 0x69.

Does anyone experienced and solved that problem?

#### enkaytynguyen91

#530
##### Jun 18, 2014, 05:03 am
Hi,
We know that: The default sensitivity is high, and the sensor returnes 16 bits,a variation of 50 is just a very small variation.
So, when we calculate the angle base on the raw data, what is the resolution of sensor (smallest angle that the sensor can detect)?
Thanks!

#### Lauszus

#531
##### Jun 21, 2014, 01:39 am
@Geoffroy
Are you by any chance using a Due? There was a bug in the Wire library for the Due: https://github.com/arduino/Arduino/issues/1976 which will be available when a new release of the Arduino IDE is available - or simply compile the IDE yourself.
For now simply ignore the returned value.

@enkaytynguyen91
It depends on what sensitivity you use. Please see these datasheets for more information: http://www.invensense.com/mems/gyro/documents/PS-MPU-6000A-00v3.4.pdf and http://www.invensense.com/mems/gyro/documents/RM-MPU-6000A-00v4.2.pdf.

#### Geoffroy

#532
##### Jun 24, 2014, 09:27 pm
@Lauszus
No, I'm using a Arduino Uno. It seems that the problem lies in the fact that I can't access directly the magnetometer. Then I found that I should access it through the MPU6050 using it in the by-pass mode. But I'm not sure of the code I add.

Code: [Select]
`  // Bypass mode  while (i2cWrite(MPU6050, 0x6A, 0x00, true));  while (i2cWrite(MPU6050, 0x37, 0x02, true));`

Using that extra code, I'm able to get values of yaw, pitch and roll. But the yaw seems to be drifting. I don't know if it could be linked with the by-pass mode and if I can use another method to get those values.

Geoffroy

#### Lauszus

#533
##### Jul 02, 2014, 12:35 am
@Geoffroy
It seems weird that you can't access both sensors on the same bus, but yes your code looks good to me if you want to use it in bypass mode.

You should be able to simply connect both sensors to SCL and SDA at the same time. Maybe try adding a pullup resistor to 3.3V and see if that solves the problem.

#### caymanguy

#534
##### Jul 04, 2014, 11:04 am
im using a different code
I like to use yours

mpu 6050

#### desraino

#535
##### Jul 05, 2014, 11:38 am
First sorry for my bad english. I want to know something from your project MPU6050_HMC5883L Kalman Filter https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/tree/master/IMU/MPU6050_HMC5883L.

I recently bought a 10 DOF IMU GY-86 (MPU6050 gyrometre & accelerometre + HMC5883 magnetometre + MS5611 altimetre ) and use arduino mega 2560.

But I get the following error : i2cWrite failed 2. I attached Screen Shot for my problem.
I have changed the address of the MPU6050 to 0x69 as the comment, but didnt change anything.

Could everyone solved this? Or maybe have some experienced as me?

#### michinyon

#536
##### Jul 05, 2014, 04:58 pm
Your wiring of the I2C connection is probably wrong.

#### desraino

#537
##### Jul 05, 2014, 07:05 pm
Whats wrong with the wiring  michinyon?

#### shrims4u

#538
##### Jul 13, 2014, 10:11 am
Can this combination give me an accuracy of angle measurement upto 5minutes(0.083333degrees).

If not Which sensors/IMU do I use to achieve such high precision/accuracy ?

#### Barsil

#539
##### Jul 16, 2014, 11:04 am
Hi Lauszus,

I am currently trying to read my digital IMU, the "6 Degrees of Freedom IMU Digital Combo Board - ITG3200/ADXL345" from Sparkfun with my Arduino Due and I am facing some trouble since it's my first time working with Arduino and Microcontrollers at all. My coding skills are the ones of a typical Mechanical Engineer: I know how code looks like.
I read through this blog and saw, that you and Kashif already solved that particular problem but that was a few years ago and I didn't become smarter by reading your exchange of replies.
I do get some data in the Serial Monitor by using the code from the late Fabio Versano (http://www.varesano.net/blog/fabio/my-first-6-dof-imu-sensors-fusion-implementation-adxl345-itg3200-arduino-and-processing) but it doesn't work 100% and I can't find the mistake. The newer FreeIMU Version doesn't work either, because the Due doesn't support EEPROM.
The code I like the best is yours but unfortunately it is for analog IMUs and even though I tried to combine the code of Versano and yours I couldn't get it work.
If there is an easy way to change your code to work with digital IMUs or even better, if you still have some working code for that problem I would be super appreciative if you could send it to me.

Thanks in advance and thanks for the great blog you're having here!
Barsil

Go Up

Please enter a valid email to subscribe

To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy