Magnetometer Calibration Machine
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...
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|
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.
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|
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.
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|