We offer many ready-to-use apps, among them a serial-over-IP (SoI) app and Modbus Gateway app.
This tutorial demonstrates the options LTPS can be integrated with AggreGate platform. Understanding of the process implies some basic knowledge of the platform. For communication with a device, we will use a TPS-driver mentioned in the previous tutorials. As for the platform, its models and alarms will be required. Let's create an App based on a function block diagram (FBD) and an ST function. We need the program to analyze the LTPS movement. As soon as the movements are detected the data of the ambient light sensor undergo a further analysis. If the light is not bright enough, the LED will be turned on for additional lighting.
First, let's create a helper function for the data of the 3-axis accelerometer to be processed. A helper function will be written in ST language. It's time to create a code in ST with settings left default.
In the opened window, we create local variables.
VAR_INPUT newX, newY, newZ : DINT; END_VAR VAR_OUTPUT averregeVal : DINT; END_VAR VAR differences : ARRAY[0..4] OF DINT; summ : DINT; i : LINT; END_VAR
Now we can create functions for average (value) computing to reduce and eliminate random noise in the accelerometer output.
summ :=0; FOR i := 4 TO 1 BY 1 DO differences[i] := differences[i-1]; summ := summ + differences[i]; END_FOR; differences[0] := newX + newY + newZ; summ := summ + differences[0]; averregeVal := summ / 5;
Implementation of the program logic. General program will be created by building a function block diagram (FBD). When creating a code, the following properties must be set:
To implement the scheme, we will need a function block employing a previously created and imported function. As soon as the function block is added it requires function values to be set (see the screenshot below).
To create a scheme, it is necessary to add several "inputs" with the expressions written in ST language. Inside themselves, the functions use the Aggregate expression language. Let's drill down two types of the expressions from the scheme:
OBJECT_TO_DINT(cell({users.admin.devices.TPSAgent:s6_tibbit36} , "accelerationX" , 0 , FALSE))
//1 - ST function "OBJECT_TO_DINT"
//2 - AggreGate expression language "cell"
//cell paramiters:
//{users.admin.devices.TPSAgent:s6_tibbit36} - dataTable from context, "accelerationX" - field, 0 - row, FALSE - description.
OBJECT_TO_DINT(cell({users.admin.devices.TPSAgent:s4_tibbit28}, "illumination" , 0 , FALSE)) < 30
//1 - ST function "OBJECT_TO_DINT"
//2 - AggreGate expression language "cell"
//cell paramiters:
//{users.admin.devices.TPSAgent:s4_tibbit28} - dataTable from context, "illumination" - field, 0 - row, FALSE - description.
//3 - compare <.
Conditions mentioned in the scheme are implemented as jumps to the label (see blocks 7 and 9). The jump condition will be successfully done right after the Boolean expression is calculated in the "input".
It is necessary to create the model with a variable which controls alarms.
Finally, it's time to run the program. As soon as it detects a motion it will change the variable value in the model and trigger the alarm in AggreGate platform. If the lighting is not sufficient the program will turn on the LED.