Zum Inhalt springen

CANopen devices and mapping

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

A CANopen connection needs the list of the nodes (devices) on the bus. Each node has a node id and a device description from an EDS or DCF file. Then you map PDO entries to PLC variables.

The device description holds the identity of the device (object 0x1018), its object dictionary and its PDO mapping.

  • EDS (electronic data sheet): the file of the vendor. It describes the device with the default PDO mapping.
  • DCF (device configuration file): an EDS with the values of a configured device, for example a PDO mapping that you changed. Use a DCF when the device runs a mapping other than the vendor default.
  1. In the connections tree, open CANopen and select Import device files.
  2. Select one or more .eds or .dcf files. The files can be UTF-8 or Windows-1252.
  3. Select Save.

Expected result: the dialog shows Created, Updated and Skipped counts. The catalogue holds one description per organization, vendor ID, product code and revision. A new file with the same identity overwrites the description and counts as Updated.

  • A file that cannot be read is Skipped. The warning gives the line and the section of the error.
  • Customer files can hold names of machines or customers. Import only files that you may share in your organization.
  • The size of a file is limited to 2 MB. Unconfirmed: the limit is a proposal and not yet confirmed.

Open the menu of the connection and select Nodes. The dialog lists the nodes of the connection with the columns Node id, Name, Device and Mappings.

  1. Select Add node.
  2. Enter the Node id (1 to 126, not the master node id, not used twice on the connection).
  3. Search and select the Device (from the imported device files).
  4. Optionally enter a Node name. The default is the name of the device description.
  5. Select Save. Expected: the message The node was saved.

A node whose device description has a PDO entry that is not byte aligned cannot be saved. See PDO entries that are not byte aligned.

Two PDOs on one connection cannot use the same COB-ID. The save fails with an error that names both nodes and the PDOs.

Scan bus finds the nodes that answer on the bus and adds them with their device description. It needs the role Manage runtimes and the device descriptions of the nodes (import them first).

  1. Open the menu of the connection and select Scan bus. The scan starts when the dialog opens. Select Scan again to repeat it.
  2. Wait for the list. The portal waits at most 45 seconds. The worst case on the bus is a bus without any node: 16 rounds of 108 ms, about 1.7 s at 250 kbit/s (8 SDO clients in parallel, timeout 100 ms plus 2080 divided by the bit rate in kbit/s, in ms).
  3. The table shows Node id, Name, Vendor ID, Product code, Revision, Serial and Device description. A node shows Matched when an imported description has the same vendor ID, product code and revision. A node with no description cannot be added: import its EDS or DCF file and scan again.
  4. Select the nodes and select Add selected.

How the scan works:

  • Without a running connector, the scan reads object 0x1018 (and the device name, object 0x1008) of the node ids 1 to 126 by SDO. It sends no NMT command.
  • While the connector of the connection runs, the scan does not send any frame. It lists the nodes that the connector started and read, from the state file of the connector. When the connector has not read the nodes yet, the scan fails with BUS_OWNED_NO_SNAPSHOT. Wait a few seconds and scan again.
  • A node that is not started (for example after an identity mismatch) is not in this list.
  • Add selected adds the nodes or replaces the stored node with the same node id. A stored node keeps its name and the mappings that still fit the device description.

Open <connection name> Mappings. The tab has one row per mapping.

ColumnMeaning
PLC variableThe access variable.
CANopen itemA PDO entry of an active PDO of a node of this connection. Selecting it sets the node id, index, sub-index, bit length, direction and data type.
DirectionInput: device TPDO to PLC. The variable must be read-only. Output: PLC to device RPDO. The variable must be writable. The direction comes from the entry and is not editable.
BitOptional bit offset. See Binding a BOOL variable to one bit.
TypeCANopen data type of the variable. It must be as wide as the entry.

The tab saves only when all mappings pass these checks:

  • The entry is mapped by an active PDO (COB-ID bit 31 = 0 and at least one mapped object) in the direction that the mapping needs.
  • The data type has the bit length of the entry. For example, UNSIGNED16 needs a 16-bit entry.
  • A variable is mapped once per connection.
  • Two PDOs on the connection do not use the same COB-ID.

