CANopen
Encyclopedia
CANopen is a communication protocol and device profile specification for embedded system
Embedded system
An embedded system is a computer system designed for specific control functions within a larger system. often with real-time computing constraints. It is embedded as part of a complete device often including hardware and mechanical parts. By contrast, a general-purpose computer, such as a personal...

s used in automation
Automation
Automation is the use of control systems and information technologies to reduce the need for human work in the production of goods and services. In the scope of industrialization, automation is a step beyond mechanization...

. In terms of the OSI model
OSI model
The Open Systems Interconnection model is a product of the Open Systems Interconnection effort at the International Organization for Standardization. It is a prescription of characterizing and standardizing the functions of a communications system in terms of abstraction layers. Similar...

, CANopen implements the layers above and including the network layer
Network layer
The network layer is layer 3 of the seven-layer OSI model of computer networking.The network layer is responsible for packet forwarding including routing through intermediate routers, whereas the data link layer is responsible for media access control, flow control and error checking.The network...

. The CANopen standard consists of an addressing scheme, several small communication protocols and an application layer
Application layer
The Internet protocol suite and the Open Systems Interconnection model of computer networking each specify a group of protocols and methods identified by the name application layer....

 defined by a device profile. The communication protocols have support for network management, device monitoring and communication between nodes, including a simple transport layer
Transport layer
In computer networking, the transport layer or layer 4 provides end-to-end communication services for applications within a layered architecture of network components and protocols...

 for message segmentation/desegmentation. The lower level protocol implementing the data link
Data link layer
The data link layer is layer 2 of the seven-layer OSI model of computer networking. It corresponds to, or is part of the link layer of the TCP/IP reference model....

 and physical layer
Physical layer
The physical layer or layer 1 is the first and lowest layer in the seven-layer OSI model of computer networking. The implementation of this layer is often termed PHY....

s is usually Controller Area Network
Controller Area Network
Controller–area network is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer....

 (CAN), although devices using some other means of communication (such as Ethernet Powerlink
Ethernet Powerlink
Ethernet Powerlink is a deterministic real-time protocol for standard Ethernet. It is an open protocol managed by the Ethernet POWERLINK Standardization Group...

, EtherCAT
EtherCAT
EtherCAT - Ethernet for Control Automation Technology - is an open high performance Ethernet-based fieldbus system. The development goal of EtherCAT was to apply Ethernet to automation applications which require short data update times with low communication jitter and low hardware costs.-...

) can also implement the CANopen device profile.

The basic CANopen device and communication profiles are given in the CiA 301 specification released by CAN in Automation. Profiles for more specialized devices are built on top of this basic profile, and are specified in numerous other standards released by CAN in Automation, such as CiA 401 for I/O-modules and CiA 402 for motion control.

Device model

Every CANopen device has to implement certain standard features in its controlling software.
  • A Communication unit implements the protocols for messaging with the other nodes in the network
  • Starting and resetting the device is controlled via a state machine. It must contain the states Initialization, Pre-operational, Operational and Stopped. The transitions between states are made by issuing a network management (NMT) communication object to the device.
  • The object dictionary is an array of variables with a 16-bit index. Additionally, each variable can have an 8-bit subindex. The variables can be used to configure the device and reflect its environment, i.e. contain measurement data.
  • The application part of the device actually performs the desired function of the device, after the state machine is set to the operational state. The application is configured by variables in the object dictionary and the data are sent and received through the communication layer.

Object dictionary

CANopen devices must have an object dictionary, which is used for configuration and non-realtime communication with the device. An entry in the object dictionary is defined by:
  • Index, the 16-bit address of the object in the dictionary
  • Object name, a symbolic type of the object in the entry, such as an array, record, or simple variable
  • Name, a string describing the entry
  • Type, gives the datatype of the variable
  • Attribute, which gives information on the access rights for this entry, this can be read/write, read-only, write-only or read only constant
  • The Mandatory/Optional field defines whether a device conforming to the device specification has to implement this object or not


