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
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.
In the device tree, right-click the controller and select the Add Device command.
The Add Device dialog opens.
Open the Miscellaneous group and select GPIO.
Confirm the selection by clicking on the Add Device button.
The GPIO connector is inserted below the controller.
Right-click the GPIO device and select the Add Device command.
The Add Device dialog opens.
Select a device and click the Add Device command to confirm the selection.
The device is inserted below the GPIO connector.
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
In the device tree, right-click the desired connector and select the Add Device command.
The Add Device dialog opens.
Select the <interface> Master device and click the Add Device command to confirm the selection.
The device is inserted below the connector.
Right-click the inserted master device and select the Add Device command.
Select the desired device and click the Add Device command to confirm the selection.
The device is inserted below the master connector.
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
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.
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.
Right-click the Modbus COM Port device and select the Add Device command.
Select the desired device and click the Add Device command to confirm the selection.
The device is inserted below the Modbus COM Port device.
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
TCP/UDP
TCP/IP and UDP/IP protocols can be implemented with the Net Base Services library.