레이블이 CAN인 게시물을 표시합니다. 모든 게시물 표시
레이블이 CAN인 게시물을 표시합니다. 모든 게시물 표시

2017년 9월 27일 수요일

CAN Physical Layers

The CAN Bus

The CAN bus uses Non-Return To Zero (NRZ) with bit-stuffing. There are two different signaling states: dominant (logically 0) and recessive (logically 1). These correspond to certain electrical levels which depend on the physical layer used (there are several.) The modules are connected to the bus in a wired-and fashion: if just one node is driving the bus to the dominant state, then the whole bus is in that state regardless of the number of nodes transmitting a recessive state.

Different Physical Layers

A physical layer defines the electrical levels and signaling scheme on the bus, the cable impedance and similar things.
There are several different physical layers:
  • The most common type is the one defined by the CAN standard, part ISO 11898-2, and it’s a two-wire balanced signaling scheme. It is also sometimes known as “high-speed CAN”.
  • Another part of the same ISO standard, ISO 11898-3, defines another two-wire balanced signaling scheme for lower bus speeds. It is fault tolerant, so the signaling can continue even if one bus wire is cut or shorted to ground or Vbat. It is sometimes known as “low-speed CAN”.
  • SAE J2411 defines a single-wire (plus ground, of course) physical layer. It’s used chiefly in cars – e.g. GM-LAN.
  • Several proprietary physical layers do exist.
  • Modifications of RS485 was used in the Old Ages when CAN drivers didn’t exist.
  • Go to Page 6 to view a number of oscilloscope pictures for those interested in the details of a message.
Different physical layers can not, as a rule, interoperate. Some combinations may work, or seem to work, under good conditions. For example, using both “high-speed” and “low-speed” transceivers on the same bus can work.. sometimes.
A great many CAN transceiver chips are manufactured by Philips; alternative vendors include Bosch, Infineon, Siliconix and Unitrode.
A very common type is the 82C250 transceiver which implements the physical layer defined by ISO 11898. The 82C251 is an improved version.
A common transceiver for “low-speed CAN” is TJA1054 from Philips.

Maximum Bus Speed

The maximum speed of a CAN bus, according to the standard, is 1 Mbit/second. Some CAN controllers will nevertheless handle higher speeds than 1Mbit/s and may be considered for special applications.
Low-speed CAN (ISO 11898-3, see above) can go up to 125 kbit/s.
Single-wire CAN can go up to around 50 kbit/s in its standard mode and, using a special high-speed mode used e.g. for ECU programming, up to around 100 kbit/s.

Minimum Bus Speed

Be aware that some bus transceivers will not allow you to go below a certain bit rate. For example, using 82C250 or 82C251 you can go down to 10 kbit/s without problems, but if you use the TJA1050 instead you can’t go below around 50 kbit/s. Check the data sheet.

Maximum Cable Length

At a speed of 1 Mbit/s, a maximum cable length of about 40 meters (130 ft.) can be used. This is because the arbitration scheme requires that the wave front of the signal can propagate to the most remote node and back again before the bit is sampled. In other words, the cable length is restricted by the speed of light. A proposal to increase the speed of light has been considered but was turned down because of its inter-galactic consequences.
Other maximum cable lengths are (these values are approximate) –
  • 100 meters (330 ft) at 500 kbit/s
  • 200 meters (650 ft) at 250 kbit/s
  • 500 meters (1600 ft) at 125 kbit/s
  • 6 kilometers (20000 ft) at 10 kbit/s
If optocouplers are used to provide galvanic isolation, the maximum bus length is decreased accordingly. Hint: use fast optocouplers, and look at the delay through the device, not at the specified maximum bit rate.

Bus Termination

An ISO 11898 CAN bus must be terminated. This is done using a resistor of 120 Ohms in each end of the bus. The termination serves two purposes:
  1. Remove the signal reflections at the end of the bus.
  2. Ensure the bus gets correct DC levels.
An ISO 11898 CAN bus must always be terminated regardless of its speed. I’ll repeat this: an ISO 11898 CAN bus must always be terminated regardless of its speed. For laboratory work just one terminator might be enough. If your CAN bus works even though you haven’t put any terminators on it, you are just lucky.
Note that 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.

The Cable

