I’ve calibrated the IMU but the 0-360 heading doesn’t seem to read correctly. If I rotate the robot 90 degrees, the heading that is output is not changed by 90 degrees. Is this a calibration issue or is there some type of offset I have to calculate?

If you only plan to use the IMU as a compass (for heading using 2 of the axes), you will want to set your device flat and rotate it slowly around during the 30-second sample collection. If you need all 3 axes calibrated, you will need to slowly rotate your project around each of the IMU's 3 axes during the 30 seconds sample collection.

These units are effected by metal and magnetics. You need to calibrate it in the project your going to use it with otherwise when you move it the metal surrounding the project will through the measurements off.

Also if there is a large piece of metal on one side this will cause the reading to be off. Aluminum is not a metal that effects the IMU.

Ok, I am not a blockly prop person but I do know Magnetometers.

First take a look at the picture provided.

My coleman compass show that true north is off by about 50 degrees because of my environment like my monitor. If I move the compass off my desk it will return to true north.

Any way I can use this information to calibrate my magnetometer. This IMU measures the magnetic values in the X, Y and Z plain so I need to get the max and min values for those values so I can zero it to my environment.

This IMU has the Y axis at the top and the X axis to the Right of that. So as the IMU is pointing in the picture this should give me the highest value for Y. Turning it 90 degrees and taking another reading and I should have the Min value for X. Turning it again I should have the Min value for Y and one more turn the Max value for X.

From these values we can build an offset to correct the values read to give us a correct offset to use in the heading calculation.

In my case setting the IMU as 4guass level I got a reading of 3926 for X and 1937 for Y and a Min value of 1496 for X and -768 for Y.

Now by using the formula of Xoffset = (3926 + 1496) / 2 and Yoffset = (1937 + -768) /2

So for each reading of X I would subtract this offset from it.

X = 2757, Y = 1730
X = X - 2711
Y = Y - 548

heading = atan2(X, Y) * 180/PI Radians to degrees.

heading = 2 degrees.

I also had to subtract from 360 since the IMU is upside down in that positive number are counter clockwise. Also if the number is negative to add 360.

I also swapped X and Y in the atan2 function so that Y is pointing north instead of X otherwise north is to the right side of the IMU.

## Comments

11,43811636Also if there is a large piece of metal on one side this will cause the reading to be off. Aluminum is not a metal that effects the IMU.

Mike

11636First take a look at the picture provided.

My coleman compass show that true north is off by about 50 degrees because of my environment like my monitor. If I move the compass off my desk it will return to true north.

Any way I can use this information to calibrate my magnetometer. This IMU measures the magnetic values in the X, Y and Z plain so I need to get the max and min values for those values so I can zero it to my environment.

This IMU has the Y axis at the top and the X axis to the Right of that. So as the IMU is pointing in the picture this should give me the highest value for Y. Turning it 90 degrees and taking another reading and I should have the Min value for X. Turning it again I should have the Min value for Y and one more turn the Max value for X.

From these values we can build an offset to correct the values read to give us a correct offset to use in the heading calculation.

In my case setting the IMU as 4guass level I got a reading of 3926 for X and 1937 for Y and a Min value of 1496 for X and -768 for Y.

Now by using the formula of Xoffset = (3926 + 1496) / 2 and Yoffset = (1937 + -768) /2

So for each reading of X I would subtract this offset from it.

X = 2757, Y = 1730

X = X - 2711

Y = Y - 548

heading = atan2(X, Y) * 180/PI Radians to degrees.

heading = 2 degrees.

I also had to subtract from 360 since the IMU is upside down in that positive number are counter clockwise. Also if the number is negative to add 360.

I also swapped X and Y in the atan2 function so that Y is pointing north instead of X otherwise north is to the right side of the IMU.

Mike