kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.04k stars 470 forks source link

Magnetometer resolution change #240

Open cero10 opened 6 years ago

cero10 commented 6 years ago

Hello, first of all i want to thank you for your project they are really useful to me.

I am using your MPU9250BasicAHRS.ino project, i would like to know the exact lines i should use to change mpu9250 magnetometer's sample rate of to 100hz, if im right that is the 16bit resolution.. And what function should i call to know at what resolution the accel and gyro are working.

kriswiner commented 6 years ago

uint8_t Mscale = MFS_16BITS; // Choose either 14-bit or 16-bit magnetometer resolution uint8_t Mmode = 0x02; // 2 for 8 Hz, 6 for 100 Hz continuous magnetometer data read

On Wed, Feb 28, 2018 at 9:05 AM, cero10 notifications@github.com wrote:

Hello, first of all i want to thank you for your project they are really useful to me.

I am using your MPU9250BasicAHRS.ino project, i would like to know the exact lines i should use to change mpu9250 magnetometer's sample rate of to 100hz, if im right that is the 16bit resolution.. And what function should i call to know at what resolution the accel and gyro are working.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qu5KcR9nKcDjZm4fLaghbv26NCb4ks5tZYZlgaJpZM4SW_8r .

cero10 commented 6 years ago

I do not understand why is this happening, i got a " 'MFS_16BITS' was not declared in this scope" error message. Isn't uint8_t Mscale = MFS_16BITS; a declaration?

the uint8_t Mmode = 0x02; line alone did not change the sample rate for me.

kriswiner commented 6 years ago

I thought you said you were using the above sketch? Those lines are in the sketch...

On Wed, Feb 28, 2018 at 10:34 AM, cero10 notifications@github.com wrote:

I do not understand why is this happening, i got a " 'MFS_16BITS' was not declared in this scope" error message. Isn't uint8_t Mscale = MFS_16BITS; a declaration?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369337547, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1quosCiBwxRST4fZsphdTYfSP92Amks5tZZxMgaJpZM4SW_8r .

cero10 commented 6 years ago

I am using MPU9250BasicAHRS.ino and i do not see them anywhere. Should i use the MPU9250BasicAHRS_t3.ino that contain those lines?? because i am using the non-t3 version..

kriswiner commented 6 years ago

Lines 226/227

On Wed, Feb 28, 2018 at 10:45 AM, cero10 notifications@github.com wrote:

I am using MPU9250BasicAHRS.ino and i do not see them anywhere. Should i use the MPU9250BasicAHRS_t3.ino that contain those lines?? because i am using the non-t3 version..

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369340894, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qkhQiYk8OEnF3L5VtCVLp5WePqFjks5tZZ7UgaJpZM4SW_8r .

cero10 commented 6 years ago

can you point me to your i2c_t3.h library? i cant find it and there are various declaration problems when running your sketch without your i2c lib.

kriswiner commented 6 years ago

Teensy forum

On Wed, Feb 28, 2018 at 11:17 AM, cero10 notifications@github.com wrote:

can you point me to your i2c_t3.h library? i cant find it and there are various declaration problems when running your sketch without your i2c lib.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369350941, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qu76etcN3VhKRHeHQZrsQa9TxJqYks5tZaY0gaJpZM4SW_8r .

cero10 commented 6 years ago

Is this sketch only for teensy? Becaus i have arduino uno wifi

kriswiner commented 6 years ago

Which sketch?

On Wed, Feb 28, 2018 at 11:40 AM, cero10 notifications@github.com wrote:

Is this sketch only for teensy?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369358061, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qr5-hxdb5oeGTjp0AnSyHY1AXpSLks5tZauWgaJpZM4SW_8r .

cero10 commented 6 years ago

MPU9250BasicAHRS_t3.ino

kriswiner commented 6 years ago

MPU9250BasicAHRS_t3.ino

requires Teensy and i2c_t3.h wire library.

On Wed, Feb 28, 2018 at 11:54 AM, cero10 notifications@github.com wrote:

MPU9250BasicAHRS_t3.ino

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369362297, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qmahbRT4OifRhhkpxedwGO71RwRyks5tZa7ZgaJpZM4SW_8r .

cero10 commented 6 years ago

So i should use the MPU9250BasicAHRS.ino? if yes, how to change res and sample rate for arduino?

kriswiner commented 6 years ago

I already told you

On Wed, Feb 28, 2018 at 12:04 PM, cero10 notifications@github.com wrote:

So i should use the MPU9250BasicAHRS.ino? if yes, how to change res and sample rate for arduino?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369365335, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qoCLe-EuNp7VItygy7o6yKxNfccKks5tZbFAgaJpZM4SW_8r .

cero10 commented 6 years ago

So lets summarize, i am using the MPU9250BasicAHRS.ino (which does not contain those 2 lines)

uint8_t Mscale = MFS_16BITS;

uint8_t Mmode = 0x02;

and i still get the "was not declared in this scope" error ONLY for the Mscale=MFS_16BITS. So can you help me or is there something else i am not doing right?

kriswiner commented 6 years ago

Help me out here, can you tell me what is on lines 226/227 of this sketch:

https://github.com/kriswiner/MPU9250/blob/master/MPU9250BasicAHRS.ino

and if you try to compile this, are you saying you get an error?

I would try this sketch anyway:

https://github.com/kriswiner/MPU9250/tree/master/MPU9250_ BME280_SPIFlash_Ladybug

the one you are using is very old. But you will have to make some changes unless you are using a Ladybug dev board.

