CAN Bus Protocol
Diode
-by Sahaj Saxena [CompSoc]
published on May 21, 2021, midnight

The CAN Bus protocol stands for Controller Area Network Protocol, which is a two wired, bidirectional serial bus communication method. It was designed to perform in harsh environments such as in the automotive industry, but now it has emerged as a go-to network technology in industrial automation as well as in other applications. CAN define the data link and physical layer of the Open Systems Interconnections (OSI) model, thus providing a low-level networking solution for high-speed in-vehicle communication. CAN Bus is primarily used in embedded systems and provides fast communication among microcontrollers up to real-time requirements, thus eliminating the need for the much more expensive and complex technologies.

History

The controller Area Network (CAN) was originally developed by Bosch in 1986 for in-vehicle networks. Before that, automotive manufactures connected electronic devices in a vehicle using point-to-point wiring systems. Point-to-point wiring systems were those in which all the electronic components had their data line wired individually. As manufacturers began using more and more electronics in vehicles the wiring harnesses became more heavy and expensive. So they replaced the primitive point-to-point wiring system with in-vehicle networks.

As the CAN communication protocol had high immunity to electrical interference and the ability to self - diagnose and repair data errors, the automotive industry readily adopted the CAN Bus Protocol, and later in the year 1993 it became the international standard known as ISO 11898. Since 1995 many Higher Layer Protocols (HLPs) were developed for and standardized on CAN.

Today, CAN is found in almost every market while developments are continuing in the area of HLPs to support the needs of existing and new developers.

What makes CAN Bus special?

img-1

Structure of CAN Frames

Communication over the CAN Bus is done via CAN frames. The original ISO laid out what is called a Standard CAN. Standard CAN uses an 11-bits identifier for different messages, later CAN was modified and the identifier was extended to 29-bits which is known as Extended CAN.

Standard CAN

img-2

The meaning of the bit fields of the above figure is -

Extended CAN

img-3

As shown above, the Extended CAN is the same as Standard CAN with the addition of -

How CAN Communication Works

CAN data transmission uses a lossless bitwise arbitration(the process in which two or more CAN controllers agree on who is to use the bus) method of contention resolution. This arbitration method requires all nodes on the CAN network to be synchronized to sample every bit on the CAN network at the same time. The CAN Bus consists of two wires CANH and CANL, when the controller sends a stream of bits, these are complemented and placed on the CANH line. The CANL line is always the complement of CANH.

The CAN specifications use the terms "dominant" bits and "recessive" bits, where dominant is a logical 0 and recessive is a logical 1. The idle state is represented in the CAN Bus is by the recessive level. If one node transmits a dominant bit and another node transmits a recessive bit then there happens a collision and the dominant bit wins. This means there is no delay to the higher-priority message, and the node transmitting the lower priority message automatically attempts to re-transmit six-bit clocks after the end of the dominant message. This makes CAN very suitable as a real-time communications system.

The exact voltages for a logical 0 or 1 depend on the physical layer used, but the basic principle of CAN requires that each node listens to the data on the CAN network including the transmitting node itself. If a logical 1 is transmitted by all transmitting nodes at the same time, then a logical 1 is seen by all of the nodes, including both the transmitting node and receiving node. If a logical 0 is transmitted by all transmitting nodes at the same time, then a logical 0 is seen by all nodes. If a logical 0 is being transmitted by one or more nodes, and a logical 1 is being transmitted by one or more nodes, then a logical 0 is seen by all nodes including the node transmitting the logical 1. When a node transmits a logical 1 but sees a logical 0, it realizes that there is a collision and a high priority is being sent thus it quits transmitting. By using this process, any node that transmits a logical 1 when another node transmits a logical 0 re-transmits the message six-bit clocks after all the high priority message ends and the CAN frame bit-stream continues without error until only one node is left transmitting. Since the 11 (or 29 ) bit identifier is transmitted by all nodes at the start of the CAN frame, the node with the lowest identifier transmits more zeros at the start of the frame, and that is the node that wins the arbitration or has the highest priority.

CAN Message Types

Four different types of frames can be transmitted through a CAN Bus -

Conclusion

This blog introduced CAN Bus Protocol. To summarize CAN Bus is a robust serial communication network protocol that is suitable to work in harsh working environments. CAN uses a differential signal, which makes it more resistant to noise, along with a priority arbitration scheme for non-destructive message transmission.

References

Check out more blogs!