Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPU9150 - Magnetometer/Compass support #2

Open
GOHO opened this issue Dec 27, 2014 · 8 comments
Open

MPU9150 - Magnetometer/Compass support #2

GOHO opened this issue Dec 27, 2014 · 8 comments

Comments

@GOHO
Copy link

GOHO commented Dec 27, 2014

I download your code and compiled this to my Leonardo. It works fine but how do I access the Compass or Magnetometer output? I see only Accel and gyro....

@gregd72002
Copy link
Contributor

MPU9150 has a magnetometer. Compass data (heading) has to be calculated based on the magnetometer data.

To get magnetometer working you will need to alter the sensor initialisation in mpu.cpp:
mpu_set_sensors(INV_XYZ_GYRO I INV_XYZ_ACCEL I INV_XYZ_COMPASS)

And set the sample rate for compass:
mpu_set_compass_sample_rate(50);

To read data: mpu_get_compass_reg(comp,NULL);
Where comp is short[3].

See: https://github.com/rpicopter/AvrMiniCopter/blob/master/arduino/mpu.cpp

@GOHO
Copy link
Author

GOHO commented Dec 27, 2014

Thank you for the quick reply!!!

Merry Christmas!

Greg

Sent from my iPhone

On Dec 27, 2014, at 8:00 AM, gregd72002 [email protected] wrote:

MPU9150 has a magnetometer. Compass data (heading) has to be calculated based on the magnetometer data.

To get magnetometer working you will need to alter the sensor initialisation in mpu.cpp:
mpu_set_sensors(INV_XYZ_GYRO I INV_XYZ_ACCEL I INV_XYZ_COMPASS)

And set the sample rate for compass:
mpu_set_compass_sample_rate(50);

To read data: mpu_get_compass_reg(comp,NULL);
Where comp is short[3].

See: https://github.com/rpicopter/AvrMiniCopter/blob/master/arduino/mpu.cpp


Reply to this email directly or view it on GitHub.

@GOHO
Copy link
Author

GOHO commented Dec 27, 2014

One more question, what file do i add the compass sample rate? Do i add it to the mpu.cpp or my main sketch?

Thanks!
Greg

Sent from my iPhone

On Dec 27, 2014, at 8:00 AM, gregd72002 [email protected] wrote:

MPU9150 has a magnetometer. Compass data (heading) has to be calculated based on the magnetometer data.

To get magnetometer working you will need to alter the sensor initialisation in mpu.cpp:
mpu_set_sensors(INV_XYZ_GYRO I INV_XYZ_ACCEL I INV_XYZ_COMPASS)

And set the sample rate for compass:
mpu_set_compass_sample_rate(50);

To read data: mpu_get_compass_reg(comp,NULL);
Where comp is short[3].

See: https://github.com/rpicopter/AvrMiniCopter/blob/master/arduino/mpu.cpp


Reply to this email directly or view it on GitHub.

@gregd72002
Copy link
Contributor

it should be in mpu.cpp in mympu_open function.
Similar to this: https://github.com/rpicopter/AvrMiniCopter/blob/master/arduino/mpu.cpp#L68

Please do not forget to create a pull request once you are finished.

Thanks

@GOHO
Copy link
Author

GOHO commented Dec 27, 2014

Ok found the set rate for compass in the mpu.cpp but what about the read compass, does that go into the mpu.cpp?

In the main sketch you have
mympu.gyro &
mympu.y.
To read the sensor, does the compass have the same type read command?

Thanks again

Greg

Sent from my iPhone

On Dec 27, 2014, at 8:00 AM, gregd72002 [email protected] wrote:

MPU9150 has a magnetometer. Compass data (heading) has to be calculated based on the magnetometer data.

To get magnetometer working you will need to alter the sensor initialisation in mpu.cpp:
mpu_set_sensors(INV_XYZ_GYRO I INV_XYZ_ACCEL I INV_XYZ_COMPASS)

And set the sample rate for compass:
mpu_set_compass_sample_rate(50);

To read data: mpu_get_compass_reg(comp,NULL);
Where comp is short[3].

See: https://github.com/rpicopter/AvrMiniCopter/blob/master/arduino/mpu.cpp


Reply to this email directly or view it on GitHub.

@GOHO
Copy link
Author

GOHO commented Dec 27, 2014

I appreciate all your help

Im am not sure what you mean by pull request.

G

Sent from my iPhone

On Dec 27, 2014, at 11:29 AM, gregd72002 [email protected] wrote:

it should be in mpu.cpp in mympu_open function.
Similar to this: https://github.com/rpicopter/AvrMiniCopter/blob/master/arduino/mpu.cpp#L68

Please do not forget to create a pull request once you are finished.

Thanks


Reply to this email directly or view it on GitHub.

@gregd72002
Copy link
Contributor

it should go to mpu.cpp

As for the pull request I meant to contribute your work to this project.
See: https://help.github.com/articles/using-pull-requests/

@gregd72002 gregd72002 changed the title MPU9150 MPU9150 - Magnetometer/Compass support Dec 27, 2014
@GOHO
Copy link
Author

GOHO commented Dec 27, 2014

Hi Greg, I put the commands in the mpu.cpp and the sketch compiles ok until I try and call up the compass.
I used the command "mympu.comp[0]"
but this is the error I get....

This report would have more information with "Show verbose output during compilation" enabled in File > Preferences.Arduino: 1.0.6 (Windows 7), Board: "Arduino Leonardo"AvrCopter.ino: In function 'void loop()':AvrCopter:44: error: 'struct s_mympu' has no member named 'comp'

Im really sorry for being a pain in the Ass!!! I sure appreciate your help in getting this to compile and run...

How should I call up the compass in my sketch to see my heading? I would try the link you sent me but the leonardo does not have enough memory to run it...

Greg Bounds772-571-7911

Date: Sat, 27 Dec 2014 08:53:33 -0800
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [ArduinoMotionSensorExample] MPU9150 (#2)

it should go to mpu.cpp

As for the pull request I meant to contribute your work to this project.

See: https://help.github.com/articles/using-pull-requests/


Reply to this email directly or view it on GitHub.

                  =

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants