Company News

What is CAN Bus?

 What is CAN Bus?cid=16

1. Introduction to CAN Bus


1.1 What is CAN?

CAN Bus, short for Controller Area Network, was originally developed by the German electronics company Bosch. The initial motivation behind its creation was to solve the communication issues between the numerous electronic control systems in modern vehicles, reducing the growing number of signal wires. As a result, Bosch designed a single network bus, allowing all peripheral devices to be connected to this bus.


1.2 Features of CAN Bus

  • Multi-Master Capability: CAN Bus operates in a multi-master mode, meaning any node on the network can send messages to other nodes at any time, without being limited to master-slave communication. This provides flexible communication.

  • System Flexibility: Due to the design of CAN Bus, nodes can autonomously decide when to send data, allowing the system to adapt flexibly to different communication needs and conditions.

  • High Speed and Long Distance: CAN Bus supports high data transmission speeds and can transmit data reliably over long distances, thanks to its efficient communication protocol and strong anti-interference capabilities.

  • Error Detection, Notification, and Recovery: CAN Bus uses mechanisms like Cyclic Redundancy Check (CRC) to detect errors during data transmission. When an error is detected, the node sends an error frame to notify other nodes on the network. The system can then take corrective actions, such as retransmitting data, to ensure the accuracy of the transmission.

  • Fault Isolation: CAN Bus can isolate faulty nodes, preventing the fault from spreading to the entire network, ensuring the system's stability.

  • Supports Many Nodes: CAN Bus can theoretically support up to 110 nodes, making it well-suited for large-scale network communications.


2. Physical Structure of CAN Bus


2.1 Principle of CAN Bus

The CAN controller determines the bus level based on the potential difference between two wires (CAN_H and CAN_L). The bus level is divided into two states: dominant (logic 0) and recessive (logic 1). The sender changes the bus level to send a message to the receiver.

  1. CAN Bus Hardware Components

    • Microcontroller (e.g., 51 series microcontrollers): Responsible for data processing and communication control.

    • CAN Controller (e.g., SJA1000): Handles the implementation of the CAN protocol and generates data frames.

    • CAN Transceiver (e.g., PCA82C250): Converts the digital signals from the CAN controller to electrical signals suitable for transmission on the CAN Bus.

  2. Some modern microcontrollers, such as the STM32 series, have integrated CAN controllers, so only an additional CAN transceiver (e.g., SN65HVD230) is needed to handle signal conversion.

  3. CAN Bus consists of two wires: CAN_H (high) and CAN_L (low), which use differential signaling to transmit data, improving anti-interference capabilities. Typically, shielded twisted pair cables are used to reduce electromagnetic interference.


2.2 CAN Bus vs I2C

    Both CAN Bus and I2C (Inter-Integrated Circuit) are serial communication protocols for communication between devices, but they differ in several aspects:

  • Usage: CAN Bus is typically used for high-reliability applications like industrial control and automotive networks, while I2C is commonly used for low-speed control and data transmission.

  • Speed: CAN Bus can reach speeds up to 1 Mbps, while I2C typically operates below 400 Kbps.

  • Wiring: CAN Bus uses twisted pair wires, whereas I2C can use two-wire, three-wire, or four-wire setups, with the two-wire configuration being the most common.

  • Addressing: CAN Bus uses 11-bit or 29-bit standard frame identifiers for device identification, while I2C uses 7-bit or 10-bit device addresses.

  • Mode of Operation: CAN Bus is an asynchronous communication protocol in a multi-master environment, whereas I2C is a synchronous communication protocol typically used in a single-master environment.

In summary, while both CAN Bus and I2C are serial communication protocols, their application scenarios and characteristics are different.


3. Electrical Properties of CAN Bus


CAN Bus uses differential signaling for its electrical signals, transmitted over two wires (CAN_H and CAN_L). One key advantage of differential signaling is its superior immunity to external electromagnetic interference.

  • When the CAN controller sends a logic 1, the transceiver sets both CAN_H and CAN_L to 2.5V, resulting in a 0V voltage difference, which is called the recessive level.

  • When the CAN controller sends a logic 0, the transceiver sets CAN_H to 3.5V and CAN_L to 1.5V, resulting in a 2V voltage difference, which is called the dominant level.

