Controller Area Network (CAN)
-
Upload
krishna-raj-s-r -
Category
Documents
-
view
17 -
download
6
description
Transcript of Controller Area Network (CAN)
Controller Area Network (CAN)
Presented by Krishna Raj S R 14182009 Systems Engineering IIT BHU , Varanasi on Computer Networks
Why CAN?
Scope of the Presentation
NeedHistoryLayered StructureMessage FormatArbitration PolicyError DetectionImplementation
Before CAN
4
Conventional multi-wire looms
http://canbuskit.com/what.php
With CAN
5
Conventional multi-wire looms CAN bus network
vs.
http://canbuskit.com/what.php
6
Before CAN
7
With CAN
What is CAN?
Serial communications protocolEfficiently supports distributed realtime
control Very high level of security.Message Oriented
Properties of CAN
CAN has the following properties Prioritization of messages Guarantee of latency times Configuration flexibility Multicast reception with time synchronization System wide data consistency Multi-master Error detection and signalling Automatic retransmission of corrupted messages as soon as the bus is idle
again Distinction between temporary errors and permanent failures of nodes Autonomous switching off of defect nodes
Transmission Characteristics
10
Up to 1 Mbit/sec. Common baud rates: 1 MHz, 500 KHz and 125 KHz All nodes – same baud rate Max length:120’ to 15000’ (rate dependent)
© esd electronics, Inc. • 525 Bernardston Road • Greenfield, MA 01301
1 Mbit/s 40 m 500 kbit/s 110 m 250 kbit/s 240 m 125 kbit/s 500 m
Designed specifically for automotive applicationsToday - industrial automation / medical equipment
Who uses CANBUS?
11
Automotive Medical / Industrial0%
10%
20%
30%
40%
50%
60%
70%
80%
90%
100%CANBUS Market Distribution
Markets
History
CANBUS History
13
New standard - none of the communication protocols at that time met the specific requirements for speed and reliability so the engineers developed their own standard.
First idea - The idea of CAN was first conceived by engineers at Robert Bosch Gmbh in Germany in the early 1980s.
Early focus - develop a communication system between a number of ECUs (electronic control units).
CANBUS Timeline
14
1983 : First CANBUS project at Bosch
1986 : CAN protocol introduced
1987 : First CAN controller chips sold
1991 : CAN 2.0A specification published
1992 : Mercedes-Benz used CAN network
1993 : ISO 11898 standard
1995 : ISO 11898 amendment
Present : The majority of vehicles use CAN bus.
15
The CAN bus
CAN is a broadcast type of bus. ◦ This means that all nodes can "hear" all transmissions.
There is no way to send a message to just a specific node; all nodes will invariably pick up all traffic. The CAN hardware, however, provides local filtering so that each node may react only on the “interesting” messages.
Message Oriented Transmission Protocol
16
Each node – receiver & transmitter A sender of information transmits to all devices on the bus All nodes read message, then decide if it is relevant to them All nodes verify reception was error-free All nodes acknowledge reception
CAN bus
17
Basic Configuration
Layered Structure
Physical Layer
20
Bus Levels
•ISO-IS 11898. A recessive bit is represented by both CAN bus lines driven to a level of about 2.5 V so that the differential voltage between CAN_H and CAN_L is around 0 V.
•A dominant bit is represented by CAN_H going to about 3.5 V and CAN_L going to about 1.5 V. This results in a differential voltage for a dominant bit of about 2V.
Transfer Layer
Data Information – Frame Format
• SOF – Start of Frame• Identifier – Tells the content of message and priority• RTR – Remote Transmission Request • IDE – Identifier extension (distinguishes between CAN standard,11 bit identifier, and CAN
extended, 29 bit identifier.)• DLC – Data Length Code• Data – holds up to 8 bytes of data• CRC – “Cyclic Redundant Check” sum• ACK – Acknowledge• EOF – End of Frame• IFS – Intermission Frame Space. Minimum number of bits separating consecutive messages.
TypesData FrameRemote FrameError FrameOverload Frame
24
1. The Data Frame The most common message type The Arbitration Field, which determines the priority of the message
when two or more nodes are contending for the bus. The Arbitration Field contains:
◦ For CAN 2.0A, an 11-bit Identifier and one bit, the RTR bit, which is dominant for data frames.
◦ For CAN 2.0B, a 29-bit Identifier (which also contains two recessive bits: SRR and IDE) and the RTR bit.
Data Field, which contains zero to eight bytes of data. CRC Field, which contains a 15-bit checksum. This checksum is used
for error detection. Acknowledgement Slot; any CAN controller that has been able to
correctly receive the message sends an Acknowledgement bit at the end of each message. The transmitter checks for the presence of the Acknowledge bit and retransmits the message if no acknowledge was detected.
25
2. The Remote Frame The Remote Frame is just like the Data Frame, with two important
differences:◦ It is explicitly marked as a Remote Frame (the RTR bit in the Arbitration Field is
recessive), and◦ there is no Data Field.
The intended purpose of the Remote Frame is to solicit the transmission of the corresponding Data Frame
Used to implement a type of request-response type of bus traffic management.
CAN controllers can be programmed either to automatically respond to a Remote Frame, or to notify the local CPU instead.
The Data Length Code must be set to the length of the expected response message. Otherwise the arbitration will not work.
26
3. The Error Frame•Special message that violates the framing rules of a CAN message. •Transmitted when a node detects a fault and will cause all other nodes to detect a fault - so they will send Error Frames, too.• The transmitter will then automatically try to retransmit the message.• Error counters ensures that a node can't destroy the bus traffic by repeatedly transmitting Error Frames.
The Error FrameError Flag- 6 bits of the same value (thus violating the bit-stuffing rule) Error Delimiter, which is 8 recessive bits. The Error Delimiter provides some space in which the other nodes on the bus can send their Error Flags when they detect the first Error Flag.
27
4 The Overload Frame It is very similar to the Error Frame with regard to the
format Transmitted by a node that becomes too busy. The Overload Frame is not used very often, as today's CAN
controllers are clever enough not to use it.
Bus Arbitration
Bus Arbitration
29
Arbitration – needed when multiple nodes try to transmit at the same time Only one transmitter is allowed to transmit at a time. A node waits for bus to become idle Nodes with more important messages continue transmitting
CAN bus© 2005 Microchip Technology Incorporated. All Rights Reserved.
Bus Arbitration
30
Message importance is encoded in message ID.Lower value = More important
As a node transmits each bit, it verifies that it sees the same bit value on the bus that it transmitted.
A “0” on the bus wins over a “1” on the bus. Losing node stops transmitting, winner continues.
Error Detection
Error detection If one or more errors are detected, the transmission is aborted.
This prevents all other stations or nodes from accepting the message.
Re-transmission is automatic. If errors continue, then the station or node may switch itself off to prevent the bus from being tied up.
Error detection is done on two levels:◦ Message level◦ Bit level
Error detection Message Level
◦ CRC = Cyclic Redundant Check sum◦ Frame Check = compares message to fixed format and frame
size◦ ACK errors = if transmitter does not receive an ACK signal from
the receivers
Bit level
◦ Monitoring = The transmitter monitors the bus signal as it sends the message and compares the bit sent to the bit received.
◦ Bit Stuffing = After five consecutive equal bits, the transmitter inserts a stuff bit with a compliment value into the bit stream. The receivers remove this stuff bit.
Object layer
CAN Controller Diagram
Implementation 1Basic CAN
◦Limited number of receive buffers and filters
◦Can get bogged down quickly with multiple consecutive messages.
Implementation 2Full CAN
◦Has several message objects (usually 15)
◦Can loose data if message objects are setup for multiple filters
◦Can still get bogged down if too many messages are sent consecutively
Implementation 3FIFO
◦“First In First Out” receive buffer
◦Fixes problem with multiple consecutive messages
◦Cannot allow a high priority message to move to front. It has to wait its turn
Implementation 4Enhanced Full Can
◦Dedicated FIFO for each individual message object
◦Very complicated to use
◦Less common
Manufacturers
Over 20 different chip manufacturers produce microcontrollers with on-chip CAN interfaces.
Some more notable ones are:◦Cygnal◦ Intel◦Motorola◦NEC◦Phillips◦Toshiba
Useful Links
Manufacturer and Product List◦http://www.can-cia.org/products/can/chips/
CAN Information◦http://www.canbus.us/◦http://www.can-cia.org/can/