Sunday, July 10, 2011

Interfacing the Airmar H2183 Gyrocompass (Part 1)

In this system, the Olimex microcontroller is used to read the NMEA output from the gyrocompass and from the GPS. It is also programmed as an I2C client that the main controller interrogates ten times per second.

The system actually uses an Airmar H2183 gyrocompass to get heading, heel and pitch angles, and rate of turn values. This compass can provide both NMEA 0183 and NMEA 2000 outputs. Here we use the NMEA 0183 output which is a standard RS232 serial bus.

In order to configure and calibrate the compass, it is necessary to get a specific Airmar cable and USB converter in the following temporary arrangement.

The Airmar WeatherCaster software has been used to configure the following NMEA 0183 sentences:
               $HCHDG (at 5 Hz) for the magnetic heading
               $PFEC,GPatt (at 5 Hz) for the heel and pitch angles
               $TIROT (at 2 Hz) for the rate of turn.

For this selection of outputs, we are limited to 5 Hz by the 4800 baud NMEA 0183 bandwidth.

Here is the format of the output sentences:
               $HCHDG,55.6,0.0,E,,*1F     (magnetic heading : 55.6 deg)
               $PFEC,GPatt,,-8.7,+4.8*63   (pitch angle : -8.7 deg,  heel angle: 4.8 deg)¸
               $TIROT,4.3,A*3C   (rate of turn:  4.3 deg/min).

The WeatherCaster software has also an autocalibration routine, but it is almost necessary to use a custom calibration, as explained in a previous post:

Once configured, here is how the compass is interfaced to the microcontroller, using a Conxall CX-428-8-pin connector :

Here is the pin-out of the WS-C01 cable. On the microcontroller side of the cable, we need to provide +12 V to pin 2, ground pins 1 and 8, and connect pin 5 (A/+ OUT) to the receive pin of the DB9 connector of the Olimex board.

In part 2, I will post the microcontroller code used to parse the NMEA sentences.


  1. You can use some proprietary NMEA commands to adjust the baud rate and message transmission rates on the H2183, so that you could get 10Hz. I have a document titled "PB100 Weatherstation Technical Manual" that describes this, if you'd like it. I can't find a link to it on airmars site, anymore, so I uploaded it here.

    Also, my H2183 gives the heel and trim with the YXXDR. I wonder if these are different versions, or something.

  2. It is my understanding that the Airmar WeatherCaster software effectively uses these proprietary commands behind the scenes when you use it to configure which sentences you want and their respective update rates. Depending on your selection, the WeatherCaster also reports which percentage of the NMEA 0183 4800 baud bandwidth you will be using. Keeping only the $HCHDG sentence, it is indeed possible to ask for a 10 Hz transmission rate, but when adding something else, the bandwidth is exceeded.

    If I ever decide to get the 10 Hz update rate on all 3 sentences, I plan to use the N2K output of the H2183 and replace the Olimex AVR-MT-128 board by this one ( which has a CAN controller that can be programmed to decipher N2K PGNs.

    The H2183 can output both '$YXXDR' and '$PFEC,GPatt' sentences for heel and pitch, but the latter is more economical in terms of bandwidth.

  3. I've never used the WeatherCaster software, so I can't speak to that. One think that you can do with the raw NMEA commands is turn the baud up to 38400 (PAMTC,BAUD), which is enough to get heading, attitude, and rot at 10 Hz.

    I just found this document, which is specific to the H2183: It also specifies how to view and set the compass's internal calibration tables (PAMTC,COMP). The available values are X,Y, and Z axis gain and linear offset, X axis angular offset, and damping. I don't know enough to know if these numbers serve the same purpose as a deviation table, but my intuition says no.

  4. Thanks Grady Morgan, I was unaware of the 38400 baud possibility. I will certainly try to implement it at the end of this sailing season. This will require a bi-directional communication link to properly initialize the compass, as the baud rate always reverts to 4800 on power up. But this is well documented in the linked document.

    As for calibration data, the document indicates that reading or writing calibration values is not currently supported, even if the proprietary sentences have some fields reserved for that. I suspect that the actual non-documented calibration routine is much more elaborate that updating the gain (sensitivity) and offset (bias) of the magnetometer. This comforts me to pursue and complete the development of a custom compass, where everything will be transparent and more accurate.