F354_FSCAL

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).

Parameters

Input

x (REAL)

Input value X

xy_data (user-defined DUT)

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

y (REAL)

Output value Y

Remarks

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.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • 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.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • 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.

Example

DUT

The Data Unit Type is created in the DUT Pool.

POU header

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

POU body

When the variable CalculateY is set to TRUE, the function is carried out.

LD body

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

ST body

IF start then
    F354_FSCAL(x := X_value, xy_data := XY_values.Number, y => Y_value);
END_IF;
Related topics:

Modified on: 2019-06-04Feedback on this pagePanasonic hotline