Sei sulla pagina 1di 32

CAN BUS

SIDDHARTH CHAUDHURY VIT University

INTRODUCTION

CAN stands for Controller Area Network Developed by Robert Bosch GmbH It is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer.

CAN bus is a message-based protocol, designed specifically for automotive applications but now also used in other areas such as industrial automation and medical equipment.

WORKING

CAN is a multi-master broadcast serial bus standard for connecting electronic control units Each node is able to send and receive messages, but not simultaneously. A message consists primarily of a serially transmitted ID (identifier), which represents the priority of the message, and up to eight data bytes. This signal pattern is encoded in NRZ and is sensed by all nodes. Sensors, actuators, and other control devices are connected by a CAN network. These devices are not connected directly to the bus, but through a host processor and a CAN controller.

WORKING

If the bus is free, any node may begin to transmit. If two or more bus nodes start their transmission at the very same time after having found the bus to be idle, collision of the messages is avoided by the implemented CSMA/CA + AMP (Arbitration on Message Priority) bus access method. Each node sends the bits of its message identifier and monitors the bus level. As long as the bits from all transmitters are identical nothing happens. If the messages are not identical the message with the more dominant ID (which has more dominant bits, i.e., zeroes) will overwrite other nodes' less dominant IDs. This mechanism is referred to as priority based bus arbitration.

REQUIREMENTS OF A NODE TO SEND A SIGNAL

Host processor
The host processor decides what received messages mean and which messages it wants to transmit itself. Sensors, actuators and control devices can be connected to the host processor.

CAN controller (hardware with a synchronous clock).


Receiving: the CAN controller stores received bits serially from the bus until an entire message is available, which can then be fetched by the host processor (usually after the CAN controller has triggered an interrupt). Sending: the host processor stores its transmit messages to a CAN controller, which transmits the bits serially onto the bus.

Transceiver
Receiving: it adapts signal levels from the bus to levels that the CAN controller expects and has protective circuitry that protects the CAN controller. Transmitting: it converts the transmit-bit signal received from the CAN controller into a signal that is sent onto the bus.

DATA TRANSMISSION

CAN features an automatic arbitration-free transmission. A CAN message that is transmitted with highest priority will succeed, and the node transmitting the lower priority message will sense this and back off and wait. This is achieved by CAN transmitting data through a binary model of "dominant" bits (a logical 0) and "recessive" bits (a logical 1).

BIT TIMING

Each node in a CAN network has its own clock, and no clock is sent during data transmission. Synchronization is done by dividing each bit of the frame into a number of segments: Synchronization Propagation Phase 1 Phase 2

The length of each phase segment can be adjusted based on network and node conditions. The sample point falls between phase buffer segment 1 and phase buffer segment 2, which helps facilitate continuous synchronization. Continuous synchronization in turn enables the receiver to be able to properly read the messages.

An example CAN bit timing with 10 time quanta per bit.

LAYERS

Application layer Object layer Message filtering Message and status handling

Transfer layer The transfer layer receives messages from the physical layer and transmits those messages to the object layer. It performs: Bit Timing and Synchronization Fault Confinement Error Detection and Signalling Message Validation Acknowledgement Arbitration Message Framing Transfer Rate and Timing Information Routing

FRAMES

CAN has four frame types: Data frame: a frame containing node data for transmission Remote frame: a frame requesting the transmission of a specific identifier Error frame: a frame transmitted by any node detecting an error Overload frame: a frame to inject a delay between data and/or remote frame

FRAME FORMATS

A CAN network can be configured to work with two different frame formats: base frame format extended frame format CAN base frame supports a length of 11 bits for the identifier CAN extended frame supports a length of 29 bits for the identifier, made up of the 11-bit base identifier and an 18-bit identifier extension. The distinction between CAN base frame format and CAN extended frame format is made by using the IDE bit, which is transmitted as dominant in case of an 11-bit frame, and transmitted as recessive in case of a 29-bit frame.

Base frame format

extended frame format

BASE FRAME FORMAT


Field name Length (bits) Purpose

Start-of-frame Identifier

1 11

Denotes the start of frame transmission A (unique) identifier for the data which also represents the message priority Dominant (0) Must be dominant (0). Optional Reserved bit (it must be set to dominant (0), but accepted as either dominant or recessive) Number of bytes of data (08 bytes)

Remote transmission request 1 (RTR) Identifier extension bit (IDE) Reserved bit (r0) Data length code (DLC) 1 1 4

Data field
CRC CRC delimiter ACK slot ACK delimiter End-of-frame (EOF)

064 (0-8 bytes)


15 1 1 1 7

Data to be transmitted (length in bytes dictated by DLC field)


Cyclic Redundancy Check Must be recessive (1) Transmitter sends recessive (1) and any receiver can assert a dominant (0) Must be recessive (1) Must be recessive (1)

