NMEA2000 and CAN Bus

CAN bus

CAN Stands for Controller Area Network.

Converting between CAN Frames and NMEA2000 Messages

The NMEA2000 Protocol uses the extended 29-bit CAN ID.

CAN Frame

Each CAN frame can transmit up to 8 bytes of data.

The 29-bit ID is the 11 bit ID and 18 bit IDE.

Important parts of a CAN Frame

  1. ID - The 29-bit ID is the 11-bit ID and 18-bit IDE.

  2. DLC - Data Length Code - tells us how many bytes of data the frame contains, up to 8 bytes

  3. Data - 0 to 8 bytes

Parts of a NMEA Message

  1. Priority - Priority of the message, highest priority messages are sent onto the network first.

  2. PGN - Parameter Group Number, message type identifier

  3. Source - ID of the device sending the message, 0-255

  4. Data Length - 0 to 223

  5. Data - 0 to 223 bytes

Conversion from CAN to NMEA2000

The priority, PGN, and source are taken from the 29-bit extended CAN ID. Bits 0-7 are the source, 8-25 is the PGN, and bits 26-28 are the priority.

For a CAN ID of 0x15F80103, the Priority is 5, the PGN is 129025 (0x1F801), and the Source is 3.

Extended CAN ID to NMEA2000

The NMEA message's data length is determined from the PGN. Each PGN has a set data length. This tells us how many bytes of data are in the message.

No processing is needed between the CAN and NMEA data.

Fast Packet Protocol

Each CAN frame can only transmit up to 8 bytes of data, but NMEA Messages can be up to 223 bytes of data. To send and receive messages larger than 8 bytes, NMEA2000 has defined a Fast Packet protocol.

With the Fast Packet Protocol, multiple CAN frames make up 1 NMEA message, depending on the length of the message. In the CAN frames that make up the message, the CAN ID is the same for each message frame, but the first byte of data for each frame is reserved for a packet identifier, and the second byte of the first frame is reserved for the data length.

The packet identifiers contain a Sequence ID (bits 5-7) and Sequence Item Number (bits 0-4). The Sequence ID is the same for all frames in a sequence (all frames that form 1 NMEA message), but the Sequence Item Number increments by one for each message (it contains the message order). Messages don't have to be sent in order because they can be re-ordered from teh Sequence Item Number.

Example of PGN 129029 - GNSS Position Data

This message has a data length of 43 bytes (0x2B). Here's an example of the data that could be transmitted.E0, E1, E2... represent the sequence ID, 2B represents the data length, and the rest of the values are the data.

E0 2B 09 4A FF 23 44 39
E1 89 FF FF FF 43 DC FC
E2 2D B5 CF FF FF FF FF 
E3 98 3E E4 81 46 A7 CC
E4 38 59 8A BC CF FE FF
E5 57 4C 8D F1 F2 99 58
E6 43 22

Don't confuse the data length with a CAN Frame's Data Length Code (DLC). The NMEA message's Data Length can be up to 223, while the CAN Frame DLC can be up to 8. For the above example, all CAN frames would have a DLC of 8 except for the last frame, which would have a DLC of 3.

Last updated