36
Controller Area Network (CAN) Communication By Ann Lazare

What is a Controller Area Network? History of CAN CAN communication protocol Physical layer ISO 11898 CiA CANopen DeviceNet Applying

Embed Size (px)

Citation preview

Page 1: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Controller Area Network (CAN) Communication

By Ann Lazare

Page 2: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Overview What is a Controller Area Network? History of CAN CAN communication protocol Physical layer ISO 11898 CiA CANopen DeviceNet Applying CAN

Page 3: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Definitions

CAN = controller area network ECU = electronically controlled unit Dominant = 0 Recessive = 1

Page 4: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

What is a Controller Area Network?

CAN implements a vehicle bus to which all CAN devices are connected

Allows all devices to communicate with one another

Page 5: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

CAN applications

Cars, trucks, buses, off-road vehicles Maritime electronics Aircraft/aerospace electronics Medical equipment and devices Coffee machines Elevators

Page 6: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

History of CAN

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

Page 7: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Benefits of CAN - firmware

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

Page 8: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Other benefits of CAN

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

Page 9: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Message frames

Data frame – sends data Remote frame – requests data Error frame – reports an error Overload frame – reports a node is

overloaded

Page 10: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Data Frame/Remote Frame

SOF – 1 dominant bit Arbitration Field – message ID + RTR

Page 11: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Data Frame/Remote Frame

Control Field-Length of the

data field to follow

-For remote frame DLC is ignored, data field is always zero

Page 12: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Data Frame/Remote Frame CRC Field – CRC segment + delimiter

bit

ACK Field – acknowledgement bit + delimiter bit

Page 13: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Data/Remote Frame

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

Page 14: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Extended CAN Protocol

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

Page 15: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Error Frame

Error occurs: bit stuffing, CRC incorrect, etc.

Error flag set followed by recessive delimiter and interframe

Page 16: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Error Frame 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

Page 17: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Overload Frame

Overload flag – 6 dominant bits so all nodes detect overload, messaging ceased

Page 18: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Message Broadcasting

Producer/consumer All messages are acknowledged for

consistency (error if inconsistent or unacknowledged)

Nodes can accept or decline message filitering

Page 19: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Bus Arbitration 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

Page 20: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Bus Arbitration - example

Node A = 1000101100 (high priority) Node B = 1110110000

B send a recessive, detects dominant, then listens

1st arbitration bit

2nd arbitration bit

3rd arbitration bit

Node A 1 0 0

Node B 1 1 listen

Bus level 1 0 0

Page 21: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Error Detection

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

Page 22: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Fault Confinement

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

Page 23: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Fault Confinement

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

Page 24: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Physical Layer 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

Page 25: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

ISO 11898 “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

Page 26: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

CAN-in-Automation (CiA)

Users + manufacturers develop and support CAN

Based on participation and initiative Represented at ISO and IEC

committees

Page 27: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

CANopen

Higher layer protocol adds:› Network management› Device monitoring › Communication between nodes

Requires CANopen nodes to have:› Communication unit › State machine› Object dictionary

Page 28: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

DeviceNet

Application layer protocol adds 4 required objects:› Identity object› Connection object› Message router object› DeviceNet object

Page 29: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Companies that use CAN

Hewlett-Packard Lockheed Martin Boeing NASA GE Medical Siemens Medical John Deere

Page 30: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

CAN Tools

Vehicle Spy (Vspy) NETCAR-Analyzer Volcano Network Architect (VNA) Ability to:

› Read bus signals› Transmit messages› Log data› Write to ECU memory

Page 31: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Vspy

Page 32: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

CAN – a practical application ECU TCU CCU SSM15 SSM25 CMU

Page 33: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Alternatives to CAN

LIN-Bus (Local Interconnect Network) Ethernet RS232 Universal serial bus

Page 34: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

CAN Development useful documents

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

Page 35: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

Questions?

Page 36: What is a Controller Area Network?  History of CAN  CAN communication protocol  Physical layer  ISO 11898  CiA  CANopen  DeviceNet  Applying

References

[1] Wilfried Voss. (2005). A Comprehensible Guide to Controller Area Network. Greenfield: Copperhill

Technologies Corporation.

[2] Pazul Keith. (2002). Controller Area Network (CAN) Basics. In Microchip.

[3] CiA. (2001). Can physical layer. Retrieved 1 24, 2012, from http://www.can-cia.de/index.php?id=systemdesign-can-physicallayer

[4] International Standard ISO 11898. First edition 2003-12-01. Road vehicles - Controller area network (CAN).

[5] Robert Bosch. (1991). CAN Specification. Robert Bosch GmbH.

[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