-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No need to wait after Wire.requestFrom() #4
Comments
Thanks for spotting that! I will remove the line. Awesome! |
Thanks. That was fast. You use the I2Cdev code, which is using the Wire library in a wrong way ( jrowberg/i2cdevlib#265 ). That library is no longer maintained and the issues are piling up. The library is also a little outdated. Your copy of "init_mpu6050" is therefor also a little outdated. The FastWire option is not really needed and setting the TWBR for the speed is no longer needed, since there is a Wire.setClock() function now. Changing the I2Cdev.cpp is risky. There is not much you or me can do about the library at Github. Keep in mind that the library is slower than needed, with extra unnecessary bus activity that slows it down. With the current version of the AVR Wire library the I2Cdev library works (despite the wrong use), so for now it is okay. |
I guess it would be possible to use the i2c_t3 library in I2Cdev, however as you said it could be a lot of work. I have sufficient power on my microcontroller to be able to do my own sensor fusion, so this library by Kris Winer is worth looking at for me. Thank you for pointing out the issues! |
You might consider to upgrade to the MPU-9250 and try the Kris Winer AHRS fusion. Sometimes a MPU-6050 module is shipped with a smaller capacitor which causes extra noise. The MPU-9250 doesn't have that capacitor. |
Ok, that sounds like it will improve the IMU quite a bit. I am wondering about the tradeoffs of using on-chip sensor fusion vs. doing it on the main board. I guess I will try both! BTW, great job on helping all those other people use the Wire library correctly. |
In the file raPID/src/imu.cpp you can remove this line:
while (Wire.available() < 6) {}
. It is used twice.The Wire.requestFrom() waits until the complete I2C transaction on the bus has finished. There is no need to wait for something after the call to Wire.requestFrom().
In case of a bus collision or an error that the Wire library could detect (it can not detect most problems), then the Wire.available() will probably return zero, and that loop will halt the sketch.
The text was updated successfully, but these errors were encountered: