CAN protocol is a serial communication protocol that allow micro-controllers to communicate with each other. It’s a multi-master message broadcast system which is used mostly in Automotive industry. It’s a peer-to-peer network i.e. all ECUs have equal right to send a message over the CAN bus.

First things first: What is an ECU?

An Electronic Control Unit (ECU) is an embedded device fitted inside the vehicle which controls a specific feature. Most common ECU example are Engine Control Module (ECM), Transmission Control Module (TCM), Powertrain Control Module (PCM), ABS (Anti-lock braking system), Body Control Module (BCM) and many more. These are electronic devices which control mechanical movable parts of the vehicle through a software code running inside them. Modern day vehicles contain more than 100 ECUs per vehicle.

These ECUs communication with each other continuously over a in-vehicle network like CAN, CAN-FD, LIN, Ethernet, FlexRay, MOST etc. CAN is the most commonly used in-vehicle network in modern day automotive vehicles.

What is CAN protocol?

CAN is short for ‘controller area network’. CAN is an in-vehicle bus network designed to allow micro-controllers and ECUs to communicate with each other in accordance with the ISO 11898 standards. These standards define how the CAN communication happens, how the wiring is configured and how the CAN messages are constructed.

CAN is a peer-to-peer network i.e. all the ECUs have equal rights to send messages on the bus. CAN Identifier sets the priority of the messages i.e. lowest identifier has the highest priority and it will be sent first. If 2 ECUs start a transmission at the same time, then the priority of CAN-ID decides which ECU is permitted to send its message. This process is called bit-by-bit Arbitration according to CSMA/CA. The maximum speed of a CAN bus is 1 Mbit/sec according to the standard however this varies based on the CAN configuration used.

CAN protocol has different CAN configurations according to the wiring and voltage levels i.e. High Speed CAN, Low Speed CAN and Single Wire CAN (SWC). However, generally, High speed CAN is mostly used and is called just CAN.

Block Diagram of an ECU with CAN interface

Acceptance Filter: It decides whether a message is relevant or not for an ECU.

CAN core Block: It implements the CAN protocol.

Interface Management Logic: It makes an interface with the micro controller.

Transmit Block: It stores complete CAN messages (standard or extended).

Receive FIFO: It can store up to 32 CAN messages, According to Filter setting, the received messages are either transferred to Receive FIFO or not.

ECUs connected over High Speed CAN

CAN protocol physical layers

The CAN physical layer refers to the hardware and electrical characteristics of the CAN protocol, defining how data is transmitted over the CAN physical medium (which is typically a twisted-pair of copper wiring). It includes specifications for voltage levels, signaling rates, wiring topology, termination, which ensures reliable communication between different nodes in a CAN network.

There are several different physical layers:

High Speed CAN

The most common type of CAN physical medium is called High Speed CAN and is defined by the CAN standard ISO 11898-2.

High Speed CAN is a parallel or twisted, shielded or un-shielded pair of wires with differential voltage. High speed CAN has a baud rate of up to 500 kbits/sec. The two wires in CAN are called CAN_H (CAN_High) and CAN_L (CAN_Low). The maximum length of stub must not exceed 30 cm for 500 kbits/sec speed. For longer wiring a ground is included.

A high speed CAN has to be terminated using 120 Ohm terminating resistors on both ends of the bus. This is to supply characteristic line impedance. CAN_H and CAN_L have differential voltage levels. The recessive level is 2.5 V on both CAN_H and CAN_L. Whereas, the dominant level is 3.5V for CAN_H and 1.5V for CAN_L. The differential Signal is Vdiff = CAN_H – CAN_L.

Gateways can be used to connect ECUs in a system where both High Speed CAN and Low Speed CAN networks exist.

    High Speed CAN and Low Speed CAN connected via a Gateway

Low Speed CAN

ISO standard, ISO 11898-3, defines another two-wire CAN physical medium for lower bus speeds which is called as Low Speed CAN.

