Kumar S. Golla 4/10/2010

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 51

Kumar S.

Golla
4/10/2010
What is CAN?
Controller Area Network
A serial communication protocol
Originally developed for automotive industry but is used
in other industries
Is a multi-master broadcast “bus”
Each node can transmit and receive, not simultaneously
Uses differential signaling
The signal pattern is encoded in NRZ
Excellent error handling and fault confinement
Bit rate 1 Mbps (< 40m) 125 Kbps (~500m)
Where is CAN used?
Modern dashboards
Before CAN
Modern cars
Automotive networks
Automotive networks (contd…)
Automotive Protocol Comparison
LIN CAN FlexRay MOST
20 Kbps max. 1 Mbps max. 10 Mbps max./ch 23 Mbps max.
Single Multiple master TDMA Multiple master
master/multiple
slave
Door Locks, Body Systems, Drive-by-Wire, Media
Climate Control, Engine Brake-by-Wire,
Seat Belts, Management, Advanced Safety
Sunroof, Lighting, Transmission and Collision
Window Lift, Avoidance
Mirror Control Systems, Steer-by-
Wire, Stability
Control, Camera-
Based Monitoring
Systems
CAN History
Started in 1986
By Robert Bosch for
Mercedes
Defined for only logical link
and physical layer
Data link layer divided into
logical link layer and media
access control
ISO 11898 (High Speed)
ISO 11519 (Low Speed)
J1939 – Trucks & Busses
CAN Layers
CAN Layers
 LLC sub-layer deals with message acceptance filtering, overload
notification, and error recovery management.
 MAC sub-layer presents incoming messages to the LLC sub-layer and
accepts messages to be transmitted forward by the LLC sub-layer.
 MAC sub-layer is responsible for message framing, arbitration,
acknowledgement, error detection, and signaling.
 MAC sub-layer is supervised by the fault confinement mechanism.

 The physical layer defines how signals are actually transmitted, dealing
with the description of bit timing, bit encoding, and synchronization.
 CAN bus driver/receiver characteristics and the wiring and connectors are
not specified in the CAN protocol.
 System designer can choose from several different media to transmit the
CAN signals
CAN Characteristics
Carrier Sense Multiple Access with Collision
Detection (CSMA/CD) + AMP
Every node on the network must monitor the bus
(carrier sense) for a period of no activity before trying
to send a message on the bus.
Once the bus is idle, every node has equal opportunity
to transmit a message.
If two nodes happen to transmit simultaneously, a
nondestructive arbitration method is used to decide
which node wins.
CAN Characteristics
Message-Based Communication
 Each message contains an identifier.
 Identifiers allow messages to arbitrate and also allow each node to
decide whether to work on the incoming message.
 The lower the value of the identifier, the higher the priority of the
identifier.
 Each node uses one or more filters to compare the incoming
messages to decide whether to take actions on the message.
 CAN protocol allows a node to request data transmission from
other nodes.
 There is no need to reconfigure the system when a new node joins
the system.
CAN Characteristics
Error Detection and Fault Confinement
The CAN protocol requires each node to monitor the
CAN bus to find out if the bus value and the
transmitted bit value are identical.
The CRC checksum is used to perform error checking
for each message.
The CAN protocol requires the physical layer to use bit
stuffing to avoid long sequence of identical bit value.
Defective nodes are switched off from the CAN bus.
Bit Stuffing
CAN uses NRZ encoding
To guarantee edges
Insert opposite bit after 5 consecutive bits
Eliminates clock drift
Bit Stuffing
CAN Messages
Data Frame
Remote Frame
Error Frame
Overload Frame

Two states of CAN bus


Recessive: high or logic 1
Dominant: low or logic 0
CAN Data Frame
Data Frame Bits
 SOF = Start Of Frame = one dominant bit
 SRR = Substitute Remote Request = one bit (recessive), so Standard
