• 沒有找到結果。

CHAPTER 3 CAN specification

3.2 CAN protocols

3.2.2 CAN Technology

CAN is a multi-master broadcast serial bus standard for connecting electronic control units (ECUs).

Each node is able to send and receive messages, but not simultaneously: a message

up to eight message bytes) is transmitted serially onto the bus, one bit after another — this signal-pattern codes the message (in NRZ) and is sensed by all nodes.

The devices that are connected by a CAN network are typically sensors, actuators and control devices. A CAN message never reaches these devices directly, but instead a host-processor and a CAN Controller is needed between these devices and the bus.

If the bus is free, any node may begin to transmit. If two or more nodes begin sending messages at the same time, the message with the more dominant ID (which has more dominant bits i.e. bit 0) will overwrite other nodes less dominant IDs, so that eventually (after this arbitration on the ID) only the dominant message remains and is received by all nodes.

3.2.3 Data Types

A CAN network can be configured to work with two different message (or "frame") formats:

the standard or base frame format (or CAN 2.0 A), and the extended frame format (or CAN 2.0 B). The only difference between the two formats is that the “CAN base frame” supports a length of 11 bits for the identifier, and the “CAN extended frame” supports a length of 29 bits for the identifier, made up of the 11-bit identifier (“base identifier”) and an 18-bit extension (“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. CAN controllers that support extended frame format messages are also able to send and receive messages in CAN base frame format. All frames begin with a start-of-frame (SOF) bit that denotes the start of the frame transmission.

CAN has four frame types:

Figure 3.4 Types of CAN frame

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 frames [5]

z 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.

Figure 3.5 CAN data frame

Base frame format [5]

The frame format is as follows:

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 Dominant (0) (see Remote Frame below)

Identifier extension bit (IDE)

1 Must be dominant (0)Optional

Reserved bit (r0) 1

Reserved bit (it must be set to dominant (0), but accepted 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)

ACK slot 1

Transmitter sends recessive (1) and any receiver can assert a dominant (0)

ACK delimiter 1 Must be recessive (1) End-of-frame (EOF) 7 Must be recessive (1)

One restriction placed on the identifier is that the first seven bits cannot be all recessive bits.

(I.e., the 16 identifiers 1111111xxxx are invalid.)

Extended frame format The frame format is as follows:

Field name

Length (bits)

Purpose

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

Identifier A 11 First part of the (unique) identifier for the data Substitute remote request

(SRR)

1 Must be recessive (1)Optional

Identifier extension bit (IDE)

1 Must be recessive (1)Optional

Identifier B 18 Second part of the (unique) identifier for the data Remote transmission

request (RTR)

1 Must be dominant (0)

Reserved bits (r0, r1) 2 Reserved bits (it must be set dominant (0), but

accepted 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)

ACK slot 1

Transmitter sends recessive (1) and any receiver can assert a dominant (0)

ACK delimiter 1 Must be recessive (1)

End-of-frame (EOF) 7 Must be recessive (1)

The two identifier fields (A & B) combined form a 29-bit identifier.

* It is physically possible for a value between 9-15 to be transmitted in the 4-bit DLC, although the data is still limited to 8 bytes. Certain controllers allow the transmission and/or reception of a DLC greater than 8, but the actual data length is always limited to 8 bytes.

z 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 2 differences between a Data Frame and a Remote Frame. Firstly the RTR-bit is transmitted as a dominant bit in the Data Frame and secondly in the Remote Frame there is no Data Field.

Figure 3.6 CAN remote frame

i.e.

RTR = 0 ; DOMINANT in data frame RTR = 1 ; RECESSIVE in remote frame

In the very unlikely event of a Data Frame and a Remote Frame with the same identifier 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.

z Error frame

Error frame consists of two different fields

The first field is given by the superposition of ERROR FLAGS contributed from different stations. The following second field is the ERROR DELIMITER.

There are two types of error flags

Active Error Flag

Transmitted by a node detecting an error on the network that is in error state "error active".

Passive Error Flag

Transmitted by a node detecting an active error frame on the network that is in error state

"error passive".

z Overload frame

The overload frame contains the two bit fields Overload Flag and 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 overall form corresponds to that of the active error flag. The overload flag’s 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. The overload delimiter is of the same form as the error delimiter.

相關文件