Example: CiA 401 digital I/O module
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
This example connects one CANopen digital I/O module (device profile CiA 401) to a logiccloud runtime. At the end, one input bit of the module controls two output bits.
The screenshots show the simulated module SIM-DIO-401 at node id 5 on the virtual interface vcan0. A real CiA 401 module works the same way: only the device file, the interface name and the bit rate differ.
What you need
Section titled “What you need”| Item | Value in this example |
|---|---|
| Device | A device with logiccloud Control on Linux (amd64 or arm64), installed with linux-setup.sh --network host |
| CAN interface | can0 at 250 kbit/s (or vcan0 for a test without hardware) |
| CANopen module | CiA 401 module at node id 5, with heartbeat producer (object 0x1017 not 0) |
| Device file | The EDS file of the module. Its PDO mapping must map the 8 inputs as one byte (0x6000:01, UNSIGNED8) in TPDO 0x1A00 and the 8 outputs as one byte (0x6200:01, UNSIGNED8) in RPDO 0x1600. |
| Roles | Manage runtimes (lc_manage_runtimes) |
The node id and the bit rate of the module are set with the vendor tool or with switches on the module. logiccloud does not set them (no LSS).
1. Set up the host
Section titled “1. Set up the host”Follow Setting up the host for can0 with the bit rate 250000.
Check: ip -details link show can0 shows state UP and bitrate 250000.
For a test without hardware, create vcan0 as described in Virtual interface for tests.
2. Create the connection
Section titled “2. Create the connection”In the project tree, open the menu of the runtime, select Add connection, CANopen, Create new, and enter:
| Field | Value |
|---|---|
| Connection name | CANopen Connection 1 |
| CAN interface | can0 (or vcan0) |
| Bit rate | 250 kbit/s |
| SYNC period (µs, 0: no SYNC) | 0 |
| Heartbeat factor | 1.5 |
| Output cycle (ms) | 50 |
| Master node id | 126 |
Select Save.
Expected result: the connection appears under the runtime with the child nodes CANopen Connection 1 Mappings and CANopen Connection 1 Object dictionary.
3. Import the device file
Section titled “3. Import the device file”Select CANopen Connection 1 in the project tree. In the header of its tab, select the Import device files icon. Select Upload file, select the EDS file of the module, and select Import.
Expected result: Created: 1 (or Updated: 1 when the file was imported before), and no warning. A warning about an entry that is not byte aligned means that the file cannot be used for this example: see PDO entries that are not byte aligned.
4. Add the node
Section titled “4. Add the node”Two ways:
- By hand: select the Add node icon (green plus). Enter Node id
5, select the device in Device (from the imported device files), and select Add. Expected: CANopen node 5 added. - By scan (the runtime is deployed and the module is powered): select the Scan bus icon. Expected: a row with Node id 5 and Matched in Device description. Select the row and select Add selected.
Expected result: the connector tab shows the card 5: <device name>. Select it: the grid lists the two entries that you can map.

5. Declare the variables
Section titled “5. Declare the variables”In a global variable block of the project, declare one input and two outputs:
VAR_GLOBAL canIn3 : BOOL {IN}; canOut0 : BOOL {OUT}; canOut3 : BOOL {OUT};END_VARIn my_program, assign both outputs:
canOut0 := canIn3;canOut3 := NOT canIn3;The program must assign each output variable. A value that you write to an {OUT} variable in the debugger is currently not applied by the runtime (LC-4342).
Build the project. Expected: the three variables appear in the inputs and outputs of the configuration. If they do not, select Refresh in the inputs and outputs view. See Variables for the mapping.
6. Map the variables
Section titled “6. Map the variables”Open CANopen Connection 1 Mappings and add three rows with Add mapping:
| PLC variable | CANopen item | Bit |
|---|---|---|
canIn3 | node 5, 0x6000:01 | 3 |
canOut0 | node 5, 0x6200:01 | 0 |
canOut3 | node 5, 0x6200:01 | 3 |
The Direction follows from the entry. The Type shows BOOL, bit <n> of Unsigned8. Save with Ctrl+S (Cmd+S on macOS).

7. Deploy and check
Section titled “7. Deploy and check”- Build the project and deploy the runtime to the device.
- Open the log of the canopen-connector process on the device. Expected:
NMT Start sentfor node 5, with the vendor ID, product code and revision of the module. - Switch input 3 of the module on and off. Expected: output 0 follows the input, and output 3 shows the opposite value.
- For more detail, set the log level of the connector to Debug. It then logs once per second the values that it reads (
CANopen input PDO values) and writes (CANopen output PDO value). Set the level back to Info when you are done.
Optional check with the SDO probe: open CANopen Connection 1 Object dictionary, select node 5, and select Read in the row 0x1008 (device name) or 0x6000:01 (inputs). Last result shows the value. See Object dictionary and SDO probe.
If the node is not started or a value does not change, see Troubleshooting.