Frame gets priority
 IDE = Identifier Extension Bit = Standard Frame (dominant),
Extended Frame (recessive)
 RTR = Remote Transmission Request = one bit (recessive)
 R1, R2 = Reserved Bits
 DLC = Data Length Code = 4 bits (rxxx = 8 bytes) (code length 9-15
not allowed)
 CRC = Cyclic Redundancy Check = 15 bit with 1 bit recessive CRC
delimiter
 ACK = Acknowledgement = Ack slot and delimiter = transmitter sends
2 recessive bits
 EOF = End Of Frame = 7 recessive bits
 IFS = Inter Frame Space
Arbitration
ID
Remote Frame

Used by nodes to request messages of certain type


Error Detection
Bit Error
Transmitted bit not same as received
Exception: Arbitration Field and Acknowledgement Field
Bit-Stuff Error
Receiver reads more than 5 bits of same polarity
Exception: EOF
CRC Error
Format or Form Error
Ex: CRC delimiter not recessive, EOF violation
Acknowledgement Error
Error Handling

Active error flag – 6 dominant bits


Passive error flag – 6 recessive bits
Error delimiter – 8 recessive bits
All nodes that received the last frame – discard it
Transmitter re-sends the frame automatically
Error Confinement
 Xmitter finds error REC <127
and error active
 TEC = TEC + 8 TEC <=127
'reset' or 'init
 Receiver finds error REC >127 or
node'

127<TEC<255
 REC = REC + 1
 Receiver finds error after
transmitting a error frame error passive
bus off

 REC = REC + 8
TEC > 255

 Error active node finds stuff


error in error frame
 TEC = TEC + 1
 Success Receive Error Counter (REC)
 TEC = TEC - 1 ; REC = REC - 1
Transmit Error Counter (TEC)
Overload Frame

Three conditions cause overload


 Internal conditions of a receiver require a delay of the next data
frame or remote frame.
 At least one node detects a dominant bit during intermission.
 A CAN node samples a dominant bit at the eighth bit (i.e., the last
bit) of an error delimiter or overload delimiter.
Flag – 6 dominant bits Delimiter – 8 recessive bits
Interframe Space
Data & Remote frames separated by IFS
Error & Overload frames not preceded by IFS

IFS for error-active or receive node

IFS for error-passive node


Interframe Space
Intermission space is 3 recessive bits
No node can transmit during Intermission space
Bus Idle length is arbitrary
Suspend transmission is 8 recessive bits
CAN Message Bit Timing
CAN Nominal Bit Time
SYNCSEG
sjw
sjw
tseg1 tseg2

TQ

Transmit Point Sample Point

 TQ = SYNCSEG
CAN Spec Says
 tseg1  tseg2
 Tseg1 = PROP_SEG +
 3/BRP ≤ tseg1 ≤ 16 TQ
PHASE_SEG1  3/BRP ≤ tseg2 ≤ 8 TQ
 Tseg2 = PHASE_SEG2  1 TQ ≤ sjw ≤ MIN[ 4*TQ , tseg2]
 TQ = (BRP + 1) / SYSCLK  BRP  5 ( if three sample mode is used)
CAN Bit Timing Example
 Bit Configuration for SYSCLK = 150 MHz
 Sample Point at 80% of Bit Time :
CAN-Baudrate BRP TSEG1 TSEG2

1 MBPS 9 10 2

500 KBPS 19 10 2

250 KBPS 39 10 2

125 KBPS 79 10 2

100 KBPS 99 10 2

50 KBPS 199 10 2

 Example 50 KBPS:
TQ = (199+1)/150 MHz = 1.334 ns
tseg1 = 1.334 ns ( 10 + 1) = 14.674 ns  tCAN = 20.010 ns
tseg2 = 1.334 ns ( 2 + 1) = 4.002 ns
Message Filtering
Used to decide which message to use
Filtering applied to whole message ID
Can use optional mask registers to decide which bits
to look at in the message ID
If using mask registers, all bits should be
programmable
Types of CAN
BASIC-CAN
 Close loop between MCU-core and CAN
 Only one transmit buffer
 Only two receive buffers
 Only one filter for incoming messages
 Software required to select between messages

