CANopen
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
With a CANopen connection, the logiccloud runtime exchanges process data with CANopen devices, for example I/O modules (CiA 401), drives (CiA 402) and sensors. logiccloud is the CANopen master of the bus. The connection runs as the canopen-connector process on the device and reaches the bus through a SocketCAN interface of the device, for example can0.
The CANopen documentation has these parts:
- Creating a CANopen connection (this page).
- Setting up the host: CAN interface, bit rate, link up at boot, per package type.
- Devices and mapping: EDS and DCF import, nodes, bus scan, mapping, and PDO entries that are not byte aligned.
- Object dictionary and SDO probe: read and write one object of a live node.
- Troubleshooting: log lines and common problems.
How it works
Section titled “How it works”- The connector sends NMT Start to every configured node and exchanges process data by PDO. The PDO mapping comes from the EDS or DCF file of the device, as it is. The connector never writes PDO mapping or communication parameters to a device.
- A PLC variable maps to one PDO entry of a node. Inputs are entries of a device TPDO (device to PLC). Outputs are entries of a device RPDO (PLC to device).
- Start-up checks, the bus scan and the SDO probe use SDO. Variable values never use SDO.
- The connector sends every output PDO cyclically, every Output cycle (ms), changed or not.
Prerequisites
Section titled “Prerequisites”- A device with logiccloud Control on Linux, 64-bit: amd64 or arm64. The connector is not offered for other platforms.
- A CAN adapter with a SocketCAN driver in the Linux kernel, set up as described in Setting up the host. The host sets the bit rate. The connector only checks it.
- CANopen appears under Add connection only when it is enabled for your logiccloud installation. Existing CANopen connections stay visible and editable.
- Every node has a node id and the bit rate of the bus set before you connect it (see Limits).
- The EDS or DCF file of every device. Take the files from the device vendor.
- The role Manage runtimes (
lc_manage_runtimes) to create, change or scan. The role View runtimes (lc_view_runtimes) is enough to read objects.
Creating a CANopen connection
Section titled “Creating a CANopen connection”-
In the project tree, open the menu of the runtime and select Add connection. Select CANopen, then Create new. Alternative: open CANopen in the connections tree and select Add CANopen connection.
-
Enter these values:
Field Meaning Default and limits Connection name Name of the connection, unique in the runtime required Connection description Free text optional CAN interface SocketCAN interface name on the device, for example can0at most 15 characters, no /,:or spacesBit rate Bit rate of the bus in kbit/s. The connector compares it with the interface and does not set it. 10, 20, 50, 125, 250, 500, 800 or 1000. Default 250. SYNC period (µs, 0: no SYNC) Period of the SYNC message that the master sends. 0 sends no SYNC. integer, 0 or more. Default 0. Heartbeat factor The connector reports a node as lost when no heartbeat arrives for this factor times the heartbeat producer time of the node (object 0x1017). A number of 1.0 or more. Default 1.5. Output cycle (ms) Period at which the master sends every output PDO 1 to 65535. Default 50. Master node id Node id of the local node of the master. It produces SYNC and sends its heartbeat on 0x700 + id. Use an id that no node uses.1 to 126. Default 126. -
Select Save.
Expected result: the connection appears under CANopen in the project tree, with the child nodes <connection name> Mappings and <connection name> Object dictionary.
One connection uses one CAN interface. A runtime can have several connections, each on its own interface. Two connections cannot use the same interface.
Next, add the devices: see Devices and mapping.
Start-up and supervision
Section titled “Start-up and supervision”When the runtime starts, the connector does these steps for each connection:
- It checks the interface: it exists, it is UP and it runs at the configured bit rate (a deviation of 1 % is accepted). A virtual
vcaninterface needs no bit rate. When the check fails, the log line names the command that you run on the host, and the connector tries again after 1 s, doubling the wait up to 30 s. - It opens the interface and starts the master (SYNC and heartbeat on the master node id).
- For each node: it reads the identity (object 0x1018, sub-indexes 1 to 4) by SDO and compares vendor ID, product code and revision with the device description. On a mismatch it does not start this node and logs one line with both identities. The other nodes start.
- It sends NMT Start to the node. The node goes to Operational.
While it runs:
- When a node sends a boot-up message, or its heartbeat returns after a timeout, the connector sends NMT Start again. Measured on an in-process bus: a restarted node delivers values again after 66 ms. The limit of the requirement is 5 s.
- A node that does not answer at start-up is tried again every 10 s.
- The connector logs EMCY messages of the nodes with the error code, the error register and the CiA 301 description.
- A node without a heartbeat producer (object 0x1017 missing or 0) is started, but the connector cannot detect that it stops or restarts. The connector logs a warning.
When the runtime stops, the connector sets all outputs to 0, waits one output cycle (at most 2 s) so that the PDOs leave, and sends NMT Enter Pre-Operational to every configured node.
Limits
Section titled “Limits”- No LSS (CiA 305). Set the node id and the bit rate of a device with its vendor tool before you connect it.
- No PDO editor. The connector uses the PDO mapping of the EDS or DCF file and never writes PDO configuration to a device. The device must really use the mapping that the file describes.
- Variables only on PDO entries. An entry that no active PDO maps cannot be mapped to a variable. Use the SDO probe to read or write other objects.
- Outputs are cyclic. The master sends every output PDO every Output cycle (ms), not on change.
- Node ids 1 to 126. Node id 127 is not supported.
- Byte-aligned PDO entries. An active PDO that contains an entry with a width that is not a multiple of 8 bits cannot be used. See PDO entries that are not byte aligned.
- Data types: BOOL (see the Bit column), SINT, INT, DINT, LINT, USINT, UINT, UDINT, ULINT, REAL and LREAL. Strings and structures cannot be mapped.
- Not supported: CAN FD, 29-bit identifiers, CANopen slave mode, CANopen Safety, firmware download, several masters on one bus.
- One master per interface: the connector and the bus scan of the portal never use one interface at the same time. See Devices and mapping.
- No cloud vPLC and no Kubernetes vPLC: they have no CAN interface.
- No live node state (NMT state, heartbeat, EMCY) in the portal. Read the connector log.
- No authentication: CANopen has none. Everyone with access to the bus can write to the devices.
- Tested on:
vcanand an in-process bus. A test on real CAN hardware is not done yet.