Detailed example
The sample can be downloaded here: TF38x0_Extended_PLC_Sample.zip.
The ZIP contains a tszip archive (see PLC documentation, tszip) and a Beckhoff ML XML file (TrigonometryMLP.XML). Copy the XML file to the place defined in the PLC as the destination, or change the string to a different path.
The ML model description file contains an MLP with an input and an output, cf. XML tag <Configuration> with int64_numInputNeurons = 1
as well as the second (last) layer with int64_numNeurons = 1
. Two parameter tags exist, i.e. the file contains two MLPs that are trained differently but are identical in structure (<Configuration>). One of them is an MLP that was trained to approximate a sine function, while the other is an MLP that is intended to approximate a cosine function. In the <IODistributor> area it can be seen that one engine is reachable with the reference "sin_engine" and the other with the reference "cos_engine". Some metadata are stored in the <CustomAttributes> area, e.g. the name of the model, the version and the validity range of the input variables.
As in the quick start sample, a simple state machine is run through in the PLC source code. It differs from the quick start sample in the executability of the "Configure" state and the use of several engines.
The "Configure" state shows by way of example how flexibly you can handle the number of inputs and outputs and how you can read as much information as possible from the description file and put it to use directly in the PLC.
You can switch between the two engines manually in the online view by setting the EngineId to 0 or 1.