Magnetometer calibration error

104 views
Skip to first unread message

Michael K Johnson

unread,
May 10, 2017, 8:17:28 AM5/10/17
to BeagleBoard
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?

Michael K Johnson

unread,
May 10, 2017, 9:06:42 PM5/10/17
to BeagleBoard
I should add that the problem persists after cycling power fully, including disconnecting the battery. So it does not look like a transient error.

Michael K Johnson

unread,
May 13, 2017, 2:36:38 PM5/13/17
to BeagleBoard
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?

William Hermans

unread,
May 13, 2017, 2:46:33 PM5/13/17
to beagl...@googlegroups.com
nan == "not  a number". So something you've "hacked" is most likely causing that output.

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/80355085-f2a2-4f99-b43c-582af571c301%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Hermans

unread,
May 13, 2017, 2:48:37 PM5/13/17
to beagl...@googlegroups.com

On Sat, May 13, 2017 at 11:46 AM, William Hermans <yyr...@gmail.com> wrote:
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.

William Hermans

unread,
May 13, 2017, 2:56:17 PM5/13/17
to beagl...@googlegroups.com
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/

Michael K Johnson

unread,
May 13, 2017, 4:32:27 PM5/13/17
to BeagleBoard
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.

Michael K Johnson

unread,
May 13, 2017, 6:20:09 PM5/13/17
to BeagleBoard
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. ☺)

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

Clark Sann

unread,
May 14, 2017, 10:31:57 AM5/14/17
to BeagleBoard
How far did you have to move the BB from the motors?

Michael K Johnson

unread,
May 14, 2017, 1:23:14 PM5/14/17
to beagl...@googlegroups.com
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 May 14, 2017 10:32 AM, "Clark Sann" <acs...@icloud.com> wrote:
How far did you have to move the BB from the motors?

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to a topic in the Google Groups "BeagleBoard" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/beagleboard/yfYm-GOq9oE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/5984f57c-bba3-47ea-93f2-6ca02d456b05%40googlegroups.com.

Dennis Lee Bieber

unread,
May 14, 2017, 2:04:27 PM5/14/17
to beagl...@googlegroups.com
On Sun, 14 May 2017 13:22:58 -0400, Michael K Johnson
<mcd...@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...
--
Wulfraed Dennis Lee Bieber AF6VN
wlf...@ix.netcom.com HTTP://wlfraed.home.netcom.com/

Michael K Johnson

unread,
May 14, 2017, 4:08:07 PM5/14/17
to beagl...@googlegroups.com
The implied other half of the question is I suppose how close was too close. About 4-5cm away.

Clark Sann

unread,
May 14, 2017, 4:14:49 PM5/14/17
to beagl...@googlegroups.com
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.

Michael K Johnson

unread,
May 14, 2017, 4:52:22 PM5/14/17
to BeagleBoard
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. ☹

Dennis Lee Bieber

unread,
May 14, 2017, 6:25:02 PM5/14/17
to beagl...@googlegroups.com
On Sun, 14 May 2017 13:52:22 -0700 (PDT), Michael K Johnson
<mcd...@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?
Reply all
Reply to author
Forward
0 new messages