0% found this document useful (0 votes)
12 views16 pages

Emb Mod3 Part 2

Uploaded by

katyaini1511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views16 pages

Emb Mod3 Part 2

Uploaded by

katyaini1511
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

MODULE 3:

PROTOCOLS Part 2

DR BINU PAUL , EMB

BUS PROTOCOL
EMBEDDED SYSTEMS CAN
DR BINU PAUL , EMB
CAN – CONTROLLER AREA NETWORK

WHAT IS CAN BUS

CANBUS or CAN bus – Controller Area Network bus


An automotive serial bus system developed to satisfy
the following requirements:

 Network multiple microcontrollers with 1 pair of wires.


 Allow microcontrollers communicate with each other.
 High speed, real-time communication.
 Provide noise immunity in an electrically noisy environment.
 Low cost

 Message oriented communication

Dr Binu paul , EMB

CAN

MESSAGE ORIENTED COMMUNICATION


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

Dr Binu paul , EMB


THE DEVELOPMENT OF CAN
The development of CAN began when more and more electronic devices were
implemented into modern motor vehicles. Examples of such devices include
engine management systems, active suspension, ABS, gear control, lighting
control, air conditioning, airbags and central locking. All this means more safety
and more comfort for the driver and of course a reduction of fuel consumption
and exhaust emissions.

To improve the behavior of the vehicle even further, it was necessary for the
different control systems (and their sensors) to exchange information. This was
usually done by discrete interconnection of the different systems (i.e. point to
point wiring). The requirement for information exchange has then grown to such
an extent that a cable network with a length of up to several miles and many
connectors was required. This produced growing problems concerning material
cost, production time and reliability .

Dr Binu paul , EMB

CANBUS HISTORY CANBUS TIME LINE


First idea - The idea of CAN was  1983 : First CANBUS project at Bosch
first conceived by engineers at
Robert Bosch Gmbh in Germany in  1986 : CAN protocol introduced
the early 1980s.
 1987 : First CAN controller chips sold

Early focus - develop a  1991 : CAN 2.0A specification


communication system between a
published
number of ECUs (electronic control
units).
 1992 : Mercedes-Benz used CAN
network
New standard - none of the
communication protocols at that time  1993 : ISO 11898 standard
met the specific requirements for
speed and reliability so the  1995 : ISO 11898 amendment
engineers developed their own
standard.  Present : The majority of vehicles use
CAN bus.

Dr Binu paul , EMB


What are some real world applications of CAN?
 Controller Area Networks are used in many different fields, the
bulk of which are
 Auto-motive industry
 Factory Automation
 Machine Control
 Medical Equipment and devices
 And more….

Dr Binu paul , EMB

BEFORE CAN 

CAN 
• point-to-point wiring is
replaced by one serial
bus connecting all
control systems.
• CAN-specific hardware
to each control unit that
provides the "rules" or
the protocol for
transmitting and
receiving information via
the bus.

Dr Binu paul , EMB


CAN - FEATURES
 Multi-Master Protocol
 All devices on the network
receive every bit of information
sent on the BUS
Serial communication
 CSMA/CD/NDA  Compact
 Carrier Sense Multiple Access/Collision Detection with Non-
Destructive Arbitration ( resend if error detedcted)  Twisted Pair Bus line with 120
 Upto 1 Megabit per second Ohm terminations
 Common baud rates: 1 MHz, 500 KHz
and 125 KHz
 Robust in noisy environments
 All nodes – same baud rate
 Max length:120 ft to 15000 ft (rate
dependent)
Maximum speed decided by 2 x tpd
tpd = propagation delay of electrical medium (wire)

CAN Bus Length

Dr Binu paul , EMB

A BASIC CAN CONTROLLER

Cheap CAN controller – CPU could get overrun with messages even if it
didn’t need them.
Newer version use hardware filters to reorganise the received data

DR BINU PAUL , EMB


CANBUS FOLLOWS THE OSI (OPEN SYSTEM IDENTIFICATION) MODEL

Physical and Data Link layers in silicon.