Low Speed CAN has a maximum baud rate of 125 Kbits/sec. According to the standard ISO 11898-3:2006 (low speed, fault tolerant (LSFT) medium-dependent interface) a data rate between 40 kbit/sec and 125 kbits/sec is specified.

There is no termination on both ends of the bus in low speed CAN unlike High speed CAN. The low speed CAN has to be terminated separately at every node. Different voltage levels on low speed CAN are:

0.2V and 3.6V for CAN_H

1.8V and 4.8V for CAN_L

The main difference between High Speed CAN and Low Speed CAN is not the data rate, but the voltage levels. Because of the low data rate in combination with high voltage range, low speed CAN is able to operate despite the following malfunctions:

  • Interruption of CAN_H and CAN_L.
  • Shortcut between CAN_H or CAN_L and battery voltage.
  • Shortcut between CAN_H or CAN_L and ground.
  • Shortcut between CAN_H and CAN_L.

Single Wire CAN

Single Wire CAN (SWC), defined by SAE J2411, consists of a un-shielded single wire as a physical connection between CAN nodes with voltage level related to the ground. Voltage level is between 0V and 4.1V.

Single Wire CAN was developed by General Motors as an alternative to SAE J1850. It is also called as GMLAN. It is mostly applied in comfort electronics, example: central locking system, power windows etc. SWC transceiver is connected directly to the battery voltage with termination on every transceiver.

In SWC, data rate in normal mode for onboard communication is 33.33 kbits/sec. The data rate in high speed mode for diagnostic communication is 83.33 kbits/sec. The maximum number of nodes in a network is 32. SWC has a selective sleep mode.

History of CAN protocol development

CAN protocol was developed by Robert Bosch GmbH. Its development started in 1983 and it was released in 1986 at the Society of Automotive Engineers (S.A.E.) conference in Detroit, Michigan. CAN was developed because of the rising need of a serial bus communication in vehicles to add new functionalities in the vehicles. CAN also helped in reducing the wiring harnesses.

CAN protocol Standard

CAN is an ISO defined serial communications bus network. Full form of CAN is Controller Area Network. It was originally developed for the automotive industry to replace the complex wiring harness with a two-wire bus system. CAN communication ISO standard is ISO-11898: 2003.

How CAN protocol works?

CAN is a message-based protocol which is used to transmit data digitally via twisted pair of copper wires with differential voltage. Information is sent via fixed format messages. When the CAN bus is free, any ECU or node can send its messages. Each ECU can have many messages depending on the amount of information it has. A single CAN message can send a maximum of 8 bytes (8*8=64 bits) of data.

CAN message

Each ECU sends information to each other in the form of CAN messages. These messages contains the data. Since CAN bus is a broadcast bus, therefore all nodes can ‘hear’ all transmissions. Each CAN message has a unique CAN identifier (CAN-ID) using which a CAN message is redirected to a specific ECU. A CAN message can carry upto 8 bytes of data.

CAN identifier / CAN Arbitration ID

Each message has a unique Identifier (hexadecimal) called as CAN-ID or CAN Arbitration ID. A CAN-ID uniquely identifies a CAN message. There are two types of CAN-IDs i.e. Standard CAN and Extended CAN frames. This is how a CAN message is structured:

Standard CAN frame structure

Types of CAN messages

There are 4 types of CAN frames. They are:

1. Data Frame

A data frame is the most common frame in CAN protocol. It contains the data. All regular frames on the CAN bus containing the data is called Data frame. It consists of 7 fields.

2. Remote frame

If a node requires data from another node on the network then this can be achieved by sending a Remote Frame. For example – A comfort electronics ECU sends a remote frame to the powertrain ECU to know the state of the transmission gear (i.e. is the car in parking mode?). A remote frame is same as a data frame with two major differences:

  • It is explicitly marked as a Remote Frame by setting RTR bit as recessive (1).
  • There is no Data Field in the remote frame.
