NMEA HDG --> HDT conversion

MPep

Senior Member
NMEA HDM --> HDT conversion

Hi there,

I am posting this as an example of how I came to convert an NMEA APHDM sentence to APHDT.

*In it, I have used maths directly on ASCII characters. I thought it was easier to do it this way, rather than converting to binary, then back to ASCII again. Space is rather limited in a 08M!

*The M sentence stands for HeaDing Magnetic, the T sentence for HeaDing True.

The differences are that the T sentence is effectively what a Gyrocompass outputs.

Unfortunately, the only data there was came from an autopilot that had a magnetic fluxgate sensor connected.

The other difference is that of magnetic variation. A Gyrocompass is referenced to lines of longitude, whereas the fluxgate is referenced to the magnetic magma in the centre of the earth. In the southern hemisphere the magnetic south pole is not even on Antarctica!!

The vessel in question is a local boat that does not travel away from its home port much. The, then current, GPS did not have the magnetic variation as part of the GPRMC sentence anyway, so a fixed variation of 23.4 degrees was set. This is correct for Christchurch, New Zealand.

Also, as a 08M was used, I had run out of inputs!
No CRC is transmitted as the navigation program (Seaplot 6) does not require it.
*In fact many navigation programs can be set to ignore the CRC, though not all.

If you use this, you will need to find the variation for your locale, or even better strip out the variation value from the RMC sentence, and add to, or subtract from, the magnetic compass heading.

If I were to do this project again, I would probably use an 18X (more code space and more IO), in order to do automatic variation correction.

Feel free to use it. Any feedback appreciated.
Feel free to ask questions.

Regards,
Mark.
 

Attachments

Last edited:
Top