Sierra

Radio

PayPal: View Cart

Project:  Digital Electronic Compass

The following experiments were performed with a Honeywell HMC6352 compass sensor on a HamStack prototype board plulgged on top of a HamStack CPU board which is, in turn, plugged on top of a HamStack Project Board to provide a power supply and serial RS232 connections.


The test program was written to read the sensor at roughly 10 times per second, with the result displayed on an LCD display and sent to a PC via the serial port. The sensor’s built-in calibration routine was run once, a day before the experiment was started, before the sensor and processor stack was placed in location for the experiment.

The Hamstack with sensor was set on a shelf, and data was captured data in three orientations: with each of 3 edges of the case bottom against the back of the bookshelf.


The third orientation was captured twice, once for a little over an hour, then overnight. The setup was then repositioned to orientation 1. Data was captured for a few minutes, then power was cycled, and a final set of data was captured.











The two orientation 3 experiments differed by only 0.2 degrees. The two orientation 1 experiments, separated by approximately 18 hours differed by 0.1 degrees. The two orientation 1 experiments, separated by a power cycle differed by 0.1 degree.

There is some non-linearity in the sensor, even with calibration. The orientations should differ by exactly 90 degrees (assuming that the plastic case is square, which is probably true to within a few tenths of a degree). Subtracting:


O2 – O1 = 96.5 degrees

O3 – O2 = 178.7 degrees

O3 – O1 = 275.1 degrees


The non-linearity error with calibration suggests a peak error of less than 7 degrees (although a more thorough measurement of all orientations may show a larger error). Calibration is accomplished by sending the start calibration command to the sensor, then slowly rotating the senor in place at least one full rotation. It is completed by sending the stop calibration routine to the sensor. To achieve the best calibration, the sensor should be far from any magnetic material and should be held level while rotating. This was not done carefully prior to these experiments. The sensor was rotated while resting on a desk which contains some steel supports. The sensor accuracy is also very sensitive to tilt. The sensor was not carefully leveled for this experiment.


There is a low frequency drift component to the noise, which is visible in a plot of the overnight data set. Without further experiment, it is not clear if the long drift is temperature or voltage drift, or is 1/f noise. The plots suggest that there are sudden shifts in value as would be expected for sensor magnetic domain noise. These may be associated with automatic domain reset operations performed by the sensor to limit the magnitude of errors caused by sensor magnetic domain effects.


























The results shown above are for the second time this complete experiment was performed. The same data was captured 24 hours earlier using a version of the Hamstack program which did not capture all of the sampled points. The noise calculations are not valid for that experiment, however the mean values, in comparison with the data above provide a further indication of the sensor stability over time. The worst case mean change for all experiments was less than 1.7 degrees.

































Typical hardware connections

The hardware connections between the compass chip and the HamStack CPU is very simple using the I2C (Inter-IC) serial communications channel.  


Software test case written in Microchip C18 C language


/*  user_code_compass.c  J. S. Best  9/21/2011  */


#include "hamstack.h"

#include "stdio.h"

// The mode switch on the Hamstack

// CPU board is used to trigger

// the compass sensor calibration

// routine. Initialize it for

// input.


void user_init(void) {

  MODESWDIR = 1;

}


void user_once(void) {

  static char s[30];

  lcd_clear();

  lcd_home();

  // Must wait for compass to

  // initialize before talking to

  // it.

  waitlong(1000);

  // This isn't necessary, it is

  // just used to verify that

  // communication with the sensor

  // is working correctly and

  // it is set in the correct mode

  // (0x50)

  sprintf(s,"mode: 0x%x",

  compass_getmode());

  lcd_puts(s);

  waitlong(5000);

}


void calibrate(void) {

  lcd_clear();

  lcd_home();

  lcd_putrs("Calibration ");

  lcd_line2();

  lcd_putrs("Rotate sensor ");

  if (compass_calstart()) {

    lcd_line2();

    lcd_putrs("i2c error ");

  }

  else {

    waitlong(20000);

    lcd_clear();

    if(compass_calend()) {

      lcd_putrs("i2c error ");

    }

    waitlong(20);

  }

}


void user_code(void) {

int cnt, oldcnt;

static char s[30];

if (!MODESWIN) calibrate();

  cnt = compass_read();

    if (cnt < 0) {

      lcd_line2();

      sprintf(s, "i2c error: %d", -cnt);

      lcd_puts(s);

      waitlong(5000);

    }

    else { //if (cnt != oldcnt) {

      oldcnt = cnt;

      sprintf(s, "heading: %3d.%0d ",cnt/10, cnt%10);

      lcd_home();

      lcd_puts(s);

      sprintf(s, "%3d.%0d\r\n", cnt/10,cnt%10);

      serial_puts(s);

    }

    waitlong(100);

}


Summary


The noise is very low. The repeatability is good, within a range of less than 2 degrees. There is a low frequency wander with an amplitude which is comparable to the high frequency noise. This was observable in the plot of the overnight run. Non-linearity, after calibration is on the order of 7 degrees peak to peak.

The sensor was not characterized while exposed to significant levels of RF. Note that non-ferrous Faraday shielding could be used to mitigate the influence of RF without compromising the sensitivity to measuring the earth’s magnetic field.

Overall, these results are very encouraging, and suggest that this sensor would be appropriate for indicating the heading of an HF beam antenna.


At this point it would not be recommended for use in situations where a sensor reading error could result in injury or damage to equipment.

Honeywell HMC6352

Download this whitepaper