View Single Post
  #11   Spotlight this post!  
Unread 03-02-2016, 20:16
RyanN's Avatar
RyanN RyanN is offline
RyanN
AKA: Ryan Nazaretian
FRC #4901 (Garnet Squadron)
Team Role: Mentor
 
Join Date: Jun 2006
Rookie Year: 2005
Location: Columbia, SC
Posts: 1,126
RyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond reputeRyanN has a reputation beyond repute
Re: MPU-9150 (I2C) with Labview

Quote:
Originally Posted by RyanN View Post
I used the MPU-9150 a few years ago on my senior design project for college. It was a pain in the butt to get the magnetometer working. The accelerometer and gyro were relatively easy though.

Please post your code and I'll take a look at it.
Told ya so!

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];		
}
You can find those register constants in https://github.com/sparkfun/MPU-9150...6050/MPU6050.h
__________________
Garnet Squadron
FRC 4901
Controls Mentor
@rnazaretian

Previous mentor and student from Team Fusion, FRC 364
Reply With Quote