3. Error frame

If a transmitting or receiving node detects an error, it will send an error frame and cancels the transmission. Error frame consists of an error flag made up of six dominant bits (000000) and an error flag delimiter made up of eight recessive bits (11111111).

Error frame structure in CAN protocol

Since this bit string violates the bit stuffing rule, all the other nodes respond by transmitting error flags as well. After detecting a sufficient number of errors, the node will eventually turn itself off.

There are two types of error flags – Active and Passive. Active error flags consists of 6 dominant bits (000000) and Passive error flags have 6 recessive bits (111111). The errors are calculated in a counter:

REC – Receive Error Counter

TEC – Transmit Error Counter

When TEC/REC > 255, then Bus is off

When TEC/REC > 127, then Passive error flags is set

When TEC/REC < 128, then Active error flags is set

4. Overload frame

An Overload frame is used to report an overload. It is sent when a CAN node receives messages faster than it can process them to provide extra time between successive Data or Remote frames. Similar to an Error frame, the Overload frame has two fields as well: an overload flag consisting of six dominant bits (000000), and an Overload Delimiter consisting of eight recessive bits (11111111). Unlike error frames, error counters are not incremented in Overload frames.

Overload frame structure in CAN protocol

Bus Arbitration

CAN Identifier sets the priority of the message. Lower the CAN-ID (meaning lower hexadecimal number), higher is the message priority. Therefore, high priority messages are reserved for safety critical features like braking, steering, Airbags. Example: message with CAN-ID 0x001 has high priority as compared to message with 0x004 CAN-ID. Now what is the benefit of high priority? If 2 ECUs starts a transmission at the same time, then priority of the message decides which ECU is permitted to send the message first. This process is called bit-by-bit Arbitration according to CSMA/CA (Carrier-sense multiple access with collision avoidance).

Bit-rate or Baud rate of CAN

CAN bit rate is the number of bits that can be transmitted over a CAN bus in a second. It defines the data rate or speed of CAN network. CAN max speed is 1 MBits/sec (i.e. 1*1000*1000 bits = 1,000,000 bit = 125,000 Bytes = 125 KByte per sec). This is the max a CAN message can transmit in 1 second.

Error Detection techniques in CAN

CAN uses many ways to detect errors on the bus. There are majorly 5 techniques to detect an error in a CAN frame:

1. Checksum Error (CRC error)

CAN controller of transmitting ECU calculates a checksum over all bits of the message and sends a checksum in the CRC field. Each receiving ECU also calculates the checksum and compares it to the checksum of the transmitter. If there is a mismatch then CRC error is detected.

2. Frame check (Format error)

Both transmitting (Tx) and receiving (Rx) ECUs check if the frame format is correct or not. Example: A dominant (0) bit is detected in the EOF field (which should contain all recessive bits).

3. Acknowledge (ACK) check

Every receiver ECU which has performed a CRC check successfully overwrites ACK bit (1) by a dominant bit (0).

4. Bit Monitoring

Every ECU transmitting CAN messages also monitors the CAN bus. Therefore the transmitting ECU also receives its own message. A bit error is detected if a transmitted bit differs from a received bit.

5. Bit Stuffing and Resynchronization

CAN uses NRZ (No Return to Zero) for bit coding. Transmitter adds a complementary bit to the bit stream when the level does not change for more than 5 bits. These bits are called stuff bits and have to be extracted from the data flow by the receiver. This process is called bit stuffing.

Further Developments

CAN FD (Controller Area Network with Flexible Data-rate) was introduced as an extension to the original CAN protocol. The standardization of CAN FD took place with the release of ISO 11898-1:2015, which was published in 2015. Further, CAN XL (Controller Area Network extended data-field length) is developed by CAN in Automation (CiA). It is an addition to the existing CAN protocol to increase its bandwidth capabilities over 10 Mbit/s.