CHARCURVE

Provided by util.lib.

This function block serves to represent values, piece by piece, on a linear function:

../_images/fc4d86590674a1670a317f3441167f79

IN of the type INT is fed with the value to be manipulated. The BYTE N designates the number of points which defines the presentation function. This characteristic line is then generated in an ARRAY P[0..10] with P of the type POINT which is a structure based on two INT values (X and Y).

The output consists of OUT of the type INT, the manipulated value and BYTE ERR, which will indicate an error if necessary.

The points P[0]..P[N-1] in the ARRAY must be sorted according to their X values, otherwise ERR receives the value 1.

If the input IN is not between P[0].X and P[N-1].X, ERR=2 and OUT contains the corresponding limiting value P[0]. Y or P[N-1].Y.

If N lies outside of the allowed values which are between 2 and 11, then ERR=4.

Example in ST

First of all ARRAY P must be defined in the header:

VAR

CHARACTERISTIC_LINE:CHARCURVE;

KL:ARRAY[0..10] OF POINT:=(X:=0,Y:=0),(X:=250,Y:=50),

(X:=500,Y:=150),(X:=750,Y:=400),7((X:=1000,Y:=1000));

COUNTER:INT;

END_VAR

Then we supply CHARCURVE with for example a constantly increasing value:

COUNTER:=COUNTER+10;

CHARACTERISTIC_LINE(IN:=COUNTER,N:=5,P:=KL);

The subsequent tracing illustrates the effect:

../_images/cb4dcc000674a4530a317f342048bdca