TwoPointFun
TwoPointFun (FUN)
TwoPointFun (FUN)FUNCTION TwoPointFun: REAL
Short description
Linear conversion of a numerical input value by a characteristic curve defined by two points.
Typical application: scaling of process raw values
Interfaces
Inputs
rIn_X
REAL
Analog value input
rX1
REAL
0
Point 1 of the input range
rY1
REAL
0
Point 1 of the output characteristic
rX2
REAL
100
Point 2 of the input range
rY2
REAL
100
Point 2 of the output characteristic
xMinMaxLimit
BOOL
Enable / disable limiting at the analog value output
iMinMaxOffset
INTEGER
Limit values at the analog value output
Outputs
TwoPointFun
REAL
Linear conversion of a numerical input value
xErr
BOOL
* FALSE: Conversion error-free * TRUE: Error during conversion process
Function description
Analog value output
The analog value output is calculated from the analog value input rIn_X depending on the linear characteristic defined by the two points P1(rX1/rY1) and P2(rX2/rY2). In the event of a conversion error (xErr = TRUE), the analog value output remains unchanged.
Formula
rOut_Y = (((rX1-rIn_X)*(rY2-rY1))/(rX1-rX2))+rY1
Restrictions
The analog value output is of the data type
REAL. Due to an unsuitable selection of the parameters rX1, rX2, rY1 and rY2 and the value of the analog value input rIn_X the limits of the data type may be exceeded.
Enable / disable the limits xMinMaxLimit
The limits of the analog value output can generally be enabled and disabled with this input.
xMinMaxLimit
Limits
Notes
FALSE
none
Analog value output without absolute limits
TRUE
Y_min and Y_max
Limiting of the analog value output active
Limit values iMinMaxOffset
The limits of the analog value output are only active if the input xMinMaxLimit is active (= TRUE). The limit values Y_min and Y_max are then calculated as follows:
Formulas
Y_min = rY1 - ((ABS(rY2-rY1))*iMinMaxOffset)/100 Y_max = rY2 + ((ABS(rY2-rY1))*iMinMaxOffset)/100
rY1
rY2
rY2 - rY1
iMinMaxOffset
Y_min
Y_max
Notes
0
100
100
0
0
100
Default limits
0
100
100
10
-10
110
Positive offset
0
100
100
-10
10
90
Negative offset
Digital output xErr
The digital output xErr signals an error during the conversion process. The following errors are taken into account:
rX1 AND rX2 = 0
rX1 = rX2
rY1 AND rY2 = 0
rY1 = rY2
Error during conversion process
xErr
Notes
FALSE
FALSE
Conversion error-free
TRUE
TRUE
Error during conversion process
Legend: X = any
Codesys
InOut:
Return
TwoPointFun
REAL
Input
rIn_X
REAL
Analog value input
Input
rX1
REAL
0
Point 1 of the input range
Input
rX2
REAL
100
Point 2 of the input range
Input
rY1
REAL
0
Point 1 of the output characteristic
Input
rY2
REAL
100
Point 2 of the output characteristic
Input
xMinMaxLimit
BOOL
Enable / disable limiting at the analog value output
Input
iMinMaxOffset
INT
Limit values at the analog value output
Output
xErr
BOOL
FALSE: Conversion error-free TRUE: Error during conversion process
Last updated