FULL-CAN
 Message server
 Extensive acceptance filtering
 User-configurable mailboxes
 Mailbox memory/size configurable
 Advanced error recognition
Types of CAN
CAL
CAN-Open
MicroCAN Open
CANiA
CAN-Open IA
DeviceNet
CAN Kingdom
SDS
J1939
Advantages
Capable of providing real-time communication
Error correction and confinement useful in noise-
critical environments
Uses lossless, bit-wise arbitration
Provides high speeds at low cost
Used for control, not data movement
Suitable for small networks
Protocol design to increase integrity of the system
Disadvantages
Electrical properties set physical limits in
combination with transmission speed
Same with branch lines
Must be terminated with load resistors
Cable end not correctly terminated can make the
whole bus inoperable
Node starvation is possible
CAN Bus Waveform
Typical CAN Implementation
Kumar S. Golla
9866005323
Backup
Masking Example
CAN Standard Frame
2.0A – Max. Frame Length 127 bits with stuffing
Arbitration Field Control Field Data Field

12 bits 6 bits 0 to 64 bits


S R I ACK
Identifier r DLC CRC EOF
O T D Data Field Field
11bits 0 4bits 15bits 7bits
F R E 2bits

No Bit
Bit Stuffing
Stuffing
SOF = Start Of Frame= one dominant bit
RTR = Remote Transmission Request = Data Frame (dominant), Remote Frame (recessive)
IDE = Identifier Extension Bit = Standard Frame (dominant), Extended Frame (recessive)
DLC = Data Length Code = 4 bits (rxxx = 8 bytes) (code length 9-15 not allowed)
R0 = reserve bit = transmitted as dominant
CRC = Cyclic Redundancy Check = 15 bit with 1 bit recessive CRC delimiter
ACK = Acknowledgement = Ack slot and delimiter = xmitter sends 2 recessive bits
EOF = End Of Frame = 7 recessive bits
Error Counters
CAN Extended Frame
2.0B : Max. frame length 150 bits with stuffing
Arbitration Field Control Field Data Field

32 bits 6 bits 0 to 64 bits


S ACK
Identifier Identifier Ext. DLC CRC EOF
O SRR IDE RTR r1 r2 Data Field Field
F 11bits 18bits 4bits 15bits 7bits
2bits

No Bit
Bit Stuffing
Stuffing

SOF = Start Of Frame = one dominant bit


SRR = Substitute Remote Request = one bit (recessive), so Standard Frame gets priority
IDE = Identifier Extension Bit = Standard Frame (dominant), Extended Frame (recessive)
RTR = Remote Transmission Request = one bit (recessive)
R1, R2 = Reserved Bits
DLC = Data Length Code = 4 bits (rxxx = 8 bytes) (code length 9-15 not allowed)
CRC = Cyclic Redundancy Check = 15 bit with 1 bit recessive CRC delimiter
ACK = Acknowledgement = Ack slot and delimiter = xmitter sends 2 recessive bits
EOF = End Of Frame = 7 recessive bits
CRC
15 bit with generator polynomial x15 + x14 + x10 + x8 + x7 +
x4 + x 3 + 1
1 bit CRC delimiter (always) recessive
Only error detection, no correction
Hamming distance 6
 Detect up to six bit errors
Arbitration Field

 The identifier of the standard format corresponds to the base ID in the


extended format.
 The RTR bit is the remote transmission request and must be 0 in a
data frame.
 The SRR bit is the substitute remote request and is recessive.
 The IDE field indicates whether the identifier is extended and should
be recessive in the extended format.
 The extended format also contains the 18-bit extended identifier.
Control Field

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy