CAN Bus
Enable Javascript for TOC.
Basics
- CAN Formats:
- CAN 2.0 A - Standard Format (11 Bit identifier)
- CAN 2.0 B - Extended Format (29 Bit identifier)
- ISO 11898:
- ISO 11898-2 High speed applications up to 1Mbps
- ISO 11898-3 Low speed applications up to 125Kbps
- CAN defines the OSI Layers 1 and 2
- Layers above are typically defined by DeviceNet, CANOpen, ISO 1192 (e.g. for heavy trucks), SAE J1939 (automotive), etc.
- All messages are Broadcast message. Each receive decides itself whether to process the message or ignore it.
- The messages have an ID which defines the source or the content
- 1Mbps -> 40 meters ... 125Kbps -> 500 meters
- The number of nodes is not specified by the CAN Standard, they are limited by electrical loading - but up to 64 nodes are normal.
- Bit stuffing after 5 bits (on error - e.g. 6 equal bits in a row - all nodes reset)
Can Frames:
- Data Frame - used to transmit data (used for mainly all data transmitted)
- Remote Frame - used to request data transmission (only infrequently used)
- Error Frame - sent by a node that detects an error
- Overload Frame - send by a node to request a delay in transmission
Field |
Bits |
Comment |
Start of frame |
1 |
|
Identifier |
11 |
or 29 on extended format |
Remote transmission (RTR) |
1 |
signalizes an request |
ID extension (IDE) |
1 |
|
Reserved |
1 |
FD frame bit (FDF) in "CAN FD" |
Data lengtd code (DLC) |
4 |
|
Data field |
0-8 byte |
|
CRC |
15 |
|
CRC delimiter |
1 |
gives you time to check the CRC on receiver side |
ACK slot |
1 |
written by the receiver |
ACK delimiter |
1 |
|
End of frame |
7 |
|
Source: Youtube
Implementations
DeviceNet
DeviceNet is a CAN based Layer 7 protocol, which was originally developed by Allen Bradley. Operation of DeviceNet is based on an object-oriented communications model. DeviceNet is maintained by the "Open DeviceNet Vendor Association (ODVA)" and can be implemented free of license. (www.odva.org) DeviceNet is widely used in US factory automation.
Source: Vector - Protocol Selection Guide, p2
CANOpen
- Object Directory
- Index - Physical Address of the information
- Object Type - VAR, ARRAY, STRING, etc
- Name - descriptional
- Data Type - UNSIGNED 32, etc
- Attribute - rw, ro, wo, const
- Default Value
- COB-ID - Communication Object Idenfier (4 bit function code, 7 bit node number, node=0 for broadcast)
- NMT - Network Management
for setting operating states: Initialized, Pre-Operational, Operational, Prepared, COB-ID=zero
Node number and commands is stored in content
- SYNC - Broadcast a "heart beat" by the master
e.g. configure devices to send data every 2nd SYNC
- EMCY - emergency message (for sending error codes)
- PDO - Process Data Object (regular operation to access device's data, contents and trigger can be customized)
- SDO - Service Data Object (register based access)
- NODE GUARD - NMT Error Control (test to seed whether the node is alive)
- ...
Source: WEBINAR: Unitronics Vision - CANOpen (Youtube)
Source: Vector - CANOpen Introduction
- The Object Dictionary is stored in an EDS-File (electronic data sheet, example) in the INI file format (according to CiA 306)
- In CiA 311 (since 2007) the Object Dictionary can be stored as XML
- The EDS file (object dictionary) can be converted to an DCF file (device configuration file). The DCF is a modified EDS file with settings for node ID and baud rate
- Except of NMT and SDO the other commands can be customized for special purposes.
- CANOpen devices are required to make the transition from the state "initializing" to "pre-operations" automatically during bootup.
- The "predefined connection set" defines 4 PDOs (4x rec, 4x send); with configuration 512 are possible
- ...
Source: Wikipedia - CANOpen
CAN/CANOpen Implementations
J1939
J1939 Implementations
ISO-TP (Transport Layer) - ISO 15765-2
OSI Layer 3 and 4 protocol, to manage packet sizes up to 4095 bytes of payload. The addressing (CAN IDs) is not changed. The additional protocol overhead is 1 or 2 bytes in each packet (so data is reduced to 7 or 6 bytes per packet) and an additional return package (flow control frame).
ISO-TP Implementations
can-isotp implementation of hartkopp
CAN Kingdom
see https://www.kvaser.com/difference-can-open-can-kingdom/
https://www.kvaser.com/wp-content/uploads/2014/02/ck301p.pdf