Go Down

Topic: MPU6050/MPU6500/MPU9150/MPU9250 library over I2c (Read 6 times) previous topic - next topic

joshchab

Hello,

I'm interested in using the MPU-6500 along with this library in my project. As far as hardware is concerned, is this all that's needed aside from the Arduino:

http://store.invensense.com/ProductDetail/EMSENSR6500-Embedded-Masters/495014/

They also have an evaluation board:

http://store.invensense.com/ProductDetail/MPU6500EVB-InvenSense-Inc/488434/

I wanted to make sure I get the correct board.

Thanks!

gregd72002

Hi,

I'm unsure about the evaluation boards. What you need for this library is any of MPU6050, MPU6500, MPU9150 or MPU9250.
You can get it off ebay, sparkfun, etc.

Gregory

gregd72002


Hi again !

I've tried that :
in function "mympu_open", with MPU_DEBUG activated, I have suppressed the line
"if (ret) return 10+ret;"

Then, the program ouputs that :
"Firmware compare failed addr 0
0 0 112 0 0 0 0 36 0 0
33 55 0 118 7 0 1 4 40 1 "

Probably an interesting information... but difficult to understand for me !

Regards,

Sylvain



Hi,

I believe I fixed the issue with MPU9250. Can you pull and update and re-try?

Thanks,
Gregory

apitaru

Hi, I've been having a similar issue with the 9250.

Thanks for attempting a fix! I've just tried the latest commit and it's still resulting in the same error notice. Let me know if there's any debugging I can help with.

And thanks for the great work - it works great with the 6050!

Amit

ddeard

I can get the sketch to work with the 9250 now, but I had to do two things:

1. Had to add a line
#define MPU9250
in the file inv_mpu.h.
2. Had to use a Mega.  On an Uno, it still spews the error -1's.

Dan

gregd72002

#20
Sep 22, 2014, 03:45 pm Last Edit: Sep 22, 2014, 08:33 pm by gregd72002 Reason: 1
Dan,

If this works on one board but not on the other, this might be down to I2c library.

Can you try changing fastwire speed to 400 ?
https://github.com/rpicopter/ArduinoMotionSensorExample/blob/master/AvrCopter.ino#L8


If this does not help you can try to use ArduinoWire library instead of FastWire:
- comment line 53 and uncomment line 52:
https://github.com/rpicopter/ArduinoMotionSensorExample/blob/5c4bdf2aa464bdfcf903bc166afd3bb8752bf83d/I2Cdev.h#L52

- also the setup needs to change slightly in https://github.com/rpicopter/ArduinoMotionSensorExample/blob/master/AvrCopter.ino#L8

conrads1arduino

Hi Greg,

I have debugged this issue on the 9250 a bit and it seems to be related to the programming the DMP firmware to the 9250 board.
I have logged the bytes written and bytes read back and when the issue happens it seems to be when the bytes read back does not match the bytes written. Furthermore, it seems that the bytes read back is always the same as the previous written buffer.
It seems the something in either the i2c state machine or the memory bank/write machine on the mpu gets stuck.
I have also added some retry mechanism to try to reprogram the bank if at first it failed. It improved a bit but it still not very stable.
Here is an output dump of the bytes written and read back
[font=courier]write mem 0 0 112 0 0 0 0 36 0 0 0 2 0 3 0 0
read mem 0 0 112 0 0 0 0 36 0 0 0 2 0 3 0 0
write mem 0 101 0 84 255 239 0 0 250 128 0 11 18 130 0 1
read mem 0 101 0 84 255 239 0 0 250 128 0 11 18 130 0 1
write mem 3 12 48 195 14 140 140 233 20 213 64 2 19 113 15 142
read mem 3 12 48 195 14 140 140 233 20 213 64 2 19 113 15 142
write mem 56 131 248 131 48 0 248 131 37 142 248 131 48 0 248 131
read mem 3 12 48 195 14 140 140 233 20 213 64 2 19 113 15 142
Firmware compare failed addr 48
write mem 56 131 248 131 48 0 248 131 37 142 248 131 48 0 248 131
read mem 3 12 48 195 14 140 140 233 20 213 64 2 19 113 15 142
Firmware compare failed addr 48
write mem 56 131 248 131 48 0 248 131 37 142 248 131 48 0 248 131
read mem 3 12 48 195 14 140 140 233 20 213 64 2 19 113 15 142
[/font]

Weirdly though if i use some of the other libraries available (for example the one from Jeff for the 9axis motion sensor) the DMP programming works fine and I do not run into the same issue)

I have ordered some 9150 devices now (which has the mpu6050 inside), to see if is exposes the same problem.
I like your library since it utilizes  the internal sensor fusion of the DMP if you use the quaternion outputs, but I need to correct for yaw drift now and that is why i want to move to either the 9150 or 9250 to be able to use the compass.

Cheers,
Conrad

Alexvc14

Hi Gregory,

Great library, that is what I was looking for. Got it up and running on Nano + GY-521. And even connected it to famous teapot demo.

I have a few questions.

1. Why you produced your own version mpu.cpp? Can I use inv_mpu.cpp?
2.What should I do to change FSR from 2000 to 250 ? (as far as I understand it is much more than just simple #define FSR 250 in mpu.cpp)

Alexvc14

Here is what I found on Invensense forum.

Post Re: Wrong Quaternion angle with DMP at 500 DPS
This is a know bug on our end. 2000 DPS is the only full scale range the MotionDriver firmware currently supports for the gyroscope.

July 7th, 2014, 3:14 pm

gregd72002


Hi Gregory,

Great library, that is what I was looking for. Got it up and running on Nano + GY-521. And even connected it to famous teapot demo.

I have a few questions.

1. Why you produced your own version mpu.cpp? Can I use inv_mpu.cpp?
2.What should I do to change FSR from 2000 to 250 ? (as far as I understand it is much more than just simple #define FSR 250 in mpu.cpp)


Hi,

The mpu.cpp is not a substitution of inv_mpu.cpp. It contains just a common initialisation code that in turn calls for inv_mpu functions.

You should be able to change FSR, just remember to update GYRO_SENS accordingly. See line 6 and 7 in mpu.cpp


gregd72002


Hi Greg,

I have debugged this issue on the 9250 a bit and it seems to be related to the programming the DMP firmware to the 9250 board.
I have logged the bytes written and bytes read back and when the issue happens it seems to be when the bytes read back does not match the bytes written. Furthermore, it seems that the bytes read back is always the same as the previous written buffer.
It seems the something in either the i2c state machine or the memory bank/write machine on the mpu gets stuck.
I have also added some retry mechanism to try to reprogram the bank if at first it failed. It improved a bit but it still not very stable.
[...]



Hi Conrad,

This really might be down to the i2c library used. Have you tried to use slower transmission speeds? See my previous posts for details.

I'm using myself 9150 on pro mini and this works flawlessly. But again, this might be different on other arduino models.

Alexvc14

I dug deeper and found the answer on Invensense forum.
The answer to my question is NO. I cant do FSR_250 and use DMP.

http://www.invensense.com/developers/forum/viewtopic.php?f=3&t=1096&p=4631#p4631
"This is a know bug on our end. 2000 DPS is the only full scale range the MotionDriver firmware currently supports for the gyroscope."

gregd72002


Go Up