CAN Bus Reference
Free reference guide: CAN Bus Reference
About CAN Bus Reference
The CAN Bus Reference is a comprehensive cheat sheet covering the Controller Area Network protocol family across six categories: CAN 2.0 (classic), CAN FD (flexible data rate), CANopen (application layer), J1939 (heavy-duty vehicles), hardware specifications, and analysis tools. Each entry provides protocol details, frame structures, and practical configuration examples.
This reference covers CAN 2.0A standard frames (11-bit ID) and CAN 2.0B extended frames (29-bit ID), including bit timing parameters, arbitration mechanisms, error detection methods (CRC, ACK, stuff, form, bit errors), and error state transitions from Error Active through Error Passive to Bus Off. The CAN FD section details the flexible data rate extensions with DLC-to-byte mapping up to 64 bytes and dual bit rate operation.
For higher-layer protocols, the reference includes CANopen network management (NMT), Service Data Objects (SDO) for parameter access, Process Data Objects (PDO) for real-time exchange, Heartbeat monitoring, and the Object Dictionary structure. The J1939 section covers Parameter Group Numbers (PGN), 29-bit message ID breakdown, address claiming, DM1 diagnostic messages, and Transport Protocol for multi-packet transfers. Hardware entries detail termination resistors, wiring specifications (ISO 11898-2), transceiver ICs, DBC file format, and SocketCAN Linux commands.
Key Features
- CAN 2.0A/B frame structure with field-by-field breakdown: SOF, Identifier (11/29-bit), RTR, IDE, DLC, Data, CRC, ACK, EOF
- Bit timing parameters (Sync_Seg, Prop_Seg, Phase_Seg1/2, SJW) and baud rate vs. maximum bus length table (125 kbps to 1 Mbps)
- CAN FD DLC-to-byte mapping (DLC 9-15 maps to 12/16/20/24/32/48/64 bytes) with BRS dual-rate operation details
- CANopen protocol stack: NMT state machine, SDO upload/download with index/subindex addressing, PDO COB-ID assignments (TPDO/RPDO)
- J1939 29-bit ID structure (Priority, Data Page, PF, PS, SA), key PGN definitions (EEC1, ET1, CCVS), and DM1 DTC format (SPN/FMI/OC)
- Hardware specifications: 120-ohm termination, ISO 11898-2 voltage levels (dominant/recessive), DB9 pinout, and transceiver IC selection guide
- DBC file format syntax with message/signal definitions including bit position, length, byte order, factor, offset, and range
- SocketCAN Linux commands (ip link set, candump, cansend) and CAN FD setup with dbitrate configuration
Frequently Asked Questions
What is the difference between CAN 2.0A and CAN 2.0B?
CAN 2.0A uses standard frames with an 11-bit identifier, supporting up to 2,048 unique message IDs. CAN 2.0B uses extended frames with a 29-bit identifier (11-bit base + 18-bit extension), supporting over 500 million unique IDs. The IDE (Identifier Extension) bit distinguishes them: 0 for standard, 1 for extended. Both formats can coexist on the same bus, with standard frames winning arbitration over extended frames with the same base ID.
How does CAN bus arbitration work?
CAN uses non-destructive, priority-based bitwise arbitration. When multiple nodes transmit simultaneously, they compare each bit of the identifier on the bus. A dominant bit (logical 0) overwrites a recessive bit (logical 1). The node with the lowest identifier value wins arbitration and continues transmitting, while other nodes detect the difference and switch to receive mode. This means lower ID values have higher priority.
What payload sizes does CAN FD support?
CAN FD supports payload sizes of 0-8, 12, 16, 20, 24, 32, 48, and 64 bytes, compared to classic CAN which is limited to 0-8 bytes. The DLC (Data Length Code) values 0-8 map directly to byte counts, while DLC 9-15 map to 12, 16, 20, 24, 32, 48, and 64 bytes respectively. CAN FD also supports a higher data phase bit rate (up to 8 Mbps) through the BRS (Bit Rate Switch) mechanism.
What are SDO and PDO in CANopen?
SDO (Service Data Object) is used for non-real-time parameter configuration, allowing read/write access to the Object Dictionary using index and subindex addressing. SDO uses COB-IDs 0x600+NodeID (request) and 0x580+NodeID (response). PDO (Process Data Object) is used for real-time data exchange without protocol overhead. TPDO COB-IDs start at 0x180+NodeID and RPDO at 0x200+NodeID, with up to 4 of each per node.
How is a J1939 29-bit message ID structured?
The J1939 29-bit CAN ID is divided into: Priority (3 bits, 0-7 where lower is higher priority), Reserved (1 bit), Data Page (1 bit), PF/PDU Format (8 bits), PS/PDU Specific (8 bits), and SA/Source Address (8 bits). When PF < 240, the message is point-to-point (PDU1) and PS contains the destination address. When PF >= 240, the message is broadcast (PDU2) and PS is a group extension used to calculate the PGN.
Why do I need 120-ohm termination resistors on a CAN bus?
CAN uses a differential signaling scheme that requires impedance matching at both physical ends of the bus to prevent signal reflections. Each end needs a 120-ohm resistor between CAN_H and CAN_L. With two 120-ohm resistors in parallel, measuring between CAN_H and CAN_L with the bus powered off should read approximately 60 ohms. Missing or incorrect termination causes communication errors, especially at higher baud rates.
What is the DBC file format used for?
DBC (CAN Database) files define CAN message and signal structures in a standardized text format used by tools like Vector CANdb++ and PEAK PCAN-Symbol Editor. Each message definition (BO_) includes the CAN ID, name, DLC, and transmitting node. Signals (SG_) within a message specify the bit position, length, byte order, factor, offset, value range, unit, and receiving nodes. DBC files are essential for interpreting raw CAN data into engineering values.
How do I set up CAN communication on Linux with SocketCAN?
First configure the interface: "ip link set can0 type can bitrate 500000" and "ip link set can0 up". Use "candump can0" to receive all messages and "cansend can0 123#DEADBEEF" to send a message with ID 0x123. For CAN FD, add the fd flag and data bitrate: "ip link set can0 type can bitrate 500000 dbitrate 2000000 fd on". SocketCAN provides a standard socket API that tools like candump, cansend, and Wireshark can use directly.