Jump to content
I2Cdevlib Forums
Jmakin23

Multiple MPU6050's using DMP and interrupts

Recommended Posts

Hi,

I am new to this so please bear with me. My current project requires that i use multiple MPU6050's in order to track the motion of a person.

I am aware that the MPU6050 has two addresses and that in the code supplied by jeff you can state which address on the I2C bus to read from.

The problem is with the use of the DMP code and interrupts, am I able to attach the second IMU to the alternate interrupt pin on the Arduino Pro Mini that I am using? If i was to do this what would i have to do in the example code and/or the libraries in order to determine which interrupt is read etc.

 

I have tried to interpret the libraries to see if there was a line of code that states which interrupt pin is being used but i quite frankly dont know what i am looking at or looking for.

 

I hope that someone will be able to help me.

 

Thanks

Share this post


Link to post
Share on other sites

The MPU6050.* files (the actual device libraries) don't have any of the actual interrupt detection or pin assignment code in them; this is found in the MPU6050_DMP6.ino example sketch, specifically (at the moment) on line 196:

 

https://github.com/jrowberg/i2cdevlib/blob/master/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino#L196

        // enable Arduino interrupt detection
        Serial.println(F("Enabling interrupt detection (Arduino external interrupt 0)..."));
        attachInterrupt(0, dmpDataReady, RISING);
        mpuIntStatus = mpu.getIntStatus(); 

This uses interrupt 0, which on the Arduino Uno is digital pin 2. You would need to assign an additional interrupt with a different pin connection, and duplicate the "dmpDataReady" function (perhaps into "dmpDataReady2") and set a new "mpuIntStatus2" variable which can be tested in the main loop.

Share this post


Link to post
Share on other sites

1. Is there a way to use other pin as interrupt other than pin 0 on DUE?  2. I discover that interrupt does not response when there is no serial data passing pin 0 - So,  I have to send just any data on the loop() like Serial.print("anything") to create interrupt. Is this the whole idea why it is on pin 0? or I am missing something.

 

Thanks

Share this post


Link to post
Share on other sites

Regarding your first question:

 

1. Is there a way to use other pin as interrupt other than pin 0 on DUE?

I don't have DUE but this site:

http://arduino.cc/en/Reference/attachInterrupt

says that it should be possibe.

 

The Arduino Due board has powerful interrupt capabilities that allows you to attach an interrupt function on all available pins. You can directly specify the pin number in attachInterrupt().

So just use another pin and change this fragment of code:

attachInterrupt(0, dmpDataReady, RISING);

To be honest I didn't understand the second question.

Share this post


Link to post
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...

×
×
  • Create New...