DSP or Application Layer


microcontroller Data Logic Link control
Embedded CAN Link
controller Layer
Medium Access

CAN Transceiver Physical Physical Signalling


Layer
Physical medium
CAN Bus line Interface
Basic Configuration

Application layer: interacts with operating system or with CAN device


Data Link layer : involved in actual data transfer as per the protocol.. like Send/receive/validate etc
Physical layer : denotes the required hardware
Dr Binu paul , EMB

THE CAN STANDARD - MESSAGE TYPES

The CAN standard defines four message types

 Data Frame – the predominantly used message type


 Remote Frame
 Error Frame
 Overload Frame

The CAN standard also defines an elaborate scheme for error


handling and confinement.
CAN – A number of different connector types are in use.

Dr Binu paul , EMB


CAN – DATA FRAME MESSAGE FORMAT

Each message has an ID(11 bit or 29 bit) , Data and overhead.


Data – 8 bytes max
Overhead – start, end, CRC, ACK

Dr Binu paul , EMB

CAN - DATA FRAME MESSAGE FORMAT

The physical layer uses differential transmission on a twisted pair wire


as the bus medium

The bus uses Non-Return To Zero (NRZ) with bit-stuffing


 (see bit encoding slide)

Max. transfer rate of 1000 kilobits per second at a maximum bus


length of 40 meters or 130 feet

Message length is short with a maximum of 8 data bytes per message

The messages are protected by a CRC type checksum

Dr Binu paul , EMB


DATA FRAME MESSAGE FORMAT – WITH STANDARD IDENTIFIER
Field name Length(bits) Purpose

Start-of-frame 1 Denotes the start of frame transmission


Identifier 11 A (unique) identifier for the data

Remote transmission request (RTR) 1 Must be dominant (0) for DATA frame

Identifier extension bit (IDE) 1 Must be dominant (0)


Reserved bit (it must be set to dominant (0), but accepted
Reserved bit (r0) 1 as either dominant or recessive)
Data length code (DLC) 4 Number of bytes of data (0-8 bytes)

Data field 0-8 bytes Data to be transmitted (length dictated by DLC field)
CRC 15 Cyclic redundancy check
CRC delimiter 1 Must be recessive (1)
Transmitter sends recessive (1) and any receiver can
ACK slot 1 assert a dominant (0)
ACK delimiter 1 Must be recessive (1)
End-of-frame (EOF) 7 Must be recessive (1)

Dr Binu paul , EMB

CAN - DATA FRAME MESSAGE FORMAT - CONTINUED

Identifier: (ID) denotes priority of


message also-
 lower the value - higher priority
 Wired AND connection between nodes
 Has priority information and arbitration
information

RTR: “1” when information is


needed from another node. But only
that node whose identifier matches
takes the data

Other message types discussed later 


Dr Binu paul , EMB
BUS ARBITRATION – WHAT/HOW?
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

© 2005 Microchip Technology Incorporated. All Rights Reserved.

CAN bus
Dr Binu paul , EMB

BUS ARBITRATION - HOW?


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.

Bit-wise arbitration to control access to the bus each message is tagged with a
priority
(the one that sends a “0” bit first as its identifier, after start of frame wins the bus)
Dr Binu paul , EMB
CAN BUS OVERVIEW

The bus access is via the advanced serial communications


protocol Carrier Sense Multiple Access/Collision Detection with
Non-Destructive Arbitration. (CSMA/CD/NDA)
 collision of messages is avoided by bitwise arbitration without loss of
time.
no explicit address in the messages, instead, each message
carries a numeric value which controls its priority on the bus,
and also serve as an identification of the contents of the
message.
An elaborate error handling scheme that results in
retransmitted messages when they are not properly received.
6 concecutive bits same – error alert ( see bit encoding
format slide )

Dr Binu paul , EMB

THE CAN STANDARD - MESSAGE TYPES (CONTINUES)

CAN standard defines four message types


(Data ,Remote,Error,Overload frames)
 Data Frame – the predominantly used message type (discussed earlier)
 Remote Frame
 The Remote Frame is just like the Data Frame, with two important
