Skip to main content

Linking Your Own I/Os

With this functionality, local I/Os can be connected to a controller and used from the IEC application.

Linking peripheral devices

. CODESYS supports the linking of any number of peripheral devices via the following interfaces:
  • GPIOs

  • I²C

  • SPI

  • 1-Wire

  • CAN

  • Ethernet-based communication

  • Socket-based communication (TCP, UDP, Unix domain sockets)

  • Any other peripherals via glue code

Linking a new peripheral

GPIOs

Extension API

GPIOs can be linked via the extension API.

For more information, see the following: Linking Your Own I/Os

Device description and IEC library

In Linux, GPIOs can be accessed via the command line. The device descriptions and libraries required for this are provided by CODESYS.

Procedure. Adding a GPIO device:
  1. In the device tree, right-click the controller and select the Add Device command.

    The Add Device dialog opens.

  2. Open the Miscellaneous group and select GPIO.

  3. Confirm the selection by clicking on the Add Device button.

    The GPIO connector is inserted below the controller.

  4. Right-click the GPIO device and select the Add Device command.

    The Add Device dialog opens.

  5. Select a device and click the Add Device command to confirm the selection.

    The device is inserted below the GPIO connector.

  6. Configure the devices

For more information about controlling via the command line, see the Linux Kernel Archive.

Raspberry Pi GPIOs

The GPIOs are already integrated into the device descriptions of the supported Raspberry Pi models.

For more information, see the following: Examples: GPIO

I²C, SPI, and 1-Wire

Extension API

I²C, SPI, and 1-Wire can be linked via the extension API.

For instructions, see the following chapter: Linking Your Own I/Os.

Device repository

Procedure. Adding I²C, SPI, and 1-Wire devices via the device repository:
  1. In the device tree, right-click the desired connector and select the Add Device command.

    The Add Device dialog opens.

  2. Select the <interface> Master device and click the Add Device command to confirm the selection.

    The device is inserted below the connector.

  3. Right-click the inserted master device and select the Add Device command.

  4. Select the desired device and click the Add Device command to confirm the selection.

    The device is inserted below the master connector.

  5. Configure the devices

Tip

If the desired devices are not available in the Add Device dialog, then you need to install these devices via the device repository.

If a device description with the desired inputs and outputs is not yet available, then you can also adapt an existing device description. For instructions, see the following chapter: Linking Your Own I/Os.

RS-232 and RS-485

ModBusRTU

Procedure. Adding RS-232 and RS-485 via ModBusRTU:
  1. In the device tree, right-click the controller (for example, CODESYS Control​ for Linux) and select the Add Device command.

    The Add Device dialog opens.

  2. In the Fieldbuses group under Modbus, select the Modbus COM Port device and click the Attach device command to confirm the selection.

    The device is inserted below the controller.

  3. Right-click the Modbus COM Port device and select the Add Device command.

  4. Select the desired device and click the Add Device command to confirm the selection.

    The device is inserted below the Modbus COM Port device.

  5. Configure the devices

For more information about ModBusRTU, see the following: CODESYS Modbus.

Custom protocol

Custom protocols can be implemented using the CAA Serial Com or SysCom libraries.

For more information, see also the example Serial COM.

CAN and Ethernet-based protocols

. General information about CAN and Ethernet-based protocols:

TCP/UDP

TCP/IP and UDP/IP protocols can be implemented with the Net Base Services library.