Home » Communications » Controller Area Network (CAN)
Jul
07
 

Controller Area Network (CAN)


[What is the endianness of CAN ? ]

"CAN we talk? : Distributed systems require protocols for communication between devices. CAN and SPI are two of the most common." article by Niall Murphy 2003-05-14 http://www.embedded.com/story/OEG20030509S0042

Controller Area Network (CAN)

Controller Area Network (CAN)

[What is the endianness of CAN ? ]
“CAN we talk? : Distributed systems require protocols for communication between devices. CAN and SPI are two of the most common.” article by Niall Murphy 2003-05-14 http://www.embedded.com/story/OEG20030509S0042

… a text-based protocol. This is how most of the Internet works; HTTP and SMTP are both built on text protocols. This approach allows the protocol to remain architecture agnostic. Text is less efficient than a protocol where each byte is given a meaning, but the upside is a protocol thats easy for a human to read and debug.

The biggest difference between CAN and SPI is that the CAN protocol defines packets. In SPI (and serial interfaces in general), only the transmission of a byte is fully defined. Given a mechanism for byte transfer, software can provide a packet layer, but no standard size or type exists for a serial packet. Since packet transfer is standardized for CAN, its usually implemented in hardware. Implementing packets, including checksums and backoff-and-retry mechanisms, in hardware hides a whole family of low-level design issues from the software engineer.

There are a number of higher layer protocols that have been layered on top of the basic CAN specifications . These include SAE J1939, DeviceNet, and CANOpen. …
 
points to the Linux CAN-bus driver project http://home.wanadoo.nl/arnaud/
Open DeviceNet Vendor Association, Inc. http://www.odva.org/ (DeviceNet is a more detailed specification for CAN)
information from “Hard real-time connectivity: Its in the CAN” article by Bruce Boyes in _Computer Design_ 1998-01, p. 88
“CAN is a robust network designed for hard real-time distributed control systems in harsh environments. Its an open standard (and the subject of ISO 11898)…” … “CAN is a peer-to-peer network … packets with a maximum payload of 8 bytes … … adept at passing around simple commands or small amounts of data quickly… … not well-suited to moving around large files …” “can go up to 1 Mbit/s, CAN systems most commonly operate at 250 Kbit/s or 125 Kbit/s, because lower baud rates are more resistant to brief bursts of noise.” ” fiber-optic cable also is common. …” “The ISO 11898 document specifies a 120 Ohm nominal impedance using terminated twisted-pair media. … line length versus baud rate … … 40 m, 1 000 Kbits/s … 1 000 m, 50 Kbits/s …”
“low cost and relative simplicity” “Kevin Parkinson … typically uses optically isolated chip-to-bus electronics using RS485 type drivers.”
“Emphasis on content” “When data is transmitted by a CAN node, no other nodes are /addressed/; rather, the /content/ of the message (pressure, voltage, temperature, etc.) is designated by the identifier, which is unique throughout the network. The identifier also prioritizes the message. With care, this prioritizing guarantees the most important messages are transmitted with the least delay. … Arbitration is nondestructive. In the case of an overloaded network, the highest-priority messages still get through. … Latency … is also very low. … CAN hardware also provides message acknowledgment and automatic re-transmission in the event of an error.”
“CAN data bits are either “dominant” or “recessive”. … A frame always begins with a dominant-level SOF (start-of-frame) bit. A dominant bit always “wins” over a recessive bit being transmitted at the same time. … If 2 nodes start transmitting concurrently, each node performs bit-wise arbitration to resolve the conflict. … A transmitter stops sending if it sends a recessive bit, but monitors a dominant bit. That guarantees a lower-priority CAN device immediately stops transmitting, while the higher-priority device continues unimpeded. The lower-priority device waits for the next bus idle time and tries again. … 2 nodes [should] never send the same [arbitration field] followed by different data …”
“… ACK … indicates sucessful message … reception by at least one receiver … the hardware ACK is an important component of CANs real-time capability.”

“For example, a vehicle wheel-speed sensor should transmit its data properly and let other nodes, if any, handle the data as they wish.”
“The RTR bit permits any node to request data from another node.”
“receiving nodes which detect a problem … transmit… in the end of frame space. The sender monitors the error flag, which triggers an automatic retransmission by the sending node.”
“Honeywells Smart Distributed System (SDS) … DeviceNet (initiated by Allen-Bradley) … … DeviceNet and SDS also include specifications for rugged cable and connectors.”
“The CAN in Automation (CiA) group (Erlangen, Germany) promotes the CAL”
“CAN specification 2.0B describes the extended message frame with a 29-bit ID.”
Siemens (SAE81C91), Motorola (MC68376), Intel (i82527), Philips (SJA1000), National Semiconductor (COP87L84BC). offer CAN controllers and/or microprocessors with CAN 2.0B capability.
CAN extended message format (bit field width is not to scale)
| Arbitration field | Control Field | Data field | CRC field | Response field
Arbitration field:
| SOF | 11 bit identifier | SSR | IDE | 18 bit identifier | RTR |
Control field:
| R1 | R0 | DLC |
Data field:
| Data: 0 to 8 bytes |
CRC field:
| 15 bit CRC |

Response field:
| ACK field | EOF 7 bits | INT 3 bits | bus idle (or another node starts transmitting)
SOF: Start of Frame, a single dominant bit
SRR: Substitute Remote Request
IDE: identifier extension bit is recessive for extended format
ID Fields: a total of 29 ID bits for extended frmat
RTR: remote transmit request, dominant for data frames, recessive for remote frames.
R1, R0 are reserved, dominant bits.
DLC: a 4 bit data length code indicates the number of bytes in the data field.
DATA: 0 to 8 bytes. A remote frame contains zero bytes.
CRC: a 15 bit CRC and a recessive CRC delimiter bit. (Covers what ? just the data ?
The entire packet before the CRC ? )
ACK: acknoledgement is a single dominant bit followed by a recessive delimiter bit
EOF: End of Frame: seven recessive bits end a frame
INT: intermission is 3 bits between remote and data frames

For an extended frame, this is a total of 64 to 128 bits (depending on data size). With 8 bytes of data, overhead (non-data bits) is therefore 1/2.