The compass has 4 components mounted on a rigid base:
- a small board featuring an ATmega128A microprocessor operating at 3.3V and 8 MHz
- a MicroMag 3-axis magnetometer
- an SCA3000 3-axis accelerometer
- an NCP1400-5V Step-Up board acting as a power supply to the SCA3000.
Four flexible wires connect the compass to a remote 3.3 V power supply, a remote serial-to-USB converter, and a remote momentary-contact button. This configuration corresponds to the intended installation on the boat.
In accelerometer calibration mode, when the button is pressed, 64 consecutive raw measurements are sent to the serial port. A remote laptop running Hyperterminal continually saves these measurements in a text file. The compass assembly is rotated step by step around X axis and measurements are taken after each small rotation. Then the procedure is repeated around Y axis.
The following figure illustrates the first set of measurements taken with this arrangement, as rendered in Google Sketchup.
The resulting text file is then processed by the Magneto software to find the calibration parameters.
The compass base is then placed completely horizontal, and a set of measurements (64 consecutive values) is taken at this position. The average of these 64 raw measurements is:
arx = -93.7656 ary = 61.56813 arz = 1420.344
After applying the calibration correction,
aax = -0.2244 aay = 68.61544 aaz = 1332.229 (vector v1)
and the norm for these calibrated values is calculated at 1333.995, which is a comforting result.
These calibrated values describe the orientation of the accelerometer reference frame in the gravitational field.
From the calibrated values, the heel and pitch values are calculated at -2.95 deg (heel) and 0.010 deg (pitch). These angles reflect the orientation of the accelerometer vs the rigid base.
At this same horizontal position, we conclude that the orientation of the rigid base in the gravitational field is described as:
abx = 0.0 aby = 0.0 abz = 1333.995 (vector v2)
From the values of vectors v1 and v2, it is now possible to calculate the rotation matrix that can be applied to any calibrated vector v1 (accelerometer orientation) to get the associated vector v2 (rigid base orientation) :
The technique to calculate a rotation matrix from 2 vectors is documented here.
We will need this rotation matrix later on for the tilt compensation corrections.
The next step is to apply the same calibration procedure to the magnetometer.