The sensor parameter can be a compound expression. Due to such parameters, you can create a wide variety of sensors which meet any needs and purposes. In the expression, you can use:
- parameters from the last message (adc1, in1, and so on);
- parameters from the previous message (they should be preceded by the sign #, for example, #adc1);
- bitwise control of a parameter (param199:3, and so on);
- sensor names (they should be indicated in square brackets, for example, [Fuel level]);
- constant parameters (const10, const-4.54, and so on);
- mathematical operation signs listed below.
Sign | Operation |
---|---|
+ | addition |
− | subtraction |
∗ | multiplication |
/ | division |
^ | exponentiation (for example, ^const2 denotes squaring, ^const0.5 denotes square rooting) |
( ) | parentheses of priority (for example, in the expression const1.5*(param1−#param1), the parentheses indicate that subtraction should be performed before multiplication) |
| | |
: | parameter conversion |
The parameters from the previous message are not available:
- for the Private mode sensor and its validator,
- for the Driver assignment sensor and its validator,
- for sensors in notifications,
- in tooltips for charts,
- during the retransmission of sensors.
Sensor values are calculated in the following order:
- calculating the expression in the Parameter field,
- conversion of the value according to the calculation table (if configured),
- validation (if configured).
Parameter of the sensor determining speed by coordinates
This section describes how to prepare a formula for the sensor parameter that allows you to determine the speed of a unit from its coordinates. A sensor with this parameter can be useful if the tracker does not send the speed value, but only the coordinates.
The ready formula is specified in the Parameter field of the sensor to be created. The sensor type should be Custom.
Below is an example of the ready formula for Vilnius, as well as the steps to apply the formula. The formula is based on the calculation of speed as distance divided by time.
(((lat-#lat)*const111.1365)^const2+((lon-#lon)*const64.3541)^const2)^const0.5/((time-#time)/const3600)
The steps to calculate the speed using this formula can be divided into 3 steps:
- Calculation of coefficients to convert latitude and longitude values into kilometers, taking into account the location of the unit.
- Calculation of distance using the Pythagoras’ theorem.
- Final calculation of speed using the data obtained in step 2.
Calculating coefficients for lat and lon values
Latitude (lat) and longitude (lon) values need to be converted from degrees to kilometers. To do this, you need to calculate the coefficients. The coefficient for the longitude value depends on the location.
- Latitude (lat). The distance covered by 1 degree of latitude differs slightly from north to south pole: from 110.579 kilometers at the equator to 111.694 kilometers at the poles. To simplify calculations we can use the average value: 110.579+111.694)/2=111.1365.
- Longitude (lon). The distance covered by 1 degree of longitude varies considerably from north to south pole: from 0 kilometers at the poles to 111.321 kilometers at the equator. This distance is calculated by the formula 111.321*cos(lat). Vilnius is located at latitude 54.6833 degrees (in decimal format), so we get: 111.321*cos(54.6833)=64.3541.
If you want to calculate the coefficient for another location, substitute its latitude into the formula without changing the other values.
You can also create a calculation table that automatically calculates the cosine value for different latitudes. In this case, the following formula will be used:
(((lat-#lat)*const111.1365)^const2+((lon-#lon)*const111.321*[Sensor for calculating the cosine of latitude])^const2)^const0.5/((time-#time)/const3600)
Calculating distance by Pythagoras' theorem
When calculating distance by Pythagoras' theorem, the following steps are performed:
- Calculating the difference between the latitude values from the current and previous message in kilometers, squaring it.
- Calculating the difference between the latitude values from the current message and the previous message in kilometers, squaring.
- Adding the two values together.
- Taking the square root of the sum to get the distance in kilometers.
Final speed calculation
To calculate the speed using the resulting distance value, the following steps are performed:
- Converting the time difference between the current message and the previous message from seconds to hours. To do this, it is necessary to divide the number of seconds by a coefficient of 3600.
- Dividing the distance by the obtained value.
Adding an ignition sensor to a formula (optional)
If an ignition sensor is configured for a unit, you can add a zero condition to the formula when the ignition is switched off. This will prevent taking into account the erroneous change of coordinates during parking. For this purpose, the expression can be specified in the following form:
(((lat-#lat)*const111.1365)^const2+((lon-#lon)*const64.3541)^const2)^const0.5/((time-#time)/const3600)*[Ignition sensor name]
Result
The resulting speed is expressed in kilometers per hour. This method shows the average speed required to travel from one point to another in the time between two messages, rather than the instantaneous speed as trackers do.
Parameter for determining relative engine hours
To obtain data on real engine hours, you should create two sensors:
- sensor of the coefficient of engine hours (determines the intensity of the equipment operation depending on engine revolutions);
- sensor of relative engine hours.
To create a sensor of the coefficient of engine hours, follow these steps:
- Click New.
- Enter the sensor name.
- Select the Custom sensor type.
- As the sensor parameter, specify the expression (param1+#param1)/const2, where param1 stands for the parameter which sends the value of engine revolutions. The parameter of the coefficient sensor is the arithmetic average of engine revolutions within the interval between two successive messages.
In the calculation table, enable the XY pairs option and configure them as follows:
X Y Explanation 500
0.33
One minute of operation at 500 rpm corresponds to 20 seconds of engine operation, which means that the coefficient is 0.33.
1000
0.67
One minute of operation at 1000 rpm corresponds to 40 seconds of engine operation, which means that the coefficient is 0.67.
1500
1
One minute of operation at 1500 rpm corresponds to 60 seconds of engine operation, which means that the coefficient is 1.
2000
1.5
One minute of operation at 2000 rpm corresponds to 90 seconds of engine operation, which means that the coefficient is 1.5.
- Click Generate.
Click ОК.
Next, create a sensor of the Relative engine hours type and specify the following parameter for it:
(time-#time)*[Coefficient sensor name]/const3600
This parameter is the time difference between two successive messages which is multiplied by the coefficient of operation intensity and divided by 3600. Division by 3600 is required to convert seconds to hours.
You can use such sensors in reports and counters, but not in online notifications, because they require parameters from the previous message.
Value availability check
The value availability check is used to avoid data loss when the equipment is replaced. To apply this operation, specify the required parameters in the Parameter field, separating them by a vertical bar (|). The system takes into account the first valid value from the specified parameters.
Example. The equipment installed on the unit during the first month sent data in the param1 parameter, and the equipment used since the second month sends the same data in the param2 parameter. To exclude the loss of data, when executing a report for two months you should specify param1|param2 in the Parameter field of the sensor properties. In this case, the system takes the value from the param1 parameter, and if it is invalid, from param2.
The values of other sensors can also be used in the format [Sensor name1]|[Sensor name2] instead of the parameter.