CHARCURVEΒΆ
This function block ( The library UTIL.Library\ \) serves to represent values, piece by piece, on a linear function:
Example in FBD\ \ \ \
IN of type INT is fed with the value to be manipulated.
N of type BYTE designates the number of points which defines the presentation function.
P of type ARRAY P[0..10] OF POINT, which is a structure based on two INT values (X and Y), determines this characteristic curve.
OUT of type INT contains the manipulated value.
ERR of type BYTE indicates an error.
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);
Illustration of the resulting curves: