SurfLinPLCopen motion icon

FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. block- Linear interpolation on a surface.

Inputs

X : REAL     X coordinate of the point to be interpolated.

Y : REAL     Y coordinate of the point to be interpolated.

XAxis : REAL[]     X coordinates of the known points of the X axis.

YAxis : REAL[]     Y coordinates of the known points of the Y axis.

ZVal : REAL[,]     Z coordinate of the points defined by the axis.

Outputs

Z : REAL      Interpolated Z value corresponding to the X,Y input point

OK : BOOL      TRUE if successful.

ERR : DINT      Error code if failed - 0 if OK.

Remarks

This function performs linear surface interpolation in between a list of points defined in XAxis and YAxis single dimension arrays. The output Z value is an interpolation of the Z values of the four rounding points defined in the axis. Z values of defined points are passed in the ZVal matrix (two dimension array).

ZVal dimensions must be understood as: ZVal [ iX , iY ]

Values in X and Y axis must be sorted from the smallest to the biggest. There must be at least two points defined in each axis. ZVal must fit the dimension of XAxis and YAxis arrays. For instance:

XAxis : ARRAY [0..2] of REAL;

YAxis : ARRAY [0.3] of REAL;

ZVal : ARRAY [0..2,0..3] of REAL;

In case the input point is outside the rectangle defined by XAxis and YAxis limits, the Z output is bound to the corresponding value and an error is reported.

The ERR output gives the cause of the error if the function fails:

Error Code Meaning

0

OK

1

Invalid dimension of input arrays

2

Invalid points for the X axis

3

Invalid points for the Y axis

4

X,Y point is out of the defined axis