HMC5883L compass with external magnet
Adil Ali
Posts: 9
I am using the HMC5883L digital compass to get the north,east,south,west directions. (0 degrees - 360 degrees).
[compass connected to atmega, atmega connected to LCD]
When i get a magnet close to the magnetometer (compass), distortion happens on the heading (output), and when i move away the magnet from the magnetometer the header doesnt return back to its correct value. (no set/reset occurs)
Although the datasheet says set/reset is controlled automatically.
Any solutions?
[compass connected to atmega, atmega connected to LCD]
When i get a magnet close to the magnetometer (compass), distortion happens on the heading (output), and when i move away the magnet from the magnetometer the header doesnt return back to its correct value. (no set/reset occurs)
Although the datasheet says set/reset is controlled automatically.
Any solutions?
Comments
This sensor is very sensitive to any magnetic field.
I would really not put a known strong magnet close to the sensor.
It's possible that placing a magnet in close proximity to this sensor will magnetize some metal near by.
Any stray magnetic fields within a few feet of the sensor will cause it to read out in error.
Even a 9 volt battery close to the sensor will cause reading errors.
You might want to try turning off the power to the HMC5883L and leave it sit in the off state for a while.
On power up, maybe it will have corrected itself.
With my setup, I need to locate the HMC5883L in a particular area in my shop, then it consistently works ok.
I need to still figure out how to correct for the errors generated by nearby magnetic fields.
If I can figure out how to get the compass working accurately and consistently, I can use it in my robotic scarecrow platform.
For now, it's on the shelf until I get an inspiration.
I also need it on my robots , and i do not want any stray magnetic fields to deviate my results.
Do you think magnetic field protection (shield) could help?
Thank you for the helpful post.
If you find any further solutions please let me know.
Seems like I remember hearing about doing something like that back in the 1980's when I was being trained as an ElectroMechanical Technician. The basics are true, unlike lots of info that's found on the internet.
If you are thinking about Magnetic Shielding, there is something called MuMetal that is commonly used to shield magnetic fields.
I started looking into this material based on someone's suggestion in a different thread on this site.
MuMetal aparently is a Nickel-Iron alloy.
The only source I know to get this from at this time is McMaster Carr. They are an industrial Jobber store.
When I did some internet research on Magnetic shielding, I was a bit put off by the complexity of all of the descriptions.
With my background, the descriptions and math are way above me.
If the compass I have on the shelf starts calling me, I think my 1st instinct is to put about a 4"x4" piece of MuMetal under the compass.
I have no clue if it will improve the stray magnetic field effect.
That's just another of my two cents worth.
gg
Do you know if the MuMetal placed close to the compass, but not enclosing the compass will affect the compass readings?
My thought is to possibly enclose a platform in a MuMetal enclosure, then put the compass module, perhaps with a riser on top
of the enclosure so the Compass is outside and on top.
I know that in my situation, the compass is thrown off by things like flourescent lights and motors running in my shop.
But I also know that my platform motors running also throw the compass readings off.
Thanks
He was pretty adamant that MuMetal was for shielding noise sources not for shielding a sensor. I think a compass has to be able to sense the magnetic field in all directions for it to be accurate. I believe the susceptibility to magnetic noise is one of the limitations of using a magnetic compass in direction finding. I don't think they generally work well indoors (but I'm far from an expert on the subject).
Maybe you will be wondering why am i testing it with a very strong magnet. This is because I am going to have an electromagnet on my robot and a compass, and i do not want the electromagnet to distort the compass output..
Is there an external set/reset circuit for HMC5883L?
HMC6352 datasheet says
"The periodic Set/Reset function performs a re-alignment of the sensors magnetic domains in case of sensor perming (magnetic upset event)"
"With the periodic Set/Reset bit set, the set/reset function occurs every few minutes."
Do you think HMC6352 compass will solve my problem? Resets the distorted output every few minutes. Or it will be the same as HMC5883L?
Have you measured the magnitude of the magnetic field generated by the electromagnet? At a reasonable distance, it may not be nearly as strong as the field of a permanent magnet up close. Hopefully the electromagnet isn't so strong as to cause the sensor to loose its calibration.
I haven't found the MuMetal forum link yet but there are several threads about compass calibration on the SparkFun forum. Here's one.
I think you're likely to have the same sort of problem with other magnetic field sensors when used near a strong magnetic field. I think it's a common practice to keep a compass on a robot elevated by a dowel in order to keep it away from the robot's motors. Other electronic compass modules might not be as susceptible to this problem but I don't think any are immune to it.
Solution:
With digital compass + gyroscope, external magnetic field will not distort the results.