|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
MPU-9150 (I2C) with Labview
Hello everyone,
This year, our team decided to go ahead and use an extra motion tracking devide. We opted for the MPU-9150, but we are having problems getting it to work with Labview. It is connected to the roboRIO's onboard I2C, and we based our Labview code on this Arduino example: http://playground.arduino.cc/Main/MPU-9150 After hours of trying to get a response from it, we haven't had any success. I'll upload the code later today Last edited by Ian R. : 02-02-2016 at 10:04. |
|
#2
|
||||
|
||||
|
Re: MPU-9150 (I2C) with Labview
Quote:
Please post your code and I'll take a look at it. |
|
#3
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
Quote:
Periodic Tasks: ![]() MPU Config VI: ![]() Read HL VI: ![]() We've tried with MPU address 0x68 and 0x69, but no luck so far Last edited by Ian R. : 02-02-2016 at 17:29. |
|
#4
|
||||
|
||||
|
Re: MPU-9150 (I2C) with Labview
Can you include your I2C Open code as well (probably stuck in the Begin.vi)?
Your config code looks messed up. Why are you re-opening so many times? You only need to do one 'open'. The device address is stored after that. Your config should happen before you start your while loop. Currently, you're trying to do two things at once. Use the Error block to control the order of execution. Comment what your config code is doing at each point. Monitor the error outputs. If it can't communicate, it will tell you. Last edited by RyanN : 03-02-2016 at 08:11. |
|
#5
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
Quote:
All we do inside the begin.vi is open the I2C with the I2C On-board bus and 0x69 address. I'll post the code later on today. About the error outputs, there's no error at all. We also tried to clear just the sleep byte at 0x6B inside the begin.vi and then read raw values from the temperature sensor at 0x41 and 0x42 while in timed tasks, but we got no response |
|
#6
|
||||
|
||||
|
Re: MPU-9150 (I2C) with Labview
Quote:
My recommendation is to keep it as simple as possible. I think reading the temperature is a good start. Don't try anything else until you get that working. So, create a minimum programming sequence to get the temperature. Once you get that working, start implementing other stuff such as setting the gains. Last edited by RyanN : 03-02-2016 at 08:59. |
|
#7
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
We're using Sparkfun's SEN-11486 (https://www.sparkfun.com/products/11486)
We also tried the temperature reading using address 0x68 instead of 0x69, but we got the same result Last edited by Ian R. : 03-02-2016 at 09:07. |
|
#8
|
||||
|
||||
|
Re: MPU-9150 (I2C) with Labview
Quote:
I have no idea if my code works since I no longer have an MPU-9150, but maybe it'll point out your problem. |
|
#9
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
Thanks, I'll give it a try later today and post the results
|
|
#10
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
Ok, did some tweaking and it worked. I added the gyro and accelerometer too, BUT the magnetometer is still an issue. According to the Arduino code I was refering to, as well as the GitHub example linked in the Sparkfun page, you have to open a new channel with device 0x0C, which is the magnetometer, and then set the register 0x0A to 0x01, but the issue is there is NO 0x0C device.
|
|
#11
|
||||
|
||||
|
Re: MPU-9150 (I2C) with Labview
Quote:
It's been three years since I messed with it. So the magnetometer is a 3rd party sensor. InvenSense doesn't make it... they just buy the silicon and wire it up inside the little chip you have, then slap black plastic and their logo on top. (I think it's really an MPU 6050 core with a magnetometer wired up). The magnetometer is hidden behind the auxiliary I2C bus on the IMU. You have to talk through the auxiliary bus in order to talk to the magnetometer. You can setup the IMU to go into pass-through mode. I wish I had access to my old code (Thanks IT for deleting it). This might get you started: https://github.com/sparkfun/MPU-9150...50/MPU6050.cpp Code:
void MPU6050::getMotion9(int16_t* ax, int16_t* ay, int16_t* az, int16_t* gx, int16_t* gy, int16_t* gz, int16_t* mx, int16_t* my, int16_t* mz) {
//get accel and gyro
getMotion6(ax, ay, az, gx, gy, gz);
//read mag
I2Cdev::writeByte(devAddr, MPU6050_RA_INT_PIN_CFG, 0x02); //set i2c bypass enable pin to true to access magnetometer
delay(10);
I2Cdev::writeByte(MPU9150_RA_MAG_ADDRESS, 0x0A, 0x01); //enable the magnetometer
delay(10);
I2Cdev::readBytes(MPU9150_RA_MAG_ADDRESS, MPU9150_RA_MAG_XOUT_L, 6, buffer);
*mx = (((int16_t)buffer[1]) << 8) | buffer[0];
*my = (((int16_t)buffer[3]) << 8) | buffer[2];
*mz = (((int16_t)buffer[5]) << 8) | buffer[4];
}
|
|
#12
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
Quote:
Code:
I2Cdev::writeByte(devAddr, MPU6050_RA_INT_PIN_CFG, 0x02); //set i2c bypass enable pin to true to access magnetometer Thanks for pointing it out! |
|
#13
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
Quote:
But anither issue arised. While we can read from all the low byte registers, the high ones always return 0. We tried communicating with the mag directly, as well as through the MPU, but it's the same problem. I'm not sure if we have to read each independent register and then shift the high one and add the low one to it, or if we should read the low register and ask for 2 bytes. |
|
#14
|
||||
|
||||
|
Re: MPU-9150 (I2C) with Labview
Quote:
Quote:
I'm not sure what's going on from your description. Mind sharing your current LabVIEW code? |
|
#15
|
|||
|
|||
|
Re: MPU-9150 (I2C) with Labview
Quote:
We tried to rotate the sensor all the way around, but the MSB wasn't returning anything, and the LSB is just ranging from 20 to 50 |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|