CAN Protocol
CAN Protocol
CAN Protocol
At HCL
CAN (Controller Area Network)
CAN Fundamentals
User benefits
Overview
How it all began
(before introduction of CAN)
Pictorial view of Point to point wiring connections
How it can be better
(CAN Network)
One serial bus connecting all control systems
Why CAN
Advantages of CAN, to list a few:
CAN is fast and flexible. Maximum data rate is 1MBits/s @40m bus
length
}
2 Data Link Layer
CAN
1 Physical Layer
Multi Easy
CAN
master connectio
Nodes
Concept n/
disconnec
Node A Node n
Number of tion
nodes e.g. e.g. of nodes
not limited ABS Dash-
by protocol board
Broadcast
No node capability
addressing,
Message CAN-Bus Event
identifier (logical) driven
specifies system
content &
priority
Basic Concepts
Node A Node n
Sophisti-
Application e.g. ABS e.g. Dash- cated
board Error
e.g. Detection
e.g.
Host-Controller 80C166 C167CR /
or C515C Handling
CAN
High
Speed
bit rate / kbps CAN
ISO-IS
Low
11898
Speed
ISO-IS
1000 11519-2 Engine
Class C management,
125 Gearbox, ABS
Class B dashboard,
diagnostics
10
Class A body
control
Real-time capability
CAN Protocol Versions
V2.0A CAN
Module Tx/Rx OK Bus ERROR
Basic CAN Controller
CAN
Status/Control
Registers
low high
Host
CPU
CAN
Bus Protocol
Host CPU load
Controller Transmit
Inter-
Bus Interface
Buffer
face Tx Rx
Acceptance Receive
Filtering Buffer(s)
Only used in CAN networks with very low baud rates and/or
very few messages
Full-CAN Controller
Status/Control
CAN CAN Registers
Bus Protocol
Controller Message
Host
Inter-
Bus Interface
Object 1
face low high
Acceptance Message
Filtering Object 2 CPU load
...
Host CPU
Message
Object n
Receive
Buffer(s)
CAN Controller
An Example: Freescale S12
CAN Fundamentals
ISO-IS 11898 CAN Bus (there exists more than one physical
layer standard)
Bit Levels / Bit Representation
Bit Stuffing
Synchronization
Physical Layer according to
ISO-IS 11898
CAN
Node 1 Node 30 High
Speed
ISO-IS
11898
...
1000
500
Bus lines
assumed to be
200 an electrical
medium
100
Bit Rate (e.g.twisted
50 pair)
[kbps]
20
10
5
CAN
High
V Recessive Dominant Recessive Speed
ISO-IS
5
11898
4 UCAN_H
3.5 V
3
2.5 V
2 Udiff= 2V
1.5 V
1 UCAN_L
CAN and EMI
The usual CAN-realization is insensitive to electromagnetic interference
V
Node A Node B Node C
CAN_H
Udiff =2V
CAN_L
t
CAN_H
120 120
Ohm Ohm
CAN_L EMI CAN-Bus
Why 120 Ohm terminations
Needed to limit wave reflection at high frequency in electronically
harsh environments. If not terminated there could be miss-matched
impedances
For details read through Basic wave mechanics and Transmission Line
theory
Basic Concepts -Message Coding
Signal to Signal to
transmit a 0 transmit a 1
HIGH HIGH
LOW LOW
1
0
0 1 0 ...
Basic Concepts -Bit Stuffing
Bit Stuffing ensures enough recessive to dominant edges (also needed
due to limitation of NRZ)
Stuff Bit inserted after 5 consecutive bits at the same state
Stuff Bit is inverse to previous bit
De-Stuffing done at receiver
1 2 3 4 5 6 7 8 ... 1 2 3 4 5 6 7 8 ...
data stream
Nr. of
consecutive
bits with
Stuff Stuff Stuff
same polarity
Bit Bit Bit
bit stream
1 2 3 4 5 1 2 3 4 51 2 3 4 5
Bus Synchronization
Hard Synchronization at Start Of Frame bit
CAN frame
1 Bit Time
1 2 3 4
1 Time Sample
Quantum Point
Bus Synchronization -
Synchronization Segment
1 Bit Time
1
1 Bit Time
3
1 Bit Time
4
Phase Buffer Phase Buffer Sync- Propagation Phase Buffer Phase Buffer Sync-
Segment 1 Segment 2 Segment Time Segment Segment 1 Segment 2 Segment
Transmitter
(faster) next edge for Re-synchronization is 1 TQ too early...
Phase Buffer Phase Buffer Sync- Propagation Phase Buffer Phase Buffer Sync-
Segment 1 Segment 2 Segment Time Segment Segment 1 Segment 2 Segment
Receiver
(slower) tq expected Sample Point
for bit n+1
Bus Synchronization -
Bit Shortening (cont.)
bit n bit n+1 Needed Sample
Point for bit n+1
Phase Buffer Phase Buffer Sync- Propagation Phase Buffer Phase Buffer Sync-
Segment 1 Segment 2 Segment Time Segment Segment 1 Segment 2 Segment
Transmitter
(faster) Phase Buffer segment 2 in bit n is shortened by 1 TQ
Phase
Buffer
Phase Buffer SegmentSync- Propagation Phase Buffer Phase Buffer Sync-
Segment 1 2 Segment Time Segment Segment 1 Segment 2 Segment
Receiver
(slower) new Sample Point
for bit n+1
Bus Synchronization -
Synchronization Jump
Width
Amount by which bit length can be adjusted
during Re-synch is defined as Synchronization
Jump Width
1 Bit Time
1 Bit Time
Maximum
Synchronization
Jump Width (4)
Transmit Early
Point Sample
Point
Bus Synchronization -
Why Program the Sample
Position ? (cont.)
Late sampling allows maximum signal
propagation time
Maximum bus length / Poor bus topologies can be handled
1 Bit Time
Transmit Late
Point Sample
Point
CAN (Controller Area Network)
CAN Fundamentals
Bus Arbitration
Frame formats
Node X
Node A
Node B
Node C
Start
Identifier Field
Arbitration Bit
Node A
phase
Node B
Rest of
Node C
Frame
CAN Bus
Transmit
Request Node B loses Arbitration Node C loses Arbitration
Frame Formats -
Data Frame
Standard Data Frame Inter Frame Space
recessive
1 11 1 1 1 4 0...64 15 1 1 1 7 3
dominant
Bus Idle
ACK Slot
IDE Bit (D)
Data Field
RTR Bit (D)
Intermission
End of Frame
Identifier Field
CRC Delimiter
( reserved (D))
Start of Frame
ACK Delimiter
CRC Sequence
Data Lenght Code
recessive
1 11 1 1 1 4 0...64 15 1 1 1 7 3
dominant
recessive
The numbers
1 11 1 1 1 4 15 1 1 1 7 3 indicate the
dominant length of
each bitfield
Frame Formats -
InterFrame Space
Separates a frame (of whatever type) from a
following Data or Remote Frame
3 0.....
Bus Idle
I ntermission Field
Error Handling -
Frame Formats - Overload
Frame
Overload Frame:
Used to delay next CAN message
Interframe
Space or
Interframe Overload
Space Overload Frame Frame
6 0-6 8
Flag
Error
of Active
Delimiter
Overload
(recessive)
Overload Frame
Superimposition
Error Detection - Overview
Detected Errors
ACK Bit
Error Error
Error Detection -
Cyclic Redundancy Check
Calculated and received CRC checksum must match...
Node A Node B
Calculated Calculated
Idle CRC Checksum: CRC Checksum: Idle
Receive 1234h 1234h Receive
Transmit Transmit
Transmitted Received
CRC Checksum: CRC Checksum:
1234h 1234h match
CAN_L
CRC Sequence
Error Detection -
Cyclic Redundancy Check
(cont.)
otherwise Frame was not received correctly (CRC
Error)
Node A Node B
Calculated Calculated
Idle CRC Checksum: CRC Checksum: Idle
Receive 1234h 1235h Receive
Transmit Transmit
Transmitted Received
CRC Checksum: CRC Checksum:
1234h 1234h mismatch
CAN_L
Error Detection - Frame
Check
No dominant bits
allowed in: CRC
Delimiter, ACK
Delimiter, End of
Frame, Intermission
->(Form Error)
Error Detection - Bit
Monitoring
A transmitted bit
must be correctly
read back from the
CAN bus (otherwise
Bit Error)
Dominant bits may
overwrite recessive
bits only in the
Arbitration Field and
in the Acknowledge
Slot
Error Detection - Bit
Stuffing Check
6 consecutive bits with
same polarity are not
allowed between
Start Of Frame and
CRC Delimiter
CAN_L
Error Handling
REC<=127 REC>127
and or TEC>255
TEC<=127 TEC>127
Re-Initialization only
Error Handling -
Frame Formats - Error Frame
Active Error Frame: Used for error signaling
Interframe
Field within Space or
Data or Overload
Error Frame Error Frame Frame
Error Active
Field
Error
Field
Delimiter
Error Flag
Common Misunderstandings
Attempting to send messages again after leaving the node open for a
while
Quiz
1. Which of the following logic CAN follows?
a) Wired OR logic
b) Wired NAND logic
c) Wired AND logic
d) Wired NOT logic
6. If Node 1 sends 764 and Node 2 sends 744 which will get the
arbitration?
e) None
f) 764
g) 744
h) both
Quiz
7. CAN Bus is _______?
a) Parallel Synchronous
b) Serial Synchronous
c) Serial Asynchronous
d) Parallel Asynchronous