![]() |
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 |
Re: MPU-9150 (I2C) with Labview
Quote:
Please post your code and I'll take a look at it. |
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 |
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. |
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 |
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. |
Re: MPU-9150 (I2C) with Labview
Quote:
We also tried the temperature reading using address 0x68 instead of 0x69, but we got the same result |
Re: MPU-9150 (I2C) with Labview
2 Attachment(s)
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. |
Re: MPU-9150 (I2C) with Labview
Quote:
|
Re: MPU-9150 (I2C) with Labview
Quote:
|
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) { |
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 magnetometerThanks for pointing it out! |
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. |
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? |
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 |
Re: MPU-9150 (I2C) with Labview
Quote:
Here's the code. We are setting the mag as a slave so we can read the values from the MPU. We alsot tried reading the values directly from the mag, but it's the exact same issue: Periodic tasks: MPU Initialize: ![]() Read Compass VI: ![]() Read Burst VI: ![]() |
Re: MPU-9150 (I2C) with Labview
Man that config is long and scary...
The way you're reading the magnetometer looks fine. Just to note, it's not going to give you degrees, but rather, magnetic flux. The data sheet says the values can range from -4096 to +4095 (13-bit signed integer). 4095 represents 1229 µT, and 1 represents 0.3 µT. (micro Teslas) Unless you use a magnet, you're not going to see any readings near those extremes. http://mythopoeic.org/magnetometer/ It's been a while since I've messed with this stuff, but there is a NOAA calculator that you can use to get an idea of how strong the magnetic flux is in your area. http://www.ngdc.noaa.gov/geomag-web/ I wouldn't expect anything over 50 µT in our area unless an external source is applied (such as a magnet, motor, electromagnet). |
Re: MPU-9150 (I2C) with Labview
Quote:
|
Re: MPU-9150 (I2C) with Labview
It might be easier to use use the example Arduino code and hook the sensor up to an Arduino and communicate over serial port with Arduino which would read the sensor values and send them to your LabView program.
The 9150 has more than 100 registers and the compass on it is a separate I2C device which the 9150 accesses over its own internal I2C bus. I recommend code from Kris Winer on github. Also the 9150 is no longer available and got replaced with 9250 which is mostly compatible except for some of the calibration. You can also use my code on github (uutzinger). Teensy works well as Arduino replacement. Making USB serial communication work with RoboRIO is not trivial either. |
Re: MPU-9150 (I2C) with Labview
Quote:
At the moment we're sticking with the normal gyro, but we already had the Arduino in mind. One thing that will make that process complicated is opening a communication with the sensor AND the rio at the same time. |
| All times are GMT -5. The time now is 01:23. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi