Technical Introduction

There are two main use cases for the TwinCAT Analytics Library.

  1. The library is used by the automatic PLC code generation of the TwinCAT Analytics Workbench. All base algorithm of the Toolbox in the Analytics configurator are also available in the TwinCAT Analytics Library. The generated code can be downloaded to the Analytics Runtime, where it runs 24h 7 days a week parallel to the applications in the field.
  2. The library can be used also as standard PLC library on the target device in the field. In fact, it is not necessary to use the library always together with MQTT communication. You can take also just local variables and put them to the algorithm of the library. This you can see in the sample code of this document.

Where it works in the TwinCAT Analytics workflow is shown in the picture below.

Technical Introduction 1:

Princip and handling

The function blocks of the algorithm provide different methods. With the exception of a few algorithms, each function block has a configuration method. This method will be called first to configure the algorithm with e.g. thresholds or operators etc. An additional “SetChannelValue” method provide the specific input variable to the algorithm. The input value is not processed until the “Call” method has been invoked. Therefore every function block has a call method which starts finally the calculation. The results are outputs at the body of the function block.

Timestamps

The timestamps and timespans in a TwinCAT analytics system are based on the DC time used in EtherCAT. Timestamps are expressed in nanoseconds since 1.01.2000 UTC. They are represented in a unsigned 64 bit integer value. Timespans are represented in a signed 64 bit integer value. For a better visualization the algorithms provide function blocks in their outputs to store timestamps or timespans. For timespans the function block FB_ALY_DateTime is used. Timespans are stored in the function block FB_ALY_Timespan. By using this function blocks it is easy to calculate with or to provide them as strings for an HMI application.