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

Calibration values question #19

Open
jc508 opened this issue Nov 3, 2017 · 9 comments
Open

Calibration values question #19

jc508 opened this issue Nov 3, 2017 · 9 comments

Comments

@jc508
Copy link

jc508 commented Nov 3, 2017

Hi,
Thanks for this but I hope you have time for a couple of questions about the code...
I am trying to convert this for use on a QMC5883L chip (sometimes you just have to work with what arrives).
This says its 16bit but does not actually say anywhere what unit-of-measure the registers return, just that they are 16 bit integer from -32768 to 32767.
It also does not have any factory calibration nor scale - or none that are published anyway.

so for the lines of code like ...
dest1[0] = (float) mag_bias[0] * mRes * MPU9250magCalibration[0];
mx = (float)magCount[0]mResmagCalibration[0] - magBias[0];
I have eliminated MPU9250magCalibration

In the main program I have also found you have defined mres for 16bit values as.......
mRes = 10.*4912./32760.0

Can you please explain the magic of these values ?

My original sketch had simply
float heading = (atan2((float)y,(float)x));
headingDegrees = (heading * C_rad_to_deg);
this mostly worked except for non-linear values < 50degrees - whereupon people tell me I have to calibrate the animal first !

I think I understand adjusting by the bias ie "- magBias[0]"
and scaling ie mx *= magScale[0];
but the presence of mRes is escaping me.

Thanks in anticipation
JC

@kriswiner
Copy link
Owner

kriswiner commented Nov 3, 2017 via email

@maopal
Copy link

maopal commented Feb 15, 2021

Hi there Kris, first off your Github page is a gold mine. Secondly, in this code
`// Get hard iron correction
mag_bias[0] = (mag_max[0] + mag_min[0])/2; // get average x mag bias in counts
mag_bias[1] = (mag_max[1] + mag_min[1])/2; // get average y mag bias in counts
mag_bias[2] = (mag_max[2] + mag_min[2])/2; // get average z mag bias in counts

dest1[0] = (float) mag_bias[0]MPU9250mResMPU9250magCalibration[0]; // save mag biases in G for main program
dest1[1] = (float) mag_bias[1]MPU9250mResMPU9250magCalibration[1];
dest1[2] = (float) mag_bias[2]MPU9250mResMPU9250magCalibration[2]; `

You also use MPU9250magCalibration. What is this term for?

Thanks in advance

@kriswiner
Copy link
Owner

kriswiner commented Feb 15, 2021 via email

@maopal
Copy link

maopal commented Feb 15, 2021

Is that the same as the Sensitivity adjust values as shown in this picture?

If not how could I calculate/find this value? What value did you use?

Many thanks

IMG_20210215_221113115.jpg

@kriswiner
Copy link
Owner

kriswiner commented Feb 15, 2021 via email

@maopal
Copy link

maopal commented Feb 19, 2021

Hi Kris, other than accounting for soft-iron and hard-iron biases, is there any other calculation I need to do before inputting mag data into madwickquaternionupdate() function. Correcting for magnetic declination perhaps?

Thanks again

@kriswiner
Copy link
Owner

kriswiner commented Feb 19, 2021 via email

@maopal
Copy link

maopal commented Feb 19, 2021

I just came across this post where you mention accounting for declination in your response. "you have taken into account the
local magnetic declination". kriswiner/MPU9250#345

Just a bit confused now... thanks again

@kriswiner
Copy link
Owner

kriswiner commented Feb 19, 2021 via email

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

3 participants