Each error names the node, the object and the conflicting object.

Data types: BOOLEAN (BOOL), INTEGER8 (SINT), INTEGER16 (INT), INTEGER32 (DINT), INTEGER64 (LINT), UNSIGNED8 (USINT), UNSIGNED16 (UINT), UNSIGNED32 (UDINT), UNSIGNED64 (ULINT), REAL32 (REAL), REAL64 (LREAL).

After you save, the portal creates a new canopen.json and writes it to the device. Unconfirmed: whether a running connector applies a changed configuration without a restart of the runtime. Restart the runtime after a change to be sure.

A BOOL variable normally maps to a BOOLEAN entry of 8 bits. Many I/O modules map a group of 8 channels in one UNSIGNED8 entry, for example 0x6000:01 for the inputs and 0x6200:01 for the outputs. Use the Bit column to bind one BOOL variable to one bit of such an entry.

  1. In CANopen item, select the UNSIGNED8, UNSIGNED16, UNSIGNED32 or UNSIGNED64 entry, for example 0x6200:01.
  2. In PLC variable, select a BOOL variable.
  3. In Bit, enter the bit offset. 0 is the least significant bit. The range is 0 to the width of the entry minus 1 (0 to 7 for UNSIGNED8).
  4. Repeat for the other bits of the entry. Save.

Rules:

  • Input: the value of the variable is (entry >> bit) & 1.
  • Output: the connector builds the entry from all variables that are mapped to bits of it, and sends bits that no variable maps as 0.
  • The Bit column is editable only for a BOOL variable on an unsigned integer entry. Empty: the variable takes the whole entry.
  • An output entry is mapped either whole or by bits, not both. One output bit is mapped once.

The connector uses only PDOs whose entries have a width of 8, 16, 32 or 64 bits. A PDO that maps an entry with another width, for example a 1-bit object such as 0x6000:01 of type BOOLEAN with 1 bit, cannot be used. The library that implements CANopen in the connector (gocanopen v2.1.1) cannot place such an entry in a PDO. It marks the whole PDO as invalid on both sides. The PDO then sends no frame and its values never update. The connector rejects these files so that you do not get a node whose PDO does nothing.

What you see:

  1. At import, the dialog lists a warning for each such entry. Example text: <file>: PDO 0x1A00 maps entry 0x6000:01 with 1 bits, which is not byte aligned. The file is imported, but a node that uses it is rejected. The file is still imported: the object dictionary is useful for the object dictionary browser and the SDO probe.
  2. When you add a node with this description, the save fails with: The connector accepts only byte-aligned PDO entries, so the device file of this node cannot be used.
  3. Only active PDOs count. A PDO that is disabled in the file (COB-ID bit 31 = 1) or has no mapped objects is not a problem.

How to fix it: use a DCF that maps the 8-bit objects.

  1. Open the vendor tool of the device (a CANopen configuration tool). Change the PDO mapping so that the PDO maps the 8-bit objects, for example 0x6000:01 (8 inputs in one byte) and 0x6200:01 (8 outputs in one byte). CiA 401 modules usually offer these objects.
  2. Write the new mapping to the device and keep it, for example with the “store parameters” function of the device (object 0x1010). The connector never writes PDO mapping to a device, so the device must run the mapping that the file describes. Unconfirmed: the exact procedure depends on the device. Check the manual of the vendor.
  3. Save the configuration from the tool as a DCF file.
  4. In the portal, select Import device files and import the DCF. Expected: Updated: 1 and no warning.
  5. Open Nodes and Mappings. A mapping to an entry that the new file does not have must be replaced: select the new entry, and use the Bit column for single channels.
  6. Save. Expected: no error. Deploy the runtime and check that the connector log shows NMT Start sent for the node.

Deploy the runtime as for any other connection. The device installs the canopen-connector process when the runtime has a CANopen connection, and the canopen-browsing-service process for Scan bus and the SDO probe. The connection is also part of the export and import of a project.