XloBorg Calibration issue(s)


I'm getting some odd results as I try to "calibrate" my XloBorg magnetometer using this instructables article:

I haven't had a chance to look at this closely yet, but I suspect his code isn't reading things properly.

Anybody else ever looked at this?


piborg's picture

It might be worth checking the XloBorg is working correctly.

We have seen one before which seemed to have a damaged Z reading:

sigpaw@hotmail.com's picture

When using the utility downloaded from the instructables article mentioned above, I see NO change in the X magnetic reading. Although Y and Z show repeatable change. But none of the axis are bipolar when flipped 180 deg as he sugests.

When I use examples from this site I see repeatable changes in X, Y and Z. But none are bipolar there either.

Should each magnetic axis flip in sign as it is rotated 180 deg in it's axis?


I do see + and - 1G in each accelerometer axis as I align each axis with respect to earths gravity.

piborg's picture

Usually you would, but it might just be very offset readings.

What sort of readings are you seeing?

sigpaw@hotmail.com's picture

Here are the samples I obtained using the code off of the instructables webpage (however, using YOUR XLoBorg.py driver, I am seeing a nice variance in the X axis - albeit not bipolar):

x -594.4
y 277.6
z -129.2

x -546. ;Rotated 180 deg
y 683.3
z -134.7

x -543.7 ;Flipped upside down
y 313.2
z -1076.6

x -607.6 ;Upside down and rotatedd back 180 deg
y 684.4
z -1073.7

As you can see, X has very little variance with their driver/software. I'm going to do a "diff" between their XLoBorg.py file and yours. Hopefully they are similar enough to point out the difference(s).

I will do another run using your example XLoBorg.py file and post them shortly...

sigpaw@hotmail.com's picture


I'm using the ReadCompass.py file off of the Instrucables "Simple Manual Magnetometer Calibration" (at the URL above). But in this set of values I used YOUR XLoBorg.py file (included at the top of ReadCompass.py) rather than the one he supplies. I did a simple N, S, E, W sample of all the values as outlined below:

X -677.9 2.1
Y 698.7 2.2
Z -282.8 3.3

X -738.7 2.6
Y 424.6 2.0
Z -302.6 3.4

X -504.2 2.1
Y 331.1 2.4
Z -310.4 3.7

X -399.9 2.8
Y 581.4 1.8
Z -309.9 3.5

I see values within the STDVN time after time. But they are severely "tweaked" to say the least.

ideas? :-)

piborg's picture

I have had a look at the differences between our script and his and they are:

  1. The device is put into standby before setting the registers unlike ours
  2. A slight tweak in register setup order in InitCompass: he sets CTRL_REG1 first, then CTRL_REG2
  3. He is reading and applying offsets in XLoBorg.py itself
  4. Some changes to the output when the script is run directly

I am not entirely sure how much of an effect this will all have.
One question is do you have a MAG3110offsets file and if so what are the values in it?

The calbration routine we have been using here was a simple offset and gain procedure like this:
The examples are for C but the idea of what it does should be fairly straight forward.

On a side note I am guessing the XLoBorg is fitted inside your Metal Edition.
If so I expect that the two large metal plates affect the magnetometer readings somewhat.
It is quite possible they are the reason for such large offsets.
Hopefully the calibration will remove the unwanted effects.

sigpaw@hotmail.com's picture

There is no MAG3110offsets file. But now I wonder if he is initializing his offset variables to zero prior to looking for/reading in a file.

Not using the stainless diddy yet. All my tinkering thus far has been "indoors" with my DiddyRed.

I had also considered a gain value for my X axis, since it has slightly less "travel" than the Y axis. Just enough gain to get it to run from 0 to 400 like the Y axis. Something like a multiplier of 1.18 or so...

So you concur then that my XLoBorg is likely OK?

I'm going to order a second XLoBorg (or two) here in a bit for my diddy stainless, I guess I can compare them to one another then. ;-)

piborg's picture

Yes, it does sound like it is okay, it just has some rather large offsets.

The gain between axes is not that unusual, a fair number I have tried had an axis which wanted a ±10% gain or more.
I think a large amount of the gain comes from the mounting of the magnetometer, even the board itself adds some 'noise' to the reading.

As a heads-up if you put the same XLoBorg into a different robot later it will probably warrant a re-calibration.
In particular I would suspect the metal plates to throw the readings somewhat.

sigpaw@hotmail.com's picture

You know... It may actually work BETTER on the Diddy Metal. The permanent magnets in those 6 large motors HAVE to be causing some interference. Don't you think? :-)

piborg's picture

That is a very good point, it probably deserves a bit of an experiment :)

Subscribe to Comments for "XloBorg Calibration issue(s)"