Linear interpolation of discrete REAL values
This function performs scaling (linearization) of a real number data table and renders the output (Y) for an input value (X).
Input
Input value X
Apply the first element of the user-defined DUT, i.e. the number of xy values, to this input. See description of DUT structure below.
Output
Output value Y
Instead of using this F instruction, we recommend using the corresponding FP7 instruction: FP_SCALE
For a detailed description, refer to the instructions: F282_SCAL andF283_DSCAL.
if the specified address using the index modifier exceeds a limit.
if a non-real number value is input into 'x'.
if the number of values (first element of the DUT) < 2 or > 99.
if a non- real number value is specified to be the real numerical value (xt, yt) specified in 'xy_data'.
if the linear table of 'xy_data' is not registered in ascending order of the x-sequence.
if the linear table of 'xy_data' exceeds the area.
if an overflow (operation is unable) occurs during the scaling operation.
if the specified address using the index modifier exceeds a limit.
if a non-real number value is input into 'x'.
if the number of values (first element of the DUT) < 2 or > 99.
if a non- real number value is specified to be the real numerical value (xt, yt) specified in 'xy_data'.
if the linear table of 'xy_data' is not registered in ascending order of the x-sequence.
if the linear table of 'xy_data' exceeds the area.
if an overflow (operation is unable) occurs during the scaling operation.
The Data Unit Type is created in the DUT Pool.
All input and output variables used for programming this function have been declared in the POU header.
The same POU header is used for all programming languages.
VAR
CalculateY: BOOL:=FALSE;
X_value: REAL:=4.0;
Y_value: REAL:=0.0;
XY_values: XY_DUT;
@'': @'';
END_VAR
VAR_EXTERNAL
ProcessData: ProcessDataStructure;
END_VAR
VAR
@'': @'';
END_VAR
When the variable CalculateY is set to TRUE, the function is carried out.
BODY
WORKSPACE
NETWORK_LIST_TYPE := NWTYPELD ;
ACTIVE_NETWORK := 0 ;
END_WORKSPACE
NET_WORK
NETWORK_TYPE := NWTYPELD ;
NETWORK_LABEL := ;
NETWORK_TITLE := ;
NETWORK_HEIGHT := 5 ;
NETWORK_BODY
B(B_VARIN,,CalculateY,10,1,12,3,);
B(B_VARIN,,X_value,10,2,12,4,);
B(B_VARIN,,XY_values.Number,10,3,12,5,);
B(B_VAROUT,,Y_value,19,2,21,4,);
B(B_F,F354_FSCAL!,Instance,12,0,19,5,);
L(1,0,1,5);
END_NETWORK_BODY
END_NET_WORK
END_BODY
IF start then
F354_FSCAL(x := X_value, xy_data := XY_values.Number, y => Y_value);
END_IF;