The ISO 11898 prescribes that the cable impedance be nominally 120 Ohms, but an impedance in the interval of [108..132] Ohms is permitted.
There are not many cables in the market today that fulfill this requirement. There is a good chance that the allowed impedance interval will be broadened in the future.
ISO 11898 is defined for a twisted pair cable, shielded or unshielded. Work is in progress on the single-wire standard SAE J2411.

CAN connectors

There is no standard at all for CAN bus connectors! Usually, each Higher Layer Protocol(!) defines one or a few preferred connector types. Common types include
  • 9-pin DSUB, proposed by CiA.
  • 5-pin Mini-C and/or Micro-C, used by DeviceNet and SDS.
  • 6-pin Deutch connector, proposed by CANHUG for mobile hydraulics.
  • Go to Page 7 to view a few different connector layouts.

CAN Messages, Part I

참조: Link

The CAN bus 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.
CAN bus는 broadcast 타입의 bus 입니다. 이 말은 모든 node들은 모든 통신내용을 들을 수 있다는 걸 의미합니다. 특정 node만이 들을 수 있도록 message를 보내는 것은 가능하지 않습니다.

The CAN messages

CAN uses short messages – the maximum utility load is 94 bits. There is no explicit address in the messages; instead, the messages can be said to be contents-addressed, that is, their contents implicitly determines their address.
CAN은 짧은 message를 사용합니다. – 가능한 최대 길이는 94bit(11byte + 6bit) 입니다. message에는 특정 주소가 있는 것은 아니지만; 대신, message는 내용에 주소가 있다고 이야기 할 수 있습니다. 그 이야기는 내용 자체에 암암리에 주소가 있기 때문 입니다.

Message Types

There are four different message types (or “frames”) on a CAN bus:
CAN bus에는 message의 타입(혹은 frame이라고 불림)이 4가지 있습니다.
  1. the Data Frame,
  2. the Remote Frame,
  3. the Error Frame, and
  4. the Overload Frame.

1. The Data Frame

Summary: “Hello everyone, here’s some data labeled X, hope you like it!”
요약: "안녕 모두들, 여기 라벨이 X라고 붙은 data가 있어, 좋아했으면 해!"
The Data Frame is the most common message type. It comprises the following major parts (a few details are omitted for the sake of brevity):
Data frame은 가장 일반적인 message 타입입니다. 몇가지 중요한 부분으로 구성되어 있습니다.(몇몇 세부내용은 간결함을 위하여 생략되었습니다.)
  • the Arbitration Field, which determines the priority of the message when two or more nodes are contending for the bus. The Arbitration Field contains:
  • Arbitration Field 라고 하는 부분은 message 간의 우선순위를 결정해 줍니다. bus에 있는 내용들이 2개 이상일 때 구별해 줍니다. Arbitration Field 는 아래 내용을 포함합니다:
    • For CAN 2.0A, an 11-bit Identifier and one bit, the RTR bit, which is dominant for data frames.
    • CAN 2.0A 에서는 11bit의 구별자와 1bit, RTR bit로서 data frame에서 dominant(0)인,
    • For CAN 2.0B, a 29-bit Identifier (which also contains two recessive bits: SRR and IDE) and the RTR bit.
    • CAN 2.0B 에서는 29bit의 구별자(두 개의 recessive bit(1)를 가진, SRR, IDE))와 RTR bit
  • the Data Field, which contains zero to eight bytes of data.
  • Data Field 는 0~8byte 의 길이를 가진다. 
  • the CRC Field, which contains a 15-bit checksum calculated on most parts of the message. This checksum is used for error detection.
  • CRC field 는 15bit로 계산 된 checksum 값을 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.
  • Acknowledgement Slot는 각 message의 마지막에 붙은 bit로서 transmitter가 마지막에 보냈는지 체크해서 보내지 않았으면 다시 보낸다.? 방향이 헷갈림
Note 1: It is worth noting that 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.
Note 1: Acknowledgement bit는 내가 원했던 node에서 message를 받았다는 것을 나타내지는 않는다 하지만 누군가는 받았다는것을 확인할 수 있으므로 있는것이 좋다.
Note 2: The Identifier in the Arbitration Field is not, despite of its name, necessarily identifying the contents of the message.
Note 2: Identifier의 Arbitration Field(중재 필드)는 그 이름에도 불구하고 충분히 message를 구분하지 못한다.
 A CAN 2.0A (“standard CAN”) Data Frame.
 A CAN 2.0B (“extended CAN”) Data Frame.





