Jump to content
I2Cdevlib Forums

gilperon

Members
  • Posts

    10
  • Joined

  • Last visited

  • Days Won

    2

gilperon last won the day on August 20 2016

gilperon had the most liked content!

Recent Profile Visitors

1,227 profile views

gilperon's Achievements

Newbie

Newbie (1/14)

3

Reputation

  1. Is this forum up? Nobody looks to answer anything here...
  2. All the codes of this page are hanging/freezing after about 20 seconds. Does anybody knows why? //Código do MPU6050. #include "MPU6050_6Axis_MotionApps20.h" MPU6050 mpu; uint8_t mpuIntStatus; uint16_t packetSize; uint16_t fifoCount; uint8_t fifoBuffer[64]; Quaternion q; VectorFloat gravity; float ypr[3]; void setup() { //Código do MPU6050. Wire.begin(); TWBR = 24; mpu.initialize(); mpu.dmpInitialize(); mpu.setXAccelOffset(-1343); mpu.setYAccelOffset(-1155); mpu.setZAccelOffset(1033); mpu.setXGyroOffset(19); mpu.setYGyroOffset(-27); mpu.setZGyroOffset(16); mpu.setDMPEnabled(true); packetSize = mpu.dmpGetFIFOPacketSize(); //Por algum motivo se utilizar "9600" aparece erro "FIFO overflow!". //COMENTAR_OFICIAL Serial.begin(115200); } void loop() { while (fifoCount < packetSize) { //do stuff fifoCount = mpu.getFIFOCount(); } if (fifoCount == 1024) mpu.resetFIFO(); else { fifoCount = mpu.getFIFOCount(); mpu.getFIFOBytes(fifoBuffer, packetSize); mpu.resetFIFO(); fifoCount -= packetSize; mpu.dmpGetQuaternion(&q, fifoBuffer); mpu.dmpGetGravity(&gravity, &q); mpu.dmpGetYawPitchRoll(ypr, &q, &gravity); //COMENTAR_OFICIAL Serial.print("ypr\t"); Serial.print(ypr[0]*180/PI); Serial.print("\t"); Serial.print(ypr[1]*180/PI); Serial.print("\t"); Serial.print(ypr[2]*180/PI); Serial.println(); } }
  3. 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.
  4. Hi, I am pretty sure Jeff's MPU6050 library is the best in the internet to retrieve ypr angles from MPU6050 using the DMP on arduino. It's a really good library but it's not easy to beginners cause the way the basic Arduino code to retrieve ypr from the DMP is a little complicated. Anyway, after spending almost 3 months I am confident I understand very well the code and it works really fine. But I found a problem: sometimes I really need to execute some routine that can take up to 3 to 10 seconds and Jeff's code simply crashes. Sometimes Arduino freezes and no FIFO OVERFLOW error message is displayed, other times the error message is displayed. I know that using DMP relies on interrupt and my code must be really really really optimize in order to not hang arduino for too long. So I decided that before doing my routine I should do mpu.setDMPEnabled(false) and after I finish my routine I should do mpu.setDMPEnabled(true);. But there is a problem: after I execute mpu.setDMPEnabled(true); the MPU6050 restarts its internal "calibration" algorithm and takes at least 5 to 8 seconds to get solid readings to ypr. Doing the method above I can at least prevent fifo overflow or my arduino to freeze, but it creates another problem cause now my new readings (after mpu.setDMPEnabled(true) are not precise anymore for at least 5-8 seconds. Is there someway to ignore DMP readings without overflowing the buffer and at the same time doing something else so in the future I can start to pay "attention" again to DMP and keep reading its angles without any recalibration?
  5. Thank you so much! My problem is that smoetimes my arduino freezes and I need to restart it but there is no FIFO OVERFLOW message in the serial. Maybe JEFF R. library is not reseting the fifo when it should and causing my arduino to freeze?
  6. Thank you so much luisrodenas! I agree, probably there is no way to get angles without DMP. I will have to live with that But I would like to ask you one question: do you know how to force a read in the buffer? For example, if I have a function that I know is very slow, how can I force a few readings from the sensor during my function execution? Is there some way to do this: long running code... readDmp(); readDmp(); readDmp(); long running code... ? Also, is there someway I can discover if the buffer is getting full?
  7. Does anybody know how to check if the buffer is getting close to overflow? Is there any conditional that I can use to check if the buffer is almost full? Also, if after the check I realize the buffer is about to overflow, is it possible to clear the last 10 readings?
  8. Hi everyone, I am using in the last months the really nice library provided by Jeff which is A M A Z I N G. Thank you man I am using it in my quadcopter and works really nice (thank you again). But there is a problem: I dont like the idea of using sensor fusion cause it is too complicated to setup with arduino and also uses too much proccessing power from my arduino. That's why I am using the DMP angle values from the MPU6050. The problem is this, after days trying to find a solution: I would like someway to obtain angles from MPU6050 DMP calling a function "get_angles()" not using interrupt pin or the buffer. The reason is that I make many other computation in arduino and frequently the buffer of MPU6050 overflows and my quad get out of control and fall. I already reduced the frequency that the buffer gets populated to the minimum but I still sometimes get overflows. That's why I would like to know if there is some way I could retrieve angles from MPU6050 using a function exactly like "mpu.getMotion6" but with angles, not with giro and accel data. Thank you so much, you helped me a lot with this great and very well documented library.
×
×
  • Create New...