The basic datatypes for object dictionary values such as Booleans, integers and floats are defined in the standard, as well as composite datatypes such as arrays, records and strings. The composite datatypes can be subindexed with an 8-bit index. The value in subindex 0 of an array or record indicates the number of elements in the data structure, and is of type UNSIGNED8.

For example, the device communication parameters, standardized in the basic device profile CiA 301 are mapped in the index range 0x1000 - 0x1FFF ("communication profile area"). The first few entries in this area are as follows:
Index Object name Name Type Attribute M/O
0x1000 VAR device type UNSIGNED32 ro M
0x1001 VAR error register UNSIGNED8 ro M
... tributed in jan. 6(1991)
0x1008 VAR manufacturer device name Vis-String const O
...


Given suitable tools, the object dictionary of a device can be configured by editing an electronic data sheet (EDS) file and uploading the variable values to the device. The format of the EDS-file according to CiA306 is INI file,
there is an upcoming XML-style format, that is described in CiA311.

Communication objects

CANbus, the physical layer of CANopen, can only transmit short packages consisting of an 11-bit id, remote transmission request (RTR) bit and 0 to 8 bytes of data. The CANopen standard divides the 11-bit CAN frame id into a 4-bit function code and 7-bit CANopen node id. This limits the number of devices in a CANopen network to 127. An extension to the CANbus standard (CAN 2.0 B) allows extended frame ids of 29 bits, but in practice CANopen networks big enough to need the extended id range are rarely seen.

In CANopen the 11-bit id of a CAN-frame is known as communication object identifier, or COB-ID. In case of a transmission collision, the bus arbitration used in the CANbus allows the frame with the smallest id to be transmitted first and without a delay. Since in CANopen frames the first 4 bits of the frame id are reserved to the function code, giving a low code number for time critical functions ensures the lowest possible delay.

Contents of a standard CANopen frame:
Function code Node ID RTR Data length Data
Length 4 bits 7 bits 1 bit 4 bits 0-8 bytes


The standard reserves certain COB-IDs to network management and SDO transfers. Some function codes and COB-IDs have to be mapped to standard functionality after device initialization, but can be configured for other uses later.

Communication models

Different kinds of communication models are used in the messaging between CANopen nodes.

In a master/slave relationship, one CANopen node is designated as the master, which sends or requests data from the slaves. The NMT protocol is an example of a master/slave communication model.

A client/server relationship is implemented in the SDO protocol, where the SDO client sends data (the object dictionary index and subindex) to an SDO server, which replies with one or more SDO packages containing the requested data (the contents of the object dictionary at the given index).

A producer/consumer model is used in the Heartbeat and Node Guarding protocols. In the push-model of producer/consumer, the producer sends data to the consumer without a specific request, whereas in the pull model, the consumer has to request the data from the producer.

Network management (NMT) protocols

The NMT protocols are used to issue state machine change commands (e.g. to start and stop the devices), detect remote device bootups and error conditions.

The Module control protocol is used by the NMT master to change the state of the devices. The CAN-frame COB-ID of this protocol is always 0, meaning that it has a function code 0 and node id 0, which means that every node in the network will process this message. The actual node id, to which the command is meant to, is given in the data part of the message. This can also be 0, meaning that all the devices in the bus should go to the indicated state.

The Heartbeat protocol is used to monitor the nodes in the network and verify that they are alive. A heartbeat producer (usually a slave device) periodically sends a message with binary function code of 1110 and its node id (COB ID = 0x700 + node id). The data part of the frame contains a byte indicating the node status. The heartbeat consumer reads these messages. If the messages fail to arrive within a certain time limit (defined in the object dictionary of the devices) the consumer can take action to, for example, reset the device or indicate an error.
Frame format is :
COBID Data Byte 0
0x700 + NodeID State


CANopen devices are required to make the transition from the state Initializing to Pre-operational automatically during bootup. When this transition is made, a single heartbeat message is sent to the bus. This is the bootup protocol.

A response/reply-style (pull model) protocol for slave monitoring called Node guarding protocol exists.

