Controller Area Network
(CAN)
CAN
Intra-vehicular communication
•A typical vehicle has a large number of Electronic Control Units (ECU).
•Some of such control systems
–Engine timing
–Gearbox and carburetor throttle control
–Anti-brake systems (ABS)
–Acceleration skid control (ASC)
•The growth of automotive electronics is a result of:
–Customers wish for better comfort and better safety.
–Government requirements for improved emission control
–Reduced fuel consumption
How do we connect these control devices?
•With conventional systems, data is exchanged by means of dedicated signal lines.
•But this is becoming increasingly difficult and expensive as control functions become
ever more complex.
•In case of complex control systems in particular, the number of connections cannot be
increased much further.
Solution: Use Fieldbus networks for connecting the control devices
Fieldbus Networks
Some of the Fieldbus technologies currently available are
–RS-232
–RS-485
–CAN
–ARCNET
–IEC 1158-2
–BITBUS (IEEE 1118)
–ModBus
Controller Area Network (CAN)
Controller Area Network (CAN) is a fast serial bus that is designed to provide
–an efficient,
–Reliable and
–Very economical link between sensors and actuators.
❖ The Controller Area Network was developed by Robert Bosch GmbH for
automotive applications in the early 1980s and publicly released in 1986.
❖ The Bosch CAN specification became an ISO (International Standard Organization)
standard (ISO 11898) in 1993 (CAN 2.0A), and extended in 1995 to permit longer
device identifiers (CAN 2.0B)
❖ CAN uses a twisted pair cable to communicate at speeds up to 1Mbit/s with up to 40
devices.
❖ Originally developed to simplify the wiring in automobiles.
❖ CAN fieldbuses are now used in machine and factory automation products as well.
Controller Area Network (CAN) Features
❖ No host (Master) device required. Uses shared bus topology.
❖ CAN Bus is a broadcast type of bus means each node can transmit.
❖ Robust in noisy environments.
❖ Non-destructive bitwise arbitration to allow 100% use of the bandwidth without loss
of data.
❖ Automatic error detection, signaling and retries
❖ Data packets are 8 bytes long
❖ CAN protocol is a message based protocol
❖ Asynchronous type of communication
❖ Half duplex serial communication
Before Controller Area Network
After Controller Area Network
Tradeoff: CAN bus versus point-to-point connections
❖ By introducing one single bus as the only means of communication as opposed to
the point-to-point network, we traded off the channel access simplicity for the
circuit simplicity.
❖ Since two devices might want to transmit simultaneously, we need to have a MAC
protocol to handle the situation.
❖ CAN manages MAC issues by using a unique identifier for each of the outgoing
messages.
❖ Identifier of a message represents its priority.
CAN layered Architecture
● OSI (Open Systems Interconnection) 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.
Contd…
● Data-link layer: This layer is responsible for node to node data transfer. It allows
you to establish and terminate the connection.
● It is also responsible for detecting and correcting the errors that may occur at the
physical layer. Data-link layer is subdivided into two sub-layers:
○ MAC: MAC stands for Media Access Control. It defines how devices in a
network gain access to the medium. It provides Encapsulation and
Decapsulation of data, Error detection, and signaling.
○ LLC: LLC stands for Logical link control. It is responsible for frame
acceptance filtering, overload notification, and recovery management.
● Physical layer: The physical layer is responsible for the transmission of raw data. It
defines the specifications for the parameters such as voltage level, timing, data
rates, and connector. PMS stands for Physical Medium Specification.
Contd…
● The CAN physical layer can be divided in three sub-layers. The PLS (Physical Layer
Signalling) layer is implement in the CAN controller chips. The PMA (Physical
Medium Attachment) layer describes the transceiver characteristics. The MDI
(Medium Dependent Interface) layer specifies the cable and connector characteristics.
● CAN specifications define CAN protocol and CAN physical layer, which are defined in
the CAN standard ISO 11898. ISO 11898 has three parts:
● ISO 11898-1: This part contains the specification of the Data-link layer and physical
signal link.
● ISO 11898-2: This part comes under CAN physical layer for high speed CAN. The
high- speed CAN allows data rate upto 1 Mbps used in the power train and the charges
area of the vehicle.
● ISO 11898-3: This part also comes under CAN physical layer for low-speed CAN. It
allows data rate upto 125 kbps, and the low speed CAN is used where the speed of
Physical CAN connection
Contd..
● A CAN network consists of multiple of CAN nodes. CAN node consists of three
elements which are given below:
● Host
A host is a microcontroller or microprocessor which is running some
application to do a specific job. A host decides what the received message
means and what message it should send next.
● CAN Controller
CAN controller deals with the communication functions described by the
CAN protocol. It also triggers the transmission, or the reception of the CAN
messages.
● CAN Transceiver
CAN transceiver is responsible for the transmission or the reception of the
data on the CAN bus. It converts the data signal into the stream of data
Bit Rate/Bus Length
CAN characteristics
Contd…
● With 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.
CAN Bus Logic
Contd..
● From 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.
● There are four types of CAN messages, or “frames:” Data Frame, Remote Frame, Error
Frame and Overload Frame.
● The data frame is the standard CAN message, broadcasting data from the transmitter to the
other nodes on the bus. A remote frame is broadcast by a transmitter to request data from a
specific node. An error frame may be transmitted by any node that detects a bus error.
Overload frames are used to introduce additional delay between data or remote frames.
Standard CAN Frame format
● CAN devices send data across the CAN network in packets called frames. A CAN
frame consists of the following sections.
■ CAN Frame: An entire CAN transmission: arbitration ID, data bytes, acknowledge
bit, and so on. Frames also are referred to as messages.
■ SOF–The single dominant start of frame (SOF) bit marks the start of a message,
and is used to synchronize the nodes on a bus after being idle.
■ Arbitration ID – identifies the message and indicates the message's priority.
Standard CAN frame uses an 11-bit arbitration ID. The lower the binary value, the
higher its priority.
Contd…
■ RTR–The single remote transmission request (RTR) bit is dominant when information is
required from another node. All nodes receive the request, but the identifier determines the
specified node.
■ The responding data is also received by all nodes and used by any node interested. In this
way, all data being used in a system is uniform.
■ IDE (identifier extension) bit – –A dominant single identifier extension (IDE) bit means
that a standard CAN identifier with no extension is being transmitted.
■ r0–Reserved bit (for possible use by future standard amendment).
■ DLC (data length code) – The 4-bit data length code (DLC) contains the number of bytes of
data being transmitted.
■ Data–Up to 64 bits of application data may be transmitted.
■ CRC–The 16-bit (15 bits plus delimiter) cyclic redundancy check (CRC) contains the
checksum (number of bits transmitted) of the preceding application data for error detection.
Contd…
■ ACK–any CAN controller that correctly receives the message sends an ACK bit at the end
of the message. The transmitting node checks for the presence of the ACK bit on the bus
and reattempts transmission if no acknowledge is detected.
■ In this way, each node acknowledges (ACK) the integrity of its data. ACK is 2 bits.
■ EOF–This end-of-frame (EOF), 7-bit field marks the end of a CAN frame (message).
■ IFS–This 7-bit interframe space (IFS) contains the time required by the controller to move
a correctly received frame to its proper position in a message buffer area.
Contd…
Extended CAN Frame format
● The Extended CAN message is the same as the Standard message with the addition
of:
● SRR–The substitute remote request (SRR) bit replaces the RTR bit in the standard
message location as a placeholder in the extended format.
● IDE–A recessive bit in the identifier extension (IDE) indicates that more identifier
bits follow. The 18-bit extension follows IDE.
● r1–Following the RTR and r0 bits, an additional reserve bit has been included ahead
of the DLC bit.
Contd…
CAN Communication Principle
■ As 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.
■ 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
Contd…
CAN Arbitration Example
■ If 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.
Contd…
● 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.
CAN Working??
■ If multiple nodes try to transmit a message onto the CAN bus at the same time, the
node with the highest priority (lowest arbitration ID) automatically gets bus access.
Lower-priority nodes must wait until the bus becomes available before trying to
transmit again. In this way, you can implement CAN networks to ensure
deterministic communication among CAN nodes.