26 - 09 - 2017

Mathematical library

Block ExpressionOneIn

This block is very powerful for mathematical operations. It has a parameter Expression,which connect mathematecaly the output Y with input X. It is important the input X to be presented in expression. Examples for expression:

3.14*X

((2+X)*10)/2.5

The expression can include the existing in application functions. For example:

3*(sin(x)+log(2*x))

Some of the functions have more than one parameters. The function Equal has four parameters:

Equal(X1;X2;Res1;Res2)

It compares paramaters X1 and X2 and in case they are equal, the function will return result Res1, in other case will return Res2;

 

The list of existing functions is:

  • positive(X) - returns the absolute value of the argument;
  • over(X;Limit) - in case X is under Limit, the result is 0.0, else the result is X-Limit;
  • Round(X;RoundFactor) - rounds the value of X to RoundFactor sign after decimal separator;
  • Equal(X1;X2;Res1;Res2) - compares X1 and X2, if they are equal, the result is Res1, else Res2;
  • Min(X1;X2) - returns the smallest value of X1 and X2;
  • Max(X1;X2) - returns the greater value of X1 and X2;
  • IsZero(X;Res1;Res2) - if X is zero, the result is Res1, else Res2;
  • Rem(X;Y) - returns remaining of division X/Y. For example: 200.0/300.0, Remaining is 200.0;
  • acos(X) - arccosine of X;
  • asin(X) - arcsine of X;
  • atan(X) - arctangent of X;
  • cos(X) - cosine of X;
  • cosh(X) - hyperbolic cosine  of X;
  • exp(X) - exponential function of X;
  • fabs(X) - absolute value of X;
  • log(X) - natural logarithm of X;
  • log10(X) - Calculate base-10 logarithm of X;
  • sin(X) - sine of X;
  • sinh(X) - hyperbolic sine of X;
  • sqrt(X) - Find square root of X;
  • tan(X) - tangent of X;
  • tanh(X) - hyperbolic tangent of X;

Block ExpressionUni

In case the user needs more Expression blocks, then ExpressionUni is suitable. Every output Y1 .. Y8 has independent expression, which is presented as parameter ExpressionY1 .. ExpressionY8.  The other trick here is that every output can be related with one or more inputs. For example, if parameter ExpressionY1, which correspond to output Y1 has a string X1+2*X2+sin(X3), then the output Y1 is related to inputs X1, X2, X3.

The block has parameter InOut, which opens GPIO interface and allows some inputs and outputs to be hiden. The supported mathematical functions are the same as in the block ExpressionOneIn and are described above.

Parameters:

  •  ExpressionY1 .. ExpressionY8 - one expression for each output;
  • InOut - GPIO interface to hide and show inputs and outputs. The type of In/Out from analog to digital can't be changed;

 

Block AverageVal

The output Y of the block returns the average value of last few inputs X values of the block. The parameter QueueSize determines the average value of how many values of input X to be calculated. For example, if the parameter QueueSize is 3 and last 3 values of input X were: 3.0, 3.4, 3.8, then the output Y will be (3.0+3.4+3.8)/3 = 3.4.

The block is suitable for filtering signals with noise. The QueueSize can be up to 200 values.

If the input Process is connected, then passing in a high level, the current value of the inputs X will be added to the queue of values on which the block will calculate the average. 

 

Block Approximation

The block is suitable for converting non-linear relationship between input and output signals. Parameter Setings opens interface where to introduce the correlation table. If the user needs to convert several signals through the same table, then Number of approximations in settings interface has to be set. The example is a relation between distance and output voltage of sensor: Sharp GP2Y0A21YK0F 10-80 sm.