CAN (Controller Area Network) protocolCAN stands for Controller Area Network protocol. It is a protocol that was developed by Robert Bosch in around 1986. The CAN protocol is a standard designed to allow the microcontroller and other devices to communicate with each other without any host computer. The feature that makes the CAN protocol unique among other communication protocols is the broadcast type of bus. Here, broadcast means that the information is transmitted to all the nodes. The node can be a sensor, microcontroller, or a gateway that allows the computer to communicate over the network through the USB cable or ethernet port. The CAN is a message-based protocol, which means that message carries the message identifier, and based on the identifier, priority is decided. There is no need for node identification in the CAN network, so it becomes very easy to insert or delete it from the network. It is a serial half-duplex and asynchronous type of communication protocol. The CAN is a two-wired communication protocol as the CAN network is connected through the two-wired bus. The wires are twisted pair having 120Ω characteristics impedance connected at each end. Initially, it was mainly designed for communication within the vehicles, but it is now used in many other contexts. Like UDS, and KWP 2000, CAN also be used for the on-board diagnostics. Why CAN?The need for a centralized standard communication protocol came because of the increase in the number of electronic devices. For example, there can be more than 7 TCU for various subsystems such as dashboard, transmission control, engine control unit, and many more in a modern vehicle. If all the nodes are connected one-to-one, then the speed of the communication would be very high, but the complexity and cost of the wires would be very high. In the above example, a single dashboard requires 8 connectors, so to overcome this issue, CAN was introduced as a centralized solution that requires two wires, i.e., CAN high and CAN low. The solution of using CAN protocol is quite efficient due to its message prioritization, and flexible as a node can be inserted or removed without affecting the network. Applications of CAN protocolInitially, CAN protocol was designed to target the communication issue that occurs within the vehicles. But later on, due to the features it offers, it is used in various other fields. The following are the applications of CAN protocol:
CAN layered architectureAs we know that the OSI model partitions the communication system into 7 different layers. But the CAN layered architecture consists of two layers, i.e., data-link layer and physical layer. Let's understand both the layers.
CAN specifications define CAN protocol and CAN physical layer, which are defined in the CAN standard ISO 11898. ISO 11898 has three parts:
CiA DS-102: The full form of CiA is CAN in Automation, which defines the specifications for the CAN connector. As far as the implementation is concerned, the CAN controller and CAN transceiver are implemented in the software with the help of the application, operating system, and network management functions. CAN FramingLet's understand the structure of the CAN frame.
Now we will see how data is transmitted through the CAN network. A CAN network consists of multiple of CAN nodes. In the above case, we have considered three CAN nodes, and named them as node A, node B, and node C. CAN node consists of three elements which are given below:
In the above diagram, unshielded twisted pair cable is used to transmit or receive the data. It is also known as CAN bus, and CAN bus consists of two lines, i.e., CAN low line and CAN high line, which are also known as CANH and CANL, respectively. The transmission occurs due to the differential voltage applied to these lines. The CAN uses twisted pair cable and differential voltage because of its environment. For example, in a car, motor, ignition system, and many other devices can cause data loss and data corruption due to noise. The twisting of the two lines also reduces the magnetic field. The bus is terminated with 120Ω resistance at each end. CAN CharacteristicsWith the help of differential voltage, we will determine how 0 and 1 are transmitted through the CAN bus. The above figure is the voltage graph that shows the voltage level of CAN low and CAN high. In CAN terminology, logic 1 is said to be recessive while logic 0 is dominant. When CAN high line and CAN low line are applied with 2.5 volts, then the actual differential voltage would be zero volt. A zero volt on CAN bus is read by the CAN transceiver as a recessive or logic 1. A zero volt on CAN bus is an ideal state of the bus. When CAN high line is pulled up to 3.5 volt and the CAN low line is pulled down to 1.5 volt, then the bus's actual differential voltage would be 2 volts. It is treated as a dominant bit or logic 0 by the CAN transceiver. If the bus state is reached to dominant or logic 0 then it would become impossible to move to the recessive state by any other node. Key points learnt from the CAN characteristics
CAN bus logicFrom the above scenario, we get to know that the dominant state overwrites the recessive state. When the node sends the dominant and the recessive bit simultaneously, then the bus remains dominant. The recessive level occurs only when all the nodes send the recessive bit. Such logic is known as AND logic, and physically it is implemented as an open collector circuit. CAN Communication PrincipleAs we know that the message is sent based on the priority set in the arbitration field. For the standard frame, the message identifier is 11 bit, while for the extended frame, the message identifier is 29 bit. It allows the system designer to design the message identifier at the design itself. The smaller the message identifier, the higher, would be the message priority. Let's understand how arbitration works through a flow chart. The sender wants to send the message and waiting for the CAN bus to become idle. If the CAN bus is idle, then the sender sends the SOF or the dominant bit for the bus access. Then, it sends the message identifier bit in the most significant bit. If the node detects the dominant bit on the bus while it has transmitted the recessive bit, it means that the node has lost the arbitration and stops transmitting further bits. The sender will wait and resend the message once the bus is free. CAN Arbitration ExampleIf we consider three nodes, i.e., Node 1, Node 2, and Node 3, the message identifiers of these nodes are 0x7F3, 0x6B3, and 0x6D9, respectively. The transmission of all the three nodes with the most significant bit is shown in the above diagram. 11th bit: As all the three bits of nodes are recessive, so bus bit will also remain recessive. 10th bit: All the nodes have 10th bit as recessive, so the bus will also remain recessive. 9th bit: Node 1 has recessive bit while other nodes have a dominant bit, so the bus will also remain dominant. In this case, node 1 has lost the arbitration, so it stops sending bits. 8th bit: Both node 2 and node 3 are sending recessive bit, so that the bus state will remain recessive. 7th bit: The node 2 is sending dominant bit while node 3 has sent recessive bit, so that the bus state will remain dominant. In this case, the node 3 has lost the arbitration, so it stops sending the message while the node 2 has won the arbitration means that it will continue to hold the bus until the message is received. Next TopicHTTP Status Codes |