The CAN (Controller Area Network) bus protocol defines four basic frame types and one inter-frame space, which are used for data transmission, error handling, bus load control, and other scenarios. Below is a detailed explanation of the structure, function, and practical applications of each frame type:
1. Data Frame
1. Function
-
Core Purpose: Transmission of actual data between nodes (e.g., sensor readings, control commands).
-
Frame Type:
-
Standard Data Frame: 11-bit identifier (ID).
-
Extended Data Frame: 29-bit identifier (ID).
2. Frame Structure
| Field | Bit Count | Description |
|---|---|---|
| Start of Frame (SOF) | 1 | Dominant 0, indicates the start of the frame. |
| Arbitration Field | 12/32 | 11-bit ID (standard frame) or 29-bit ID (extended frame) + RTR bit (dominant 0). |
| Control Field | 6 | IDE bit (identifies frame type), reserved bits, DLC (Data Length Code, 0-8 bytes). |
| Data Field | 0-64 | Payload, length defined by DLC. |
| CRC Field | 16 | 15-bit CRC checksum + recessive 1 delimiter. |
| ACK Field | 2 | ACK slot (receiving node pulls low) + recessive 1 delimiter. |
| End of Frame (EOF) | 7 | 7 recessive 1s, indicates the end of the frame. |
3. Application Scenarios
-
Automotive Electronics: Engine ECU sends RPM data (ID=0x123, data=0x01 0x45).
-
Industrial Control: PLC sends position commands to motor drivers (ID=0x200, data=0x00 0x7F).
-
Key Design:
-
High priority IDs (lower values) win arbitration, ensuring critical data (e.g., brake signals) is transmitted first.
-
The DLC field must accurately match the data length to avoid parsing errors at the receiver.
2. Remote Frame
1. Function
-
Core Purpose: Request other nodes to send a data frame with a specified ID (no data payload).
-
RTR Bit Identification: Recessive 1 (distinguished from the dominant 0 in data frames).
2. Frame Structure
-
Differences from Data Frame:
-
RTR Bit: Recessive 1 (in the arbitration field).
-
Data Field: No data (DLC=0).
3. Application Scenarios
-
On-Demand Data Retrieval: Dashboard requests engine temperature (sends remote frame ID=0x123, receiver replies with data frame).
-
Resource Conservation: Avoid periodic data transmission, reducing bus load.
-
Considerations:
-
Remote frames must match the data frame ID; otherwise, no response will be triggered.
-
The receiving node must be configured to support remote frame processing (some protocols like CANopen disable this by default).
3. Error Frame
1. Function
-
Core Purpose: Nodes actively interrupt communication when an error is detected, forcing the sender to retransmit.
-
Error Types: Bit error, CRC error, format error, ACK not acknowledged, etc.
2. Frame Structure
| Field | Bit Count | Description |
|---|---|---|
| Error Flag | 6 | Dominant 0 (active error) or recessive 1 (passive error). |
| Error Delimiter | 8 | 8 recessive 1s, indicates the end of the error frame. |
3. Trigger Conditions and Handling
-
Active Error:
-
When a node detects an error, it immediately sends 6 dominant 0s to notify the entire network.
-
All nodes terminate the current frame, and the sender retries.
-
Error Counters:
-
When the transmission error counter (TEC) and reception error counter (REC) exceed limits, the node enters a “bus off” state.
-
Application Scenarios:
-
When electromagnetic interference causes CRC check failure, an error frame is triggered for retransmission.
-
Critical systems (e.g., brake control) must be configured with a fast error recovery mechanism.
4. Overload Frame
1. Function
-
Core Purpose: The receiving node notifies the bus to delay processing the next frame (similar to a “busy line” signal).
-
Trigger Conditions: Internal processing overload in the node (e.g., buffer full, high CPU load).
2. Frame Structure
| Field | Bit Count | Description |
|---|---|---|
| Overload Flag | 6 | Dominant 0, similar to error frame but sent by the receiving node. |
| Overload Delimiter | 8 | 8 recessive 1s, indicates the end of the overload frame. |
3. Application Scenarios
-
High Load Systems: Gateway nodes temporarily delay reception while processing multiple CAN data streams.
-
Design Considerations:
-
Overload frames should not be abused, as they can significantly reduce bus efficiency.
-
Node processing capabilities must be optimized (e.g., increase buffer size, enhance MCU performance).
5. Inter-Frame Space (IFS)
1. Function
-
Core Purpose: Separates consecutive frames, ensuring node synchronization and bus idle detection.
-
Composition:
-
Inter-Frame Segment: 3 recessive 1s (standard interval).
-
Bus Idle Segment: Variable length of recessive 1s (when no frame is transmitted).
2. Application Scenarios
-
Multi-Master Arbitration: After the bus is idle, nodes can compete for transmission rights.
-
Error Recovery: Nodes attempt to retransmit error frames after the bus is idle.
-
Low Power Mode: If the bus is idle for too long, nodes can enter sleep mode (e.g., “Partial Network Wake-Up” in CAN FD).
6. Frame Type Comparison and Design Guidelines
| Frame Type | Sender | Typical Application | Design Points |
|---|---|---|---|
| Data Frame | Any Node | Transmission of real-time data (sensors, control commands) | Optimize ID priority allocation to ensure low latency for critical data. |
| Remote Frame | Requesting Node | On-demand data retrieval | Avoid frequent requests to prevent bus congestion. |
| Error Frame | Error Detecting Node | Error recovery and retransmission | Configure reasonable error counter thresholds to prevent node disconnection. |
| Overload Frame | Overloaded Receiving Node | Delay processing of new frames | Optimize node processing capabilities to reduce overload trigger frequency. |
| Inter-Frame Space | Automatically Generated | Separates frames and detects bus idle | Ensure interval time meets protocol requirements (e.g., CAN FD extension). |
7. Practical Application Cases
1. Automotive Power Systems
-
Data Frame: Transmission of current gear by the transmission controller (ID=0x100, data=0x03).
-
Error Frame: When a short circuit occurs on the CAN line, the ECU triggers an error frame and enters “bus off” protection mode.
2. Industrial Robots
-
Remote Frame: The main PLC requests the position of the joint encoder (ID=0x200), and the driver replies with a data frame.
-
Overload Frame: During multi-axis synchronous control, the slave node sends an overload frame due to computational delay.
3. Battery Management System (BMS)
-
Data Frame: The battery module (ID=0x301) reports voltage and temperature (data=0x25 0x3C).
-
Inter-Frame Space: When the bus is idle, the master node initiates a new round of data collection.
Conclusion
The design of CAN bus frame types is the core guarantee of its high reliability and real-time performance:
-
Data Frames and Remote Frames enable flexible data transmission.
-
Error Frames and Overload Frames ensure rapid recovery from abnormal states.
-
Inter-Frame Spaces maintain bus order and multi-master arbitration. Hardware engineers need to configure ID priorities, error handling strategies, and node load capabilities reasonably based on specific application scenarios (such as automotive and industrial) to fully leverage the performance advantages of the CAN bus.