CAN Communication Protocol
Download
Report
Transcript CAN Communication Protocol
What is a Controller Area Network?
History of CAN
CAN communication protocol
Physical layer
ISO 11898
CiA
CANopen
DeviceNet
Applying CAN
CAN = controller area network
ECU = electronically controlled unit
Dominant = 0
Recessive = 1
CAN implements a vehicle bus to which
all CAN devices are connected
Allows all devices to communicate with
one another
Cars, trucks, buses, off-road vehicles
Maritime electronics
Aircraft/aerospace electronics
Medical equipment and devices
Coffee machines
Elevators
Developed in Germany in the 1980's by
engineers working at Robert Bosch
More functionality while reducing the
weight and complexity of the wiring
between controllers.
Multi-processor system which has better
performance, increased reliability and is
more maintainable
No communication protocols at the time
met the speed and reliability requirements
so Bosch developed CAN specification 2.0
Physical and data link layer
are implemented in the
CAN controllers
Standard CAN bypasses
layers 3-6
(1) Physical layer = actual
hardware
(2) Data link layer =
connects data to the
protocol
(7) Application layer =
interacts with OS of CAN
device
Since CAN is so widely used CAN chips
are cheap
Reliability and error resistance of CAN
calculated in mathematical model
shown to have only 1 undetected error in
1000 years
Has world wide acceptance
Higher layer protocols defined for data
intensive applications
Data frame – sends data
Remote frame – requests data
Error frame – reports an error
Overload frame – reports a node is
overloaded
SOF – 1 dominant bit
Arbitration Field – message ID + RTR
Control Field
-Length of the
data field to
follow
-For remote
frame DLC is
ignored, data
field is always
zero
CRC Field – CRC segment + delimiter bit
ACK Field – acknowledgement bit +
delimiter bit
SOF – 1 bit
Arbitration field – 12 or 32 bits
Control field – 6 bits
Data field – up to 8 bytes
CRC field – 16 bits
ACK field – 2 bits
EOF -7 bits
IFS – 3 bits
Off-road vehicles require more messages
11 bit message ID -> 29 bit
Use IDE to determine format:
› 0 = 11 bit
› 1 = 29 bit
Extended frame has trade-offs:
› Bus latency time is longer
› More bandwidth required
› Error detection performance decreased
Error occurs: bit stuffing, CRC incorrect,
etc.
Error flag set followed by recessive
delimiter and interframe
Errors are caught quickly and have short
recovery times:
Error Frame Length
Baud Rate
Total error recovery time
(error frame + interframe)
14 bits
1 Mbit/sec
14 + 3 uSec
14 bits
500 kBit/sec
28 + 6 uSec
14 bits
250 kBit/sec
56 + 12 uSec
20 bits
1 Mbit/sec
20 + 3 uSec
20 bits
500 kBit/sec
40 + 6 uSec
20 bits
250 kBit/sec
80 + 12 uSec
Overload flag – 6 dominant bits so all
nodes detect overload, messaging
ceased
Producer/consumer
All messages are acknowledged for
consistency (error if inconsistent or
unacknowledged)
Nodes can accept or decline message
filitering
CAN uses message ID of the node to
prevent collisions – high priority first
Uses bitwise arbitration as follows:
› Node sends SOF with dominant level
Non-sending nodes begin listening
› Node sends next bit and compares output
signal with actual bus level
If sent recessive, detects dominant, then
begins listening, else sends next bit
› Transmits the rest of the message if it
transmits all arbitration bits
Node A = 1000101100 (high priority)
Node B = 1110110000
1st arbitration bit
2nd arbitration bit
3rd arbitration bit
Node A
1
0
0
Node B
1
1
listen
Bus level
1
0
0
B send a recessive, detects dominant,
then listens
Errors detected by:
› Bit monitoring
› Checksum Check
› Variable bit stuffing with a stuff width of 5
› Frame check
› Acknowledge Check
Defective frames are aborted and
retransmitted
Malfunctions that would disrupt the
system:
› Transmitting Error from malfunctioning node
› Receiving Error from malfunctioning node
CAN determines permanent vs.
temporary malfunctions
› Transmit error counter
› Receive error counter
Based on the counters, a node is in one
of the following states:
› Error Active
Transmit and receive counters <128
› Error Passive
Transmit or receive counters >127
› Bus-Off
Transmit error counter >255
ISO 11898-2 is the most common standard for
the physical layer
Nodes connected by 2 wires: CAN_H and
CAN_L
Bus level determined by:
› Vdiff = Vcan_h – Vcan_l
› 2V for recessive, 0V for dominant
Bus terminated by 120 Ω resistors to suppress
electrical reflections on the bus
Electromagnetic interferences are minimized
with the differential voltage between CAN_H
and CAN_L
At a maximum baud rate of 1 Mbit/sec a bus
can be up to 40m long
› At <10 kbit/sec can have up to 5000 m bus
“Road vehicles – Controller area network
(CAN)” 1993
Contains:
› Data link layer and physical signaling
› High speed medium access unit
› Low speed fault tolerant medium
dependant interface
› Time triggered communication
Users + manufacturers develop and
support CAN
Based on participation and initiative
Represented at ISO and IEC committees
Higher layer protocol adds:
› Network management
› Device monitoring
› Communication between nodes
Requires CANopen nodes to have:
› Communication unit
› State machine
› Object dictionary
Application layer protocol adds 4
required objects:
› Identity object
› Connection object
› Message router object
› DeviceNet object
Hewlett-Packard
Lockheed Martin
Boeing
NASA
GE Medical
Siemens Medical
John Deere
Vehicle Spy (Vspy)
NETCAR-Analyzer
Volcano Network Architect (VNA)
Ability to:
› Read bus signals
› Transmit messages
› Log data
› Write to ECU memory
ECU
TCU
CCU
SSM15
SSM25
CMU
LIN-Bus (Local Interconnect Network)
Ethernet
RS232
Universal serial bus
CAN specification 2.0
› A = standard format
› B = extended format
ISO 11898
› Specific requirements on the sub layers of the
data link layer and physical layer
CANopen specification
Book: A comprehensible guide to CAN
Book: Embedded networking with CAN and
CANopen
[1]
Wilfried Voss. (2005). A Comprehensible Guide to Controller Area Network. Greenfield: Copperhill
Technologies Corporation.
[2]
[3]
CiA. (2001). Can physical layer. Retrieved 1 24, 2012, from http://www.cancia.de/index.php?id=systemdesign-can-physicallayer
[4]
International Standard ISO 11898. First edition 2003-12-01. Road vehicles - Controller area
network (CAN).
[5]
[6]
National Instruments. (2012). Controller Area Network (CAN) Overview. Retrieved 2 2, 2012, from
http://zone.ni.com/devzone/cda/tut/p/id/2732
[7]
Vehicle Spy. (2005-2012). Vehicle Spy Professional. Retrieved 2 4, 2012 from
http://intrepidcs.com/VehicleSpy/
[8]
CANopen. CANopen USA. Retrieved 2 4, 2012 from http://www.canopen.us/
[9]
Real Time Automation. DeviceNet Introduction. Retrieved 2 4, 2012 from
http://www.rtaautomation.com/devicenet/#2
Pazul Keith. (2002). Controller Area Network (CAN) Basics. In Microchip.
Robert Bosch. (1991). CAN Specification. Robert Bosch GmbH.