Friday, March 23, 2012

Magnetometer Calibration Machine

It's simple, it's cheap, and easy to make. What else would you expect on this blog?

What is it? A calibration machine for gyro and magnetometer sensors.

To help with my struggles in magnetometer calibration I've built a large, non-magnetic turntable device with encoders for precise and accurate angular measurement. The device is big enough to fit Data Bus or any other 1/10 RC chassis. Here's how I made it...


Physical Construction

Turntable and base are made of 1/2" thick Medium Density Fiberboard which resists warping quite well. The shaft is 3/8" solid aluminum rod threaded 3/8"-16 on one end.

The unthreaded part of the shaft rotates in a bronze bushing mounted in a section of 2x4 that is glued to the underside of the base. I used my planer to plane down the 2x4 to a reference surface which in turn allowed me to drill a hole for the bushing with my drill press.

A nylon nut is threaded onto the shaft first; it rides on the bronze bushing flange. Brass washers and nuts hold the turntable to the shaft at an appropriate distance from the base.

My initial SketchUp drawing differs from the finished device due to parts availability and improvements in the design after prototyping. But you get the idea.

Dimensions differ from as-built but you get the idea
Drive System

The table is currently driven by a digital interface: my fingers. Adding a motor could corrupt the magnetic field. That isn't to say I won't run it off a motor at some point, but I have to figure out a good way to mount the motor far, far away from the DUT.

Encoder

As you might expect, encoder electronics are quick and dirty.  I used my WheelEncoderGenerator app to print an 8" encoder disc on paper that I cut down and tacked to the base with spray adhesive. Due to size constraints the encoder disc has 2° resolution. I later added a second track with an index mark.


Two QRE1113 IR reflectance sensors are mounted with hot glue under the turntable with wires feeding up through a hole in the turntable. I connect the sensor directly into the wheel encoder boards on Data Bus. The robot can simultaneously record compass heading, gyro, and turntable position.

One of the two encoder sensors; the second was added later

Software

I coded up the software into my existing code base to make use of the existing wheel encoder drivers. My main code has a menu selection for various functions and swinging the compass is one of those.


I then added an LCD panel so I didn't have to drag the laptop and USB umbilical outside when performing calibration and compass swing.


Whenever the encoder count increases by some number of ticks, I multiply that number by 2 degrees. Then I calculate the magnetometer heading and compare that with the turntable heading and write the data out to the microSD card.

The code runs for five total rotations as detected by the index track counter then the user is dumped back to the main menu. Selecting 'shell' launches the unix-like shell where I can cat out the resulting logfile and capture it to my PC for plotting and analysis.


Now What?

With this data I can do multi-point gyro calibration and I can swing the compass to test the quality of my hard- and soft-iron calibration parameters.  Here's a plot of compass error versus true heading reported by the machine. This plot covers 15+ rotations on the machine.


It shows an error range of about 4 degrees. The mean error is about 90 degrees which is expected since my IMU board is mounted that way. The error is still pretty bad so there's still more work to do.

Data Bus on the calibration machine in the driveway


2 comments:

  1. Michael,

    Looks like you have a good setup. Are you stopping the rotation for each reading? The reason I ask is that aircraft are susceptible to "northerly turning error". I'm not sure that this is the case for your setup, as you are rotating the DUT, not turning it, and you are not accelerating the DUT.
    Ted

    ReplyDelete
  2. @Ted, I rotate continuously--2° is a surprisingly small amount of rotation so even if I wanted to I doubt that I could. :) Not sure what the effects of acceleration are on the magnetometer but judging by prior experiments the acceleration is 0.1g or less.

    ReplyDelete