On Wed, Feb 28, 2018 at 12:42 PM, cero10 notifications@github.com wrote:

So lets summarize, i am using the MPU9250BasicAHRS.ino (which does not contain those 2 lines)

uint8_t Mscale = MFS_16BITS;

uint8_t Mmode = 0x02;

and i still get the "was not declared in this scope" error ONLY for the Mscale=MFS_16BITS. So can you help me or is there something else i am not doing right?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369375974, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qvUfUkNBN7WmtCUJH0pFQGYRf16aks5tZbpPgaJpZM4SW_8r .

kriswiner commented 6 years ago

I think the problem is you need to add the quaternionFilters.ino file to your sketch tab.

On Wed, Feb 28, 2018 at 12:49 PM, Tlera Corporation tleracorp@gmail.com wrote:

Help me out here, can you tell me what is on lines 226/227 of this sketch:

https://github.com/kriswiner/MPU9250/blob/master/MPU9250BasicAHRS.ino

and if you try to compile this, are you saying you get an error?

I would try this sketch anyway:

https://github.com/kriswiner/MPU9250/tree/master/MPU9250_BME 280_SPIFlash_Ladybug

the one you are using is very old. But you will have to make some changes unless you are using a Ladybug dev board.

On Wed, Feb 28, 2018 at 12:42 PM, cero10 notifications@github.com wrote:

So lets summarize, i am using the MPU9250BasicAHRS.ino (which does not contain those 2 lines)

uint8_t Mscale = MFS_16BITS;

uint8_t Mmode = 0x02;

and i still get the "was not declared in this scope" error ONLY for the Mscale=MFS_16BITS. So can you help me or is there something else i am not doing right?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369375974, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qvUfUkNBN7WmtCUJH0pFQGYRf16aks5tZbpPgaJpZM4SW_8r .

cero10 commented 6 years ago

I found my mistake, i was probably using an old version of MPU9250BasicAHRS.ino which i download along with your depository. As i see this MPU9250BasicAHRS.ino is totally different. Anyway i tried to run it (with quaternionfilters.ino) and it stopped at MahonyQuaternionUpdate(..); it was missing the deltat, added the deltat, so this time i uploaded it be the mpu9250 is FF and it should be 71. although i was getting values normally with most of sketches.

kriswiner commented 6 years ago

Try changing this #define ADO 1 to 0

On Wed, Feb 28, 2018 at 1:20 PM, cero10 notifications@github.com wrote:

I found my mistake, i was probably using an old version of MPU9250BasicAHRS.ino which i download along this your depository. As i see this MPU9250BasicAHRS.ino https://github.com/kriswiner/MPU9250/blob/master/MPU9250BasicAHRS.ino is totally different. Anyway i tried to run it (with quaternionfilters.ino) and it stopped at MahonyQuaternionUpdate(..); it was missing the deltat, added the deltat, so this time i uploaded it be the mpu9250 is FF and it should be 71. although i was getting values normally with most of sketches.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369386947, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qgp35NqXw9HvhOMykGTQklbd3j0aks5tZcM2gaJpZM4SW_8r .

cero10 commented 6 years ago

Yep it works now. so i got some problems, the q0,qx,qy,qz are constantly {1.0.0.0} so im guessing it has something to do with the MahonyQuaternionUpdate(..);?? and by default it's using the mahony filter, what are the advantages over Madgwich

kriswiner commented 6 years ago

You need to calibrate your sensors. I would switch to a different sketch.

On Wed, Feb 28, 2018 at 1:42 PM, cero10 notifications@github.com wrote:

Yep it works now. so i got some problems, the q0,qx,qy,qz are constantly {1.0.0.0} so im guessing it has something to do with the MahonyQuaternionUpdate(..);?? and by default it's using the mahony filter, what are the advantages over Madgwich

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369393133, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qt6f-KrBiPXKroi4yX6am2W3gFZ4ks5tZchOgaJpZM4SW_8r .

cero10 commented 6 years ago

ok then, one last question. Is there a possibility that i get a pitch that doesn't get affected by high dynamics with either Mahony or Madgwick filter?

kriswiner commented 6 years ago

I don;t understand the question, what does high dynamics mean?

On Wed, Feb 28, 2018 at 1:57 PM, cero10 notifications@github.com wrote:

ok then, one last question. Is there a possibility that i get a pitch that doesn't get affected by high dynamics with either Mahony or Madgwick filter?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369397148, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qlc3tC5NOVmNZ44NGXj1XUocZApIks5tZcuxgaJpZM4SW_8r .

cero10 commented 6 years ago

I mean that when you rotate the sensor slowly it shows you accurately the pitch and roll but when you make sudden movements the accel values are all over the place so the pitch/roll are wrong too. I am literally asking if the Mahony or Madgwick filter will almost zero that error by throwing gyro and mag values into the formula?

kriswiner commented 6 years ago

Should do

On Wed, Feb 28, 2018 at 2:17 PM, cero10 notifications@github.com wrote:

I mean that when you rotate the sensor slowly it shows you accurately the pitch and roll but when you make sudden movements the accel values are all over the place so the pitch/roll are wrong too. I am literally asking if the Mahony or Madgwick filter will almost zero that error by throwing gyro and mag values into the formula?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU9250/issues/240#issuecomment-369402845, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qvzYfePelR-N7AMbrXLDhcyGYentks5tZdCVgaJpZM4SW_8r .

cero10 commented 6 years ago

ok then thank you very much. you were really helpful man!!