Examples

This chapter deals with exemplary use cases for the TwinCAT JSON Data Interface. Example calls for all available commands can be found in the API description.

Easy access from other operating systems

The JSON Data Interface represents a simple way of accessing the symbols of a TwinCAT system from other operating systems. Two communication channels are available for this purpose. On the one hand, as in the application idea below, both the client application and the JSON Data Interface can be connected to the same message broker.

Examples 1:

It is freely selectable on which of the two systems the message broker runs or whether it even runs on a third system. There is no technical difference here, there just has to be a connection from both sides to the same broker.

On the other hand, ADS communication can also be used on other operating systems. An ADS router is always required for ADS communication on a system. On other operating systems, however, this ADS router can also be replaced by a standalone router with reduced functionality, which is provided by TwinCAT ADS .NET V5.

Two communication types in one application

The JSON Data Interface is also suitable for mapping two types of communication in an application. Another component such as the TwinCAT MQTT Client (TF6701) can be used for cyclic communication. Here, previously selected variables are then cyclically communicated to the user application via MQTT.

Examples 2:

The user application then decides which scenarios to react to and how. If cyclic communication detects that more information is needed, the read commands of the JSON Data Interface can be used to query variables that are not communicated cyclically to the user application. On the other hand, if it is recognized that certain parameters need to be affected, the write commands of the JSON Data Interface can be used.

Simple retrofitting of existing projects

The JSON Data Interface is available with TwinCAT version 3.1.4024.11 or higher. The following section only refers to TwinCAT systems with this or newer TwinCAT versions.

Direct access to the JSON Data Interface via ADS is recommended if no intervention in the TwinCAT system is possible or if this is not desired. Access via MQTT, on the other hand, offers more communication options, but requires adjustments on the target system. These adjustments are the editing of StaticRoutes.xml and a TwinCAT context change.