CAN Protocol basics
Issue - 1(24/11/19) This series article is intended for beginners, this article provides basic understanding about CAN Protocol.
CAN protocol is Widely used in Automotive industry.
For understanding purpose let us assume 3 nodes are connected in the CAN bus,
a. BCM (Identifier 0x41).
b. ECM (Identifier 0x42).
c. ABS (Identifier 0x43).
Multi-Master Message Based Protocol:
Any node can initiate data transfer or request data in the bus.
Carrier Sense Multiple Access Protocol:
Consider BCM node transmitting data in the bus.
Now ABS node wants to transmit data in the bus.
ABS node first observes the bus for any data already transmitting and will detect BCM node is transmitting data in the bus.
So the ABS node not will not transmit its own data, instead it will wait for some predefined time and try again.
Collision detection:
To understand the Collision detection concept, let’s answer some questions below,
What are the two states of the CAN Bus?
a. Dominant State (0).
b. Recessive State (1).
Which node will get the bus if one node is transmitting dominant bit and another node transmitting recessive bit?
Node which transmits dominant bit (0) will get the bus.
From the above 3 nodes Which node will get the bus?
Node which is having smaller Identifier BCM (Identifier 0x41).
How the node will transmit the data?
First, node will send one bit in the bus and sense the bus, if the same value is sensed back then the node continue transmitting the data bit by bit. if different value is sensed then the node stops transmitting and starts listening to the BUS.
Collision Detection Example:
Consider two nodes ECM and ABS request for the bus at the same time. Now which node will get the bus, in this situation identifier plays a major role in determining which node get access to the bus.
1. Both the bus will transmit the SOF(Start Of Frame) which will have no effect.
2. Now both the nodes will start transmitting the identifier field.
3. The identifier field will be transmitted from MSB to LSB.
Identifier is transmitted bit by bit, from bit 7 to bit 1 no effect and finally ECM node will transmit bit 0 (dominant bit) an ABS will transmit bit 0(recessive bit), Since ECM node is transmitting dominant bit, ECM node with Identifier 0x42 will get the bus.
ABS node sent bit-0 (recessive value) and sense back dominant value, now ABS node understands some high priority node transmitting data, so the ABS node stops transmitting and start listening to the bus.
Message Framing:
Two types of frames,
a. Standard Frame.
b. Extended Frame.
The major difference between the Standard and Extended frame is the identifier field.
Standard frame uses 11- bit Identifier.
Extended frame uses 29- bit Identifier.
SOF – Start of the frame.
11-bit Identifier – Determines which node get access to the bus.
RTR (Remote Transmission Request) – dominant (0) for data frame, recessive (1) for remote frame.
IDE (Identifier Extension) – dominant (0) for standard frame, recessive (1) for Extended frame.
R0 – Reserved bit for future use.
DLC (Data Length Code) – contains the length of the data field.
Data – Data to be transmitted.
CRC (cyclic Redundancy Check)- checksum for error detection.
ACK (Acknowledge) – when the data received correctly, acknowledge slot recessive value is overwritten by dominant value.
EOF – End of Frame.
IFS (Inter Frame Space) – gives delay between the consecutive frames.
The additional fields that differs from standard CAN is given below,
SRR (Substitute Remote Request) – transmitted as recessive bit.
R1- Reserved for future use.
Note : If node with standard CAN and node with Extended CAN request BUS at the same time, node Standard CAN will get access to the BUS. To give priority to the Standard CAN, the SRR field is always recessive in extended CAN.
In the next article I will provide some basic information about the different types of frames, errors and fault containment.
Very Good. Keep Rocking
Great initiative Sabari! Keep going!!