SlideShare a Scribd company logo
CAN Bus
What is CAN
and
What is a Bus?
What is CAN ?
CAN stands for
Controller Area Network
i.e.
Microcontroller Area Network
What is a bus?
A channel of communication between two or more electronic
devices where messages in the form of electrical
waveforms can travel in both directions
What is a CAN Bus?
A channel of communication between two or more microcontrollers
Where messages in the form of electrical waveforms can travel in both
direction Which obey a highly sophisticated set of rules called the
CAN Bus Protocol
Where can you find
a CAN Bus System ???
 Automotive
 Farming
 Aeroplanes
 Medical equipment and devices
 Passenger and Cargo Trains
 Lifts and escalators
 Factory automation
 Industrial machine control
 Maritime electronics
 Non-industrial control and equipment
Understanding+CAN.ppt,....................
Why do we need a CAN Bus ???
Without a CAN Bus
(point to point communication)
Controller A
Controller B
Controller C
Controller F
Controller G
Controller E
Controller D
Wiring harnesses without CAN (complicated, messy & confusing)
With a CAN Bus
Controller A
`Controller B
Controller C
Controller F
Controller G
Controller E
Controller D
The Bus
(serial)
Example of a CAN Bus system with 8 nodes
A little History lesson
 CAN was first developed by Robert Bosch GmbH, Germany in 1986
when they were requested to develop a communication system
between three ECUs (electronic control units) in vehicles designed by
Mercedes.
 They found that point to point communications was no longer
suitable in this situation. The need for a multi-master communication
system became imperative.
 The first CAN silicon was then fabricated in 1987 by Intel
What are advantages of a CAN Bus ?
 Organized and sophisticated compared to point to point communication
 Reduction in weight and cost of wiring looms/harnesses
 Can handle multiple controllers simultaneously
 Works in Real Time
 Can be used in various applications
A CAN Bus system works by sending and receiving
messages
from
node X to node Y
How does a CAN BUS works?
A sensor or actuator connected to a microcontroller and any other device
(for ex: ADC) that helps to turn this assembly into a fully functional
stand- alone unit is called a NODE
There are 2 types of Nodes
Transmitter
A node originating a message is called a transmitter of that message
Receiver
A node receiving a message that it is not transmitting itself is called a
receiver of a message
What is a NODE?
How many CAN Bus protocols are there?
There are two CAN Bus protocols
 CAN BUS 2.0 A
 CAN BUS 2.0 B
CAN 2.0 A is used with smaller, less complicated systems
CAN 2.0 B is used with larger, more complicated systems
The heart & soul of the CAN Bus protocol deals with a
FRAME
into which the
MESSAGE
to be sent or received on the CAN Bus is encoded
What are the 2 main types of Frames in CAN?
A Frame that contains
a request for data
A Frame that contains
the requested data
The frame that contains a request for a particular
data is called the
REMOTE TRANSMISSION REQUEST FRAME
The frame that contains the requested data is
called the
DATA FRAME
The DATA FRAME
The start of frame The end of frame
The Data frame consists of 7 distinct parts
1 2 3 4 5 6 7
The RTR Frame
Remote Transmission Request
Notice the absence of the DATA field
The start of frame The end of frame
1 2 3 4 5 6
The Data frame consists of 6 distinct parts
A Frame consists
of a large number of bits (0’s and 1’s)
The bits present in a frame are of two types
Dominant bit
&
Recessive bit
Dominant bit represents 0
&
Recessive bit represents 1
The Dominant bit has a higher priority
than the Recessive bit
We shall now discuss each of the 7 parts that make
up a FRAME starting with SOF – Start of Frame
SOF – Start of Frame
The SOF consists of a single bit
This is the MSB i.e. Most Significant bit present
in the FRAME
This bit is dominant (0) always
Arbitration Field
The arbitration field is the
most important field for the programmer or
system designer
It is also called as the Identifier field as the
INDENTITY of the entire frame traveling on the
bus is figured out by decoding this field
What does ARBITRATION mean?
&
What does IDENTITY mean?
What is Arbitration?
The settling of a dispute between two or more individuals
by a third person chosen by them
In CAN, this translates into the settling of a collision
between two or more frames sent onto the bus
simultaneously (by two or more nodes) with the help of
the CAN protocol (third person)
What is an IDENTITY?
The unique, individual characteristics by which a person or thing is
recognized or known such as
 Genes
 PAN card number
 Telephone number
Arbitration & Identity
The bits present in the ARBITRATION field can be arranged
intelligently
by
the programmer so that each FRAME is easily distinguished
by the unique sequence of bits present in this field
This unique sequence of bits constitute an IDENTITY
Thus an IDENTITY facilitates the ARBITRATION process
with it’s unique pattern of 0’s and 1’s
which
We shall see in the coming slides a little further down in this
presentation
Arbitration field - Contd
 CAN Bus 2.0 A, has an arbitration field that is 11 bits
long which can have 2048 different combinations
 This means - that with a 11 bit long identifier there can be
2048 unique frames
 These 2048 unique frames can then be sent onto the bus
and each of these frames can then be easily identified by
all the nodes present on the bus
How do we get 2048 unique combinations
from 11 bits?
Since we follow the Binary format consisting of 0 and 1,
11 bits can give us 2048 combinations as follows
211
= 2*2*2*2*2*2*2*2*2*2*2= 2048
CAN Bus 2.0 B, has an arbitration
field that is 29 bits long which can have over 5 million
different combinations
This means with a 29 bit long identifier there can be over
5 million unique frames
These 5 million unique frames can then be sent onto the
bus and each of these frames can then be easily identified
by all the nodes present on the bus
Thus, the bits present in an arbitration field are a carefully selected
combination of dominant (0) and recessive (1) bits that have to be
decided by the programmer which
decides the priority level of the different FRAMES being sent onto the
bus and also acts as a unique identifier which helps a node identify
any FRAME present on the Bus
Our discussion from this point onwards shall consist only of
CAN Bus 2.0 A, as the 2048 unique identifiers it provides
to send and receive 2048 unique frames is more than
sufficient for most applications present in the world today
 The last bit present in the arbitration field is an RTR bit
 In the DATA frame the RTR bit is always dominant (0)
 In the Remote frame the RTR bit is always recessive (1)
RTR – Remote Transmission Request
Control Field
 It consists of 6 bits
 The first bit is an IDE bit i.e. Identifier Extension bit
 This bit is used if CAN Bus 2.0 B with the extended identifier format
consisting of 29 bits is desired to be used
 The second bit r0 has been reserved for future use and its status is of
no use to us
Control field
 The last 4 bits represent the number of bytes that are present
in the next field i.e. the Data field
 There can be a minimum of 0 bytes to a maximum of 8 bytes that can
be sent as data in a frame
Data Length Code
Control Field – Data Length code in Binary
Byte Code in Binary
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
Data Field
Maximum length = 8 bytes
CRC Field
Cyclic Redundancy Check
 This field is used to calculate the
bit errors present within a CAN frame
 The CAN controller does this operation automatically
 There are a total of 16 bits present in this field
 Of this, the value of the bits in the first 15 fields are automatically
calculated
 The last bit is called the CRC Delimiter and is always recessive (1)
Acknowledgement Field
 The acknowledgement
field is 2 bits long
 It consists of the ACK slot and the ACK Delimiter
Acknowledgement Field
 The ACK Delimiter as is the case with all Delimiter’s found in a frame is
always recessive (1)
 The node that transmits a frame, transmits the ACK slot as recessive (1)
 The node that receives a frame successfully, reports this to the transmitter
by sending a dominant bit in the ACK slot (0)
End of Frame
 The EOF consists of 7 bits
 All these bits are recessive (1)
Intermission
The Intermission field consists of 3 bits
All these bits are recessive (1), ALWAYS
An intermission field is present in between consecutive DATA frames and RTR
frames
Bus Idle
 When the bus is idle, it is in a recessive state
 Thus there will be an infinite series of recessive (1) bits that will be
found on the bus in this state
Broadcasting a frame onto the Bus &
Receiving a frame from the Bus
To broadcast a Frame onto the Bus we need a node that sends a Frame onto the Bus
i.e. a Transmitter & we need a node that receives a Frame from the Bus
i.e. a Receiver
Frame Filter
Local
Intelligence
Transmitter
The transmitter consists
of 3 different blocks
• Local Intelligence
• Frame
• Filter
Frame Filter
Local
Intelligence
Receiver
The receiver consists of 3
different blocks
• Local Intelligence
• Frame
• Filter
(Node)
(Node)
What job does the Local Intelligence block and Filter
block do ?
Local Intelligence consists of the sensor or actuator and the microcontroller functioning
intelligently by
sending FRAMES onto the bus
or
receiving FRAMES from the bus
as and when
instructed to do so
Filter
A Filter can be compared to a Security Guard standing at the entrance of a large gate
Messages carried by a person can enter this gate ONLY if the security guard is able to verify
the identity of the person by checking his ID card
Similarly in a CAN Bus system a FRAME is allowed to go through the FILTER onto the
local intelligence ONLY IF the identity of the FRAME present in the Identifier
field (also known as the arbitration field) matches the uniquely coded bits present in the
FILTER
Broadcasting & Receiving
a Frame
Frame
Local
Intelligence
Filter Frame Filter
Local
Intelligence
Frame Filter
Local
Intelligence
Frame
Local
Intelligence
Filter
Node A Node B Node C Node D
BUS
Transmitting
a Frame onto
the bus
Each Filter is now checking the IDENTIFIER bits of the Frame
and is deciding whether to let the frame in or keep it out
The bits in the identifier field of
the frame match the bits present
in the FILTER situated in Node D
The Frame is now
Nod
Thus the Frame sent
Properly finds it way
Explain FRAME Arbitration
 Let us assume that three nodes broadcast their respective frames onto the bus
simultaneously
 Of these 3 frames, finally only 1 frame with the highest priority can travel across
the bus
 The remaining 2 frames will have to wait for the highest priority frame to reach its
destination
 After it has reached its destination, the remaining 2 nodes can then begin
transmitting their frames on the bus
 These 3 nodes will have 3 unique identifiers respectively
 These unique identifiers will be present in the arbitration field of the
FRAME
 In a previous slide it was mentioned that the Dominant bit (0) has a
higher priority than the recessive bit (1)
 This bit priority predetermined by the CAN Protocol will decide
which frame wins the arbitration battle being fought on the bus
Let us make up 3 unique identifiers for each node
 Node A Identifier – 11001110001
 Node B Identifier – 11001011011
 Node C Identifier – 11001011001
(Notice that they are 11 bits long)
Node A
Node B
Node C
Bus
SOF 10 7
8
9 6 5 4 3 2 1 0 RTR
Arbitration field made up of identifiers
Listen Only – Node A Loses Arbitration
Listen Only – Node B
Loses Arbitration
On the Bus
Bus
FRAME Arbitration
011001110001
011001011011
011001011001
Node A loses the arbitration battle to Node B & Node C at the 5th
bit present in the
arbitration field as
the 5th
bit present in Node A is recessive (1)
whereas
the 5th
bit present in Node B & Node C is dominant (0)
As the dominant bit (0) has a higher priority than the recessive bit (1), Node A is
forced into LISTEN ONLY mode and
Node B & Node C continue the arbitration battle on the bus
which is finally won by Node C
What is CAN Synchronization
&
Bit Timing
 Several different nodes on a bus have their own individual internal
clocks running at a frequency that MUST be common across the bus
 Let us say that our system has 5 nodes
 Each of these 5 nodes has a clock with a frequency of 16 Mhz
 Even though each node has a clock that operates at the same 16 Mhz
frequency, it is practically impossible that these 5 clocks run in
perfect synchronicity with each other
 There is bound to be a certain tolerance limit in which the clock
operates, for example from 15.99 Mhz to 16.01 Mhz
 This deviation of +/- 0.2 Mhz is caused due to practical reasons such
as variations in
 temperature
 material properties of the quartz crystal
 manufacturing defects
To take care of these deviations in operating frequencies and to ensure that
all the nodes on the bus are in perfect synchronicity with each other we have
Bit Timing
What is a BIT & What is BIT TIME???
Bit 0
Bit 1
Bit Time Duration
also known as
BIT TIME
 Bit Time is defined as the time taken by each bit to represent itself
 Higher frequencies result in smaller bit time
 Lower frequencies result in longer bit time
A Bit Time is divided into 4 non-overlapping time segments
4 non-overlapping time segments present in a BIT
Bit Time duration
Synchronization
segment
Propagation
segment
Phase
Segment 1
Phase
Segment 2
Sample point
1 2 3 4
 Each time segment is further divided Into a number of smaller units called
Time Quanta
 A Time Quanta is the smallest unit of time present in a BIT
The total number of Time Quanta that are present in a BIT must be greater
than 8 Time Quanta and less than or equal to 25 Time Quanta
Time Quantas (TQ)
present in a BIT
Synchronization
segment
Phase
Segment 1
Phase
Segment 2
Sample point
1 2 3 4
Propagation
segment
TQ TQ TQ TQ TQ TQ TQ TQ TQ TQ TQ
TQ
Synchronization Segment
 This is the first non-overlapping time segment present in a bit
 It’s duration is 1 Time Quanta, ALWAYS
 It is responsible for synchronizing the various CAN nodes on the bus
Propagation Segment
 This is the second non-overlapping time segment present in a bit
 It’s duration is programmable to be between 1 to 8 Time Quanta in length
 It is responsible for compensating the physical delay times on the nodes and
the bus
 The physical delay (obstructions in electron flow) is caused by the CAN bus
cable, transmitting microcontroller and receiving microcontroller
Phase Segment 1
 This is the third non-overlapping time segment present in a bit
 It’s duration is programmable to be between 1 to 8 Time Quanta in
length
 It is responsible for compensating phase errors (mismatches in
timing) with the help of an additional component called SJW or
Synchronization Jump Width
Phase Segment 2
 This is the fourth and last of the non-overlapping time segments
present in a bit
 It’s duration is programmable to be between 1 to 8 Time Quanta in
length
 It is responsible for compensating phase errors (mismatches in
timing) with the help of an additional component called SJW or
Synchronization Jump Width
 The SJW acts like a washer used in mechanical systems
 Washers are added or removed from components in a mechanical system to
make components fit into each other perfectly
 SJW is a software washer
 It is implanted into a BIT in such a way that the BIT TIME can compensate
for the various shifts in phase (mismatched timing) while receiving a frame
from another node
 SJW can consist of a minimum of 1 TQ to a maximum of 4 TQ
Synchronization Jump Width - SJW
Synchronization Jump
Width - SJW
Synchronization
segment
Phase
Segment 1
Phase
Segment 2
Propagation
segment
Synchronization
segment
Phase
Segment 1
Propagation
segment
Phase
Segment 2
SJW
Notice the increase in BIT TIME with the SJW added to it to compensate for mismatches in timing
Bit time = x
Bit time = x + SJW
Sample Point
 It’s exact location is in-between the end of Phase segment 1 and the
beginning of Phase segment 2
 This is the point of time at which the BIT is read and interpreted
 At this point we know whether the bit is dominant (0) or recessive (1)
What Next ???
 Bit Timing on its own does 95% of the work required to synchronize
the frames sent by the various nodes present in a bus
 But 95% is not good enough
 Synchronization between frames sent by the various nodes must reach
as close to the 100% mark as possible for proper transmission and
reception
This is done with the help of
Bit Stuffing
What is Bit Stuffing ???
The CAN Protocol intelligently inserts (stuffs) a bit (s) of opposite polarity into
a FRAME,
If
a continuous series of bits of the same polarity exceed 5 in number
Bit Stuffing
 For example, if a frame consists of
8 consecutive dominant (0) bits, the
CAN protocol will force the transmitter
to STUFF a recessive (1) bit after the 5th
consecutive dominant bit automatically
Bit sequence to
be transmitted
Stuffed Bit
sequence
De-stuffed
Bit sequence
Transmitter
Receiver
0
1 2 3 4 5 6 7 8
9 10 11
12
13
S
0
1 2 3 4 5 6 7 8
9 10 11
12
13
0
1 2 3 4 5 6 7 8
9 10 11
12
Bit Stuffing
 Similarly, if a frame consists of 12
consecutive recessive bits, the CAN
protocol will force the transmitter to STUFF
a dominant (0) bit after every 5th
consecutive recessive (1) bit
automatically
Bit sequence to
be transmitted
Stuffed Bit
sequence
De-stuffed
Bit sequence
Transmitter
Receiver
0
1 2 3 4 5 6 7 8 9 10 11 12
13
14
15
16
0
1 2 3 4 5
S
6 7 8 9 10
S
11 12
13
14
15
16
0
1 2 3 4 5 6 7 8 9 10 11 12
13
14
15
16
 The Node transmitting a FRAME will automatically stuff bits if
required
 The Node receiving the FRAME will automatically de-stuff the bits
thereby returning the FRAME into it’s original form
Why is Bit Stuffing required ???
Because CAN follows NZR i.e. Non Return to Zero coding as against
Manchester coding
Understood
????
 Remember, we said that a BIT is made up of Time Quanta and each
BIT should have a minimum of 8 TQ to a maximum of 24 TQ
 We also know that by manipulating TQ’s we can negate the phase
shifts or mismatches in Timing of FRAMES received from different
nodes
 All these things mentioned above help to achieve synchronicity
between nodes because of which one can transmit and receive frames
successfully
For all this matching & synchronizing business to take place successfully,
there is one small requirement without which nothing will work
What is this small requirement
???
AN “EDGE”
Without an EDGE, there is no reference point and without a reference
point there is no way synchronization can take place
EDGE
So, if a FRAME has a large number of successive bits that are either
dominant or recessive, there is a long gap before an edge appears
Long gaps in a frame
Successive recessive bits (1)
Successive dominant (0) bits
These long gaps throw the synchronization mechanism into complete
confusion
In order to avoid this, an EDGE is introduced after regular intervals
In CAN an EDGE is introduced, if 5 successive bits of the same polarity
are present in a FRAME by inserting
a BIT
with opposite polarity (BIT STUFFING), to facilitate the smooth
functioning of the synchronization process
So now we know how FRAMES are sent and received on the CAN Bus
synchronously
without
sending clock pulses simultaneously with the message as is done with I2C and
SPI protocol
but
by intelligently manipulating the width of each bit (BIT TIME) with the help of
small packets of time called TIME QUANTA
and
with the help of BIT STUFFING
What is Error Handling in CAN?
• All nodes listen to any message being transmitted onto the bus
• The transmitting node too listens to its own message while transmitting it onto
the bus
Message Validation
 The point of time at which a FRAME is taken to be valid is DIFFERENT
for the transmitter and receiver of the message
 Transmitter
A FRAME is valid for a transmitter if there is no error till the end of the
FRAME
 Receiver
A FRAME is valid for a receiver if there is no error till the last but one bit
of the END OF FRAME
CAN Error Detection
 Bit value check by Transmitter
 Bit Stuff checking
 Frame check
 15 bit Redundancy check
 Acknowledgement check
What are possible CAN errors?
 Bit error
 Stuff error
 Form error
 CRC error
 Acknowledgement error
What is Bit error ?
 A Node that is transmitting a FRAME
listens to it’s own FRAME on the Bus
 For example if a Node sends a sequence 01100110011 but on the bus
it sees
01100100011, a bit error has occurred
 An error frame is then sent onto the bus and the FRAME with the Bit
error is ignored by all nodes
What is Stuff error ?
 If a FRAME consists of the following bits 0110000000011100110
 Then according to the bit stuffing rule there should a recessive bit (1)
inserted after the 5th
dominant (0) bit
 So the FRAME should be transformed into 01100000100011100110
from
0110000000011100110
BIT STUFFING is done automatically by the
CAN Controller but for some reason if it does not happen, a STUFF
ERROR occurs
An error frame is then sent onto the bus and the FRAME
with the STUFF ERROR is ignored by all nodes
What is Form error?
 The CRC Delimiter, ACK Delimiter and EOF consist of recessive bits (1)
ALWAYS
 If a dominant bit (0) is detected in any of these, a FORM ERROR has taken
place
 An Error frame is then sent onto the bus and the FRAME with the FORM
ERROR is ignored by all nodes
CRC Delimiter
ACK Delimiter
EOF
What is CRC error?
• The CRC value is 15 bits long
• This value is automatically calculated by the transmitting and receiving nodes
• If the CRC value of the FRAME calculated by the transmitting node is different
from the CRC value of the FRAME calculated by the receiving node a CRC error
has occurred
• An error frame is then sent onto the bus and the FRAME with the CRC ERROR is
ignored by all nodes
What is Acknowledgement error ?
 A transmitting node keeps the value of the ACK slot recessive (1)
 A receiving node on successful reception of a message changes the value of the
ACK slot to dominant (0)
 If it fails to do this an acknowledgement error has occurred
 An error frame is then sent onto the bus and the FRAME with the
acknowledgement error is ignored by all nodes
ACK slot
ERROR FRAME
Explain about Error Frame
 It is made up of two fields
 Error Flag Field
 Error delimiter Field
Error Flag Error Delimiter
It consists of 6 to 12 bits It consists of 8 bits
 An error can occur during transmission
 A count is kept on these errors by a counter called TEC or Transmit
Error Counter
 An error can occur during reception
 A count is kept on these errors by a counter called REC or Receive
Error Counter
 The count value in TEC and REC must be maintained between a certain
count limit that is predefined by the CAN Protocol
 Depending upon the count value present in TEC and REC at each node,
the Node can be in any of the 3 following states
 Active Error State
 Passive Error State
 Bus Off State
What is Active Error State ?
 All the nodes on the bus
should be in Active Error State for normal transmission and reception
of FRAMES
 If any given node has less than 128 counts in it’s TEC and REC,
it is in Active Error State
What is Passive Error State ?
 If any given node has greater
than 127 counts and less than 256 counts in it’s TEC and REC, it goes
into Passive Error State
This is NOT a desirable state for any given NODE to be in
This state is caused due to more than the normal number of errors
occurring while transmitting and receiving FRAMES
Nodes in Passive error state have a lower priority for transmitting
frames than nodes in Active error state
What is Bus Off State ?
If any given node has more than 255 counts in it’s TEC,
it goes into in Bus Off State
In Bus Off State the given node is not allowed to Transmit or Receive
any more FRAMES onto the Bus until the reason behind the excessive
error generation has been identified and rectified
The 3 States of a Node
Error
Active
Error
Passive
Bus
Off
Initial error free
state of a node
If
TEC > 127
or
REC > 127 If
TEC < 128
or
REC < 128
If
TEC > 255
On RESET
Or
Error rectification
Coming back to the Error Frame
Error Flag Error Delimiter
It consists of 6 to 12 bits It consists of 8 bits
 If an error occurs while a node is in
Error Active state then
 The error flag will consist of 6 consecutive dominant (0) bits
 The error delimiter will consist of 8 consecutive recessive (1) bits
6 dominant bits 8 recessive bits
Coming back to the Error Frame
Error Flag Error Delimiter
It consists of 6 to 12 bits It consists of 8 bits
 If an error occurs while a node is in
Passive Active state then
 The error flag will consist of 6 consecutive recessive (0) bits
 The error delimiter will consist of 8 consecutive recessive (1) bits
6 recessive bits 8 recessive bits
What is Overload Frame ?
 It is generated due to 2 conditions
 If the receiver is not yet ready to receive the next FRAME
 If a node detects a dominant bit during intermission
An intermission consists of 3 bits
ALL OF THEM ARE RECESSIVE (1) AT ALL TIMES
As mentioned earlier, an Intermission frame is present
between successive DATA and RTR frames
 An overload frame is similar to the error frame
 It is made up of two fields
 Overload Flag Field
 Overload delimiter Field
Overload Flag Overload Delimiter
It consists of 6 to 12 bits It consists of 8 bits
 If an overload condition occurs then
 The overload flag will consist of 6 consecutive dominant (0) bits
 The overload delimiter will consist of 8 consecutive recessive (1)
bits
6 dominant bits 8 recessive bits
The CAN Protocol generates a maximum of 2 overload frames to delay
the next DATA or RTR Frame
If the receiver is still not ready to receive the next frame, an Error
Frame is generated
Physical Layer of the CAN Bus
Physical layer
What is Physical Layer ?
 It consists of a pair of twisted wires that are shielded to reduce
electromagnetic interference caused due to noise
 One wire carries the CAN High signal
 The other wire carries the CAN Low signal
 The difference between these signals results in a dominant (0) or
recessive bit (1)
Shielded Twisted Pair Wires
 If the difference between the CAN High voltage and CAN Low voltage is
less than 0.5 volts, the resulting bit is recessive (1)
 If the difference between the CAN High and CAN Low voltage is greater
than 0.9 volts and less than 3.5 volts, the resulting bit is dominant (0)
Differential voltages CAN_H & CAN_L
CAN Bus Systems are present in harsh, noisy environments where mechanical
and electrical disturbances induce unwanted voltages into the wires thereby
corrupting the signal and making it unworthy
To prevent this from happening CAN uses the differential voltage system to figure
out whether the BIT is Dominant (0) or Recessive (1)
Electrical Waveform traveling through the Bus
For the node to read the bus level correctly it is important that signal
reflections are avoided
This is done by terminating the bus line with a termination resistor at
both ends of the bus
ISO 11898 requires a cable with a nominal impedance of 120 ohms, and
therefore 120 ohm resistors should be used for termination
Why 120 ohm resistor is used in CAN ?
Why CAN is having 120 ohms at each end?
Answer: To minimize the reflection reference, to reduce noise. To ensure that reflection does not cause communication failure, the
transmission line must be terminated
Why CAN is message oriented protocol?
Answer: CAN protocol is a message-based protocol, not an address based protocol.
This means that messages are not transmitted from one node to another node based on
addresses. Embedded in the CAN message itself is the priority and the contents of the
data being transmitted. All nodes in the system receive every message transmitted on
the bus (and will acknowledge if the message was properly received). It is up to each
node in the system to decide whether the message received should be immediately
discarded or kept to be processed. A single message can be destined for one particular
node to receive, or many nodes based on the way the network and system are designed.
For example, an automotive airbag sensor can be connected via CAN to a safety system
router node only. This router node takes in other safety system information and routes it
to all other nodes on the safety system network. Then all the other nodes on the safety
system network can receive the latest airbag sensor information from the router at the
same time, acknowledge if the message was received properly, and decide whether to
utilize this information or discard it.
. CAN logic what it follows?
Answer: Wired AND logic
How CAN will follow the Arbitration?
Answer: CSMA/CD + AMP (Arbitration on Message Priority)
Two bus nodes have got a transmission request. The bus access method is
CSMA/CD+AMP (Carrier Sense Multiple Access with Collision Detection and Arbitration
on Message Priority). According to this algorithm both network nodes wait until the bus is
free (Carrier Sense). In that case the bus is free both nodes transmit their dominant
start bit (Multiple Access). Every bus node reads back bit by bit from the bus during the
complete message and compares the transmitted value with the received value. As long
as the bits are identical from both transmitters nothing happens. The first time there was
a difference – in this example the 7th
bit of the message – the arbitration process takes
place: Node A transmits a dominant level, node B transmits a recessive level.
The recessive level will be overwritten by the dominant level. This is detected by node B
because the transmitted value is not equal to the received value (Collision Detection).
At this point of time node B has lost the arbitration, stops the transmission of any further
bit immediately and switches to receive mode, because the message that has won the
arbitration must possibly be processed by this node (Arbitration on Message Priority)
. What are the functions of CAN transceiver?
Answer: The transceiver provides differential transmit capability to the bus and
differential receive capability to the CAN controller. Transceiver provides an advanced
interface between the protocol controller and the physical bus in a Controller Area
Network (CAN) node.
Typically, each node in a CAN system must have a device to convert the digital signals
generated by a CAN controller to signals suitable for transmission over the bus cabling
(differential output). It also provides a buffer between the CAN controller and the
high-voltage spikes that can be generated on the CAN bus by outside sources
(EMI, ESD, electrical transients, etc.).
The can transceiver is a device which detects the signal levels that are used on the
CAN bus to the logical signal levels recognized by a microcontroller.
What happen when two CAN nodes are sending same identifier at a same time?
Two nodes on the network are not allowed to send messages with the same id.
If two nodes try to send a message with the same id at the same time arbitration
will not work. Instead, one of the transmitting nodes will detect that his message is
distorted outside of the arbitration field. The nodes will then use the error handling of
CAN, which in this case ultimately will lead to one of the transmitting node being
switched off (bus-off mode).
Formula for Baudrate calculation?
The baud rate is calculated as:
baud rate (bits per second) = 18.432 x 10^6 / BRP / (1 + TSEG1 + TSEG2)
Thank you
HAVE A NICE DAY !!!

More Related Content

PPTX
Can bus
PPT
Role of CAN BUS in automotives
PPTX
ABIS-interface
PPTX
7.MODBus and CANBus.pptx
PPTX
Introduction_to_CAN_Protocol: Basics.pptx
PDF
IJSTEV2I12120
PPTX
Controller Area Network(CAN)
PPTX
Controller area network (can bus)
Can bus
Role of CAN BUS in automotives
ABIS-interface
7.MODBus and CANBus.pptx
Introduction_to_CAN_Protocol: Basics.pptx
IJSTEV2I12120
Controller Area Network(CAN)
Controller area network (can bus)

Similar to Understanding+CAN.ppt,.................... (20)

PPTX
PPTX
UNIT 2b.pptx
PPT
Intro to Ethernet
PDF
Networking interview questions and answers
PDF
Project-Report
PPTX
Can bus m.n.r
PDF
Automotive bus technologies
PPTX
Controller area network
PDF
Can basics
PPS
Introduction to the OSI 7 layer model and Data Link Layer
PDF
Analysis and Implementation of Hard-Decision Viterbi Decoding In Wireless Com...
PPTX
Advanced Network Chapter I: Which is very best lecture note
DOCX
11.chapters
PPTX
Unit 3 - Data Link Layer - Part A
PPTX
Controller Area Network (Basic Level Presentation)
PDF
Automotive Networks : A Review
PPTX
Alcatel lucent bts
PPTX
Shubham chakravarty ppt_wcan
PDF
Can Protocol For Automobiles
PPTX
Can network development using arm cortex m3
UNIT 2b.pptx
Intro to Ethernet
Networking interview questions and answers
Project-Report
Can bus m.n.r
Automotive bus technologies
Controller area network
Can basics
Introduction to the OSI 7 layer model and Data Link Layer
Analysis and Implementation of Hard-Decision Viterbi Decoding In Wireless Com...
Advanced Network Chapter I: Which is very best lecture note
11.chapters
Unit 3 - Data Link Layer - Part A
Controller Area Network (Basic Level Presentation)
Automotive Networks : A Review
Alcatel lucent bts
Shubham chakravarty ppt_wcan
Can Protocol For Automobiles
Can network development using arm cortex m3
Ad

Recently uploaded (20)

PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPT
Project quality management in manufacturing
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Sustainable Sites - Green Building Construction
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
Construction Project Organization Group 2.pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Internet of Things (IOT) - A guide to understanding
PPTX
web development for engineering and engineering
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
DOCX
573137875-Attendance-Management-System-original
PDF
Well-logging-methods_new................
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
Lecture Notes Electrical Wiring System Components
PPTX
CH1 Production IntroductoryConcepts.pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Project quality management in manufacturing
Model Code of Practice - Construction Work - 21102022 .pdf
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Sustainable Sites - Green Building Construction
UNIT-1 - COAL BASED THERMAL POWER PLANTS
bas. eng. economics group 4 presentation 1.pptx
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Foundation to blockchain - A guide to Blockchain Tech
Construction Project Organization Group 2.pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
Internet of Things (IOT) - A guide to understanding
web development for engineering and engineering
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
573137875-Attendance-Management-System-original
Well-logging-methods_new................
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Lecture Notes Electrical Wiring System Components
CH1 Production IntroductoryConcepts.pptx
Ad

Understanding+CAN.ppt,....................

  • 3. What is CAN ? CAN stands for Controller Area Network i.e. Microcontroller Area Network
  • 4. What is a bus? A channel of communication between two or more electronic devices where messages in the form of electrical waveforms can travel in both directions
  • 5. What is a CAN Bus? A channel of communication between two or more microcontrollers Where messages in the form of electrical waveforms can travel in both direction Which obey a highly sophisticated set of rules called the CAN Bus Protocol
  • 6. Where can you find a CAN Bus System ???  Automotive  Farming  Aeroplanes  Medical equipment and devices  Passenger and Cargo Trains  Lifts and escalators  Factory automation  Industrial machine control  Maritime electronics  Non-industrial control and equipment
  • 8. Why do we need a CAN Bus ???
  • 9. Without a CAN Bus (point to point communication) Controller A Controller B Controller C Controller F Controller G Controller E Controller D
  • 10. Wiring harnesses without CAN (complicated, messy & confusing)
  • 11. With a CAN Bus Controller A `Controller B Controller C Controller F Controller G Controller E Controller D The Bus (serial)
  • 12. Example of a CAN Bus system with 8 nodes
  • 13. A little History lesson  CAN was first developed by Robert Bosch GmbH, Germany in 1986 when they were requested to develop a communication system between three ECUs (electronic control units) in vehicles designed by Mercedes.  They found that point to point communications was no longer suitable in this situation. The need for a multi-master communication system became imperative.  The first CAN silicon was then fabricated in 1987 by Intel
  • 14. What are advantages of a CAN Bus ?  Organized and sophisticated compared to point to point communication  Reduction in weight and cost of wiring looms/harnesses  Can handle multiple controllers simultaneously  Works in Real Time  Can be used in various applications
  • 15. A CAN Bus system works by sending and receiving messages from node X to node Y How does a CAN BUS works?
  • 16. A sensor or actuator connected to a microcontroller and any other device (for ex: ADC) that helps to turn this assembly into a fully functional stand- alone unit is called a NODE There are 2 types of Nodes Transmitter A node originating a message is called a transmitter of that message Receiver A node receiving a message that it is not transmitting itself is called a receiver of a message What is a NODE?
  • 17. How many CAN Bus protocols are there? There are two CAN Bus protocols  CAN BUS 2.0 A  CAN BUS 2.0 B CAN 2.0 A is used with smaller, less complicated systems CAN 2.0 B is used with larger, more complicated systems
  • 18. The heart & soul of the CAN Bus protocol deals with a FRAME into which the MESSAGE to be sent or received on the CAN Bus is encoded
  • 19. What are the 2 main types of Frames in CAN? A Frame that contains a request for data A Frame that contains the requested data
  • 20. The frame that contains a request for a particular data is called the REMOTE TRANSMISSION REQUEST FRAME
  • 21. The frame that contains the requested data is called the DATA FRAME
  • 22. The DATA FRAME The start of frame The end of frame The Data frame consists of 7 distinct parts 1 2 3 4 5 6 7
  • 23. The RTR Frame Remote Transmission Request Notice the absence of the DATA field The start of frame The end of frame 1 2 3 4 5 6 The Data frame consists of 6 distinct parts
  • 24. A Frame consists of a large number of bits (0’s and 1’s) The bits present in a frame are of two types Dominant bit & Recessive bit
  • 25. Dominant bit represents 0 & Recessive bit represents 1 The Dominant bit has a higher priority than the Recessive bit
  • 26. We shall now discuss each of the 7 parts that make up a FRAME starting with SOF – Start of Frame
  • 27. SOF – Start of Frame The SOF consists of a single bit This is the MSB i.e. Most Significant bit present in the FRAME This bit is dominant (0) always
  • 28. Arbitration Field The arbitration field is the most important field for the programmer or system designer It is also called as the Identifier field as the INDENTITY of the entire frame traveling on the bus is figured out by decoding this field
  • 29. What does ARBITRATION mean? & What does IDENTITY mean?
  • 30. What is Arbitration? The settling of a dispute between two or more individuals by a third person chosen by them In CAN, this translates into the settling of a collision between two or more frames sent onto the bus simultaneously (by two or more nodes) with the help of the CAN protocol (third person)
  • 31. What is an IDENTITY? The unique, individual characteristics by which a person or thing is recognized or known such as  Genes  PAN card number  Telephone number
  • 32. Arbitration & Identity The bits present in the ARBITRATION field can be arranged intelligently by the programmer so that each FRAME is easily distinguished by the unique sequence of bits present in this field This unique sequence of bits constitute an IDENTITY
  • 33. Thus an IDENTITY facilitates the ARBITRATION process with it’s unique pattern of 0’s and 1’s which We shall see in the coming slides a little further down in this presentation
  • 34. Arbitration field - Contd  CAN Bus 2.0 A, has an arbitration field that is 11 bits long which can have 2048 different combinations  This means - that with a 11 bit long identifier there can be 2048 unique frames  These 2048 unique frames can then be sent onto the bus and each of these frames can then be easily identified by all the nodes present on the bus
  • 35. How do we get 2048 unique combinations from 11 bits? Since we follow the Binary format consisting of 0 and 1, 11 bits can give us 2048 combinations as follows 211 = 2*2*2*2*2*2*2*2*2*2*2= 2048
  • 36. CAN Bus 2.0 B, has an arbitration field that is 29 bits long which can have over 5 million different combinations This means with a 29 bit long identifier there can be over 5 million unique frames These 5 million unique frames can then be sent onto the bus and each of these frames can then be easily identified by all the nodes present on the bus
  • 37. Thus, the bits present in an arbitration field are a carefully selected combination of dominant (0) and recessive (1) bits that have to be decided by the programmer which decides the priority level of the different FRAMES being sent onto the bus and also acts as a unique identifier which helps a node identify any FRAME present on the Bus
  • 38. Our discussion from this point onwards shall consist only of CAN Bus 2.0 A, as the 2048 unique identifiers it provides to send and receive 2048 unique frames is more than sufficient for most applications present in the world today
  • 39.  The last bit present in the arbitration field is an RTR bit  In the DATA frame the RTR bit is always dominant (0)  In the Remote frame the RTR bit is always recessive (1) RTR – Remote Transmission Request
  • 40. Control Field  It consists of 6 bits  The first bit is an IDE bit i.e. Identifier Extension bit  This bit is used if CAN Bus 2.0 B with the extended identifier format consisting of 29 bits is desired to be used  The second bit r0 has been reserved for future use and its status is of no use to us
  • 41. Control field  The last 4 bits represent the number of bytes that are present in the next field i.e. the Data field  There can be a minimum of 0 bytes to a maximum of 8 bytes that can be sent as data in a frame Data Length Code
  • 42. Control Field – Data Length code in Binary Byte Code in Binary 0 0000 1 0001 2 0010 3 0011 4 0100 5 0101 6 0110 7 0111 8 1000
  • 44. CRC Field Cyclic Redundancy Check  This field is used to calculate the bit errors present within a CAN frame  The CAN controller does this operation automatically  There are a total of 16 bits present in this field  Of this, the value of the bits in the first 15 fields are automatically calculated  The last bit is called the CRC Delimiter and is always recessive (1)
  • 45. Acknowledgement Field  The acknowledgement field is 2 bits long  It consists of the ACK slot and the ACK Delimiter
  • 46. Acknowledgement Field  The ACK Delimiter as is the case with all Delimiter’s found in a frame is always recessive (1)  The node that transmits a frame, transmits the ACK slot as recessive (1)  The node that receives a frame successfully, reports this to the transmitter by sending a dominant bit in the ACK slot (0)
  • 47. End of Frame  The EOF consists of 7 bits  All these bits are recessive (1)
  • 48. Intermission The Intermission field consists of 3 bits All these bits are recessive (1), ALWAYS An intermission field is present in between consecutive DATA frames and RTR frames
  • 49. Bus Idle  When the bus is idle, it is in a recessive state  Thus there will be an infinite series of recessive (1) bits that will be found on the bus in this state
  • 50. Broadcasting a frame onto the Bus & Receiving a frame from the Bus To broadcast a Frame onto the Bus we need a node that sends a Frame onto the Bus i.e. a Transmitter & we need a node that receives a Frame from the Bus i.e. a Receiver
  • 51. Frame Filter Local Intelligence Transmitter The transmitter consists of 3 different blocks • Local Intelligence • Frame • Filter Frame Filter Local Intelligence Receiver The receiver consists of 3 different blocks • Local Intelligence • Frame • Filter (Node) (Node)
  • 52. What job does the Local Intelligence block and Filter block do ?
  • 53. Local Intelligence consists of the sensor or actuator and the microcontroller functioning intelligently by sending FRAMES onto the bus or receiving FRAMES from the bus as and when instructed to do so
  • 54. Filter A Filter can be compared to a Security Guard standing at the entrance of a large gate Messages carried by a person can enter this gate ONLY if the security guard is able to verify the identity of the person by checking his ID card Similarly in a CAN Bus system a FRAME is allowed to go through the FILTER onto the local intelligence ONLY IF the identity of the FRAME present in the Identifier field (also known as the arbitration field) matches the uniquely coded bits present in the FILTER
  • 55. Broadcasting & Receiving a Frame Frame Local Intelligence Filter Frame Filter Local Intelligence Frame Filter Local Intelligence Frame Local Intelligence Filter Node A Node B Node C Node D BUS Transmitting a Frame onto the bus Each Filter is now checking the IDENTIFIER bits of the Frame and is deciding whether to let the frame in or keep it out The bits in the identifier field of the frame match the bits present in the FILTER situated in Node D The Frame is now Nod Thus the Frame sent Properly finds it way
  • 56. Explain FRAME Arbitration  Let us assume that three nodes broadcast their respective frames onto the bus simultaneously  Of these 3 frames, finally only 1 frame with the highest priority can travel across the bus  The remaining 2 frames will have to wait for the highest priority frame to reach its destination  After it has reached its destination, the remaining 2 nodes can then begin transmitting their frames on the bus
  • 57.  These 3 nodes will have 3 unique identifiers respectively  These unique identifiers will be present in the arbitration field of the FRAME  In a previous slide it was mentioned that the Dominant bit (0) has a higher priority than the recessive bit (1)  This bit priority predetermined by the CAN Protocol will decide which frame wins the arbitration battle being fought on the bus
  • 58. Let us make up 3 unique identifiers for each node  Node A Identifier – 11001110001  Node B Identifier – 11001011011  Node C Identifier – 11001011001 (Notice that they are 11 bits long)
  • 59. Node A Node B Node C Bus SOF 10 7 8 9 6 5 4 3 2 1 0 RTR Arbitration field made up of identifiers Listen Only – Node A Loses Arbitration Listen Only – Node B Loses Arbitration On the Bus Bus FRAME Arbitration 011001110001 011001011011 011001011001
  • 60. Node A loses the arbitration battle to Node B & Node C at the 5th bit present in the arbitration field as the 5th bit present in Node A is recessive (1) whereas the 5th bit present in Node B & Node C is dominant (0) As the dominant bit (0) has a higher priority than the recessive bit (1), Node A is forced into LISTEN ONLY mode and Node B & Node C continue the arbitration battle on the bus which is finally won by Node C
  • 61. What is CAN Synchronization & Bit Timing
  • 62.  Several different nodes on a bus have their own individual internal clocks running at a frequency that MUST be common across the bus  Let us say that our system has 5 nodes  Each of these 5 nodes has a clock with a frequency of 16 Mhz  Even though each node has a clock that operates at the same 16 Mhz frequency, it is practically impossible that these 5 clocks run in perfect synchronicity with each other  There is bound to be a certain tolerance limit in which the clock operates, for example from 15.99 Mhz to 16.01 Mhz  This deviation of +/- 0.2 Mhz is caused due to practical reasons such as variations in  temperature  material properties of the quartz crystal  manufacturing defects
  • 63. To take care of these deviations in operating frequencies and to ensure that all the nodes on the bus are in perfect synchronicity with each other we have Bit Timing What is a BIT & What is BIT TIME??? Bit 0 Bit 1 Bit Time Duration also known as BIT TIME
  • 64.  Bit Time is defined as the time taken by each bit to represent itself  Higher frequencies result in smaller bit time  Lower frequencies result in longer bit time A Bit Time is divided into 4 non-overlapping time segments
  • 65. 4 non-overlapping time segments present in a BIT Bit Time duration Synchronization segment Propagation segment Phase Segment 1 Phase Segment 2 Sample point 1 2 3 4
  • 66.  Each time segment is further divided Into a number of smaller units called Time Quanta  A Time Quanta is the smallest unit of time present in a BIT The total number of Time Quanta that are present in a BIT must be greater than 8 Time Quanta and less than or equal to 25 Time Quanta
  • 67. Time Quantas (TQ) present in a BIT Synchronization segment Phase Segment 1 Phase Segment 2 Sample point 1 2 3 4 Propagation segment TQ TQ TQ TQ TQ TQ TQ TQ TQ TQ TQ TQ
  • 68. Synchronization Segment  This is the first non-overlapping time segment present in a bit  It’s duration is 1 Time Quanta, ALWAYS  It is responsible for synchronizing the various CAN nodes on the bus
  • 69. Propagation Segment  This is the second non-overlapping time segment present in a bit  It’s duration is programmable to be between 1 to 8 Time Quanta in length  It is responsible for compensating the physical delay times on the nodes and the bus  The physical delay (obstructions in electron flow) is caused by the CAN bus cable, transmitting microcontroller and receiving microcontroller
  • 70. Phase Segment 1  This is the third non-overlapping time segment present in a bit  It’s duration is programmable to be between 1 to 8 Time Quanta in length  It is responsible for compensating phase errors (mismatches in timing) with the help of an additional component called SJW or Synchronization Jump Width
  • 71. Phase Segment 2  This is the fourth and last of the non-overlapping time segments present in a bit  It’s duration is programmable to be between 1 to 8 Time Quanta in length  It is responsible for compensating phase errors (mismatches in timing) with the help of an additional component called SJW or Synchronization Jump Width
  • 72.  The SJW acts like a washer used in mechanical systems  Washers are added or removed from components in a mechanical system to make components fit into each other perfectly  SJW is a software washer  It is implanted into a BIT in such a way that the BIT TIME can compensate for the various shifts in phase (mismatched timing) while receiving a frame from another node  SJW can consist of a minimum of 1 TQ to a maximum of 4 TQ Synchronization Jump Width - SJW
  • 73. Synchronization Jump Width - SJW Synchronization segment Phase Segment 1 Phase Segment 2 Propagation segment Synchronization segment Phase Segment 1 Propagation segment Phase Segment 2 SJW Notice the increase in BIT TIME with the SJW added to it to compensate for mismatches in timing Bit time = x Bit time = x + SJW
  • 74. Sample Point  It’s exact location is in-between the end of Phase segment 1 and the beginning of Phase segment 2  This is the point of time at which the BIT is read and interpreted  At this point we know whether the bit is dominant (0) or recessive (1)
  • 76.  Bit Timing on its own does 95% of the work required to synchronize the frames sent by the various nodes present in a bus  But 95% is not good enough  Synchronization between frames sent by the various nodes must reach as close to the 100% mark as possible for proper transmission and reception
  • 77. This is done with the help of Bit Stuffing
  • 78. What is Bit Stuffing ??? The CAN Protocol intelligently inserts (stuffs) a bit (s) of opposite polarity into a FRAME, If a continuous series of bits of the same polarity exceed 5 in number
  • 79. Bit Stuffing  For example, if a frame consists of 8 consecutive dominant (0) bits, the CAN protocol will force the transmitter to STUFF a recessive (1) bit after the 5th consecutive dominant bit automatically Bit sequence to be transmitted Stuffed Bit sequence De-stuffed Bit sequence Transmitter Receiver 0 1 2 3 4 5 6 7 8 9 10 11 12 13 S 0 1 2 3 4 5 6 7 8 9 10 11 12 13 0 1 2 3 4 5 6 7 8 9 10 11 12
  • 80. Bit Stuffing  Similarly, if a frame consists of 12 consecutive recessive bits, the CAN protocol will force the transmitter to STUFF a dominant (0) bit after every 5th consecutive recessive (1) bit automatically Bit sequence to be transmitted Stuffed Bit sequence De-stuffed Bit sequence Transmitter Receiver 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 0 1 2 3 4 5 S 6 7 8 9 10 S 11 12 13 14 15 16 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
  • 81.  The Node transmitting a FRAME will automatically stuff bits if required  The Node receiving the FRAME will automatically de-stuff the bits thereby returning the FRAME into it’s original form
  • 82. Why is Bit Stuffing required ???
  • 83. Because CAN follows NZR i.e. Non Return to Zero coding as against Manchester coding
  • 85.  Remember, we said that a BIT is made up of Time Quanta and each BIT should have a minimum of 8 TQ to a maximum of 24 TQ  We also know that by manipulating TQ’s we can negate the phase shifts or mismatches in Timing of FRAMES received from different nodes  All these things mentioned above help to achieve synchronicity between nodes because of which one can transmit and receive frames successfully
  • 86. For all this matching & synchronizing business to take place successfully, there is one small requirement without which nothing will work What is this small requirement ???
  • 88. Without an EDGE, there is no reference point and without a reference point there is no way synchronization can take place EDGE
  • 89. So, if a FRAME has a large number of successive bits that are either dominant or recessive, there is a long gap before an edge appears Long gaps in a frame Successive recessive bits (1) Successive dominant (0) bits
  • 90. These long gaps throw the synchronization mechanism into complete confusion In order to avoid this, an EDGE is introduced after regular intervals In CAN an EDGE is introduced, if 5 successive bits of the same polarity are present in a FRAME by inserting a BIT with opposite polarity (BIT STUFFING), to facilitate the smooth functioning of the synchronization process
  • 91. So now we know how FRAMES are sent and received on the CAN Bus synchronously without sending clock pulses simultaneously with the message as is done with I2C and SPI protocol but by intelligently manipulating the width of each bit (BIT TIME) with the help of small packets of time called TIME QUANTA and with the help of BIT STUFFING
  • 92. What is Error Handling in CAN?
  • 93. • All nodes listen to any message being transmitted onto the bus • The transmitting node too listens to its own message while transmitting it onto the bus
  • 94. Message Validation  The point of time at which a FRAME is taken to be valid is DIFFERENT for the transmitter and receiver of the message  Transmitter A FRAME is valid for a transmitter if there is no error till the end of the FRAME  Receiver A FRAME is valid for a receiver if there is no error till the last but one bit of the END OF FRAME
  • 95. CAN Error Detection  Bit value check by Transmitter  Bit Stuff checking  Frame check  15 bit Redundancy check  Acknowledgement check
  • 96. What are possible CAN errors?  Bit error  Stuff error  Form error  CRC error  Acknowledgement error
  • 97. What is Bit error ?  A Node that is transmitting a FRAME listens to it’s own FRAME on the Bus  For example if a Node sends a sequence 01100110011 but on the bus it sees 01100100011, a bit error has occurred  An error frame is then sent onto the bus and the FRAME with the Bit error is ignored by all nodes
  • 98. What is Stuff error ?  If a FRAME consists of the following bits 0110000000011100110  Then according to the bit stuffing rule there should a recessive bit (1) inserted after the 5th dominant (0) bit  So the FRAME should be transformed into 01100000100011100110 from 0110000000011100110 BIT STUFFING is done automatically by the CAN Controller but for some reason if it does not happen, a STUFF ERROR occurs An error frame is then sent onto the bus and the FRAME with the STUFF ERROR is ignored by all nodes
  • 99. What is Form error?  The CRC Delimiter, ACK Delimiter and EOF consist of recessive bits (1) ALWAYS  If a dominant bit (0) is detected in any of these, a FORM ERROR has taken place  An Error frame is then sent onto the bus and the FRAME with the FORM ERROR is ignored by all nodes CRC Delimiter ACK Delimiter EOF
  • 100. What is CRC error? • The CRC value is 15 bits long • This value is automatically calculated by the transmitting and receiving nodes • If the CRC value of the FRAME calculated by the transmitting node is different from the CRC value of the FRAME calculated by the receiving node a CRC error has occurred • An error frame is then sent onto the bus and the FRAME with the CRC ERROR is ignored by all nodes
  • 101. What is Acknowledgement error ?  A transmitting node keeps the value of the ACK slot recessive (1)  A receiving node on successful reception of a message changes the value of the ACK slot to dominant (0)  If it fails to do this an acknowledgement error has occurred  An error frame is then sent onto the bus and the FRAME with the acknowledgement error is ignored by all nodes ACK slot
  • 103. Explain about Error Frame  It is made up of two fields  Error Flag Field  Error delimiter Field Error Flag Error Delimiter It consists of 6 to 12 bits It consists of 8 bits
  • 104.  An error can occur during transmission  A count is kept on these errors by a counter called TEC or Transmit Error Counter  An error can occur during reception  A count is kept on these errors by a counter called REC or Receive Error Counter  The count value in TEC and REC must be maintained between a certain count limit that is predefined by the CAN Protocol  Depending upon the count value present in TEC and REC at each node, the Node can be in any of the 3 following states  Active Error State  Passive Error State  Bus Off State
  • 105. What is Active Error State ?  All the nodes on the bus should be in Active Error State for normal transmission and reception of FRAMES  If any given node has less than 128 counts in it’s TEC and REC, it is in Active Error State
  • 106. What is Passive Error State ?  If any given node has greater than 127 counts and less than 256 counts in it’s TEC and REC, it goes into Passive Error State This is NOT a desirable state for any given NODE to be in This state is caused due to more than the normal number of errors occurring while transmitting and receiving FRAMES Nodes in Passive error state have a lower priority for transmitting frames than nodes in Active error state
  • 107. What is Bus Off State ? If any given node has more than 255 counts in it’s TEC, it goes into in Bus Off State In Bus Off State the given node is not allowed to Transmit or Receive any more FRAMES onto the Bus until the reason behind the excessive error generation has been identified and rectified
  • 108. The 3 States of a Node Error Active Error Passive Bus Off Initial error free state of a node If TEC > 127 or REC > 127 If TEC < 128 or REC < 128 If TEC > 255 On RESET Or Error rectification
  • 109. Coming back to the Error Frame Error Flag Error Delimiter It consists of 6 to 12 bits It consists of 8 bits  If an error occurs while a node is in Error Active state then  The error flag will consist of 6 consecutive dominant (0) bits  The error delimiter will consist of 8 consecutive recessive (1) bits 6 dominant bits 8 recessive bits
  • 110. Coming back to the Error Frame Error Flag Error Delimiter It consists of 6 to 12 bits It consists of 8 bits  If an error occurs while a node is in Passive Active state then  The error flag will consist of 6 consecutive recessive (0) bits  The error delimiter will consist of 8 consecutive recessive (1) bits 6 recessive bits 8 recessive bits
  • 111. What is Overload Frame ?  It is generated due to 2 conditions  If the receiver is not yet ready to receive the next FRAME  If a node detects a dominant bit during intermission An intermission consists of 3 bits ALL OF THEM ARE RECESSIVE (1) AT ALL TIMES As mentioned earlier, an Intermission frame is present between successive DATA and RTR frames  An overload frame is similar to the error frame  It is made up of two fields  Overload Flag Field  Overload delimiter Field Overload Flag Overload Delimiter It consists of 6 to 12 bits It consists of 8 bits
  • 112.  If an overload condition occurs then  The overload flag will consist of 6 consecutive dominant (0) bits  The overload delimiter will consist of 8 consecutive recessive (1) bits 6 dominant bits 8 recessive bits The CAN Protocol generates a maximum of 2 overload frames to delay the next DATA or RTR Frame If the receiver is still not ready to receive the next frame, an Error Frame is generated
  • 113. Physical Layer of the CAN Bus
  • 115. What is Physical Layer ?  It consists of a pair of twisted wires that are shielded to reduce electromagnetic interference caused due to noise  One wire carries the CAN High signal  The other wire carries the CAN Low signal  The difference between these signals results in a dominant (0) or recessive bit (1)
  • 117.  If the difference between the CAN High voltage and CAN Low voltage is less than 0.5 volts, the resulting bit is recessive (1)  If the difference between the CAN High and CAN Low voltage is greater than 0.9 volts and less than 3.5 volts, the resulting bit is dominant (0)
  • 119. CAN Bus Systems are present in harsh, noisy environments where mechanical and electrical disturbances induce unwanted voltages into the wires thereby corrupting the signal and making it unworthy To prevent this from happening CAN uses the differential voltage system to figure out whether the BIT is Dominant (0) or Recessive (1)
  • 120. Electrical Waveform traveling through the Bus
  • 121. For the node to read the bus level correctly it is important that signal reflections are avoided This is done by terminating the bus line with a termination resistor at both ends of the bus ISO 11898 requires a cable with a nominal impedance of 120 ohms, and therefore 120 ohm resistors should be used for termination Why 120 ohm resistor is used in CAN ?
  • 122. Why CAN is having 120 ohms at each end? Answer: To minimize the reflection reference, to reduce noise. To ensure that reflection does not cause communication failure, the transmission line must be terminated Why CAN is message oriented protocol? Answer: CAN protocol is a message-based protocol, not an address based protocol. This means that messages are not transmitted from one node to another node based on addresses. Embedded in the CAN message itself is the priority and the contents of the data being transmitted. All nodes in the system receive every message transmitted on the bus (and will acknowledge if the message was properly received). It is up to each node in the system to decide whether the message received should be immediately discarded or kept to be processed. A single message can be destined for one particular node to receive, or many nodes based on the way the network and system are designed. For example, an automotive airbag sensor can be connected via CAN to a safety system router node only. This router node takes in other safety system information and routes it to all other nodes on the safety system network. Then all the other nodes on the safety system network can receive the latest airbag sensor information from the router at the same time, acknowledge if the message was received properly, and decide whether to utilize this information or discard it.
  • 123. . CAN logic what it follows? Answer: Wired AND logic How CAN will follow the Arbitration? Answer: CSMA/CD + AMP (Arbitration on Message Priority) Two bus nodes have got a transmission request. The bus access method is CSMA/CD+AMP (Carrier Sense Multiple Access with Collision Detection and Arbitration on Message Priority). According to this algorithm both network nodes wait until the bus is free (Carrier Sense). In that case the bus is free both nodes transmit their dominant start bit (Multiple Access). Every bus node reads back bit by bit from the bus during the complete message and compares the transmitted value with the received value. As long as the bits are identical from both transmitters nothing happens. The first time there was a difference – in this example the 7th bit of the message – the arbitration process takes place: Node A transmits a dominant level, node B transmits a recessive level. The recessive level will be overwritten by the dominant level. This is detected by node B because the transmitted value is not equal to the received value (Collision Detection). At this point of time node B has lost the arbitration, stops the transmission of any further bit immediately and switches to receive mode, because the message that has won the arbitration must possibly be processed by this node (Arbitration on Message Priority)
  • 124. . What are the functions of CAN transceiver? Answer: The transceiver provides differential transmit capability to the bus and differential receive capability to the CAN controller. Transceiver provides an advanced interface between the protocol controller and the physical bus in a Controller Area Network (CAN) node. Typically, each node in a CAN system must have a device to convert the digital signals generated by a CAN controller to signals suitable for transmission over the bus cabling (differential output). It also provides a buffer between the CAN controller and the high-voltage spikes that can be generated on the CAN bus by outside sources (EMI, ESD, electrical transients, etc.). The can transceiver is a device which detects the signal levels that are used on the CAN bus to the logical signal levels recognized by a microcontroller.
  • 125. What happen when two CAN nodes are sending same identifier at a same time? Two nodes on the network are not allowed to send messages with the same id. If two nodes try to send a message with the same id at the same time arbitration will not work. Instead, one of the transmitting nodes will detect that his message is distorted outside of the arbitration field. The nodes will then use the error handling of CAN, which in this case ultimately will lead to one of the transmitting node being switched off (bus-off mode). Formula for Baudrate calculation? The baud rate is calculated as: baud rate (bits per second) = 18.432 x 10^6 / BRP / (1 + TSEG1 + TSEG2)
  • 126. Thank you HAVE A NICE DAY !!!