Can Protocol: Mohamed Bahae OUAADDI
Can Protocol: Mohamed Bahae OUAADDI
[email protected]
Table of
Content
CAN
1 INTRODUCTION
[email protected]
CAN FEATURES
CAN
developed by the International Organization for DATA LINK
Standardization (ISO) PHYSICAL
CAN NETWORK
TOPOLOGY CAN Node
CAN BUS
PHYSICAL
LAYER
High Speed
CSMA CAN AND Low
Networks Speed CAN
NRZ
Encoding and
Bit Stuffing
CAN NETWORK TOPOLOGY
CANH CANH
CANL
CANL
CSMA (CARRIER SENSE MULTIPLE ACCESS)
Networks
This method was developed to decrease the chances of collisions when two or more nodes
start sending their signals. Carrier Sense multiple access requires that each node sense the
bus before transmit any data. The bus has two states :
1- Persistent : 2- Non-Persistent :
If bus is busy the node sense the bus If bus is busy the node waits a random period
continuously until it becomes idle of time and then repeat the transmission
Types of CSMA Access Modes:
3- P-Persistent :
CSMA / CA :
The basic idea behind CSMA/CA is that the node should be
able to receive while transmitting to detect a collision from
different nodes. In wired networks, if a collision has occurred
then the energy of the received signal almost doubles, and the
node can sense the possibility of collision. In the case of
wireless networks, most of the energy is used for transmission,
and the energy of the received signal increases by only 5-10% if
a collision occurs. It can’t be used by the node to sense
collision. Therefore CSMA/CA has been specially designed for
wireless networks.
CSMA With Collision detection
CAN Message
Standard CAN
Types vs Extended
CAN
Standard CAN vs Extended CAN
IFS
Extended CAN
IFS
SOF (Start of Frame) : Marks the beginning of data and remote Frames
Used for synchronization ,It’s a single dominant bit, can start
only if bus was idle
Arbitration Field : Includes the message Identifier (consists of 11bits in CAN
2.0A and 29bits in CAN 2.0B)
RTR (Remote Transmission Request) bit, which
distinguishes data and remote frames (dominant in data
frame and recessive in remote frame).
For Extended CAN
IDE (Extended Identifier) indicates that the identifier field in
the frame is using the extended format.
SRR (Substitute Remote Request):When this bit is set to 1, it
indicates that this frame is a substitute remote request,
meaning the node wants to request data from another
node. If set to 0, it's a data frame.
The IDE (Identifier Extension) bit belongs to:
- The Control Field of the Standard Format
- The Arbitration Field of the Extended Format
Control Field : IDE (Extended Identifier) : A low (dominant) IDE bit
indicates an 11-bit message identifier, a high (recessive)
IDE bit indicates a 29-bit identifier.
r0, a Dominant bit reserved for future usage.
And the DLC (Data length code) field, which consists of 4
bits indicates the number of bytes of data contained in the
CAN frame. It ranges from 0 to 8 bytes, allowing for
variable-length data payloads.
For Extended CAN
The Control Field was redesigned in CAN 2.0B, as shown in the
picture at the bottom, in order to support the coexistence of 11-
bit and 29-bit message identifiers on the same CAN bus network.
Includes two bits, r1 and r0, reserved for future use and
were kept at a low (dominant) level.
And the DLC (Data length code) like standard CAN.
Data Field : The data field can contain upto 8 bytes.
CRC Field : Or (Cyclic Redundancy Check) field, it contains a 15-bit
checksum used for error detection, followed by CRC delimiter
(always recessive). It features a Hamming distance of six.
ACK Field : ACK field is 2 bits, one is the acknowledgment bit and the
second is a delimiter (always recessive).
Sender writes a recessive bit in the ACK slot, and every node
receiving an accurate message overwrites this recessive bit in
the original message with a dominant bit, so the sender knows
if at least one receiver has correctly received the message.
EOF(End of Frame) : it’s a 7 recessive bits marks the end of a CAN frame (message)
and disables bitstuffing, indicating a stuffing error when
dominant.
IFS(Interframe space) : It’s a bit field used to separate Data(or Remote) frames from
preceding frames whatever type they are. It contains the bit
fields INTERMISSION (3 recessive bits) and BUS IDLE.
REMOTE FRAME
The remote frame serves to request data transmission from another node, resembling
the data frame but with two notable distinctions. Firstly, it's distinctly identified as a
remote frame by a recessive RTR bit in the arbitration field. Secondly, unlike the data
frame, it doesn't contain any data payload.
ERROR FRAME
The error frame is a special message characterized (like the End Of Frame) by a
deliberate breach of the bit-stuffing rules. It's dispatched when a node detects an error
within a message, prompting all other nodes in the network to send out an error frame
too. Subsequently, the initial transmitter automatically initiates a retransmission of the
message.
Transmission of error frame starts simultaneously with the next bit after the detection of
an error (CRC error frames start after the ACK delimiter).
• Active Error Flag
It's a sequence of 6 dominant bits that violates bit stuffing. When it's raised by a node,
the other CAN nodes will see the Active Error Flag as a Bit Stuffing Error. In response
they also raise an Active Error Flag.
CAN
frame
• Error Active
This is the normal state of a CAN node, in which messages can be sent and received.
In the event of a fault, an Active Error Flag, consisting of dominant bits, is transmitted.
• Error Passive
This state is reached after several errors have been detected on the CAN bus. In this
state, the CAN node may continue to send and receive messages, but in the case of
an error, only a Passive Error Flag is sent, consisting of recessive bits.
• Bus Off
In this state, the CAN node is completely disconnected from the CAN bus. It therefore
cannot send or receive messages or Error Flags. This state is reached when there is a
long disturbance on the CAN bus or a frequently repeated disturbance.
ERROR Counters :
The error state transitions are controlled by error counters.
Each CAN node has an error counter
for receive errors : REC (Receive Error Counter).
for transmit errors : TEC (Transmit Error Counter) .
ERROR Handling :
The error handling is done in the following order :
1. An error is detected.
2. An Error Frame is sent by any CAN node that has detected the error.
3. The message currently in progress is rejected by all CAN nodes.
4. Error counters incremented.
5. The disturbed message is retransmitted
State Diagram for CAN node :
Error
Active Hardware reset or Host reset
with 128 x 11 recessive bit
waiting time
Error Bus
Passive OFF
The states are characterized by the following count values :
• Error Active:
The counts of the Receive Error Counter and Transmit Error Counter
are both less than or equal to 127.
• Error Passive:
At least one of the two error counts is greater than 127 and the
Transmit Error Counter is less than 256.
• Bus Off:
The Transmit Error Counter is greater than 255.
The transition from Error Active to Error Passive and vice versa is done
automatically. The Bus Off state can be exited only by appropriate
actions of the host controller (software or hardware reset).
Update of Counters :
Receive Error Counter :
→
A receiver detects an error REC=REC+1.
→
A receiver detects a dominant bit after sending an Error Flag REC=REC+8.
A receiver detects a Bit-Error while sending an Active Error Flag or an Overload
→
Flag REC=REC+8.
A receiver with REC>0 will decrement after each reception of a fault-free Data
→
Frame or Remote Frame REC=REC - 1.
→
A receiver with REC=0 REC=0.
Any CAN node tolerates up to seven consecutive dominant bits after sending
an Active Error Flag, Passive Error Flag, or Overload Flag. After detecting the
14th consecutive dominant bit (in case of an Active Error Flag or an Overload
Flag) or after detecting the eighth consecutive dominant bit following a
Passive Error Flag, and after each sequence of additional eight consecutive
→
dominant bits, every receiver increases REC=REC+8.
Transmit Error Counter :
→
A transmitter starts an Error Flag TEC=TEC+8.
Exception 1: When a transmitter is in Error Passive state and detects an
Acknowledgment-Error (no dominant bit in the ACK Slot) and it does
not detect a dominant bit while sending its Passive Error Flag, the TEC
is not changed.
Exception 2: If a transmitter detects a Bit-Error on a recessive stuff-bit in the
Arbitration Field before the RTR bit, the TEC is not changed.
A transmitter detects a Bit-Error while sending an Active Error Flag or an Overload
→
Flag TEC=TEC+8.
A transmitter with TEC>0 will decrement after each successful transmission of a
→
Data Frame or a Remote Frame TEC=TEC−1.
Any CAN node tolerates up to seven consecutive dominant bits after sending an
Active Error Flag, Passive Error Flag, or Overload Flag. After detecting the 14th
consecutive dominant bit (in case of an Active Error Flag or an Overload Flag) or
after detecting the eighth consecutive dominant bit following a Passive Error
Flag, and after each sequence of additional eight consecutive dominant bits,
→
every transmitter increases TEC=TEC+8.
WARNING Level :
We can use the Warning level to determine if a CAN node gets near the
threshold to the Error Passive state by checking constantly the Error Warning
flag.
OVERLOAD FRAME
Overload Frames are dispatched under two conditions. Initially, when a dominant bit
appears in the first two bits of the Interframe Space (IFS), an Overload Frame is sent to
synchronize all CAN nodes. Additionally, a CAN controller might utilize an Overload
Frame to signal to other CAN nodes that it is currently overloaded and unable to
handle a new message immediately due to high workload.
The overload frame has no effect on the error counters (REC and TEC).
Today’s CAN controllers are fast enough, they are able to handle all bus traffic without
the additional delay of Overload Frames.
Overload Superposition of Overload
flag Overload flags Delimiter
IFS