NMEA2000 and CAN Bus
Last updated
Last updated
CAN Stands for Controller Area Network.
The NMEA2000 Protocol uses the extended 29-bit CAN ID.
Each CAN frame can transmit up to 8 bytes of data.
The 29-bit ID is the 11 bit ID and 18 bit IDE.
ID - The 29-bit ID is the 11-bit ID and 18-bit IDE.
DLC - Data Length Code - tells us how many bytes of data the frame contains, up to 8 bytes
Data - 0 to 8 bytes
Priority - Priority of the message, highest priority messages are sent onto the network first.
PGN - Parameter Group Number, message type identifier
Source - ID of the device sending the message, 0-255
Data Length - 0 to 223
Data - 0 to 223 bytes
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.
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.
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.
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.