The CAN (Controller Area Network) protocol was developed by the European automotive electronics company Robert Bosch GmbH in 1983 for in-vehicle networks. Developing the CAN protocol enabled robust data communication between different electronic control units (ECU) and microcontroller control units (MCU) of a vehicle on a single wire to eliminate complex peer-to-peer wiring between them. Despite communicating data over a single bus, CAN does not require any host computer.
The standard CAN protocol operates at the OSI model’s physical and data link layers. The other protocol stack layers are not implemented within CAN, which proved a great advantage. System engineers are free to design other protocol stack layers in a way that best suits an application. Today, CAN has a reputation as a robust, simple, cross-domain, versatile serial network communication protocol that must be implemented whenever frequent real-time data communication is required between electronic devices belonging to different domains. The CAN makes variations like CANopen, DeviceNet, and J1939, allowing implementation of all seven protocol stack layers along with standard CAN layers 1 and 2 for specific use cases. Learning the implementation of standard CAN protocol would be insightful.
In this article, we will examine the CAN protocol and its distinct features. Then, we will explore some typical applications of the CAN protocol and investigate how CAN is utilized there.
CAN standard
CAN specifications define the CAN protocol and the CAN physical layer. ISO-11898 specifications mainly define the protocol, but other specifications like ISO-11519 for low-speed serial data communication also apply to the protocol. The ISO-11898 specification is divided into three parts. The first part defines the specifications for the data link layer and single physical link. The second part of the specification describes the CAN physical layer for high-speed CAN. The third part of the specification defines the CAN physical layer for low-speed CAN.
The low-speed CAN has data rates of 5Kbps, 10, 20, 50, and 125Kbps. The high-speed CAN has data rates of 250, 500, 800Kbps, and 1Mbps. In a CAN network, the data is communicated over a shielded or unshielded twisted pair or ribbon cable having a characteristic impedance of 120 ohms. The DB9 (male) connectors are used as per CiA DS-102 specification. CiA stands for “CAN in Automation”. The maximum range of a CAN bus is 1000m (at 40Kbps). For high-speed CAN, the maximum range is 40m at 1Mbps. A maximum of 127 nodes can be connected to a CAN bus.
How CAN protocol works
Each electronic device or system connected to the bus is a node in a CAN network. Each node consists of three elements—Host controller, CAN controller, and CAN transceiver. The host controller is a microcontroller or processor within the device/system that runs some application for a specific job. The CAN controller handles the transmission and reception of CAN messages between the host controller and the CAN bus. It acts as a protocol handler. The CAN transceiver takes care of the transmission and reception of CAN messages over the CAN bus. It acts as a line driver. While the host controller is a physical controller/processor, the CAN controller and CAN transceiver are implemented in software or firmware.
Each node is a CAN transceiver. The data is communicated in a half-duplex, asynchronous manner. The bits are transmitted over the CAN bus using differential voltage. The two wires in the CAN bus are called CAN low and CAN high. The CAN bus has two unusual logic states: recessive and dominant. Logic 1 is the recessive state, and logic 0 is the dominant state. Usually, the bus rests at a recessive state, i.e., logic 1. For recessive state or communicating logical 1, both wires CAN low and CAN high are applied a voltage half of supply voltage VDD or VCC. The supply voltage is typically 5V, so both wires are applied at 2.5V. As a result, the differential voltage between the wires is 0V. This is read as logical 1. In the dominant state, CAN high is pulled up to 3.5V, and CAN low is pulled to 1.5V. As a result, the differential voltage between two wires is 2V. This is the dominant state of the bus, which is read as logical 0 by the CAN transceiver.
The dominant state always overrides the recessive state. When all nodes send the recessive bit, the bus only rests at the recessive level. Due to AND logic, the bus state is dominant even if a single node sends a dominant bit.
CAN is a message-based protocol. The data is communicated in the form of message frames. A frame is a meaningful sequence of bits. There are four types of message frames: data, remote, error, and overload. Data frames carry messages from a CAN transceiver, remote frames are sent to request data from other CAN transceivers, error frames are sent to indicate an error in a data frame, and overload frame is sent to indicate overloading of data frames, indicating the requirement of delay in transmission of data frames. An identifier field identifies each frame. The identifier field is 11-bit long in standard CAN and 29-bit long in extended CAN protocol. To learn more about the structure/format of the data frames and other CAN frames, check out this article on standard CAN protocol.
At a time, only one node can access the bus. The access method used in the CAN protocol is a Carrier Sense Multiple Access with Collision Detection (CSMA/CD) method called Bitwise Arbitration (BA). The identifier field of a data frame sets the priority of the message. The lower the identifier value, the higher the priority. So a data frame with identifier field 0x6C3 has higher priority than a data frame with identifier field 0x7B4. Similarly, a data frame with identifier field 0x7B3 has higher priority than a data frame with identifier field 0x7B4.
Any node can access the CAN bus if it is idle, i.e., in a recessive state. Suppose two or more nodes try to access the bus simultaneously. In that case, the node transmitting a data frame with a lower identifier field, i.e., a data frame with higher priority, gets the bus access. The identifier fields are compared bit-by-bit from MSB (bit 10) to LSB (bit 0) until a node wins arbitration. If a node is transmitting a correspondingly recessive bit while another is transmitting a dominant bit, the node loses the arbitration. In this manner, the node transmits a data frame with the lowest identifier value, i.e., highest priority, and gets access to the CAN bus. The other nodes have to wait for their turn according to the priority level of their data frame.
A data frame transmitted by a CAN node is transmitted to all other nodes on the bus. At each node, it is filtered by them and received only if the identifier field applies to them.
Why CAN?
There are many reasons to choose the CAN protocol. CAN is a serial network communication protocol that requires only two wires to communicate data among multiple devices. All the devices connected in a CAN network communicate over a common two-wire bus, so no two nodes/devices need to be connected.
As the CAN controller and transceiver are implemented at the software/firmware level, and the protocol is implemented at only the physical and data link layers, devices from different domains can communicate on the same bus. System engineers can individually design the other layers of the OSI model on each device or node according to the need or role of the particular node/device.
CAN is a message-based protocol. Unlike address-based protocol, adding or removing nodes on the bus does not affect this type of protocol. The messages transmitted over the bus are broadcast to all other nodes and filtered according to the identifier field at the node level. The priority is attached to the message frames, not the CAN nodes, using their identifier fields. In this way, there is no need to identify nodes sharing the CAN bus. The nodes can be inserted or deleted without affecting the CAN network.
As built for in-vehicle networks, the protocol uses differential voltages. So, data cannot be corrupted or altered by other nodes. Due to differential voltage levels, CAN is one of the most robust serial communication protocols.
The CAN bus has the least chance of collision between devices. By bitwise arbitration, priority is attached to messages, so the most important messages are communicated first over the bus, irrespective of the nodes transmitting them. The data is transmitted over the bus asynchronously and prioritized by bitwise arbitration.
The protocol enables error checking for reliability and offers excellent noise immunity. CAN is a widely used serial communication protocol for low-speed but frequent data exchange among embedded electronic devices. Many chips have built-in CAN interfaces. The semiconductor chips for setting up the CAN network are available from vendors like Maxim Integrated, Texas Instruments, Analog Devices, Microchip Technology, NXP, ST Microelectronics, and others.
Applications of CAN
The CAN protocol is widely used by all types of motor industry applications, including passenger vehicles, heavy goods and utility vehicles, and agricultural vehicles. Being a robust, reliable, and versatile serial communication protocol, CAN is not just limited to automobiles. The control modules of high-speed trains and aircraft use the protocol. It is used by entertainment and infotainment systems in automobiles. The protocol is used to control and monitor cranes and drilling probes. It is used by elevators and lift control systems. The protocol is utilized for building automation like heating and air-conditioning systems. Automatic doors and curtain openers are also used. It is used for automated watering in glasshouses and farms. The protocol is widely adopted in medical instrumentation due to its robustness and versatility. Many machine tool control systems use the CAN network as an in-device bus system enabling factory automation. The protocol is also used by sensor networks where signal robustness due to environmental factors is required.
CAN in automobiles
The CAN protocol is used in most passenger cars and enables data communication among several ECUs without any one-to-one wiring. Most cars have a CAN-based engine management system. Not just that, most cars connect body electronics ECUs through CAN-based multiplex systems. The in-vehicle entertainment systems are connected through the CAN bus. Apart from that, the CAN bus is used by in-vehicle diagnostic systems. ISO-15765 is a specification for CAN-based diagnostic interfaces. The CAN is also used for connection-oriented data communication between in-car entertainment devices.
The CAN network unexpectedly has a wider role in electric cars and hybrid vehicles. It is useful for communication between inverters, battery management systems, and servo motor controllers. It also connects servo controllers with a human-machine interface for the driver. Though CANopen is the CAN variant mostly used in non-automotive applications, it is finding utility in hybrid and electric vehicles.
Many agriculture machines, such as excavators and forklifts, rely on CAN-based networks. In truck-based cranes, the CAN is used to monitor and control the crane system.
CAN in public transport systems
The CAN protocol is widely used in high-speed trains and aircraft. Trains use CAN to connect brake control systems and enable automatic braking. Trains also use CAN to communicate with subsystems like brake control, door control, diagnostics, freight car monitoring, and gateways at train bus systems. CAN is also useful in automating customer services and passenger information systems.
In road transport, CAN-based sensor networks are used for speed detection, traffic surveillance, and traffic light management. CAN is also the protocol used by maritime electronic equipment. It also connects aircraft engine control systems with flight state sensors and navigation systems.
CAN for industrial automation
Because CAN is a reliable serial communication protocol equipped with error detection methods, robust signal logic, and capability of fault confinement, CAN-based protocols like CANopen, DeviceNet, and Smart Distributed Systems are widely used for industrial machine control. Semiconductor manufacturing equipment, carton packaging machines, textile processing machines, printing machines, and quality control equipment rely on embedded CAN networks. CAN-based distributed control systems are widely used for robot control and assembly line automation.
CAN in building automation
In building automation, the CAN protocol is widely used by sub-networks. The elevator and lift control system, air conditioning systems, automatic doors, automatic curtain openers, window shade control systems, heating, and cooling systems, and lighting control systems use CAN-based protocols for communication among electronic devices from different domains.
CAN in medical electronics
Due to robust signals, error-detection capability, and cross-domain communication, CAN is a protocol widely used for in-device communication in medical electronic equipment like X-ray machines and CT scanners. CAN-based protocols are also used for inter-device networking in intensive care units and operating theatres.
CAN in embedded electronics
CAN enables flexible embedded networking and is employed as a system bus in many consumer appliances and devices like washing machines, vending machines, audio video systems, coffee machines, and many other domestic appliances.
You may also like:
Filed Under: Tech Articles
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.