Jump to content
I2Cdevlib Forums

Leaderboard

Popular Content

Showing content with the highest reputation on 08/20/2016 in all areas

  1. Greetings, My project requires connecting multiple MPU sensors and sending all rotation data to comp using USB. I have the single sensor code working absolutely fine. Now i am hooking up 2 sensors. Idea is : Tie together the SDA, SCL, Vcc, GND and INT lines of both MPUs together. Connect the AD0 pins of MPUs to different Arduino pins. Declare only 1 MPU6050 object (as given by jeff rowberg) with devAddr = 0x69 (I dont want to maintain X no. of object for X no. of sensors. My project going ahead may need 8+ sensors and i don't want to have 8+ MPU objects in my Arduino) Whenever any sensor needs to be Init / Read / Written to, enable that sensor by writing HIGH to AD0 pin, and writing LOW on all other AD0 pins of other sensors. Once the particular sensor has been enabled, i use the normal mpu functions from my MPU6050 object which have been provided by Jeff. Now while initializing, i enable sensor 1, call mpu.initialize, testconn, dmpInit.... etc... , then i enable sensor 2, and do the same. Same method is followed to collect data from all sensors. Problem is, only Sensor 2 gives valid output. Sensor 1 gives corrupt values. I debugged the problem a little bit, it seems only the sensor which i initalize the last (sensor 2 in above case) gives valid values. I first thought that when i init the second sensor using the single mpu object, it overwrites some SW vars in this object that were previously set by first sensor. Then when i try to access the Sensor 1 with this object, these overwritten values cause problems and arduino ends up reading garbage. However i went through the whole MPU library to see if there are any private / public vars that are MPU specific and that Jeff's code might be saving. but i found nothing. It seems almost all the seful function straightaway call I2CDev Read/WriteBit. This implies as long as the correct device's AD0 is HIGH, and MPU's SW object's devAddr = 0x69, everything should work fine. And yet it does not. Can someone help ? Thanks
    1 point
  2. Sometimes my Arduino freezes or crashes when using JEFF ROWBERG library to read DMP data from MPU6050. It took me almost a full year to discover the problem and today I had some spare time and I tried to find where exactly arduino hangs/freezes. I discovered it is usually when executin getFIFOCount() or getIntStatus(). I discovered that inserting many Serial.print with tags along my entire code so I could know exactly which line hanged. So I discovered everytime my arduino hanged/freezes it was at a line with getFIFOCount() or getIntStatus(). So I decided to take a close look at it. Inside the file MPU6050.cpp there is a code like this: uint16_t MPU6050::getFIFOCount() { I2Cdev::readBytes(devAddr, MPU6050_RA_FIFO_COUNTH, 2, buffer); return (((uint16_t)buffer[0]) << 8) | buffer[1]; } I checked the function "readBytes()" inside I2Cdev.cpp and I found this: I2Cdev::readBytes(uint8_t devAddr, uint8_t regAddr, uint8_t length, uint8_t *data, uint16_t timeout) You see the problem? The function readBytes accepts one last parameter which is "timeout" but the function getFIFOCount uses readBytes without the timeout parameter! That's probably a bug cause sometimes I think the readBytes takes too long to execute and a TIMEOUT SHOULD BE set to avoid the function hanging out forever. I am pretty sure maaaany MAAAANY other people alterady experienced this problem and spent a lot of time trying to understand what went wrong. Some people mistakenly believe it's related to bufffer overflow in the FIFO or because of some non optimized code. It could be the problem but MY PROBLEM FOR ALMOST A FULL YEAR has been this bug reported here. I really hope someone fix this and add a timeout so nobody would spent entire months anymore seeking a problem that's is really hard to track an intermitent.
    1 point
×
×
  • Create New...