RTR: Remote transmission request
SRR: Substitute remote request
IDE: Identifier extension bit

Introduction: The CAN bus

Introduction: The CAN bus

The CAN bus 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.
CAN 버스는 broadcast 타입의 bus 입니다. 이 말은 모든 node들은 모든 통신 내용을 "들을" 수 있다는 이야기 입니다. 단지 하나의 node에만 message를 보내는 방법은 없습니다; 모든 node들은 언제나 모든 통신내용을 듣습니다. 하지만 CAN 하드웨어는 내부에서 filtering을 제공하며, 각 node에서는 관련이 있는 message 에만 반응합니다.

The bus uses Non-Return To Zero (NRZ) with bit-stuffing. The modules are connected to the bus in a wired-and fashion: if just one node is driving the bus to a logical 0, then the whole bus is in that state regardless of the number of nodes transmitting a logical 1.
bus는 NRZ 과 bit-stuffing을 사용한다. 이 말은 항상 의미가 있는 bit들의 조합을 사용하며 에러를 감지하기 위하여 특정 위치에(규칙으로) bit를 삽입한다는 의미이다. module들은 bus에 wired-AND 방식으로 연결되어 있다. 만약 하나의 node가 bus를 0상태로 변경하려고 하면, 모든 bus가 그 상태(0)이 된다 몇개의 node들이 1을 만들어내는것에 상관 없이. 

The CAN standard defines four different message types. The messages uses a clever scheme of bit-wise arbitration to control access to the bus, and each message is tagged with a priority.
CAN의 표준에서는 4가지 다른 message의 타입을 정의합니다. 이 message들은 영리한 방법으로 bit-wise arbitration 을 사용하여 bus로의 접근을 제어 하며, 각 message들은 우선순위가 있습니다.

The CAN standard also defines an elaborate scheme for error handling and confinement which is described in more detail in Section 9, “CAN Error Handling” (Pg 23).
또한 CAN표준은 오류처리 와 제한을 위한 정교한 계획을 정의합니다. 자세한 내용은 9장 "CAN 오류 처리"에서 확인할 수 있습니다.

Bit timing and clock synchronization is discussed in Page 8 of this Tutorial. Here’s a bit timing calculator you can use to calculate the CAN bus parameters and register settings.
비트 타이밍 및 클럭 동기화는이 자습서 8 페이지에서 설명합니다. 다음은 CAN 버스 매개 변수와 레지스터 설정을 계산하는 데 사용할 수있는 약간의 타이밍 계산기입니다.

CAN may be implemented using different physical layers (Pg 5), some of which are described here, and there are also a fair number of connector types (Pg 7) in use. We also provide a number of oscilloscope pictures (Pg 6) for those interested in the details of a message.
CAN은 서로 다른 물리 계층 (Pg 5)을 사용하여 구현 될 수 있으며, 그 중 일부는 여기에 설명되어 있으며 사용중인 커넥터 유형 (Pg 7)의 수가 상당히 있습니다. 또한 메시지의 세부 사항에 관심이있는 사람들을 위해 여러 오실로스코프 사진 (페이지 6)을 제공합니다.



Non-Return To Zero (NRZ) (Link)
기록 · 재생에 있어서의 하나의 모드로, 기록된 데이터의 각 아이템 다음에 신호가 반드시 제로로 복귀하지 않는 것. 따라서 중성(휴지:休止) 위치는 없다. 디짓 1은 하나의 진폭 레벨이고, 또 디짓 0은 다른 진폭 레벨(극성은 동극성일 때도 역극성일 때도 있다)로 표현된다. 제로 복귀 모드에 비해 기록 속도를 빨리 할 수 있다.
[네이버 지식백과] 비 복귀 기록 [non-return to zero, 非復歸記錄] (전자용어사전, 1995. 3. 1., 성안당)
bit-stuffing(Link)
전송된 데이터열에 여분의 비트를 삽입하는 것. 비트 스터핑은 특수한 비트열이 확실히 원하는 위치에만 나타나도록 하기 위해 사용한다.
wired-AND(Link)
bit-wise arbitration
confinement
bus(Link)
In computer architecture, a bus[1] (a contraction of the Latin omnibus) is a communication system that transfers data between components inside a computer, or between computers. This expression covers all related hardware components (wire, optical fiber, etc.) and software, including communication protocols