Entering mathematical expressions

Instead of writing the tag name, you can enter mathematical expressions. This way you can scale and offset the values read from the PLCs or create more complex data processing. These expressions can be entered either directly or through the dialog window.



In the equations you can use operators + – * / and common mathematical functions such as sin, cos, exp, etc  You can also do a binary comparison and much more. To get the complete list of options, call the Tag Dialog and click on the tab Equation.


Formatting and Limits #

  • Tag name is entered by the adr() function
  • Tag name can be also entered as an alias using the alias() function
  • You can use only supported functions and operators

The supported functions and operators are listed under the input box and are broken down into five groups: Oper, Func, Trig, Vers, and Const – they will be inserted into the box if selected.

You can use multiple tags in an expression.

Example: #

  1. We read a value from Modbus H:0
  2. Let’s scale this value by 10 and offset it by 0.5
  3. Formula to enter is: =10*adr(H:0)+0.5

Supported Functions and Operators: #




Standard Operators



addition and unary positive

– r –

Substract and negative

subtraction and negation








modulus and percentage of a value









converts values to radians

Bitwise Operators



btise and



bitwise or



bitwise xor



bitwise not



bitwise left shift



bitwise right shift

Comparison Operators






not equal


less than


greater than

<= or ≤


greater than or equal

>= or ≥


greater than or equal

Logical Operators

&& or _


logical and

|| or _


logical or

! or ¬


logical not

Degree operator °

The degree operator (°) is very useful when converting user input. Because all of the trigonometric functions require their parameters to be in radians, the degree operator will convert its operand into radians. Thus, 45° is equivalent to dtor(45).

Percentage sign %

When the percent sign is interpreted as the modulo, then:

10 % 3 … evaluates to 1 (the remainder after 10 is divided by 3); however, if you flip the switch to make the % sign stand for percentage, then it becomes:

250 + 10%

By default, the percentage sign % is usually shorthand for „/100“. In other words, 42% becomes 42/100 or 0.42.

However, if the % term on the right-hand side of subtraction or addition (such as in „250 + 10%“), then the percent is evaluated as a percentage of the left-hand side (i.e. „250 plus 10% of 250“).

If you choose to interpret the percent sign as the modulo operator, you can still request a percentage by using the function name directly:

(10 % 3) + percent (50) = 1.5

Factorial and Logical Not (!)

Differentiating between factorial (!) and logical NOT (!) is more difficult.

Logical NOT is interpreted as factorial (!) only if:

  • it is the first token
  • it is preceded by a binary operator
  • it is preceded by a right associative unary operator

Otherwise (!) is always treated as factorial and the negating token ¬ as logical NOT.


Supported Functions #

Functions using more than one parameter: #

  • sum() – returns a sum of the passed parameters
  • count() – returns the number of passed parameters
  • min() – returns the minimum of the passed parameters
  • max() – returns the maximum of the passed parameters
  • median() – returns the median of the passed parameters
  • stddev() – returns the standard deviation of the passed parameters
  • average() – returns the average of the passed parameters
  • random() – returns a random integer. Can take 0, 1, or 2 parameters. The first parameter (if given) is the lower bound of the random integer. The second parameter (if given) is the upper bound of the random integer.
  • nthroot() – returns the nth root of a number; for example, nthroot(27,3) returns the cube root of 27, or 3.

Functions using one parameter: #

  • sqrt() – returns the square root of the passed parameter
  • log() – returns the base 10 log of the passed parameter
  • ln() – returns the base e log of the passed parameter
  • log2() – returns the base 2 log of the passed parameter
  • exp() – returns e raised to the power of the passed parameter
  • ceil() – returns the passed parameter rounded up
  • floor() – returns the passed parameter rounded down

Trigonometric functions: #

  • sin(), cos(), tan()
  • inverses (asin, acos, atan)
  • reciprocals (csc, sec, cotan)
  • reciprocals of the inverses (acsc, asec, acotan)
  • hyperbolic variations (sinh, cosh, tanh, asinh, acosh, atanh, csch, sech, cotanh, acsch, asech, acotanh)
  • versine functions (versin, vercosin, coversin, covercosin, haversin, havercosin, hacoversin, hacovercosin, exsec, excsc, crd)
  • dtor() – converts the passed parameter from degrees to radians
  • rtod() – converts the passed parameter from radians to degrees

Functions using no parameters („constant functions“): #

  • phi() – returns the value of ϕ (the Golden Ratio), also recognized as ϕ()
  • pi() – returns the value of π. Also recognized as π()
  • pi_2() – returns the value of π/2
  • pi_4() – returns the value of π/4
  • tau() – returns the value of τ. Also recognized as τ()
  • sqrt2() – returns the value of the square root of 2
  • e() – returns the value of e
  • log2e() – returns the value of the log base 2 of e
  • log10e() – returns the value of the log base 10 of e
  • ln2() – returns the value of the log base e of 2
  • ln10() – returns the value of the log base e of 10

The parentheses are used for grouping sub-expressions and setting the order of execution, and they can be nested to any depth. All computation is carried out with a double precision floating point. In the case of error, the editor shows a warning, and the error expressions will not be evaluated.

You can always check the validity of the entered expression Clicking on the Test button.


Click on OK after completion to see the expression in the Tag(Address) field.

Examples of valid expressions: #

  • adr(N100:0)*adr(F30:10)
  • sin(adr(N100:0))+cos(adr(F30:10))
  • median(adr(N100:0),adr(F30:10),adr(N20:5),adr(F10:10))
  • Note: Multiple arguments should be separated with commas 2>=1. Logical operations always return binary result (0 or 1).