CANOpen Configuration Manual
Introduction
This document describes how to set up an application to use the CANOpenIOServer component and how to configure the CANOpenIOServer instance to communicate correctly on the CAN bus.
About
The CANOpenIOServer component implements a CANOpen master but also supports slave mode for testing purposes. CANOpen protocols like PDO, SDO, SYNC, NMT, EMCY and functions like node guarding, heartbeat are supported, but not all are implemented to meet the full CANOpen specification. See the next chapters for detailed description of the supported CANOpen protocols.
Terms and Definitions
Node ID | A 7 bit unique address identifying each node on the bus. |
COBID | Message ID identifying different message types. Consists of 4 bit function code and 7 bit Node ID. |
RTR | The RTR Bit (Remote Transmission Request) is used by a receiver to request a remote transmitter to send his information. |
CAN frame | Is a frame of data sent on the CAN bus. A CAN frame consists of up to 10 bytes, 2 bytes header and up to 8 bytes of data. Sometimes this is called CAN telegram. |
TPDO | Transmit Process Data Object is CAN telegram containing process data. Usually sent by slave node on a bus. Received by the master (for example CanOpenIOServer) and other nodes. |
RPDO | Receive Process Data Object is a CAN telegram containing process data. Sent to slave node usually by master but may also be sent by another node. |
SDO | Service Data Object is CAN telegram used to read/write CAN node's Object Dictionary. |
SYNC | Synchronization Object is sent out by Sync-Producer usually the master to coordinate sensor sampling and actuator value applying. |
Note: Transmit and Receive in naming of PDOs are always seen from the slave nodes perspective.
COBID structure
Function code in COBID are used to define a protocol (NMT, SYNC, EMCY, PDO, SDO...).
Function code | Node ID | |
---|---|---|
Length | 4 bits | 7 bits |
CAN frame structure
The following frame data format is used by all can transport layers (wire level format varies according to respective transport standard Ethernet/CAN).
COBID | RTR | Data length | Data | |
---|---|---|---|---|
Length | 11 bits | 1 bit | 4 bits | 0-8 bytes |
CANOpenIOServer overview
Notable objects in CANOpenIOServer
Some of the items to note in CANOpenIOServer are:
Signals
Signal | Unit | Description |
---|---|---|
Telegrams received | tel/s | The number of telegrams received from CAN bus per second. |
Telegrams sent | tel/s | Telegrams successfully sent over the CAN bus per second. |
Bytes received | kB/s | Number of kilobytes received on the CAN bus per second. (not including telegram headers) |
Bytes sent | kB/s | Number of kilobytes sent on the CAN bus per second. (not including telegram headers) |
Bytes total | kB/s | Amount of data sent and received on the CAN bus per second (including estimated overhead). Equals Bytes received + Bytes sent + Telegrams total*Overhead |
ReceiveBuffer Used | msgs | Number of messages currently in the drivers receive buffer. |
TransmitBuffer Used | msgs | Number of messages currently in the drivers transmit buffer. |
Main period | s | Measurement of the actual period of CANOpenIOServer Main thread. |
Time | s | The relative time. |
Bus load | % | Estimated bus load. |
Parameters
Parameter | Description |
---|---|
Overhead | Estimated overhead bytes per telegram sent. Used when calculating Bytes total. Should include telegram header, start/stop bits, CRC, bit stuffing etc. |
Alarms
Alarm | Description |
---|---|
Transmission Error | Alarm raised if IOServer didn't receive packets in time. |
Bus off | CAN bus not connected. |
Controller error | Error indicated by some CAN drivers (when at least one of the error counters has exceeded the warning limit). |
Buffer overrun | CAN telegrams have been lost due to overflowed hardware buffers. |
Properties
Property | Description |
---|---|
fs | CANOpenIOServer component process frequency and RPDO telegram send frequency (also maximum change rate for CDPSignalChannels in TPDO telegram). |
SyncFs | Frequency of SYNC telegram send by CANOpenIOServer master. |
TransportLayer | Selection of physical transport layer to be used. Supported layers are SocketCAN, UDP, USB and CDP. |
ProtocolLayer | Currently CanIOServer only supports CANOpen protocol |
BroadcastResetNodeAtStartup | When set ResetNode telegram is sent on startup. |
BroadcastResetCommunicationAtStartup | When set ResetCommunication telegram is sent on startup. |
Priority | Defines the priority the IOServer will run at. Can have a value of "high", "normal", or "low". |
Debug | Debug level for the IOServer console printouts. |
CANOpenIOServer component configuration
Configuration procedure
To start configuring the IOServer it must be added to your application in configure mode. See CANOpen Setup Guide for tutorial.
There are various types of CANOpenIOServer models available in resources:
Name | Description |
---|---|
CANOpenUDPIOServer | Uses IP/UDP packets over Ethernet as the physical layer. |
CANOpenPCIIOServer | Uses PCI cards in controller. |
CANOpenUSBIOServer | Uses Lawicel CANUSB dongle for CAN connectivity on Windows platforms. |
The following typically must be done to the added CANOpenIOServer component to configure the i/o server:
- Configure the CAN controller transport properties. (Set baud rate if required on PCI transport. Set IP addresses and ports when using UDP transport.)
- Add a CANOpenIOServer.MasterNode/CANOpenIOServer.SlaveNode for each node in your CANOpen network. Make sure that the node Address is set correctly.
- Add one or more CANOpenIOServer.TPDO and/or CANOpenIOServer.RPDO to your Nodes to receive/transmit PDO telegram data from/to the node.
- Add ObjectDictonary entries to the Node if it needs custom configuration (CANOpenIOServer.CustomODEntry and some pre-configured OD Entries available in resources).
- Customize Node send frequency Fs if different from IOServer fs and SYNC frequency SyncFs for IOServer.
SocketCAN TransportLayer Properties in CANOpenPCIIOServer
Property | Description |
---|---|
PortName | In windows when using other ports than the default/first, the port name must be specified to indicate port to configure. Valid values are currently “CAN1” and “CAN2”. In Linux port name should contain the interface name used ex: “can0”, “can1”, “vcan0”. Interface names are case sensitive in Linux. Virtual can interface in Linux can be created with: # ip link add dev vcan0 type vcan |
BaudRate | Set the baud rate for windows in symbols/s (equals bit/s on CAN). Baud rate setting is not used in Linux. Linux the CAN interface settings can be configured with iproute2 tools having root privileges: # ip link set can0 type can bitrate 250000 |
All OS side configuration for CAN interfaces in Linux should be done during controller boot init scripts in /etc/init.d
Possible content of such init script may look like this:
# Loading modules into kernel (use PLX socketcan driver) modprobe can modprobe can-raw modprobe can-bcm modprobe vcan modprobe plx_pci # Initializing can0 /sbin/ip link set can0 type can bitrate 250000 restart-ms 100 /sbin/ip link set can0 echo 1000 > /sys/class/net/can0/tx_queue_len ifconfig can0 up # Initializing can1 /sbin/ip link set can1 type can bitrate 250000 restart-ms 100 /sbin/ip link set can1 echo 1000 > /sys/class/net/can1/tx_queue_len ifconfig can1 up
UDP TransportLayer Properties CANOpenUDPIOServer
When TransportLayer is set to UDP, CANOpen telegrams are sent over UDP packets on Ethernet. As UDP packets are not guaranteed to reach destination this needs to be taken into account when setting up Heartbeat or Node guarding for Nodes to allow for packet loss.
Property | Description |
---|---|
RemoteAddress | RemotePort where the UDP transport layer sends UDP packets on RemoteAddress IP. |
RemotePort | Port where the UDP transport layer sends UDP packets on RemoteAddress IP. |
LocalPort | Port where the UDP transport layer listens to UDP packets from RemoteAddress. The local port must be available for the application. When provided UDP port is not available the CANOpenIOServer will fail to operate. |
NetworkInterface | Indicate a NetworkInterface declared in Application. On this interface UDP transport layer opens the LocalPort (the interface must belong to same network as RemoteAddress). |
Property configuration
IOServer processing rate
The fs dictates the update rate for incoming channels value propagation in component and outgoing channel values routed from the IOServer to other components.
By default the fs Property is also used to set the sending interval of RPDO telegrams, except when Node's Fs Property is set (usually a lower value from a component fs). TPDO is still received at the nodes transmit rate, but the outputs from IOServer are not updated faster than the defined components fs.
SYNC telegram sending
CANOpenIOServer has Property SynchFs to control SYNC telegram sending. Specify the frequency at which to send out a SYNC message (rate defined in Hz). This setting has no relation to Property fs of CANOpenIOServer component.
Set to 0 or blank to disable sending SYNC telegrams.
ResetNode command during startup
To broadcast a ResetNode telegram when the CANOpenIOServer master boots, set the Property BroadcastResetNodeAtStartup.
This will ensure that the nodes are restarted and reconfigured with the current Object Dictionary values. If nodes should not be restarted when the master boots, set this value to 0 (or blank/not specified).
Slave
When Slave Property is set, the IOServer is enabled to receive and process can telegrams.
To test out the slave it is simplest to use two CANOpenUDPIOServer components with corresponding configuration, with one of them having the Slave property set and using a SlaveNode, while the other having the Slave property not set and using a MasterNode. In Linux it is possible to use virtual can driver "vcan" for configuring CANOpenPCIIOServer.
Node configuration
Nodes are added to the CANOpenIOServer by adding resource CANOpenIOServer.MasterNode and/or CANOpenIOServer.SlaveNode (Nodes will be added to the CanInterface section in the IOServer). Configuration of nodes tells the IOServer how to communicate with each node on the CanOpen bus, or how to emulate each node (if SlaveNode). It is also important to note that RPDO and TPDO telegram transmit and receive in SlaveNode are reversed compared to MasterNode.
For MasterNodes:
- When adding a TPDO, the Input Attribute is default set.
- When adding CDPSignalChannels to this TPDO, the Input Attribute is default not set.
- When adding a RPDO, the Input Attribute is default not set.
- When adding CDPSignalChannels to this RPDO, the Input Attribute is default set.
For SlaveNodes:
- When adding a TPDO, the Input Attribute is default not set.
- When adding CDPSignalChannels to this TPDO, the Input Attribute is default set.
- When adding a RPDO, the Input Attribute is default set.
- When adding CDPSignalChannels to this RPDO, the Input Attribute is default not set.
Node Fs Attribute
Nodes Fs attribute is intended for reducing the RPDO default transmit rate defined by component fs for nodes that don't use trigger based sending as a means to reduce bus traffic.
Node guarding
GuardTime Property (in seconds) configures the CANOpenIOServer to send node guarding request to the node. LifeTimeFactor (Life Time in ObjectDictonary) is the multiplier for node guarding timeout for slave. The LifeTimeFactor multiplied by GuardTime defines the time limit for the reception of a node guarding message by the slave. CANOpenIOServer.GuardTimeODEntry and CANOpenIOServer.LifeTimeODEntry resources should be added to the Node configuration, matching the Values with GuardTime and LifeTimeFactor.
Note: Note that the unit of GuardTime is in seconds versus the unit of CANOpenIOServer.GuardTimeODEntry is in milliseconds.
If a node guarding message is not received during this time, CANOpen node will assume an error has occurred. Since this mechanism is a provider-initiated service, it enables the CANOpen slave nodes to be notified if the master fails. Normally, the slave will then go to error state, which will be reported via the Emergency protocol.
The usage of node guarding is optional.
Heartbeat
A node can be configured to use the heartbeat protocol instead of the Node guarding protocol by setting Heartbeat Property. The GuardTime times LifeTimeFactor Properties will then be used for node heartbeat grace time in master, after the time expires the node is considered to be in Unknown state (see nodes NodeState signal). CANOpenIOServer.HeartbeatPTimeODEntry resource (“Heartbeat Producer Time”) must be added to the Node configuration to cause the CANOpen node to send out the heartbeat.
Note: Note that the unit of GuardTime is in seconds versus the unit of CANOpenIOServer.HeartbeatPTimeODEntry is in milliseconds.
Network Management Service
With NMT enabled, a start command is sent to each node during startup.
The current state of each node can be monitored with nodes NodeState Signal. The signal will show the last known node state from node.
Object Dictionary
The Object Dictionary (OD) or SDO configuration is set of registers that all nodes must implement. It gives access to information about CAN communication parameters and other node parameters in a standardized manner. The object dictionary is addressed using two parameters, an Index and a Subindex.
The CANopen standard defines which objects (Entries) in the object dictionary a node is required to implement, which objects a node may implement, and which objects a node may use freely for customer or application-specific data.
By writing to the OD it is possible to configure parameters such as which data is transmitted in the PDOs (PDO mapping parameters), which CAN Ids a node should receive and transmit, when TPDOs should be transmitted and a lot more.
During startup of a node, when it is in the PreOperational state, the master may write new values to the object dictionary in the node to configure it (using SDOs telegrams). The values will typically be reset to default values when the node is restarted.
Note: The master will only write the values to the node's OD when the node starts or is started by the master. If the master starts itself and the node is in the Operational state these writes will be skipped.
To make sure that all nodes are reconfigured when the master itself starts, see chapter ResetNode command during startup regarding the BroadcastResteNodeAtStartup option.
The information about which objects a node supports is supplied by either the node vendor (typically the EDS file), the documentation for the “Device Profile” that the node adheres to, or by the CANOpen standard. To be able to take advantage of an object in the object dictionary, one need to know the index, subindex, data type and meaning of each object that one wants to use.
Before master starts the node, it will write OD entries data using index, subindex values to the node's object dictionary using SDO messages. The Name and Unit Properties are not actually transferred, but used for documentation and status reporting only.
Note: Note that the AdjustWithNodeAddress attribute can be set on (non-zero) Object Dictionary Entries to clear the address part of the value (the 7 Least Significant Bits / LSBs) and add the Node Address to the Value in the OD Entry. This is useful for adjusting configuration-values that depend on the Node Address, for instance when enabling and disabling TPDOs.
When AdjustWithNodeAddress is set; if the address-part (7 LSBs) of the OD Entry Value is non-zero before adding the Node Address, a warning will be printed in the messagelog.
Disable use of "size used" and "unused bytes" fields in SDO expedited download messages
Some nodes do not support that the data size fields in the SDO expedited download message is set (one bit indicates that the size is used, and two bits indicates the number of unused data bytes). To set these bits 0 for all expedited SDO downloads for a node, unset the attribute UseSDODataSize on the node.
Supported data types
The following table lists data types that are currently supported by the CANOpenIOServer:
OD type code | Valid names | Description |
---|---|---|
0x01 (Not supported) | Bool type, single bit indicating true or false | |
0x02 | char | 8-bit signed integer |
0x03 | short | 16-bit signed integer |
0x04 | int | 32-bit signed integer |
0x05 | unsigned char | 8-bit unsigned integer |
0x06 | unsigned short | 16-bit unsigned integer |
0x07 | unsigned int | 32-bit unsigned integer |
0x08 (Not supported) | 32-bit single precision floating point number | |
0x11 (Not supported) | 64-bit double precision floating point number | |
0x09 (Not supported) | A text string containing printable ASCII characters | |
0x0a (Not supported) | An array of 8-bit unsigned integers | |
0x0f (Not supported) | Block of data |
Limitations
Currently, only expedited SDO transfer is supported. That is, only values that will fit in a single SDO message can be transferred. This effectively means that only 4 bytes of data can be transferred per OD entry.
PDO configuration
TPDO and RPDO
PDO attributes | Description |
---|---|
Nr | Number for the PDO |
Input | This property has a default pre-set value, see chapter Node configuration, but at some instances can be overridden for advanced usage. |
TriggerRouting | (RPDO only) This optional attribute for RPDO that may be used to provide event driven sending for packet. When routed to CDPSignal the RPDO is sent each time the value of the signal changes between set/unset state (true/false, 0/not 0). |
TriggerOnChange | (RPDO only) This is optional attribute for RPDO when set to “1” makes the RPDO only be sent when at least one of the CDPChannels in that RPDO change value. When TriggerOnChange is specified channels may use optional TriggerLevel to set the triggering to some specified amount of change (default “0” triggers on any value change in channel). |
COBID | If specified, defines the COBID (message ID) used by this PDO. If not specified, the Nr property is used to calculate a standard COBID according to the Default Connection Set. |
AdjustWithNodeAddress | When set, and COBID is non-zero, the 7 Least Significant Bits (LSBs) of COBID are cleared, and then the Node Address is added to COBID during Configure. If the 7 LSBs of COBID have a value before clearing them, a warning is printed that the existing address will be overwritten. |
Supported data types in PDO
The following data types can be used when instantiating CDPChannels inside node elements (data within PDOs). See chapter CDPChannel. Note that these may differ from the data types valid when specifying ObjectDictionary entries, see chapter about the Object Dictionary
CDPChannel
CANOpenIOServer supports CDPChannels to connect to/from CDPSignals.
CDPChannel attributes | Description |
---|---|
Model | The model name for the channel. |
Nr | The channel number starting from 1. On bool channels this is used as bit order number in a bit mask. When adding CDPSignalChannel<bool> to PDO a byte of data area is allocated for bits (the same byte is used for also 7 next boolean channels added. Bits are placed by their Nr field value 1-8 in that byte). When adding any other channel type after a single boolean channel the bytes are allocated after the byte for the single boolean channel. |
Type | The c++ data type, can be bool, char, unsigned char, short, unsigned short, int, unsigned int . Typical values are bool and short . |
Name | The signal name for this channel. Feel free to use more understandable names than what is used in the example, like 'Pressure', 'OilLevel' and so on. But note that the whole path under component "RPDO.Node.ChannelName" should be shorter than 31 characters. |
TriggerLevel | May be used in RPDO located channel when RPDO sets TriggerOnChange Property see chapter TPDO and RPDO |
CDPSignalChannels supports all the internal elements of CDPSignal. Operators are also available. For example ScalingOperator can be used to scale channel values.
Custom COBIDs
It is possible to receive a custom COBID, for instance a RPDO sent out by another master on the CAN bus. For that one needs to disable Nodes NMT Property to prevent the IOServer from trying to manage that node.
Note: Disabling NMT for a node may cause PDO messages to be sent to a node when it is not in a Operational state (a nonconforming behavior to CanOpen standard) as the state of the node will be unknown for the CANIOServer as the state discovery uses NMT protocol.
To configure custom COBID
- Add MasterNode
- Disable NMT Property for the MasterNode
- Add CANOpenIOServer.RPDO to MasterNode
- Set the Input Property to
true
on the RPDO to prevent the IOServer itself from sending this RPDO (since this is a RPDO, which normally would be sent out by the master, but in this case is sent out by another master). - Set the COBID Property if you want to receive custom PDOs with COBID
The same technique can be used to send out a PDO with a custom Address that does not need to exist on the network:
- Disable nodes NMT Property
- Set custom address
- Configuring the node
Note: The Node state displayed for these nodes will be “Unknown” as there is no physical node that has a state.
Monitoring and Debugging
Standard Signals
A range of signals exist in the CANOpenIOServer to allow monitoring the network traffic either by looking at the signal values manually or by using the signals to trigger alarms.
Status signals
The following signals are created for each node:
Signal name | Unit | Description |
---|---|---|
[NodeName].TelegrRcvd | telegr/s | Telegrams received each seconds. |
[NodeName].TelegrSent | telegr/s | Telegrams sent each seconds. |
[NodeName].SendPeriod | s | SendPeriod of all configured RPDOs. |
[NodeName].RecvPeriod | s | Receive period of all TPDO1. |
[NodeName].NodeState | Unknown=-1, BootUp=0, Stopped=4, Operational=5, PreOperational=127. |
Emergency protocol
The following eight error signals are also created for each node:
[NodeName].ErrorRegister | Error register from node. (OD entry 0x1001) |
[NodeName].ErrorCAN | Emergency error code (CAN defined error codes). |
[NodeName].ErrorManuf0 | Manufacturer specific error code, byte 0 (from Emergency Object). |
[NodeName].ErrorManuf1 | Manufacturer specific error code, byte 1 (from Emergency Object). |
[NodeName].ErrorManuf2 | Manufacturer specific error code, byte 2 (from Emergency Object). |
[NodeName].ErrorManuf3 | Manufacturer specific error code, byte 3 (from Emergency Object). |
[NodeName].ErrorManuf4 | Manufacturer specific error code, byte 4 (from Emergency Object). |
The signals are set to the value received in last emergency telegram from a node. These values can also be received via CM_CAN_EMERGENCY Message when EmergencyRouting Property is set on the Node.
Debug tips
Set the Debug Property at runtime to a value between 1 and 10 to get more debug output.
Troubleshooting
Problem
The Node is not configured with the correct OD parameters after reboot.
Cause
The configuration is only written to the node when the node is started by the master. If the master is restarted while the node stays in its operational state (for instance because it's not configured to use node guarding or heartbeat), the new configuration will not be set.
Solution
To force the new configuration to be set, simply reboot the node.
Or, set BroadcastResetNodeAtStartup to make the master broadcast a ResetNode command when it restarts to ensure that all nodes are reconfigured.
Appendix
Reading speed from Position encoder
To read the speed one needs to set the send period and change the PDO mapping in the encoder to enable reading the speed.
- Add Node for the Position encoder
- Set the node address
- To Node add CustomODEntry set Index to 1a01, SubIndex to 0, Name to "PDO2 nParam", Type to
unsigned char
, Value to 0 - To Node add CustomODEntry set Index to 1a01, SubIndex to 1, Name to "PDO2 value 1", Type to
unsigned long
, Value to 0x60040020 - To Node add CustomODEntry set Index to 1a01, SubIndex to 1, Name to "PDO2 value 2", Type to
unsigned long
, Value to 0x60300110 - To Node add CustomODEntry set Index to 1a01, SubIndex to 0, Name to "PDO2 nParam", Type to
unsigned char
, Value to 2 - To Node add CustomODEntry set Index to 3010, SubIndex to 1, Name to "Speed Enable", Type to
unsigned char
, Value to 1 - To Node add TPDO set Nr to 1, Name to "TPDO1"
- To TPDO1 add CDPSignalChannel<unsigned short> set Name to "position"
- To TPDO1 add CDPSignalChannel<unsigned short> set Name to "turns"
- To Node add TPDO set Nr to 2, Name to "TPDO2"
- To TPDO2 add CDPSignalChannel<unsigned short> set Name to "position"
- To TPDO2 add CDPSignalChannel<unsigned short> set Name to "turns"
- To TPDO2 add CDPSignalChannel<short> set Name to "speed"
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.