Service Data Object (SDO) protocol

The SDO protocol is used to set and read values from the object dictionary of a remote device. The device whose object dictionary is accessed is the SDO server and the device accessing the remote device is the SDO client. The communication is always initiated by the SDO client. In CANopen terminology, communication is viewed from the SDO server, so that a read from an object dictionary results in an SDO upload and a write to dictionary is an SDO download. (see talk page for "upload/download" ambiguity)

As the object dictionary values can be larger than the 8 byte limit of a CAN frame, the SDO protocol implements segmentation and desegmentation of longer messages. Actually, there are two of these protocols: SDO download/upload and SDO Block download/upload. The SDO block transfer is a newer addition to standard, which allows large amounts of data to be transferred with slightly less protocol overhead.

The COB IDs of the respective SDO transfer messages from client to server and server to client can be set in the object dictionary. Up to 127 SDO servers can be set up in the object dictionary addresses 0x1200 - 0x127F. Similarly, the SDO client connections of the device can be configured with variables at 0x1280 - 0x12FF. However the pre-defined connection set defines an SDO channel which can be used even just after bootup (in the Pre-operational state) to configure the device. The COB IDs of this channel are 0x600 + node id for receiving and 0x580 + node id for transmitting.

To initiate a download, the SDO client sends the following data in a CAN message with the 'receive' COB ID of the SDO channel:
3 bits 1 bit 2 bits 1 bit 1 bit 2 bytes 1 byte 4 bytes
ccs=1 reserved(=0) n e s index subindex data

  • ccs is the client command specifier of the SDO transfer, this is 0 for SDO segment download, 1 for initiating download, 2 for initiating upload, 3 for SDO segment upload and 4 for aborting an SDO transfer
  • n is the number of bytes in the data part of the message which do not contain data, only valid if e and s are set
  • e, if set, indicates an expedited transfer , i.e. all data exchanged are contained within the message. If this bit is cleared then the message is a segmented transfer where the data does not fit into one message and multiple messages are used.
  • s, if set, indicates that the data size is specified in n (if e is set) or in the data part of the message
  • index is the object dictionary index of the data to be accessed
  • subindex is the subindex of the object dictionary variable
  • data contains the data to be uploaded in the case of an expedited transfer (e is set), or the size of the data to be uploaded (s is set, e is not set)

Process Data Object (PDO) protocol

Process Data Object protocol is used to process real time data among various nodes. You can transfer up to 8 bytes (64bits) data per one PDO either from or to the device. One PDO can contain multiple object dictionary entries and the objects within one PDO is configurable using the mapping and parameter object dictionary entries.

There are two kinds of PDOs: transmit and receive PDOs (TPDO and RPDO). The former is for data coming from the device and the latter is for data going to the device, ie. with RPDO you can send data to the device and with TPDO you can read data from the device. In the pre-defined connection set there are identifiers for four (4) TPDOs and four (4) RPDOs available. With configuration 512 PDOs are possible.

PDOs can be sent synchronously or asynchronously. Synchronous PDOs are sent after the SYNC message whereas asynchronous messages are sent after internal or external trigger. For example, you can make a request to a device to transmit TPDO that contains data you need by sending empty TPDO with RTR flag (if the device is configured to accept TPDO requests).

With RPDOs you can, for example, start two devices simultaneously. You only need to map the same RPDO into two or more different device and make sure those RPDOs are mapped with the same COB ID.

Synchronization Object (SYNC) protocol

The Sync-Producer provides the synchronization-signal for the Sync-Consumer. When the Sync-Consumer receive the signal they start carrying out their synchronous tasks.

In general the fixing of the transmission time of synchronous PDO messages coupled with the periodicity of transmission of the Sync Object guarantees that sensor devices may arrange to sample process variables and that actuator devices may apply their actuation in a coordinated fashion.

The identifier of the Sync Object is available at index 1005h.

Time Stamp Object (TIME) protocol

Usually the Time-Stamp object represents an absolute time in ms after midnight and the number of days since January 1, 1984. This is a bit sequence of length 48 (6 byte).

