Jump to content
I2Cdevlib Forums

Why should I wait for MPU interrupt (sometimes very long!!!)


Recommended Posts

Hello all!

I am running MPU 6050 example.

 

Every time after burning arduino i see this in the com port monitor:

 

Initializing I2C devices...

Testing device connections...
MPU6050 connection successful
 
Send any character to begin DMP programming and demo: 
Initializing DMP...
Enabling DMP...
Enabling interrupt detection (Arduino external interrupt 0)...
DMP ready! Waiting for first interrupt...

And this waiting can last VERY long...

 

When I delete this while loop:

    while (!mpuInterrupt && fifoCount < packetSize) {
        // other program behavior stuff here
        // .
        // .
        // .
        // if you are really paranoid you can frequently test in between other
        // stuff to see if mpuInterrupt is true, and if so, "break;" from the
        // while() loop to immediately process the MPU data
        // .
        // .
        // .
    }

Everything works OK... No waiting at all, and I see data immediately.

 

This is the question. Must I wait for interrupt or I can read data from MPU (mpu.dmpGetXXXXXXXX) every time I need?

Link to comment
Share on other sites

Well, if it works for you... then I guess you can read it using (mpu.dmpGetXXXXXXXX) every time you want, but be sure to read it at a faster frecuency than DMP is running, or fifo will overflow.

Anyway, I haven't checked how does this (mpu.dmpGetXXXXXXXX) function work, so I am only speculating.

 

Besides, this long wait you mention has never happened to me. Are you sure that INT pin is connected where it should be connected?

Link to comment
Share on other sites

Well, if it works for you... then I guess you can read it using (mpu.dmpGetXXXXXXXX) every time you want, but be sure to read it at a faster frecuency than DMP is running, or fifo will overflow.

Anyway, I haven't checked how does this (mpu.dmpGetXXXXXXXX) function work, so I am only speculating.

 

Besides, this long wait you mention has never happened to me. Are you sure that INT pin is connected where it should be connected?

 

Thanks, luisrodenas, for your reply!

 

Here is how I connected MPU to my Arduino UNO:

MPU_table.jpg

Is it right?

And what frequency has DMP?

Link to comment
Share on other sites

That's rigth if you only want to use RAW values... or if you read fifo whenever you want...  but the optimal way is by interruptions.

 

Read the DMP sketch's comments. In order to use interruptions you have to connect your MPU's INT pin to Arduino UNO's 0 pin.

 

By default DMP runs at 100Hz, but can be modified if you want to. (Max is 200Hz)

Link to comment
Share on other sites

  • 2 years later...

Hi there,

This thread is interresting for me cause i have a problem with MPU6050.

It works fine with my standalone ATMEGA328P but when i want to make it work with my GPS unit (works fine alone), the gyro is too intrusive and the gps freeze after a while.

I try to get rid of the interrupt but i can't get anything exept "nan" instead of the pitch and roll value.

I took the DMP code for my sketch.

Any idea to get the values without interrupt ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...