Magnetometer calibration error

My Beaglebone Blue consistently reports “ERROR: center of fitted ellipsoid out of bounds” when running rc_calibrate_mag both from the installed version 0.3.4 and built from latest master from github, 5da7696.

Does this error affect others or do I more likely have a faulty IMU in this unit?

I should add that the problem persists after cycling power fully, including disconnecting the battery. So it does not look like a transient error.

Furthermore, when I hack the library to write the calibration file even if the sanity checks fail, just so I can see what it does, I get:

cat /var/lib/roboticscape/mag.cal

216.160797
10.290765
38.221786
2.125283
nan
1.748049

That “nan” looks suspicious!

Is this defective hardware?

nan == “not a number”. So something you’ve “hacked” is most likely causing that output.

Quite possibly related to sending output from an unsigned char, or
character type without first converting( casting ) to a number type. In
your case, probably float or double.

Sorry, my bad, multi tasking here, and not thinking the problem through
fully. Casting to a number type probably won't work. You'll need to use
something like strtof() http://www.cplusplus.com/reference/cstdlib/strtof/

Yeah, I know NaN. I’ve done plenty of work with floating point.

By “hack” I meant only disabling the sanity check that prints “ERROR: center of fitted ellipsoid out of bounds” to see what would happen without the sanity check. I was curious what would be written to the magnetometer calibration file if I disabled the sanity check, as a way of pursuing an understanding of whether the problem was my BeagleBone Blue hardware or the software running on it.

The “ERROR: center of fitted ellipsoid out of bounds” message is happening on my out-of-the-box pristine BeagleBone Blue, every time I run rc_calibrate_mag as required for magnetometer use.

I would hope that normal BeagleBone Blue devices have functioning magnetometers, and that the rc_calibrate_mag program that you are required to use in order to use the magnetometer in the IMU functions correctly.

That would mean that my BeagleBone Blue is a faulty hardware unit.

But before I pursue getting it replaced, I wanted to know whether there was a software bug that affects everyone else’s BeagleBone Blue IMU magnetometers.

It would be good to hear back from someone who knows something about the BeagleBone Blue on whether there is a software fault or a hardware fault.

Right now, I am not able to use my BeagleBone Blue for its intended purpose, since that specifically includes using the magnetometer.

I solved the problem.

The BeagleBone Blue was in too close proximity to the DC motors that it drives. I removed the BBBL from the chassis and kept only the battery connected, and now I can calibrate the magnetometer successfully. I will have to reconsider the layout and move the BBBL further away from the motors. (Yes, there was a hardware bug, in my configuration. :relaxed:)

The calibration file looks much better now.

cat /var/lib/roboticscape/mag.cal

27.653961
0.885905
27.744669
1.534232
1.562714
1.503506

How far did you have to move the BB from the motors?

I completely removed it from the chassis so far. I haven’t yet experimented to see how close it could be; I’m more likely to place it as far at as I can to make it most accurate.

On Sun, 14 May 2017 13:22:58 -0400, Michael K Johnson
<mcdanlj@gmail.com> declaimed the following:

I completely removed it from the chassis so far. I haven't yet experimented
to see how close it could be; I'm more likely to place it as far at as I
can to make it most accurate.

  Seem to be lots of entries on Google for

magnetometer motor interference

https://blog.nxp.com/sensors/magnetometer-placement-where-and-why even gets
down to the current flowing in PCB traces...

The implied other half of the question is I suppose how close was too close. About 4-5cm away.

Thanks for that. I'm hoping I don't have any ill effects if I locate a BB Blue 6" or so away from motors. This is on a 48" radio controlled boat so I can probably put it further away if I need to.

I’ve been playing more. I don’t notice an effect on the compass (rc_test_dmp -m -c) until the IMU is within about 2cm of one of the motors (not running). I’m sure that different motors have different magnetic fields. I haven’t even begun to explore with the motors running. I don’t know all the potential factors but I can say with confidence that the motors I got are el cheapo.

Using rc_test_imu I see that the raw IMU magnetic field readings away from the motors are all in the 10-60µT range. Within about 15-20cm away from these motors I see definite changes in the tens of µT range, within about 8cm I see readings over 100 µT, and within about 1cm I’ve seen over 2000µT.

This isn’t at all rigorous, I’m just waving a BBBL in the air while watching the output of rc_test_imu to get an intuitive sense of the strength and shape of the magnetic field around the motors.

It’s a little more work to see what it’s like when the motors are running, since running one of these rc_* test programs kills the others, so I can’t run rc_test_motors while running rc_test_imu; to do the equivalent with running motors, I’ll have to combine the test programs. :frowning:

On Sun, 14 May 2017 13:52:22 -0700 (PDT), Michael K Johnson
<mcdanlj@gmail.com> declaimed the following:

It's a little more work to see what it's like when the motors are running,
since running one of these rc_* test programs kills the others, so I can't
run rc_test_motors while running rc_test_imu; to do the equivalent with
running motors, I'll have to combine the test programs. ?

  Bypass the ESC and use a suitably rated potentiometer wired to the
power source to control motor speed by hand?