EXTENDED FRAME FORMAT


Field name Length (bits) Purpose

Start-of-frame

Denotes the start of frame transmission First part of the (unique) identifier for the data which also represents the message priority Must be recessive (1). Optional Must be recessive (1). Optional Second part of the (unique) identifier for the data which also represents the message priority Must be dominant (0) Reserved bits (it must be set dominant (0), but accepted as either dominant or recessive) Number of bytes of data (08 bytes) Data to be transmitted (length dictated by DLC field) Cyclic Redundancy Check Must be recessive (1) Transmitter sends recessive (1) and any receiver can assert a dominant (0)

Identifier A

11

Substitute remote request (SRR) Identifier extension bit (IDE)

1 1

Identifier B

18

Remote transmission request (RTR)

Reserved bits (r0, r1)

Data length code (DLC) Data field CRC CRC delimiter

4 064 (0-8 bytes) 15 1

ACK slot ACK delimiter End-of-frame (EOF)

1 1 7

Must be recessive (1) Must be recessive (1)

DATA FRAME

A Data Frame is produced by a CAN bus node when the node wishes to transmit data or if this is requested by another node. Within one frame up to 8 byte data can be transported. The Data Frame begins with a dominant Start of Frame (SOF) bit for hard synchronization of all nodes. The SOF bit is followed by the Arbitration Field reflecting content and priority of the message. The next field is the Control Field which specifies mainly the number of bytes of data contained in the message. The Cyclic Redundancy Check (CRC) Field is used to detect possible transmission errors. It consists of a 15-bit CRC sequence completed by the recessive CRC delimiter bit. During the Acknowledgement (ACK) Field the transmitting node sends out a recessive bit. Any node that has received an error free frame acknowledges the correct reception of the frame by sending back a dominant bit. The recessive bits of the End of Frame end the Data Frame. Between two frames there must be an recessive 3-bit Intermission field.

DATA FRAME
The data frame is the only frame for actual data transmission. There are two message formats:

Base frame format: with 11 identifier bits Extended frame format: with 29 identifier bits

The CAN standard requires the implementation must accept the base frame format and may accept the extended frame format, but must tolerate the extended frame format

ARBITRATION FIELD

The Identifiers length in the Standard Format is 11 bit The Identifier is followed by the RTR bit. In Data Frames the RTR bit has to be dominant. Within a Remote Frame the RTR bit has to be recessive. The Base ID is followed by the IDE (Identifier Extension) bit transmitted dominant in the Standard Format (within the Control Field) and recessive in the Extended Format. So the Standard Frame prevails the Extended Frame in case of collision.

ARBITRATION FIELD

The Extended Format comprises two sections: Base ID with 11 bit Extended ID with 18 bit. The SRR (Substitute Remote Request) bit substitutes the RTR bit and is transmitted recessive. It is to ensure that, in the case of arbitration between a Standard Data Frame and an Extended Data Frame, the Standard Data Frame will always have priority if both messages have the same base (11 bit) identifier.

CONTROL FIELD

The format of the Control Field is similar for Standard Format and Extended Format. The Control Field in Standard Format includes the Data Length Code (DLC), the IDE bit, which is transmitted dominant and the reserved bit r0 also transmitted dominant. The Control Field in Extended Format includes the DLC and two the reserved bits r1 and r0. The reserved bits have to be sent dominant.

CONTROL FIELD

Data Length Code (DLC) is 4-bit wide and is transmitted in the Control Field. The admissible number of data bytes for a data frame ranges from 0 to 8. DLCs in the range of 0 to 7 indicate data filed length of 0 to 7 bytes.

REMOTE FRAME

Generally data transmission is performed on an autonomous basis with the data source node (e.g., a sensor) sending out a Data Frame.

It is also possible, however, for a destination node to request the data from the source by sending a Remote Frame.
There are two differences between a Data Frame and a Remote Frame.
Firstly the RTR-bit is transmitted as a dominant bit in the Data Frame Secondly in the Remote Frame there is no Data Field.

If a Data Frame and a Remote Frame with the same identifier are being transmitted at the same time, the Data Frame wins arbitration due to the dominant RTR bit following the identifier. In this way, the node that transmitted the Remote Frame receives the desired data immediately.

ERROR FRAME

The error frame consists of two different fields:


The first field is given by the superposition of ERROR FLAGS (612 dominant/recessive bits) contributed from different stations. The following second field is the ERROR DELIMITER (8 recessive bits). There are two types of error flags:

Active Error Flag six dominant bits Transmitted by a node detecting an error on the network that is in error state "error active".
Passive Error Flag six recessive bits Transmitted by a node detecting an active error frame on the network that is in error state "error passive".

