TwoPoint (FB)

FUNCTION_BLOCK TwoPoint

Short Description

Linear conversion of a numerical input value by means of a characteristic curve defined by two points.


Portrayal

../_images/TwoPoint_FB.png

Interfaces

Inputs

Name

Datatyp

Range

Init-Value

Function

rIn_X REAL   0

Analog input

Outputs

Name

Datatyp

Range

Init-Value

Function

rOut_Y REAL    

Analog output

xErr BOOL    
FALSE:

Conversion successful

TRUE:

Conversion error

Setpoints / Parameters

Name

Datatyp

Range

Init-Value

Function

x1 REAL   0

Point 1 of the input range

y1 REAL   0

Point 1 of the output characteristic curve

x2 REAL   100

Point 2 of the input range

y2 REAL   100

Point 2 of the output charactersitic curve

xMinMaxLimit BOOL   FALSE

Enable / disable the limitation at the analog value output rOut_Y

iMinMaxOffset INTEGER   0

Analog value output of rOut_Y

Functional Description

Analog value output rOut_Y

The analog value output rOut_Y is calculated from the analog value input rIn_X as a function of the two points P1 (x1 /** y1**)
and P2 (x2 /** y2**) according to a linear characteristic curve. In the case of a conversion error (xErr = TRUE), the
Analog value output rOut_Y remains unchanged.
../_images/TwoPoint_Bild_1.png

Formula

rOut_Y = (((x1-rIn_X)*(y2-y1))/(x1-x2))+y1

Constraints

The analog value output rOut_Y is of the REAL data type. Due to an inappropriate selection of the parameters x1, x2, y1 and
y2 and the value of the analog value input rIn_X, the limits of the data type may be exceeded.

Releasing / blocking of the limits xMinMaxLimit

The limits of the analog value output rOut_Y can generally be released and blocked with this set-point / parameter.
xMinMaxLimit

Limits

Notes

FALSE

none

rOut_Y without absolute limits

TRUE

Y_min and Y_max

Limitation of the analog value output rOut_Y active

Value of the limit iMinMaxOffset

The limits of the analog value output are only active if the setpoint / parameter xMinMinMaxLimit is active (= TRUE).
The limit values Y_min and Y_max are then calculated as follows:

Formulas

Y_min = y1 - ((ABS(y2-y1))*iMinMaxOffset)/100
Y_max = y2 + ((ABS(y2-y1))*iMinMaxOffset)/100
y1 y2 y2 - y1 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

Negativ Offset

Digital output xErr

The digital output xErr is TRUE, when the conversion failed. The following errors are taken into consideration:

  • x1 = FALSE UND x2 = FALSE
  • x1 = x2
  • y1 = TRUE UND y2 = TRUE
  • y1 = y2

Conversion error

xErr

Notes

FALSE FALSE

Conversion successful

TRUE TRUE

Conversion error

Legend: X = any

Visualization




Information

Element

Authors

Date

Version

Note

Function

Adam Bartod 04.2016 1.0

Initial version

Programming

Adam Bartod 04.2016 1.0

Initial version

Test Alexander Halter, Jochen Reu 12.2016 1.0

Initial version

Documentation

Jochen Reu 10.2017 1.0

Initial version

Revision Lukas Pfänder 11.2017 0.1.3.0

Documentation

Codesys

InOut:
Scope Name Type Initial Comment
Input rIn_X REAL 0

Analog input

Output rOut_Y REAL  

Analog output

xErr BOOL  

Error Output: FALSE: conversion successful TRUE: conversion error

Input iMinMaxOffset INT 0

Analog value output of rOut_Y

xMinMaxLimit BOOL FALSE

Enable / disable the limitation at the analog value output rOut_Y

y2 REAL 100

Point 2 of the output charactersitic curve

x2 REAL 100

Point 2 of the input range

y1 REAL 0

Point 1 of the output characteristic curve

x1 REAL 0

Point 1 of the input range