kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.03k stars 472 forks source link

doubt in function getMres() #19

Open bar123 opened 9 years ago

bar123 commented 9 years ago

hey kris, it would be helpful for me if you can tell the reason for multiplying 10 with (4912/32760), i got to know that 4912 is magnetic flux density and 32760 is the range of magnetometer.....i found a formula in net HuT = H * 4912/32760 where H is raw data, but why are you multiplying by 10.....is it a constant? i am using ak8975....should i use the same formula? can you please justify?

thanks in advanc

kriswiner commented 9 years ago

I prefer to use milliG so I converted from microTesla.

-----Original Message----- From: bar123 [mailto:notifications@github.com] Sent: August 10, 2015 3:57 AM To: kriswiner/MPU-9250 Subject: [MPU-9250] doubt on function getMres() (#19)

hey kris, it would be helpful for me if you can tell the reason for multiplying 10 with (4912/32760), i got to know that 4912 is magnetic flux density and 32760 is the range of magnetometer.....i found a formula in net HuT = H * 4912/32760 where H is raw data, but why are you multiplying by 10.....is it a constant? i am using ak8975....should i use the same formula? can you please justify?

thanks in advanc

Reply to this email directly or view it on GitHub https://github.com/kriswiner/MPU-9250/issues/19 . https://github.com/notifications/beacon/AGY1qrBVvPf-CyRCffSPok9a-J9RHVgTks5 omHsKgaJpZM4Folnv.gif

bar123 commented 9 years ago

thanks a lot kris, it did help me a lot, i am getting very random & abrupt values for roll, pitch & yaw, i have not used the micros() function & i have not done the averaging part, i have taken deltat =1,

instead my function looks like this

MahonyQuaternionUpdate(data.gx, data.gy, data.gz, gyrData[0]0.007(PI/180), gyrData[1]0.007(PI/180), gyrData[2]0.007(PI/180), data.compmx_mRes, data.compmy_mRes, data.compmz*mRes); where gx, gy & gz are gravity values wrt x, y & z compmx,compmy & compmz are compensated values from magnetometer obtained after calibration, moreover when the chip is flat i am not getting 0 values for roll pitch and yaw, what could be the reason?

kriswiner commented 9 years ago

"data.compmxmRes, data.compmymRes, data.compmz*mRes"

Looks like you are multiplying by mRes in z but not x or y. Is this what you intend?

bar123 commented 9 years ago

no sir m multiplying all compensated magnetometer values of x,y & z with mRes i.e data.compmx * mRes, data.compmy * mRes & data.compmz*mRes

kriswiner commented 9 years ago

Why do you have the asterisk (or multiply) on the z value? Why is is different?

-----Original Message----- From: bar123 [mailto:notifications@github.com] Sent: August 12, 2015 8:51 PM To: kriswiner/MPU-9250 Cc: Kris Winer Subject: Re: [MPU-9250] doubt in function getMres() (#19)

no sir m multiplying all compensated magnetometer values of x,y & z with mRes i.e data.compmxmRes, data.compmymRes & data.compmz*mRes

Reply to this email directly or view it on GitHub https://github.com/kriswiner/MPU-9250/issues/19#issuecomment-130521778 . https://github.com/notifications/beacon/AGY1qiL_KYHMgy4XqdEc0cjMYP51nN_lks5 onAu0gaJpZM4Folnv.gif

bar123 commented 9 years ago

i am multiplying compensated values of x , y & z with resolution of magnetometer

kriswiner commented 9 years ago

I understand what you are intending to do, I am simply asking why in the cases of x and y you have i.e data.compmxmRes but for z you have data.compmz_mRes. Why "_mRes" for the z case and not "mRes" or data.compmzmRes like in the x and y cases?

-----Original Message----- From: bar123 [mailto:notifications@github.com] Sent: August 12, 2015 9:47 PM To: kriswiner/MPU-9250 Cc: Kris Winer Subject: Re: [MPU-9250] doubt in function getMres() (#19)

i am multiplying compensated values of x , y & z with resolution of magnetometer

Reply to this email directly or view it on GitHub https://github.com/kriswiner/MPU-9250/issues/19#issuecomment-130534416 . https://github.com/notifications/beacon/AGY1qnsK97d968IlkVX9lDrH-Ioupyktks5 onBixgaJpZM4Folnv.gif

bar123 commented 9 years ago

here wen i commented it came out lik dat coz i had not given space b/w compmx & mRes.....instead of compmx * mRes it got printed as compmxmRes

kriswiner commented 9 years ago

Well, assuming the coding is correct, what kind of accelerometer and gyro bias calibration have you done? You ought to calculate the bias at rest for these sensors and subtract it off of the scaled data. Bias errors can cause the Euler angles to be off. And when you say the mag is calibrated, do you mean you have read and applied the fused ROM data from the AK8963 or did you also calculate the magnetometer bias correction? Here is a description of what could be done to more fully calibrate the magnetometer:

https://github.com/kriswiner/MPU-6050/wiki/Simple-and-Effective-Magnetometer-Calibration

If you are using my code as a template and are calibrating the sensors properly, I can't understand how you could get non-zero pitch and roll, meaning 0 +/- 1 degree, with the sensor at rest on a flat table. Can you verify that you read 1 g when the sensor is oriented with the z-axis up, the y-axis up, the x-axis up, etc. The readings should be 0, 0, 1 with the 1 g for the up axis and the 0 for the other two to within 10 mg or less when calibrated. The gyro should read ~<10 mdps when at rest on all three axes. You can verify the mag reading by comparing the expected x, y, and z magnetic fields at your location.

bar123 commented 9 years ago

i have calculated the bias at rest for accelerometer & also i have calculated magnetometer bias correction, i have not used the fuse rom data at all

kriswiner commented 9 years ago

You really should use the fuse ROM data, these corrections can be as much as 20%! But their lack is not the cause of the roll/pitch error. What about gyro bias correction? This can be a large effect.

bar123 commented 9 years ago

i have used the gyro values directly....i have not done gyro bias correction coz i don have an idea on how to do it.....for accelerometer v can tak six static positions find min & max values wrt x,y,z & then do scaling & calculate g values.....for magnetometer v r rotating the chip manually, again finding min & max values wrt x,y,x & then again scaling & calculating compensated values......wat about for gyro?

kriswiner commented 9 years ago

Hold it still and average readings. Motionless bias is then subtracted from subsequent data. Same for accel and gyro.

bar123 commented 9 years ago

so sad yaar i tried dat also....not much difference in values of gyro b4 n after calibration..... no luck still m getting non zero values when the chip is flat.....i seriously dono wat the problem is :'(......i hav taken value of deltat to be 1 & i have not used micros() function in my code.....could that be d reason? if so could you tell what exactly ur implementation of micros() does so that i can try it out atleast :( thank you so much for ur kind n valuable reply.....tc