Programming two IMU6050's

Hi there all.

after getting some brilliant help from this forum i have managed to get my arduino to recognise both accelerometers. (addresses 0x68 and 0x69, using AD0 plugged in to the 3.3V pin). My problem now is getting the code to recognise both the accelerometers, receive/accept/ print the data, and then save it to an SD card. The SD card part i’m not worried about, however getting the data to the serial monitor i’m having trouble with.

In some programs like matlab you can print the data by naming the data as a separate variable, and then calling it to the command window/ serial monitor. Is that how i should approach this?

I have found a programme based on Jeff Rowbergs code which prints both but i am unsure on how to modify it to have the results on one line instead of on two, like below;

WorldAcc 0: 53.75 -37.82
WorldAcc 1: -51.95 -49.25

I would like;

WorldAcc: 53.75 -37.82 -51.95 -49.25

I know you can do the above with “OUTPUT_SERIAL.print(”\t");". but i cannot find the second accelerometer data to do this with. Any help would be greatly appreciated as i could do with this done by wednesday if i can pull my finger out.

Thanks

MPU6050_DMP6.ino (15.5 KB)

MPU6050_DMP6_Multiple.ino (14.1 KB)

I would like;

WorldAcc: 53.75 -37.82 -51.95 -49.25

Use Serial.print()s for data on the same line, perhaps with "\t" between them to output a tab between data items, then Serial.println() for the final data item to move to the next line ready for the next output.

Hi there

I managed to find that, it was more trying to find the variable to Serial.print. In the “MPU6050 Multiple” file, i can’t find the variable to use that function on. Instead they used “currentMPU”. Whereas in Jeff Rowbergs, it states the address earlier on

// class default I2C address is 0x68
// specific I2C addresses may be passed as a parameter here
// AD0 low = 0x68 (default for SparkFun breakout and InvenSense evaluation board)
// AD0 high = 0x69
MPU6050 mpu;
//MPU6050 mpu(0x69); // <-- use for AD0 high

But i can’t see that anywhere else in the code. I’ve tried searching this but there isn’t much on the actual changes required to code for one MPU to two

So been searching through the code and still can't work it out. Can anyone tell me how the variable MPU6050 has been defined? all it says in the code is this;

[/code]
#include "I2Cdev.h"

#include "MPU6050_6Axis_MotionApps20.h"

#if I2CDEV_IMPLEMENTATION == I2CDEV_ARDUINO_WIRE
#include "Wire.h"
#endif

MPU6050 mpu;
MPU6050 mpu(0x69);

#define OUTPUT_READABLE_REALACCEL[/code]

In matlab for example i would expect it that you could write something like;

mpu1 (0x68)
mpu2 (0x69)
...

Serial.print("areal_mpu1\t");
Serial.print(aaReal_mpu1.x);
Serial.print("\t");
Serial.print(aaReal_mpu1.y);
Serial.print("\t");
Serial.println(aaReal_mpu1.z);

Serial.print("areal_mpu2\t");
Serial.print(aaReal_mpu2.x);
Serial.print("\t");
Serial.print(aaReal_mpu2.y);
Serial.print("\t");
Serial.println(aaReal_mpu2.z);

How can you define the two (or more) MPU's as searate variables to be printed separately? Thanks

EDIT:

found that by changing;

MPU6050 mpu;
MPU6050 mpu(0x69);

to;

MPU6050 mpu(0x68);
MPU6050 mpu1(0x69);

then it recognises both the variables. I found some code someone wrote that includes both variables and i have modified it to output real acceleration rather than the YPR he was using. My problem is that now, when i start the serial monitor i get "FIFO Overflow". the whole thing is below;

[/code]Initializing I2C devices...
Testing device connections...
MPU6050 connection successful
MPU6050 2nd connection successful

Send any character to begin DMP programming and demo:

i then press a button and i get;

[code]Initializing I2C devices...
Testing device connections...
MPU6050 connection successful
MPU6050 2nd 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...
Initializing DMP 2 ...
Enabling DMP 2...
Enabling interrupt detection (Arduino external interrupt 0)...
DMP 2 ready! Waiting for first interrupt...
FIFO overflow![code]

What does this mean? is it that there is too much data going to the board? Is it possible to increase the FIFO buffer? or am i missing something more basic than this? Currently i have the board wired up as below

arduino pin - sensor pin
5V - MPU 1 & 2 VCC
GND - MPU 1 & 2 GND
A4 - MPU 1 & 2 SCL
A5 - MPU 1 & 2 SDA
3V3 - MPU 2 AD0
DIGITAL 2 - MPU 1 & 2 INT


Does the second MPU INT need its own pin on the board?