Go Down

Topic: Problem with HMC5883L.. help (Read 5619 times) previous topic - next topic

sasadara

Hi,
I was using HMC5883L magnetometer without a problem. It gave me around 1 degree accuracy North direction.
Since my exams I kept them away disconnecting all the wires and connections from Arduino.

After few weeks, today I took my Arduino and HMC5883L and using same program I check the direction.. :(

For North direction it give me 23 degrees.. North is changes. I check my phone compass, It gave me the correct north, But from this HMC5883L, it is not the correct North. Why?

I don't know how to calibrate it.. Earlier it gave me correct values without any calibration. But now it show 23 degree for north :(

how do I correct it? is it permanent?

https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/HMC5883L these are the libraries and example which I used for my simple program.

ps: there are no any interference or strong magnetic fields.  This is for my university project.

Peter_n

23 degrees is a lot, that doesn't seem a calibration error.
Sometimes the x,y,z values don't show the exact amount of magnetic field. For better accuracy some calibration can be needed.

Can you try another sketch to test it, and to show the x,y,z values. Perhaps the 'z' is zero due to a problem.
The I2C-bus should be a 3.3V I2C-bus, did you know that ? You can connect it to the Arduino Uno, but only without extra pullup resistors.

Is the something metal next to it ? a screwdriver or a computer ?

If you still have problems, tell us which compass module you have, which Arduino board, and is possible a photo of your setup.

jremington

You have to calibrate magnetometers frequently, especially if the environment changes. My favorite procedure, which is a bit involved, is described here: http://sailboatinstruments.blogspot.com/2011/08/improved-magnetometer-calibration.html

There are many simpler approaches, some just involve subtracting the offset from each axis and estimating the gain errors (which are usually small), e.g. http://www.bot-thoughts.com/2011/04/quick-and-dirty-compass-calibration-in.html
No PM's please.

Peter_n

jremington, did you hear before of suddenly 23 degrees calibration error ? I think there is something else going on.

michinyon

The scaling and offset of the different axes of those HMC5883L's isn't all that good.

The ones I have,  will happily tell you that the angle between north and east is about 30 degrees.   All of mine would have been up to 23 degrees off direction.  Although like a broken clock which is right twice a day,   there are a couple of directions where it coincidentally happens to be correct.

You do need to calibrate them.

Now,   the question of whether the calibration would change so much in a few weeks,  is a different question.

I use one which was calibrated about 18 months ago,   and it is still right ( after applying the corrections ) today.  I have not personally experienced the calibration change which you have described.


sasadara


23 degrees is a lot, that doesn't seem a calibration error.
Sometimes the x,y,z values don't show the exact amount of magnetic field. For better accuracy some calibration can be needed.

Can you try another sketch to test it, and to show the x,y,z values. Perhaps the 'z' is zero due to a problem.
The I2C-bus should be a 3.3V I2C-bus, did you know that ? You can connect it to the Arduino Uno, but only without extra pullup resistors.

Is the something metal next to it ? a screwdriver or a computer ?

If you still have problems, tell us which compass module you have, which Arduino board, and is possible a photo of your setup.


the module is this http://www.uctronics.com/hmc5883l-three-axis-magnetic-field-module-p-856.html

well actually there is a circuit in front of it with some screws, but the problem is before one month I used same circuit and same screws but it gave me the correct North. And I checked the wiring too since after month and whether they broken. But it is not too.
https://github.com/helscream/HMC5883L_Header_Arduino_Auto_calibration

this was gave me correct North but it is only when I run that program only.

sasadara


You have to calibrate magnetometers frequently, especially if the environment changes. My favorite procedure, which is a bit involved, is described here: http://sailboatinstruments.blogspot.com/2011/08/improved-magnetometer-calibration.html

There are many simpler approaches, some just involve subtracting the offset from each axis and estimating the gain errors (which are usually small), e.g. http://www.bot-thoughts.com/2011/04/quick-and-dirty-compass-calibration-in.html


thank you I'm going to try it. Could you please tell me, after this calibration can I used early programs again? without editing them or adding new lines?

sasadara


The scaling and offset of the different axes of those HMC5883L's isn't all that good.

The ones I have,  will happily tell you that the angle between north and east is about 30 degrees.   All of mine would have been up to 23 degrees off direction.  Although like a broken clock which is right twice a day,   there are a couple of directions where it coincidentally happens to be correct.

You do need to calibrate them.

Now,   the question of whether the calibration would change so much in a few weeks,  is a different question.

I use one which was calibrated about 18 months ago,   and it is still right ( after applying the corrections ) today.  I have not personally experienced the calibration change which you have described.




Ya may be some kind of external magnetic field affected to IC? I kept same angled and orientation.. can you provide a script for calibration?

jremington

Quote
jremington, did you hear before of suddenly 23 degrees calibration error ?
I have personally experienced much larger errors than that -- actually magnetometers are capable of producing complete nonsense.

The problem is that the atan2 function, which gives you the angle, assumes that the X and Y magnetometer axes are orthogonal and that their axes actually intersect at the origin. That is not the case if there is a magnetic disturbance nearby, or the calibration is changed by, for example, dropping  the magnetometer on the floor.
No PM's please.

sasadara


Quote
jremington, did you hear before of suddenly 23 degrees calibration error ?
I have personally experienced much larger errors than that -- actually magnetometers are capable of producing complete nonsense.

The problem is that the atan2 function, which gives you the angle, assumes that the X and Y magnetometer axes are orthogonal and that their axes actually intersect at the origin. That is not the case if there is a magnetic disturbance nearby, or the calibration is changed by, for example, dropping  the magnetometer on the floor.


Hmm, well I didn't my magnetometer ever before.. Can u provide me simple calibration method with it libraries files.. It will be very helpful.. :)

Thank you

jremington

Try visiting the links in reply #2.
No PM's please.

michinyon

Quote
his was gave me correct North but it is only when I run that program only.


If you are only interested in north,   then you might get a misleadingly good impression of how accurate the device is.

To find north,   you are looking for the point where the signal in the east-west direction is zero,    and that is pretty easy to find even if the actual axes of sensistivity are not orthogonal or if there is a major scaling difference between the two axes.


michinyon

If it is working properly,   the point where the signal in the north-south direction is maximum,    should be the same point where the signal in the east-west direction is zero,     and it doesn't take a very sophisticated experiment to determine that that usually isn't the case.

The calibration procedure I use is to sample the device outputs in a large number of different orientations,   and the upload the data to Matlab and process it using that.  There isn't an arduino sketch for it.

Go Up