## Saturday, June 23, 2012

### Compass calibration on the water

Even if an electronic compass has been meticulously calibrated on land in a non-disturbed magnetic environment, it will need additional calibration adjustments once installed in a boat.

In a previous post, I described a procedure to recalibrate a compass with a GPS if you can find a patch of water where there is absolutely no current, a situation that practically does not exist in my maritime environment.

If your system can log the headings from a fast compass (5 Hz or more), here is an alternate method that can tolerate an existing current, but requires absolutely flat water (no waves) and no (or very negligible) wind. This is in fact the method that many commercial compass vendors choose to implement in their autocalibration routines, but presented here in a transparent manner.

These conditions must be met: a low and constant motoring speed (2 to 4 knots), and a tiller or wheel blocked in position so that a complete turn will take around 3 minutes.

Here is how I produced the results presented at the end of this post.

I made several turns while logging the headings (for both the Aimar H2183 and my own Hi-Resolution compass), as well as the boat speed. From the speed log, I find a section where the boat speed has been very stable, and I extract the heading data from a full turn.

We can make the reasonable hypothesis (with no waves and no wind) that our angular velocity has been constant during this golden turn, so that all recorded headings have to be separated by equal angles. If this is not the case, we can calculate the local deviation.

So several turns are recorded, but only the best one is used in the calibration. Here is simplified example using only a reduced set of measurements.

In Colum A, we have the measured headings on a complete turn, with 20 diffferent measurements. The expected angle difference between each measurement is 360/20 = 18 degrees. In Column B, we have calculated these expected headings if there was no deviation. In Column C, we calculate the deviation (A – B).

We can graph these deviations (C) vs. the measured heading (A). This is our deviation graph.

From these data points, we can calculate (using the NLREG software)  the 5 deviation coefficients (A, B, C, D, E) such as that:

Deviation = A + B sin(H) + C cos(H) + D sin(2*H) + E cos(2*H).

By correcting the measured heading by the calculated deviation, we obtain a pre-calibrated heading that still needs a last offset correction.  Our graph is based on the assumption that there is no deviation at our starting heading of 100 deg. But this is not necessarily the case; the zero-deviation point(s) may be at some other heading(s).

This last correction is easy to do, as we need only to compare any pre-calibrated heading value to a known heading. For example if, with the boat aligned along a dock at 78.0 deg, we obtain a pre-calculated heading of 76.5 deg, we will have to add a constant offset of 1.5 deg to all our pre-calibrated headings. (Don't trust your regular magnetic compass for this : it has its own uncorrected deviations).

Here are the deviation curves obtained from my 2 compass, using data from the same turn.

Airmar H2183 Compass  (1721 meassurements, doubled 5 Hz samples ):

Hi-Resolution Compass (1737 measurements, 10 Hz samples):

So are we done?

Not really, because be still have to check if this calibration remains valid:
- when the motor is not running
- when the boat is heeling.

Getting an accurate magnetic heading is a never ending story.

1. Maybe I am not understanding this properly: In a previous post you asserted that you "came to the conclusion that a gyro is not needed in a marine compass, as the rate of turn can be calculated from the calibrated output of a fast compass." That maybe so. But wouldn't the calibration be easier since a rate gyro could provide the turn that occurred which you can compare to the turn as per compass to figure your deviation? This should relax your requirement to having to perform a turn at constant rate of turn, no?

1. In principle, yes.

But this would require an extremely sensitive and accurate gyro. Making one turn in 3 minutes gives 2 deg/s. For the Airmar H2183, the Rate-of-Turn Accuracy is 1 deg/s, far from an acceptable precision for such a task. The H2183 Rate-of-Turn output values are also very noisy.

2. ah - of course. I suppose the solution would be to speed up the turn. If your deviation is, say, max 20deg=360deg/18 and your rate-gyro sensitivity is 1deg/s you need to be turning at least (360deg/18)/s=20deg/s. Mh. I probably can do that in my Laser or even trimaran. Not sure about the oil tanker ...

2. Is the curve above for an H2183 that has been through the manufacturer defined calibration procedure?

1. Well, the story is as follows. After installing the H2183 on the boat, I went through the manufacturer calibration procedure, using the WeatherCaster software on a laptop. The procedure reported a success, but the result was truly bad. So, before doing the test described here, I used the WeatherCaster software to bring the compass back to manufacturer default values, but I don't know if it really did that, or if it kept the defective calibration. Even if I don't know the real starting point, the procedure described in this post has corrected the situation, as both compasses now agree after calibration.

The boat has a steel keel, and the deviation curves have the expected signature for this situation.

3. Hi

Thanks for a great blog.

I have a question to how you find the 5 deviation coefficients (A, B, C, D, E).

How is this done in NLREG or a similar program. Do you have link?

Martin

1. Here is the NLREG input file that will calculate the coefficients for the simplified example in this post. Open this in NLREG, run, and you will get the following coefficients:

A 9.8714987
B -6.57413958
C 6.37813634
D 0.33566988
E 2.2953011
___________________________________

Title "Deviation Coefficients";
Variables X, Y;

TOLERANCE 1E-12;
ITERATIONS 1000;

/*
* Definite parameters to be calculated.
* Specifying reasonable starting values greatly increases the chances for convergence.
*/
Parameter A = 10;
Parameter B = 0;
Parameter C = 0;
Parameter D = 0;
Parameter E = 0;

/*
* Work variables.
*/
double theta;
double dtheta;
double Norm;
double Deviation;

/*
*/

theta = X*3.14159/180.0;
dtheta = theta * 2.0;
Norm = A + B * sin(theta) + C * cos(theta) + D * sin(dtheta) + E * cos(dtheta);

/*
* Compute the deviation.
*/
Deviation = (Y - Norm) * (Y - Norm);

/*
* Minimize the sum of squared deviations.
*/
Function Deviation;
/*
* X, Y data values.
*/

Data;

100.0 0.0
117.9 -0.1
137.0 1.0
156.9 2.9
177.1 5.1
197.4 7.4
217.5 9.5
237.5 11.5
257.4 13.4
277.2 15.2
297.0 17.0
316.4 18.4
335.2 19.2
353.1 19.1
369.7 17.7
25.1 15.1
39.6 11.6
53.8 7.8
68.2 4.2
83.5 1.5

4. Thnq for sharing Informative news The Vasthi Water analyzer quality testing equipment is designed to give you field-ready durability with accurate results you can trust.