Some time critical applications especially in large networks with reduced transmission rates require very accurate synchronization; it may be necessary to synchronize the local clocks with an accuracy in the order of microseconds.
This is achieved by using the optional high resolution synchronization protocol which employs a special form of time stamp message to adjust the inevitable drift of the local clocks.

The high-resolution time-stamp is encoded as unsigned32 with a resolution of 1 microsecond which means that the time counter restarts every 72 minutes. It is configured by mapping the high resolution time-stamp (object 1013h) into a PDO.

Emergency Object (EMCY) protocol

Emergency messages are triggered by the occurrence of a device internal fatal error situation and are transmitted from the concerned application device to the other devices with high priority. This makes them suitable for interrupt type error alerts. An Emergency Telegram may be sent only once per ‘error event’, i.e. the emergency messages must not be repeated. As long as no new errors occur on a device no further emergency message must be sent.
By means of CANopen Communication Profile defined emergency error codes, the error register and device specific additional information are specified in the device profiles.

Initialization

Sample trace of communications between a master and 2 pressure transducer slaves configured for id 1 and node id 2.
CAN ID DATA LENGTH DATA Description
0x0 2 1 0 Master puts bus into operational mode
0x80 0 Master sends a SYNC message, which triggers devices to send data
0x181 4 CD 82 01 00 Node at ID 1 (CID-0x180), reading pressure of 0x0182CD(99021) pascals
Pascal (unit)
The pascal is the SI derived unit of pressure, internal pressure, stress, Young's modulus and tensile strength, named after the French mathematician, physicist, inventor, writer, and philosopher Blaise Pascal. It is a measure of force per unit area, defined as one newton per square metre...

0x182 4 E5 83 01 00 Node at ID 2 (CID-0x181), reading pressure of 0x0183E5(99301) pascals

Electronic Device Description

The EDS file is a file format, defined in CiA306, that describes the communication behaviour and the object dictionary entries of a device. This allows tools such as service tools, configuration tools, development tools, and others to handle the devices properly.

Those EDS files are mandatory for passing the CiA CANopen Conformance Test. A free EDS checker is CANchkEDS.

Since end of 2007 a new XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

 based format called XDD is defined in CiA311. XDD is conformant to ISO Standard 15745.
For both formats a free editor is available, called CANeds. This and an open platform for discussion and support is available at https://canopen-forum.com/.

Glossary of CANopen Terms

  • PDO: Process Data Object - Inputs and outputs. Values of type RPM, V, Hz, mAmps etc.
  • SDO: Service Data Object - Configuration settings, possibly NODE ID, baud rate, offset, gain etc.
  • COB-ID: CAN Object Identifiers.
  • CAN ID: CAN Identifier. This is the 11 bit CAN message identifier which is at the beginning of every CAN message on the bus.
  • EDS: Electronic Data Sheet. This is an INI style resp. XML style formatted file.
  • DCF: Device Configuration File. This is modified EDS with settings for node ID and baud rate.

See also

  • Controller area network
    Controller Area Network
    Controller–area network is a vehicle bus standard designed to allow microcontrollers and devices to communicate with each other within a vehicle without a host computer....

      Article on the CANBUS.
  • DeviceNet
    DeviceNet
    DeviceNet is a network system used in the automation industry to interconnect control devices for data exchange. It uses Controller Area Network as the backbone technology and defines an application layer to cover a range of device profiles...

  • IEEE 1451
    IEEE 1451
    IEEE 1451 is a set of smart transducer interface standards developed by the Institute of Electrical and Electronics Engineers Instrumentation and Measurement Society’s Sensor Technology Technical Committee that describe a set of open, common, network-independent communication interfaces for...

  • TransducerML
    Transducerml
    TransducerML or TML is an Open Geospatial Consortium standard developed to describe any transducer in terms of a common model, including characterizing not only the data but XML formed metadata describing the system producing that data.-Process:TML captures when and where a sensor measurement or...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK