Script examples

Script examples

Here are some script examples:

Script 1

This script is calculating a total counter value. Where the sensor 'CO' is the calculated sensor. The current value is calculated based on the value of the previous timestamp and the value of sensor 'BA' is added to that:

 

Script_Example_1.png

 

Script 2

In this script multiple sensors are calculated at once. Also script variables are calculated to be used in this script only, like 'Bread' and 'Maxbread'.

Script_Example_2.png

 

Script 3

This script is calculating a virtual sensor based on the actual value of other virtual sensors. Also a variable is used in this script. The outcome of this script is a status, depending on the value of the variable.

Script_Example_3.png

 

Script 4

In this script the duration is calculated from the Batch sensor value 3. if the calculated variable gives a value below 0, it should be zero, else should be the calculated duration divided by 60, because the format of the outcome of the 'duration' is always in seconds and we want to represent it in minutes.

Script_Example_4.png

 

Script 5

This script is calculating the speed of the line, based on the total counter. And the maximum speed is calculated on top of the speed, with an random value added between 50 and 75.

Script_Example_5.png

 

Script 6

In this script the number of produced products per shift is calculated. When a new shift starts, the counter per shift is reset to zero.

Script_Example_6.png

 

Script 7

This script takes two physical sensors and calculates two virtual sensors out of that with frequency at one per second.

V1[t] =  abs(S1[t]-S2[t])

V2[t] = (sqrt(800 + S1[t])) + 10

  

Script 8

This script counts the total value produced by adding the Carton counter value (Sensor S2) of the previous measurement (t-1) up to and including the current time (t), without evaluating the value of the Power sensor. This will be calculated every second. In the calculation of the second sensor, conditional counter, the value of the Power sensor S1 will be evaluated, whether it is equal to '1'. If it is, the total value produced by adding the Carton counter value (Sensor S2) of the previous measurement (t-1) up to and including current time (t). This will be calculated every second as well.

 

V1[t] = sum(S2[t-1,t])

V2[t] = sumif(S2[t-1,t], S1[t] == 1)

 

Script 9

This script counts the total value produced by adding up the input quantity (Sensor S1) of the previous measurement (t-1) up to and including current time (t). This will be calculated every second. The second calculation based on this outcome is calculating the sum over the Second quantity (Sensor V1) every 10 seconds. The time interval of the calculation is based on the frequency of the virtual sensor(s) which are the output of a script.

 

V1[t] = sum(S1[t-1,t])

V2[t] = sum(V1[t-1,t])

 

Script 10

This script calculates the average temperature as a virtual sensor, based on two physical temperature sensors in the machine. Both physical temperature sensors are measuring at a frequency of 1 second. The average temperature based on that is also calculated with the same frequency of 1 per second.

 

AverageTemperature[t] = (Temperature1[t] + Temperature2[t]) / 2

 

Script 11

This script calculates the production speed of the machine per minute as a virtual sensor, based on a physical cumulative counter sensor. Also calculates a virtual sensor for the threshold of the speed per minute, based on a physical sensor which indicates the type of product being produced. There is an extra calculation for the speed per minute to prevent the value dropping below 0 when the physical cumulative counter is reset by the machine operator, for example. All sensors are set at a frequency of 1 second.

 

Cartonslastminute[t] = Cartoncounter[t] - Cartoncounter[t-60]


if(Milkpercarton[t] == 2)
{
CartonThreshold[t] = 350
}
else
{
CartonThreshold[t] = 290
}

if(Cartonslastminute[t] < 2)
{
Cartonslastminute[t] = 0
}

 

    • Related Articles

    • Using the script editor

      Virtual sensors produce data based on scripts, made in the script editor. We recommend you first make your sensors in the normal way, before creating scripts. Scripts can then be accessed on the machine page in the Admin app. The drop down panel ...
    • The script language

      This article explains the script language. If you are looking for information about how to navigate around the script editor page, it is suggested you read Using the script editor and to take a look at the script examples and Essential knowledge for ...
    • What is a script?

      Scripts are simple computer programs which process and manipulate sensor data in real time. In the context of innius a script is a prerequisite for virtual sensors to produce real-time data. Scripts are associated with a specific machine, and may be ...
    • Essential knowledge for configuring scripts

      When making scripts, time [t] is a very important aspect. The following points should be taken into consideration: The timestore When referencing back to previous values (e.g. IN[t-1] for sensor IN), the script gets these values from a sensor's ...
    • How to configure a virtual sensor

      A virtual sensor acts like a physical sensor in the sense that it produces data, but is based on data from another sensor or sensors via a script. To create a new virtual sensor for your machine, you first need to define it. Do this in the Admin app ...