Frequently Asked Questions
Mon-Fri, 9am to 12pm and
1pm to 5pm U.S. Mountain Time:
Chat With Us
March 18, 2011
about 3 years ago
Ok, I did more testing and still no success in my quest to go reliably beyond the 50Hz value. However, the main program loop is fast enough that I can get close to around 500Hz in the rest of my program. And I did not optimize my code one bit (I now have many calculations, three AnalogWrite, one DigitalWrite, etc.). So it’s annoying knowing that the MPU6050 is capable of doing much more but still, it’s usable. If needed you can probably extrapolate sensor values based on the previous ones.
What I can also report is that if you want to use this chip, stay away from the Leonardo! It does not work well at all. If you simply use the chip to read the orientation and use Jeff’s code, you might be able to work it out (remember to unplug the INT line). But as soon as you try doing something with the data, the Leonardo behaves eratically. First you have to move your additional code outside of the interrupt while loop (understandably). But then, sometimes my code would work for a few seconds only and then nothing. Also, if I try to verify my AnalogWrite values with a multimeter, the Leonardo freezes! I started to believe my Leonardo possessed by an evil spirit. And BTW, the same code works fine with the UNO. If I have some time, I’ll try my Mega board.
In conclusion: thanks Jeff, 50Hz it is, use an UNO board.
Edit: the sensor works fine with my Mega2560R3 board.
Edit 2x: boy, do I feel stupid. I made a mistake in my frequency calculation, it is indeed 100hz !!
I just checked and I have:
E1 1202 D
So I guess this a revision D chip.
In my main program, I use a couple of AnalogWrite, a bit of calculation but nothing really fancy, no serial output beside these of your example code and no interrupts. Anyway, these are not to blame as I got the exact same numbers when I comment my own part of the program, i.e. run the example as is. This is actually quite strange as neither my calculation nor the serial output change the resulting sample rate at all. I even commented the serial outputs you put in your code and still… 50 Hz using the default parameters! It is as if the whole program is synchronized with a 50 Hz rate coming from the DMP.
Even more peculiar is that getting the raw values from the DMP (acc+gyro) using the code at http://arduino.cc/playground/Main/MPU-6050 I get the data at a whooping 280 Hz. But to me, the main advantage of using the MPU6050 over the other (cheap) IMU boards is that I can get motion data without burdening the Arduino board with the data processing of the raw sensors.
Oh and before I forget: thanks again for your comments!
Yeah, I tried that (changing line 261 of the library) but it didn’t help much. It gave me something around 55Hz. I played around with the I2C Master Clock (I tried setting it to different numbers between 400kHz and 500kHz) and also tried using a different clock source (setClockSource), changing the sample rate (SMPLRT_DIV), etc. Basically, I browsed the whole MPU6050.cpp function by function and tried anything that I thought might help but I never achieved a better number than 58Hz and as soon as I go beyond 50Hz, I receive a lot of “FIFO overload”.
There is no noticeable difference between the numbers/behavior I get with the Uno and Leonardo. How did you manage to get 100 Hz reliably? with what board? I used an Uno R2 and Leonardo R3. Using the default settings of your library (i.e. line 261 untouched), I have this 50 Hz figure not the 100 Hz stated in the comment. I wonder why? Maybe a different revision of the 6050?
Hi Jeff. First of all thanks for this fantastic work and for sharing it with everyone.
I used this breakout board with both the Uno and Leonardo and one difference I noticed was that while the INT of the MPU6050 should definitely be connected to the INT0 of the Uno for it to work it wasn’t the case with the Leonardo. The board only worked with the latter if the INT pin was left unconnected.
With both Arduinos, I get a refresh rate of the roll/pitch/yaw data at precisely 50Hz whether the data is sent to the serial line or not. Is this particular value (50Hz) due to the internal clock of the MPU6050? Has someone managed to get data faster than that?
No public wish lists :(
Forgot your password?
No account? Register one!