differences:
 the RTR bit in the Arbitration Field is recessive value “1”
 there is no Data Field.

Dr Binu paul , EMB


THE CAN STANDARD - MESSAGE TYPES (CONTINUES)

CAN standard defines four message types


(Data ,Remote,Error,Overload frames)

 Error Frame
 Error Frame is a special message that violates the framing rules of a CAN
message
 The Error Frame consists of an Error Flag, which is 6 bits of the same value
(thus violating the bit-stuffing rule) and an Error Delimiter, which is 8
recessive bits( “1”)

Dr Binu paul , EMB

THE CAN STANDARD - MESSAGE TYPES (CONTINUES)

 Overload Frame

 It is very similar to the Error Frame with regard to the format and it is
transmitted by a node that becomes too busy.
 At present obsolete
 Today's CAN controllers are clever enough not to use it

Dr Binu paul , EMB


ADVANTAGES OF CAN

Reduced wire looming as control is distributed


Most CAN chip come with data link and physical layers built in ( in silicon). So
Embedded system developer need to develop only the application code to
support this Bus
Good for electrically noisy environment because of differential signalling
Collision detection and Traffic congestion Avoidance is in built
Error free- as each node check for errors during transmission with error frame
being sent to alert all nodes in case any node sense an error

Dr Binu paul , EMB

END OF PRESENTATION

Dr Binu paul , EMB


1. THE DATA FRAME
Summary: "Hello everyone, here's some data labeled X, hope you like it!"
The Data Frame is the most common message type.
It has
 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.
 the Data Field, which contains zero to eight bytes of data.
 the CRC Field, which contains a 15-bit checksum calculated on most parts of the
message. This checksum is used for error detection.
 an 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.

Dr Binu paul , EMB

CAN DATA FRAMES


CAN 2.0A (“standard CAN” 11-bit ID) Data Frame.

 CAN 2.0B (“extended CAN” 29-bit ID) Data Frame.

DR BINU PAUL , EMB


2. THE REMOTE FRAME
Summary: "Hello everyone, can somebody please produce the data
labeled X?"

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. If, say, node A transmits a Remote Frame with the
Arbitration Field set to 234, then node B, if properly initialized, might respond with a
Data Frame with the Arbitration Field also set to 234.
Remote Frames can be used to implement a type of request-response type of bus
traffic management. In practice, however, the Remote Frame is little used. It is also
worth noting that the CAN standard does not prescribe the behaviour outlined here.
Most CAN controllers can be programmed either to automatically respond to a
Remote Frame, or to notify the local CPU instead.

Dr Binu paul , EMB

REMOTE FRAME (CONTD.)


There's one catch with the Remote Frame: the Data Length Code must
be set to the length of the expected response message. Otherwise the
arbitration will not work.
Sometimes it is claimed that the node responding to the Remote Frame
is starting its transmission as soon as the identifier is recognized,
thereby "filling up" the empty Remote Frame. This is not the case.
A Remote Frame (2.0A type):

DR BINU PAUL , EMB


3. THE ERROR FRAME
Summary: (everyone, aloud) "OH DEAR, LET'S TRY AGAIN"

Simply put, the Error Frame is a special message that violates the framing rules of a
CAN message. It is 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. There is an elaborate scheme of error
counters that ensures that a node can't destroy the bus traffic by repeatedly
transmitting Error Frames.

The Error Frame consists of an Error Flag, which is 6 The Error Frame
bits of the same value (thus violating the bit-stuffing
rule) and an 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.

DR BINU PAUL , EMB

4 THE OVERLOAD FRAME


Summary: "I'm a very busy little 82526 device, could you please
wait for a moment?"
The Overload Frame is mentioned here just for completeness. It
is very similar to the Error Frame with regard to the format and
it is 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. In fact, the only
controller that will generate Overload Frames is the now
obsolete 82526

Dr Binu paul , EMB


COMPARISON OF SERIAL INTERFACES

Dr Binu paul , EMB

You might also like