CAN PROTOCOL

N?o foi fornecido texto alternativo para esta imagem

Controller Area Network(CAN) is a multi-master, message broadcast system that specifies a maximum signaling rate of 1 megabit per second(bps), a protocol that, due to its cost, performance, and upgradeability provides tremendous flexibility in system design. Because CAN is a broadcast protocol, all nodes can hear the transmission, been not possible to send a message to a specific node. But each node may react only to interesting messages.?

CAN bus protocol was developed by BOSCH and was officially released in 1986 at the Society of Automotive Engineers (SAE) conference in Detroit, Michigan. The first CAN controller chips were introduced by Intel in 1987, and shortly thereafter by Philips.?

CAN Standard

CAN was originally developed for the automotive industry to replace complex wiring harness with the two-wire bus. The ISO-11898: 2003 defines how the communication in the serial communication bus is passed between devices on a network.?

The iso-1198 architecture defines the lowest two layers of the seven-layer OSI/ISO model as the data link and physical layer.?The application layer establishes the communication link to an upper-level application-specific protocol, like CANopen.?

N?o foi fornecido texto alternativo para esta imagem

CAN Physical Layer

A physical layer defines the electrical levels and signaling scheme on the bus, the cable impedance, and similar things. The modules are connected to the bus in a wired-and fashion

They are different physical layers, here three will be approached:

  1. High-Speed CAN:
  2. Defined by the CAN standard, part of ISO 11898-2
  3. Two-wire balanced signaling-scheme?
  4. Low-Speed CAN:
  5. Defined by the CAN standard, part of ISO 11898-2
  6. Two-wire balanced signaling scheme for lower bus speed
  7. SAE J2411
  8. Single-wire physical layer
  9. Is used chiefly in cars

The can bus uses Non-Return To Zero(NRZ) with bit-stuffing with 2 different signaling states:

  1. Dominant (Logically 0)
  2. Recessive(Logically 1)

Different physical layers can not, as a rule, interoperate. Some combinations may work, or seem to work, under good conditions.

Bus speed

Maximum Bus Speed(1Mbit/s)

Low-speed CAN(ISO 11898-3): 125Kbit/s

Single-wire CAN:

  1. 50Kbit/s(Standard mode)
  2. 100Kbit/s(Special high-speed mode)

Minimum bus speed

82C250 or 82C251: 10 Kbit/s

TJA1050: 50 Kbit/s

Maximum Cable Length

The cable length is restricted by the speed of light. If optocouplers are used to provide galvanic isolation, the maximum bus length is decreased accordingly. Use fast optocouplers, and look at the delay through the device, not at the specified maximum bit rate.?

N?o foi fornecido texto alternativo para esta imagem


Bus termination

According to ISO 11898 CAN be terminated to remove the signal reflections at the end of the bus and ensures the bus gets the correct DC levels. Other physical layers, such as “low-speed CAN”, single-wire CAN, and others, may or may not require termination. But your vanilla high-speed ISO 11898 CAN bus will always require at least one terminator.

N?o foi fornecido texto alternativo para esta imagem
N?o foi fornecido texto alternativo para esta imagem

CAN Conectors

9-pin DSUB

This connector layout is recommended by CAN in Automation (CiA) and is pretty much the industrial standard.?The pin numbering is valid for a male connector, viewed from the connector side, or for a female connector viewed from the soldering side. – To memorize the pinning, note that CAN_LOW has a LOW pin number and CAN_HIGH has a HIGH pin number.

N?o foi fornecido texto alternativo para esta imagem

5-pin Mini-C

Used by both DeviceNet and SDS and happens to be compatible between these two protocols. The modules have male connectors. The supplied power is 24V +- 1%. Note: in the DeviceNet specification version 1.x, the female connector in figure 9.13 has the numbers in wrong order. Specification 2.0 and later versions has got it right.

N?o foi fornecido texto alternativo para esta imagem

6-pin Deutsch DT04-6P

Recommended by CANHUG for use in mobile hydraulics applications. Module side male, bus side female. There is currently no recommendation as to the supplied power.

N?o foi fornecido texto alternativo para esta imagem

Bits Fields of Standard CAN?

N?o foi fornecido texto alternativo para esta imagem

SOF: The single dominant start of frame (SOF) bit marks the start of a message, and is used to synchronize the nodes on a bus after being idle.

11-bit Identifier: The Standard CAN 11-bit identifier establishes the priority of the message. The lower the binary value, the higher its priority.?