HOW CAN HANDLES ERRORS

The error handling aims at detecting errors in messages appearing on the CAN bus, so that the transmitter can retransmit an erroneous message.

Every CAN controller along a bus will try to detect errors within a message.
If an error is found, the discovering node will transmit an Error Flag, thus destroying the bus traffic. The other nodes will detect the error caused by the Error Flag discard the current message.

ERROR DETECTION MECHANISMS


Bit Monitoring. Bit Stuffing. Frame Check. Acknowledgement Check. Cyclic Redundancy Check.

Bit Monitoring: Each transmitter on the CAN bus monitors (i.e. reads back) the transmitted signal level. If the bit level actually read differs from the one transmitted, a Bit Error is signalled. (No bit error is raised during the arbitration process.)

Bit Stuffing: When five consecutive bits of the same level have been transmitted by a node, it will add a sixth bit of the opposite level to the outgoing bit stream. The receivers will remove this extra bit. This is done to give the receivers an opportunity to detect errors: if more than five consecutive bits of the same level occurs on the bus, a Stuff Error is signalled.
Frame check: Some parts of the CAN message have a fixed format, i.e. the standard defines exactly what levels must occur and when. (i.e., CRC Delimiter, ACK Delimiter, End of Frame, and Intermission) If a CAN controller detects an invalid value in one of these fixed fields, a Frame Error is signalled. Acknowledgement Check: All nodes on the bus that correctly receives a message (regardless of their being "interested" of its contents or not) are expected to send a dominant level in the so-called Acknowledgement Slot in the message. The transmitter will transmit a recessive level here. If the transmitter can't detect a dominant level in the ACK slot, an Acknowledgement Error is signalled. Cyclic Redundancy Check: Each message features a 15-bit Cyclic Redundancy Checksum (CRC), and any node that detects a different CRC in the message than what it has calculated itself will signal an CRC Error.

ERROR CONFINEMENT MECHANISMS


A node starts out in Error Active mode. When any one of the two Error Counters raises above 127, the node will enter a state known as Error Passive and when the Transmit Error Counter raises above 255, the node will enter the Bus Off state. An Error Active node will transmit Active Error Flags (i.e. 6 dominant bits) when it detects errors. An Error Passive node will transmit Passive Error Flags (i.e. 6 recessive bits) when it detects errors. A node which is Bus Off will not transmit anything on the bus at all. Transmit errors give 8 error points, and receive errors give 1 error point. Correctly transmitted and/or received messages causes the counter(s) to decrease.

OVERLOAD FRAME

The overload frame contains the two fields, 1. Overload Flag 2. Overload Delimiter. There are two kinds of overload conditions that can lead to the transmission of an overload flag: 1. The internal conditions of a receiver, which requires a delay of the next data frame or remote frame. 2. Detection of a dominant bit during intermission. The start of an overload frame due to case 1 is only allowed to be started at the first bit time of an expected intermission, whereas overload frames due to case 2 start one bit after detecting the dominant bit.

Overload Flag consists of six dominant bits. The overload flags form destroys the fixed form of the intermission field. As a consequence, all other stations also detect an overload condition and on their part start transmission of an overload flag. Overload Delimiter consists of eight recessive bits.

INTERFRAME SPACING

Data frames and remote frames are separated from preceding frames by a bit field called interframe space.

Overload frames and error frames are not preceded by an interframe space and multiple overload frames are not separated by an interframe space.
Interframe space contains the bit fields intermission and bus idle and, for error passive stations, which have been transmitter of the previous message, suspend transmission.

Interframe space consists of at least three consecutive recessive (i.e. 1) bits.

SECURITY

CAN is a low-level protocol, and does not support any security features intrinsically.

Applications are expected to deploy their own security mechanisms; e.g., to authenticate each other.
Failure to do so may result in various sorts of attacks. Password mechanisms exist for data transfer that can modify the control unit software, like software download or ignition key codes, but usually not for standard communication.

APPLICATIONS

Automotive A automobile may have as many as 70 electronic control units (ECU) for various subsystems, examples:- engine control unit, transmission, airbags, antilock braking/ABS, cruise control, electric power steering/EPS, audio systems, windows, doors, mirror adjustment, battery and recharging systems for hybrid/electric cars, etc. Some of these form independent subsystems, but communications among others are essential. A subsystem may need to control actuators or receive feedback from sensors. The CAN bus may be used in vehicles to connect the engine control unit and transmission, or (on a different bus) to connect the door locks, climate control, seat control, etc.

APPLICATIONS

Building automation
Railways: Tram Energy Recycle system Medical Field: The Process Optimized Operating Room by Siemens Industrial Machinery Laboratory Equipment & Research: Nuclear Research at CERN

Avionics: Electric Motor glider

Potrebbero piacerti anche