Skip to content

Latest commit

 

History

History
197 lines (121 loc) · 11.6 KB

File metadata and controls

197 lines (121 loc) · 11.6 KB

I/O Component Example

Table of contents

Introduction

Industrial automation devices like PLCs usually communicate with other devices using standard automation communication protocols, often referred to as "fieldbus" protocols. These protocols can either re-use common OSI layers (e.g. Modbus/TCP communicates over TCP/IP networks), or they can be completely proprietary protocols (e.g. Axioline on Phoenix Contact's AXC controllers).

PLCnext Control devices implement communication protocols using "I/O Components", which are a special type of ACF Component. These components are used to exchange input and output (I/O) data between devices. PLCnext Control devices already include a number of I/O Components, e.g. for Profinet, Profibus, Modbus/TCP, Ethernet/IP, Axioline, and Interbus protocols. PLCnext Store apps (e.g Ethercat) can also include I/O Components. If your PLCnext Control device needs to communicate using a custom industrial automation protocol, then you will probably need to develop an I/O Component for that protocol.

In this example, a simple I/O Component is created and deployed. A second ACF component is then used to demonstrate the operation of the I/O component.

Guide details

Description Value
Created 27.04.2026
Last modified 27.04.2026
Controller AXC F 1252
FW 2026.0
SDK 2026.0
PLCnext Technology Toolchain 2026.0

References

Coming soon: The PLCnext Technology Info Center will give a detailed description of I/O Components, including:

  • How I/O Components use the IoThread class to ensure correct scheduling within the PLCnext phase model.
  • How I/O Components use the Global Data Space (GDS).
  • Tips for selecting a suitable priority and CPU affinity for an I/O Component.
  • The Technology Independent Configuration (TIC) standard for defining I/O metadata.
  • How TIC files for a custom fieldbus can be generated from a PLCnext Engineer project.

Prerequisites for this example

  • AXC F 1252 controller with firmware 2026.0 or later.

  • PLCnext Technology Toolchain, version 2026.0, on either Windows or Linux.

  • A Software Development Kit (SDK) for the AXC F 1252 PLCnext Control device, version 2026.0.

Quick-start example

It is assumed that the user has some experience building C++ Components and Programs for PLCnext Control devices.

In addition to the required .acf.config file, this example uses the following types of configuration files:

  1. A .settings file. For an I/O Component, this file should be used to:

    • Set the priority and the CPU affinity for the component.
    • Provide the location of the project-specific I/O configuration.
  2. A links.xml file and a .tic file. These types of files use the Technology Independent Configuration (TIC) standard to describe the properties of the I/O, including meta data (e.g. data type) for each I/O point. These files are usually generated by engineering software like PLCnext Engineer, which allows the I/O to be configured in a more user-friendly way. For this example, raw XML files will simply be copied to the PLCnext Control device.

Examples of these configuration files are provided in this repository.

Procedure:

  1. Clone this repository, e.g.

    git clone https://github.com/PLCnext/CppExamples.git
  2. Create and build a new fieldbus project using PLCnext Technology CLI tool, using the following commands:

    plcncli new fieldbusproject --name DemoFieldbus
    cd DemoFieldbus
    plcncli set target --name AXCF1252 --version 2026.0 --add
    plcncli generate code
    plcncli build
    

    Currently, it's not possible to create this type of project in Eclipse or Visual Studio.

  3. Deploy the fieldbus project to the PLCnext Control device.

    This type of project can be packaged as a PLCnext Technology Extension app and distributed either privately (for installation via WBM) or through the PLCnext Store.

    For testing purposes, the required files can be manually copied to the PLCnext Control device:

    • Copy the file Examples/IoComponentExample/config/DemoFieldbus.acf.config from this repository to the directory /opt/plcnext/projects/Default. This file specifies the location of the .so file and the .acf.settings file.
    • Copy the file Examples/IoComponentExample/config/DemoFieldbus.settings from this repository to the directory /opt/plcnext/projects/DemoFieldbus. This file specifies the location of the TIC files.
    • Copy the file libDemoFieldbus.so from your DemoFieldbus project to the directory /opt/plcnext/projects/DemoFieldbus
  4. Configure the I/O meta data for the application.

    This would normally be done using a software tool like PLCnext Engineer, but in this case:

    • Copy the files Examples/IoComponentExample/config/device.tic and links.xml from this repository to the directory /opt/plcnext/projects/PCWE/Io/DemoFieldbus

    NOTE: Modifying the contents of the PCWE directory in this way will cause the project integrity check to fail. The impact of this check can be mitigated by setting the "Integrity check mode" in WBM to either "Warning" or "Disabled".

    NOTE: These files will be deleted the next time a PLCnext Engineer project is sent to the PLCnext Control device.

  5. Restart the PLCnext Runtime.

  6. Check the contents of the file /opt/plcnext/logs/Arp.log. It should contain messages showing that Demo.Fieldbus.Library was loaded, and the component Demo.Fieldbus was created.

The Demo.Fieldbus component is now exchanging data with the "field" using the I/O points defined in the TIC files. In this case the custom I/O protocol is implemented in the UpdateH2F() and UpdateF2H() methods in the file DataExchange.cpp, which exchange data with Global Data Space (GDS) variables in the PLCnext Control device.

Further demonstration

After restarting the PLCnext Runtime, the operation of the I/O Component is not immediately apparent. The following steps can be used to demonstrate the operation of the I/O Component.

This procedure creates an ACF Component that has two GDS ports, one IN port and one OUT port, corresponding to the two GDS ports that are created by the I/O Component. There are a number of ways that such a component could be created, but this method uses the PLCnext CLI that end-users can also use to create ACF components.

After the two components have been created by the PLCnext Runtime - the I/O component, and this ACF Component - the GDS ports on the two components are connected. These port connections are defined in a .gds.config file.

Finally, the GDS ports on the ACF component are marked with the "Opc" attribute. Variables with this attribute can be accessed by OPC UA Clients like UaExpert from Unified Automation. The OPC UA Server must be configured for a specific project using a .opcua.config file in the project directory on the device.

Perform the following steps:

  1. Create a new ACF project.

    plcncli new acfproject --name IoShim
    cd IoShim
    plcncli set target --name AXCF1252 --version 2026.0 --add
    
  2. Edit the file IoShimComponent.hpp.

    Add two GDS ports to the component:

    //#port
    //#attributes(Input|Opc)
    Arp::uint32 InputData;
    
    //#port
    //#attributes(Output|Opc)
    Arp::uint32 OutputData;
    

    Both ports are marked with the Opc attribute, so they will be visible to OPC UA Clients.

  3. Save the component .hpp file, generate supporting files, and build the project.

    plcncli generate code
    plcncli build
    
  4. Copy the resulting library and ACF configuration file to the device.

    • Copy the file Examples/IoComponentExample/config/IoShim.acf.config from this repository to the directory /opt/plcnext/projects/Default. This file specifies the location of the .so file.
    • Copy the file libIoShim.so from your IoShim project to the directory /opt/plcnext/projects/IoShim/lib
  5. Create the Global Data Space (GDS) port connections between the DemoFieldbus ports and the IoShim component ports.

    This would normally be done using a software tool like PLCnext Engineer, but in this case:

    • Copy the file Examples/IoComponentExample/config/IoShim.gds.config from this repository to the directory /opt/plcnext/projects/PCWE/Plc/Gds

    NOTE: This file will be deleted the next time a PLCnext Engineer project is sent to the PLCnext Control device.

  6. Configure the OPC UA server on the device.

    This would normally be done using a software tool like PLCnext Engineer, but in this case:

    • Copy the file Examples/IoComponentExample/config/PCWE.opcua.config from this repository to the directory /opt/plcnext/projects/PCWE/Services/OpcUA

    NOTE: This file will be deleted the next time a PLCnext Engineer project is sent to the PLCnext Control device.

  7. Restart the PLCnext Runtime.

  8. In UaExpert, connect to the OPC UA server on the device and add the two variables from the IoShim Component to the Data Access View.

  9. Change the value of the OutputData variable.

    The new value is passed from the IoShim Component to the I/O Component through the GDS port connection.

    The I/O Component "writes" this output value to the fieldbus, and then "reads" the input value from the fieldbus. In this example the I/O Component simply copies the output value to the input value, in lieu of a physical I/O device.

    The new input value is passed from the I/O Component to the IoShim Component through the GDS port connection.

    In UaExpert, the new value of the InputData variable appears.

Explore unlimited possibilities

Using the information in this example, it is possible to extend applications that do not use PLCnext Engineer to include custom I/O capability. In that case, you will probably need to develop a custom engineering tool to make TIC file configuration easier for users of your application.