When multiple nodes try to send messages simultaneously, bus arbitration is involved.


4. Types of CAN Frames

4.1 Types of CAN Frames

    The CAN (Controller Area Network) protocol defines several different types of data frames. Below are the basic types of CAN frames:

  • Data Frame: A frame used for sending data from the transmitting node to the receiving node.

  • Remote Frame: A frame used by the receiving node to request data from the transmitting node with the same ID.

  • Error Frame: A frame sent when a CAN node detects an error, notifying other nodes of the error (automatically done by hardware).

  • Overload Frame: Sent by a CAN node when it cannot process the received data at the current baud rate (automatically done by hardware).

  • Interframe Space: A frame that separates data and remote frames from the previous frame (automatically done by hardware).

Among these, error frames, overload frames, and interframe spaces are handled by hardware and cannot be controlled by software. For general users, understanding data frames and remote frames is sufficient.


4.2 Data Frame

   A data frame consists of seven segments: Start of Frame, Arbitration Field, Control Field, Data Field, CRC Field, ACK Field, and End of Frame.

  • Start of Frame: Marks the beginning of the data frame.

  • Arbitration Field: Indicates the priority of the frame.

  • Control Field: Contains information about the byte count of the data and reserved bits.

  • Data Field: Contains the actual data (can be 0-8 bytes).

  • CRC Field: Used for error detection in frame transmission.

  • ACK Field: Indicates confirmation of successful reception.

  • End of Frame: Marks the end of the data frame.


Data Frame Transmission Process:

  • When the bus is idle, the transmitting node starts sending the Start of Frame.

  • Next, it sends the Arbitration and Control fields.

  • If the Data Length Code (DLC) is non-zero, it sends the Data field.

  • Then it sends the CRC field for error detection.

  • If the receiving node correctly receives the frame, it sets the ACK slot to dominant in the ACK field, confirming the reception.

  • Finally, the transmitting node sends the End of Frame to complete the data frame transmission.


Arbitration Field

The Arbitration field consists of a standard format (11 bits) and an extended format (29 bits). The ID field in the arbitration section identifies the uniqueness of the frame and determines its priority on the bus. The smaller the ID number, the higher the frame’s priority.

  • RTR (Remote Transmission Request): Indicates whether this frame is a data frame or remote frame.

  • IDE (Identifier Extension): Indicates whether the arbitration field uses a standard (11-bit ID) or extended (29-bit ID) format.


Control Field

The Control field follows the Arbitration field and provides important information about the data that will be transmitted. The detailed fields include:

  • DLC (Data Length Code): A 4-bit field indicating the number of bytes in the Data field.

  • RTR (Remote Transmission Request): In data frames, this bit is dominant (0), indicating this frame contains actual data. In remote frames, it is recessive (1), indicating a data request frame.

  • IDE (Identifier Extension): Present only in extended format frames, indicating whether the arbitration field uses the standard or extended format.


4.3 Remote Frame

  A Remote Frame in CAN Bus is essentially a request for data. When a node needs data from another node, it sends a remote frame, which only contains the Arbitration and Control fields and no Data field.

Composition of Remote Frame:

  • Start of Frame (SOF): Marks the beginning of the frame.

  • Arbitration Field: Contains the identifier (ID) and the Remote Transmission Request (RTR) bit, which is recessive (1) to indicate this is a remote frame.

  • Control Field: Contains the DLC (Data Length Code), which is usually set to 0 in remote frames since they do not contain data.

  • CRC Field: Used for error detection.

  • ACK Field: Used to confirm the frame has been successfully received.

  • End of Frame: Marks the end of the remote frame.


Difference between Data Frame and Remote Frame: 

Data frames and Remote frames are similar in structure, but Remote frames do not have a Data field. The RTR bit in Data frames is dominant (0), while in Remote frames, it is recessive (1), indicating that the frame is requesting data.


Application of Remote Frame: 

Remote frames are useful when periodic data needs to be retrieved from a node, such as when a central controller in automotive or industrial automation systems periodically fetches real-time data from sensors.


What is CAN Bus?cid=16