RTR: The single remote transmission request (RTR) bit is dominant when information is required from another node. All nodes receive the request, but the identifier determines the specified node. The responding data is also received by all nodes and used by any node interested. In this way, all data being used in a system is uniform.

IDE: A dominant single identifier extension (IDE) bit means that a standard CAN identifier with no extension is being transmitted.?

r0: Reserved bit (for possible use by future standard amendment).

DLC: The 4-bit data length code (DLC) contains the number of bytes of data being transmitted.

Data: Up to 64 bits of application data may be transmitted.

CRC: The 16-bit (15 bits plus delimiter) cyclic redundancy check (CRC) contains the checksum (number of bits transmitted) of the preceding application data for error detection.

ACK: Every node receiving an accurate message overwrites this recessive bit in the original message with a dominate bit, indicating an error-free message has been sent. Should a receiving node detect an error and leave this bit recessive, it discards the message and the sending node repeats the message after arbitration. In this way, each node acknowledges (ACK) the integrity of its data. ACK is 2 bits, one is the acknowledgment bit and the second is a delimiter. THe presence of an Acknowledgement bit on the bus does not mean that any of the intended addressees has received the message. The only thing we know is that one or more nodes on the bus has received it correctly.?

EOF: This end-of-frame (EOF), 7-bit field marks the end of a CAN frame (message) and disables bit stuffing, indicating a stuffing error when dominant. When 5 bits of the same logic level occur in succession during normal operation, a bit of the opposite logic level is stuffed into the data.

IFS: This 7-bit interframe space (IFS) contains the time required by the controller to move a correctly received frame to its proper position in a message buffer area.?


CAN Message

The CAN standard defines four different message types. The messages uses a clever scheme of bitwise arbitration to control access to the bus, and each message is tagged with a priority. The maximum length utility is 94 bits and they are contents-addressed.

Arbitration?

Arbitration is a fundamental characteristic of the can bus. As a multi-master-slave protocol, more than one node can try to access the bus. To deal with that the protocol uses a non-destructive, bit-wise arbitration. It is non-destructive because the node that wins arbitration just continues on with the message, without the message being destroyed. The allocation of priority is a feature of CAN that makes it attractive for use within a real-time control environment.

The transmitting node constantly monitors each bit of its own transmission. The lower the message identifiers number the higher its priority, with bit zero as dominant and bit one as recessive. A dominant bit overwrites a recessive bit on the CAN bus.?

N?o foi fornecido texto alternativo para esta imagem


Message Types

The Data frame

Comprises the Arbitration field, The data field, the CRC field and The ACK Field.?

The Remote frame

The purpose is to solicit the transmission of data from another node. It is similar to data frame but with two major differences:

  1. The message is explicit marked as a remote frame, by a recessive RTR bit in the arbitration field.
  2. There is no Data.?

The Error frame

Is a special frame that violates the formatting rules of a CAN message. It is transmitted when a node detects an error in a message, and causes all other nodes in the network to send an error frame as well. Elaborate scheme of error counters ensure that a node can’t destroy the bus traffic by repeatedly transmitting Error frames?

The overload frame

It is similar to the error frame with the regard to the format, and it is transmitted by a node that becomes too busy.?

A valid frame

A message is considered to be error-free when the last bit of the ending EOF field of a message is received in the error-free recessive state. A dominant bit in the EOF field causes the transmitter to repeat a transmission.?

Final considerations:

I hope you enjoy this article, if you want to know more about those topics in the end of the article you can find some good references.

In case of doubts, let me know if i can help!

May the force be with you my friend!

References

https://www.kvaser.com/course/can-protocol-tutorial/

https://www.warwickcontrol.com/wp-content/uploads/2018/07/fig1-1.png

https://support.maxongroup.com/hc/en-us/articles/360009241840-CAN-bus-topology-and-bus-termination

https://www.cable-tester.com/rs232-pin-out/

https://www.ti.com/lit/an/sloa101b/sloa101b.pdf?ts=1661234719180

Abhishek Narwankar

Electronics Engineer | Embedded Software Developer | Firmware Engineer | Embedded System Engineer

2 年

Thanks for sharing José Gomes

回复
Rakuram E

Associate Architect | Automotive | AUTOSAR | Diagnostics | DCM | CAN | UDS | C | I talk about C, AUTOSAR and Automotive Communication Protocols

2 年

Thanks for sharing, José

回复

要查看或添加评论,请登录

José Gomes的更多文章

社区洞察

其他会员也浏览了