I/O device

In addition to the Tc3_IotBase PLC library, the IoT MQTT Controller and IoT MQTT Device provide two I/O devices that can be used to establish an MQTT-based communication connection between two TwinCAT systems. Alternatively, an EK9160 IoT coupler can also be integrated into this type of communication.

I/O device 1:

The two device types can be added via the corresponding dialog in the TwinCAT I/O area and are located there within the Ethernet category.

I/O device 2:

For an IoT MQTT Device, symbol information for all configured variables in the process image is stored on the message broker in a specific topic as a Retain message.

An IoT MQTT controller then has the ability to scan this symbol information and create matching variables in its own process image. The EK9160 is automatically always an IoT MQTT Device.

I/O device 3:

Data format

The data format for this type of MQTT communication must be set to "Binary".

EK9160 configuration

The EK9160 is automatically configured as an IoT MQTT Device in the background as soon as the device is configured to connect to a message broker. As a prerequisite, "Binary" must be selected as the data format and retain messages must be activated.

The following screenshot shows the corresponding section of the EK9160 configuration web page.

I/O device 4:

All I/O terminals have been activated for the communication connection with the message broker.

The following screenshot shows an example of this process on the configuration interface.

I/O device 5:
I/O device 6:

TwinCAT as IoT MQTT Device

In addition to the EK9160, a TwinCAT system can also be configured as an IoT MQTT Device. In this case, the corresponding configuration steps must be carried out manually via the TwinCAT I/O area. The IoT MQTT Device then behaves in the same way as the EK9160.

Configuration in TwinCAT

In order for TwinCAT to be able to process the symbol information and process values from the EK9160, an IoT MQTT Controller must be created in the I/O area of TwinCAT and configured for the connection with the message broker. It is important that the fields Main Topic, Device and Stream match the configuration of the EK9160. The following screenshot illustrates this process.

I/O device 7:
I/O device 8:

Publishers and Subscribers can then be created below the IoT MQTT controller, depending on whether you want to scan the output or input terminals. Input terminals are operated via the Publisher and output terminals via the Subscriber.

I/O device 9:
I/O device 10:

Subsequently, the symbol information can be read out via a scan mechanism and corresponding input/output variables can be automatically created in the process image of the device.

I/O device 11:

Result (taking the subscriber as an example):

I/O device 12:

Further Information

After the configuration has been activated on the EK9160, three topics below the configured Main Topic are used on the message broker:

  1. The Symbol Topic contains the symbol information for the connected I/O terminals and is filled by the EK9160 after the communication connection with the message broker has been established.
  2. The Description Topic contains general status information about the device and is filled by the EK9160 after the communication connection with the message broker has been established.
  3. The Data Topic contains the pure process data of the connected I/O terminals. This topic is thus cyclically filled with data by the EK9160.

The following screenshot shows a section of the Mosquitto Message Broker in verbose mode, on which you can see the individual publishes of the EK9160 on the above-mentioned topics.

I/O device 13: