HMC5883L soft iron calibrarion

Hello everyone,

I have a HMC5883L on my pcb and I would like to track my sensor which is on a post (iron). The sensor will point towards different targets (and the post follows) and I want to be able to use my compass to know the amount of degrees from original position at any given time.

This would not be a problem if it wasn't for the fact that the sensor is inside a plastic pipe attached to the pole (iron) which introduces soft-iron issues.

Does anyone of you have experience or link to resources i can use to get rid of this and get fairly ok readings? I already have hard-iron and tilt-compensation and if away from the post, the devices shows the orientation in degrees properly.

I tried to attach it to the post and then follow this: http://www.instructables.com/id/Easy-hard-and-soft-iron-magnetometer-calibration/?ALLSTEPS but didn't work properly.

Would appreciate any suggestion.

Are soft-iron distortions static ? I mean they don't move, right ? Because of that, it is possible to compensate for them.

Your HMC5883L is attached to iron. I think that is something else.
It is like a compass on an iron ship. I think magnets are used to compensate for the ship's iron and even that is not perfect.

The iron (to which the HMC5883L is attached) could get magnetized a little. If that piece of iron hits something, the motion of the electrons get aligned and the iron gets magnetized.

What kind of accuracy do you need, and how many degrees are the values wrong because of the iron ?

In my opinion, the best procedure for removing both hard and soft iron distortions is this one: Sailboat Instruments: Improved magnetometer calibration (Part 1)

Peter_n:
Are soft-iron distortions static ? I mean they don't move, right ? Because of that, it is possible to compensate for them.

Your HMC5883L is attached to iron. I think that is something else.
It is like a compass on an iron ship. I think magnets are used to compensate for the ship's iron and even that is not perfect.

The iron (to which the HMC5883L is attached) could get magnetized a little. If that piece of iron hits something, the motion of the electrons get aligned and the iron gets magnetized.

What kind of accuracy do you need, and how many degrees are the values wrong because of the iron ?

Yes it's static! That is why i thought it would be easier.
Also The compass is inside a plastic pipe / enclosure, and not directly on the iron, but spaced apart by a 3d printed plastic part. When away from iron is pretty damn good, when in the pipe on the iron post it's useless. Of course I know it has moved i a direction, but i don't know how much. At this point any reasonable accuracy would do, ideally I would like to be ~5 degrees accurate.

Note that I calibrated the compass as in the procedure above, away from the iron because that yielded better results than calibrating while attached to the iron and moving the post around.

Another strange (or maybe not to you guys) thing is that if I have my sensor calibrated away from the iron, and then attach it to the post and rotate the post 360 around, in my rendering i should see a line go 360 degrees in a circle, but it's totally screwed up and rotating basically only in one quadrant. However if instead rotating the post 360 degrees i keep the post static and i rotate the board with the sensor alone (revolutions around its center) the rendering is pretty ok accurate and i see the rendering of my line going around the circle. Why would it be like this? Why if the sensor rotates with the post yields different results than if it rotates around its own center alone with the post static?

jremington:
In my opinion, the best procedure for removing both hard and soft iron distortions is this one: Sailboat Instruments: Improved magnetometer calibration (Part 1)

Thanks I will check it out and let you know.

maeishoj:
...However if instead rotating the post 360 degrees i keep the post static and i rotate the board with the sensor alone (revolutions around its center) the rendering is pretty ok accurate...

That is the whole point. With some calculations the influence of any static (not moving) magnet or iron can be compensated for. However, when you attach the magnetometer to the iron, that calculation can no longer compensate for static influences. I also still think that the iron might be slightly magnetized.

Do you know how to make a compass with a needle and an iron rod ? Put a stone on the ground, and let the rod bounce a number of times with one end on the stone. The end gets magnetized. Slide the needle in the same way along the end of the rod, and place the needle on something floating on water. The needle will point North-South. It's that easy to magnetize iron.

Can you make a post of plastic ?

Hey Peter,

The post can only be of this kind unfortunately :cry:

So basically you are saying that in my specific case cannot be fixed even through soft-iron calibration as good as that may be?

I don't know. I just follow my feeling and I can 'see' an evenly spread earth magnetic field which gets bend/distorted by the iron, and the bad thing is that the iron rotates with the sensor on it.
Here is a nice picture how the earth magnetic field is distorted by a ship : The American Practical Navigator/Chapter 6 - Wikisource, the free online library

I see.

However I have heard that ships have compass even on docks that are full of metal and they are basically a huge metal enclosure :smiley:

SO as a ship turns, the compass turns with it, which is basically like my use case, but it seems they have it under control ?!?!?

Has anyone else any idea about how to possibly achieve detecting "orientation" in my case by means of other sensors? With gyro we could get relative change, but the problem is that the sensor would have to be on ALL the time, which doesn't make it good for battery powered applications... :confused:

The procedure mentioned in reply #2 must be performed with the magnetometer in its final resting place. So, you have to rotate the post too.

It may be impossible to correct for the post's influence, in which case you need to redesign the physical arrangement.

Thanks everyone,

I found out that placing the enclosure over the post solves the issues! :slight_smile: Just gonna make a nice fitting for it! :slight_smile:

Thanks again everyone for their help! :slight_smile: